示例#1
0
    def __init__(self):
        """
        Create the cron class
        """
        XplHlpPlugin.__init__(self, name='cron')
        self.log.debug("__init__ : Start ...")
        self.config = Query(self.myxpl, self.log)

        continue_boot = False
        self.log.debug("__init__ : Try to start the cron API")
        try:
            self._cron = CronAPI(self.log, self.config, self.myxpl, \
                self.get_data_files_directory(), self.get_stop())
        except:
            self.force_leave()
            error = "Something went wrong during cronAPI init : %s" %  \
                     (traceback.format_exc())
            self.log.error("__init__ : " + error)
            return

        self.log.debug("__init__ : Enable heplers")
        self.helpers =   \
           {
             "memory" :
              {
                "cb" : self._cron.helpers.helper_memory,
                "desc" : "Show memory usage of variables. Experimental.",
                "usage" : "memory",
              }
            }
        self.enable_helper()

        self.log.debug("__init__ : Try to create listeners")
        Listener(self.request_cmnd_cb, self.myxpl, {
            'schema': 'timer.request',
            'xpltype': 'xpl-cmnd'
        })
        Listener(self.basic_cmnd_cb, self.myxpl, {
            'schema': 'timer.basic',
            'xpltype': 'xpl-cmnd'
        })

        self.add_stop_cb(self._cron.stop_all)

        self.log.debug("__init__ : Enable the heartbeat")
        self.enable_hbeat()

        self.log.info("Plugin cron correctly started.")
示例#2
0
文件: mvhr.py 项目: wookiesh/domogik
    def __init__(self):
        """
        Create the mvhr class
        """
        XplHlpPlugin.__init__(self, name = 'mvhr')
        self.log.info("mvhr.__init__ : Start ...")
        self.config = Query(self.myxpl, self.log)

        self.log.debug("mvhr.__init__ : Try to start the mvhr library")
        try:
            self._mymvhr = HvacMvhr(self.config, self.log, self.myxpl)
        except:
            error = "Something went wrong during mvhrAPI init : %s" %  \
                (traceback.format_exc())
            self.log.exception("mvhr.__init__ : "+error)

        self.log.debug("mvhr.__init__ : Try to create listeners")
        Listener(self.mvhr_request_cmnd, self.myxpl,
                 {'schema': 'mvhr.request', 'xpltype': 'xpl-cmnd'})
        Listener(self.sensor_basic_trig, self.myxpl,
                 {'schema': 'sensor.basic', 'xpltype': 'xpl-trig'})
#        Listener(self.mvhr_basic_trig, self.myxpl,
#                 {'schema': 'mvhr.basic', 'xpltype': 'xpl-trig'})
#        Listener(self.mvhr_reload_config, self.myxpl,
#                 {'schema': 'domogik.system', 'xpltype': 'xpl-cmnd',
#                  'command': 'reload', 'plugin': 'mvhr'})
        self.helpers =   \
           { "status" :
              {
                "cb" : self._mymvhr.helper_status,
                "desc" : "Show status of the mvhr",
                "usage" : "status",
                "param-list" : "",
              },
              "reload_config" :
              {
                "cb" : self._mymvhr.helper_reload_config,
                "desc" : "Reload config of the plugin",
                "usage" : "reload_config",
                "param-list" : "",
              },
            }
        self.enable_helper()
        self.enable_hbeat()
        self._mymvhr.reload_config()
        self.log.info("mvhr plugin correctly started")
示例#3
0
文件: cron.py 项目: capof/domogik
    def __init__(self):
        """
        Create the cron class
        """
        XplHlpPlugin.__init__(self, name = 'cron')
        self.log.debug("__init__ : Start ...")
        self.config = Query(self.myxpl, self.log)

        continue_boot = False
        self.log.debug("__init__ : Try to start the cron API")
        try:
            self._cron = CronAPI(self.log, self.config, self.myxpl, \
                self.get_data_files_directory(), self.get_stop())
        except:
            self.force_leave()
            error = "Something went wrong during cronAPI init : %s" %  \
                     (traceback.format_exc())
            self.log.error("__init__ : "+error)
            return

        self.log.debug("__init__ : Enable heplers")
        self.helpers =   \
           {
             "memory" :
              {
                "cb" : self._cron.helpers.helper_memory,
                "desc" : "Show memory usage of variables. Experimental.",
                "usage" : "memory",
              }
            }
        self.enable_helper()

        self.log.debug("__init__ : Try to create listeners")
        Listener(self.request_cmnd_cb, self.myxpl,
             {'schema': 'timer.request', 'xpltype': 'xpl-cmnd'})
        Listener(self.basic_cmnd_cb, self.myxpl,
             {'schema': 'timer.basic', 'xpltype': 'xpl-cmnd'})

        self.add_stop_cb(self._cron.stop_all)

        self.log.debug("__init__ : Enable the heartbeat")
        self.enable_hbeat()

        self.log.info("Plugin cron correctly started.")
示例#4
0
 def __init__(self):
     """ Create listener and background zwave manager
     """
     XplHlpPlugin.__init__(self, name = 'ozwave')
     
     # Récupère la config 
     # - device
     self._config = Query(self.myxpl, self.log)
     device = self._config.query('ozwave', 'device')
     ozwlogConf = self._config.query('ozwave', 'ozwlog')
     self._config = Query(self.myxpl, self.log)
     print ('Mode log openzwave :',  ozwlogConf)
     # Recupère l'emplacement des fichiers de configuration OZW
     pathUser = self.get_data_files_directory()  +'/'
     pathConfig = self._config.query('ozwave', 'configpath') + '/'
     # Initialise le manager Open zwave
     try:
         self.myzwave = OZWavemanager(self._config, self.send_xPL, self.sendxPL_trig, self.get_stop(), self.log, configPath = pathConfig,  userPath = pathUser,  ozwlog = ozwlogConf)
     except OZwaveException as e:
         self.log.error(e.value)
         print e.value
         self.force_leave()
         return
     self.log.debug("__init__ : Enable heplers")
     self.helpers =   \
        {
          "infostate" :
           {
             "cb" : self.myzwave.GetPluginInfo,
             "desc" : "Show Info status. Experimental.",
             "usage" : "memory",
           }
         }
     self.enable_helper()
     # Crée le listener pour les messages de commande xPL traités par les devices zwave
     Listener(self.ozwave_cmd_cb, self.myxpl,{'schema': 'ozwave.basic',
                                                                     'xpltype': 'xpl-cmnd'})
     # Validation avant l'ouverture du controleur, la découverte du réseaux zwave prends trop de temps -> RINOR Timeout
     self.add_stop_cb(self.myzwave.stop)
     self.enable_hbeat()
     # Ouverture du controleur principal
     self.myzwave.openDevice(device)
示例#5
0
 def __init__(self):
     """
     Create the telldus class
     This class is used to connect devices (through telldus) to
     the xPL Network
     """
     XplHlpPlugin.__init__(self,
                           name='telldus',
                           reload_cb=self.telldus_reload_config_cb)
     self.log.debug("telldus.__init__ : Start ...")
     self._device = "/dev/tellstick"
     #Check if the device exists
     if not os.path.exists(self._device):
         self.log.warning(self._device +
                          " is not present but Tellstick Duo don't use it.")
     else:
         self.log.debug("Device present as " + self._device)
     self._config = Query(self.myxpl, self.log)
     self.log.debug("telldus.__init__ : Try to load API")
     try:
         self._mytelldus = TelldusAPI(self, self.send_xpl, self.log,
                                      self._config,
                                      self.get_data_files_directory(),
                                      self.myxpl)
     except Exception:
         self.log.error("Something went wrong during telldus API init.")
         self.log.error("%s" % (traceback.format_exc()))
         self.force_leave()
         exit(1)
     self.add_stop_cb(self._mytelldus.unregister)
     self.log.debug("telldus.__init__ : Create listeners")
     Listener(self.telldus_cmnd_cb, self.myxpl, {
         'schema': 'telldus.basic',
         'xpltype': 'xpl-cmnd'
     })
     Listener(
         self.telldus_reload_config_cb, self.myxpl, {
             'schema': 'domogik.system',
             'xpltype': 'xpl-cmnd',
             'command': 'reload',
             'plugin': 'telldus'
         })
     self.enable_hbeat()
     try:
         boo = self._config.query('telldus', 'lightext')
         if boo == None:
             boo = "False"
         self.lightext = eval(boo)
     except:
         self.log.warning(
             "Can't get delay configuration from XPL. Disable lighting extensions."
         )
         self.lightext = False
     if self.lightext == True:
         self.log.debug(
             "telldus.__init__ : Try to load the lighting extension.")
         self.lighting = LightingExtension(self, self._name, \
             self._mytelldus.lighting_activate_device, \
             self._mytelldus.lighting_deactivate_device, \
             self._mytelldus.lighting_valid_device)
     self.helpers =   \
        { "list" :
           {
             "cb" : self._mytelldus.helper.helper_list,
             "desc" : "List devices in telldus daemon.",
             "usage" : "list [devicetype]",
             "param-list" : "devicetype",
             "min-args" : 0,
             "devicetype" : "the type of device to find",
           },
          "info" :
           {
             "cb" : self._mytelldus.helper.helper_info,
             "desc" : "Display device information.",
             "usage" : "info <device>",
             "param-list" : "device",
             "min-args" : 1,
             "device" : "device address",
           },
          "memory" :
           {
             "cb" : self._mytelldus.helper.helper_memory,
             "desc" : "Show memory usage of variables. Experimental.",
             "usage" : "memory",
             "param-list" : "",
             "min-args" : 0,
           },
         }
     if self.lightext == True:
         self.log.debug(
             "telldus.__init__ : Try to enable the lighting extension.")
         self.lighting.enable_lighting()
     self.log.debug("telldus.__init__ : Try to load the helpers.")
     self.enable_helper()
     self.log.info("Telldus plugin correctly started")
示例#6
0
 def __sizeof__(self):
     return XplHlpPlugin.__sizeof__(self) + sum(sys.getsizeof(v) for v in self.__dict__.values())
示例#7
0
文件: telldus.py 项目: capof/domogik
 def __init__(self):
     """
     Create the telldus class
     This class is used to connect devices (through telldus) to
     the xPL Network
     """
     XplHlpPlugin.__init__(self, name = 'telldus',
         reload_cb = self.telldus_reload_config_cb)
     self.log.debug("telldus.__init__ : Start ...")
     self._device = "/dev/tellstick"
     #Check if the device exists
     if not os.path.exists(self._device):
         self.log.warning(self._device +
             " is not present but Tellstick Duo don't use it.")
     else:
         self.log.debug("Device present as "+self._device)
     self._config = Query(self.myxpl, self.log)
     self.log.debug("telldus.__init__ : Try to load API")
     try:
         self._mytelldus = TelldusAPI(self, self.send_xpl, self.log,
             self._config,self.get_data_files_directory(), self.myxpl)
     except Exception:
         self.log.error("Something went wrong during telldus API init.")
         self.log.error("%s" % (traceback.format_exc()))
         self.force_leave()
         exit(1)
     self.add_stop_cb(self._mytelldus.unregister)
     self.log.debug("telldus.__init__ : Create listeners")
     Listener(self.telldus_cmnd_cb, self.myxpl,
              {'schema': 'telldus.basic', 'xpltype': 'xpl-cmnd'})
     Listener(self.telldus_reload_config_cb, self.myxpl,
              {'schema': 'domogik.system', 'xpltype': 'xpl-cmnd',
               'command': 'reload', 'plugin': 'telldus'})
     self.enable_hbeat()
     try:
         boo = self._config.query('telldus', 'lightext')
         if boo == None:
             boo = "False"
         self.lightext = eval(boo)
     except:
         self.log.warning("Can't get delay configuration from XPL. Disable lighting extensions.")
         self.lightext = False
     if self.lightext == True:
         self.log.debug("telldus.__init__ : Try to load the lighting extension.")
         self.lighting = LightingExtension(self, self._name, \
             self._mytelldus.lighting_activate_device, \
             self._mytelldus.lighting_deactivate_device, \
             self._mytelldus.lighting_valid_device)
     self.helpers =   \
        { "list" :
           {
             "cb" : self._mytelldus.helper.helper_list,
             "desc" : "List devices in telldus daemon.",
             "usage" : "list [devicetype]",
             "param-list" : "devicetype",
             "min-args" : 0,
             "devicetype" : "the type of device to find",
           },
          "info" :
           {
             "cb" : self._mytelldus.helper.helper_info,
             "desc" : "Display device information.",
             "usage" : "info <device>",
             "param-list" : "device",
             "min-args" : 1,
             "device" : "device address",
           },
          "memory" :
           {
             "cb" : self._mytelldus.helper.helper_memory,
             "desc" : "Show memory usage of variables. Experimental.",
             "usage" : "memory",
             "param-list" : "",
             "min-args" : 0,
           },
         }
     if self.lightext == True:
         self.log.debug("telldus.__init__ : Try to enable the lighting extension.")
         self.lighting.enable_lighting()
     self.log.debug("telldus.__init__ : Try to load the helpers.")
     self.enable_helper()
     self.log.info("Telldus plugin correctly started")