#!/usr/local/bin/python # Copyright (c) 2013-2014 Erik Johansson # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA import sys import tellcore.telldus as td import tellcore.constants as const core = td.TelldusCore() try: controllers = core.controllers() except Exception as e: print("Error: unable to list controllers (are you using telldus-core >= 2.1.2?)") print(e) sys.exit(1) TYPES = {const.TELLSTICK_CONTROLLER_TELLSTICK: 'TellStick', const.TELLSTICK_CONTROLLER_TELLSTICK_DUO: "TellStick Duo", const.TELLSTICK_CONTROLLER_TELLSTICK_NET: "TellStick Net"} for controller in controllers: try: name = controller.name except AttributeError: name = "" print("{}\n name: {}\n serial: {}\n firmware: {}\n available: {}".format( TYPES[controller.type], name, controller.serial, controller.firmware, controller.available)) print("\nFound {} controller(s)".format(len(controllers)))