Exemple #1
0
    def __init__(self):
        """
        telldusTool helper
        """

        self.commands =   \
               { "list" :
                  {
                    "cb" : self.list,
                    "desc" : "List devices referenced by the telldus",
                    "min_args" : 0,
                    "usage" : "list [devicetype]"
                  },
                 "info" :
                  {
                    "cb" : self.info,
                    "desc" : "Display device information",
                    "min_args" : 1,
                    "usage" : "info <id>"
                  }
                }

        log = logger.Logger('telldus-helper')
        self._log = log.get_logger('telldus-helper')
       # self._config = Query(self.myxpl, self._log)
        self._log.info("telldusHelper.init : done")
        self._telldusd = Telldusd()
Exemple #2
0
class telldus(Helper):
    """
    telldusTool helpers
    """

    def __init__(self):
        """
        telldusTool helper
        """

        self.commands =   \
               { "list" :
                  {
                    "cb" : self.list,
                    "desc" : "List devices referenced by the telldus",
                    "min_args" : 0,
                    "usage" : "list [devicetype]"
                  },
                 "info" :
                  {
                    "cb" : self.info,
                    "desc" : "Display device information",
                    "min_args" : 1,
                    "usage" : "info <id>"
                  }
                }

        log = logger.Logger('telldus-helper')
        self._log = log.get_logger('telldus-helper')
       # self._config = Query(self.myxpl, self._log)
        self._log.info("telldusHelper.init : done")
        self._telldusd = Telldusd()

    def list(self, args = None):
        """
        List all devices
        """
        self._log.info("list : Start ...")
        data = []
        if  len(args) == 0:
            data.append("List all devices :")
            data.append("id : XPL id : Name")

            # List devices
            devices = self._telldusd.get_devices()
            for key in devices:
                data.append("%s  :  %s  : %s" % (str(key), self._telldusd.get_device(key), devices[key]["name"]))
        else:
            data.append("List all devices of type %s :" % args[0])
            data.append("id : XPL id : Name")
            self._log.debug("telldusHelper.list devicetype=%s" % args[0])
        self._log.debug("list : Done")
        return data

    def info(self, args = None):
        """
        Get information for device
        """
        self._log.info("info : Start ...")
        data = []
        data.append("Information for device %s" % args[0])
        if len(args) == 1:
            data.extend(self._telldusd.get_info(int(args[0])))
        else:
            return ["Bad usage of this helper. "]
        self._log.debug("info : Done")
        return data