コード例 #1
0
    def send_xpl(self, teleinfo):
        """ send xPL on the network """
        self.log.debug("Send xPL msg with a line of teleinfo data")

        #print "callback : receive frame is : \n\n"
        #print teleinfo
        #print "\n\n"

        # creation du message xPL
        msg = XplMessage()
        msg.set_type("xpl-stat")
        #msg.set_schema("sensor.basic")
        msg.set_schema("teleinfo.basic")
        #msg.add_data({"timestamp" : teleinfo["timestamp"]})
        #msg.add_data({"recdate" : teleinfo["recdate"]})
        #msg.add_data({"rectime" : teleinfo["rectime"]})
        msg.add_data({"optarif" : teleinfo["optarif"]})
        msg.add_data({"hchp" : teleinfo["hchp"]})
        msg.add_data({"hchc" : teleinfo["hchc"]})
        msg.add_data({"ptec" : teleinfo["ptec"]})
        msg.add_data({"inst1" : teleinfo["inst1"]})
        msg.add_data({"imax1" : teleinfo["imax1"]})
        msg.add_data({"papp" : teleinfo["papp"]})

        try:
            self.myxpl.send(msg)
        except XplMessageError: 
            self.log.debug(u"Bad xpl message to send. Xpl message is : {0}".format(str(msg)))
            pass
コード例 #2
0
    def send_xpl(self, frame):
        ''' Send a frame from teleinfo device to xpl
        @param frame : a dictionnary mapping teleinfo informations
        '''
        my_temp_message = XplMessage()
        my_temp_message.set_type("xpl-stat")
        if "ADIR1" in frame:
            my_temp_message.set_schema("teleinfo.short")
        else:
            my_temp_message.set_schema("teleinfo.basic")

        try:
            key = None
            val = None
            for entry in frame:
                key = re.sub('[^\w\.]','',entry["name"].lower())
                val = re.sub('[^\w\.]','',entry["value"].lower())
                my_temp_message.add_data({ key : val })
            my_temp_message.add_data({"device": "teleinfo"})
        except :
            self.log.warn("Message ignored : %s ; last key : %s ; last val : %s" % (my_temp_message, key, val))

        try:
            self.myxpl.send(my_temp_message)
        except XplMessageError:
            #We ignore the message if some values are not correct because it can happen with teleinfo ...
            pass
コード例 #3
0
ファイル: cron_query.py プロジェクト: wookiesh/domogik
    def stop_job(self, device, extkey="state"):
        """
        Stop a job to the cron plugin. The cron job could be restarted via a
        resume command.

        :param device: the device/job to stop
        :type device: str
        :param extkey: the message key to look for ("state" by default)
        :type extkey: str
        :return: the state sent by cron plugin : "started"|"stopped"|"halted"
        :rtype: str

        """
        configmess = XplMessage()
        configmess.set_type("xpl-cmnd")
        configmess.set_schema("timer.basic")
        configmess.add_data({"action": "stop"})
        configmess.add_data({"device": device})
        try:
            res = self.query(device, configmess, extkey=extkey)
            return res
        except:
            if self.log != None:
                self.log.error("cron_query : %s" % (traceback.format_exc()))
            return False
コード例 #4
0
ファイル: cronquery_test.py プロジェクト: ripleyXLR8/domogik
 def test_260_add_duplicate_testjob1(self):
     message = XplMessage()
     message.set_type("xpl-trig")
     message.set_schema("sensor.basic")
     message.add_data({"current": "high"})
     message.add_data({"device": "tsjob1"})
     self.assertFalse(self.cronquery.start_timer_job("testjob1", message, 45))
コード例 #5
0
ファイル: cron_query.py プロジェクト: wookiesh/domogik
    def start_timer_job(self, device, nstmess, frequence, duration=0):
        '''
        Add and start a job to the cron plugin

        :param device: the device/job to start
        :type device: str
        :param configmess: the XPL configuration message to send to the plugin
        :type configmess: XplMessage
        :param nstMess: the XPL message which will be sent by the cron job
        :type nstMess: XplMessage
        :param frequence: int
        :type frequence: the frequence of the signal (in seconds).
        :param duration: the number of pulse to live.
        :type duration: int
        :return: the state sent by cron plugin : "started"|"stopped"|"halted"
        :rtype: str

        '''
        if frequence == 0:
            return False
        configmess = XplMessage()
        configmess.set_type("xpl-cmnd")
        configmess.set_schema("timer.basic")
        configmess.add_data({"action": "start"})
        configmess.add_data({"device": device})
        configmess.add_data({"devicetype": "timer"})
        configmess.add_data({"frequence": frequence})
        if duration != 0:
            configmess.add_data({"duration": duration})
        return self.start_job(device, configmess, nstmess)
コード例 #6
0
ファイル: cron_query.py プロジェクト: capof/domogik
    def start_timer_job(self, device, nstmess, frequence, duration=0):
        '''
        Add and start a job to the cron plugin

        :param device: the device/job to start
        :type device: str
        :param configmess: the XPL configuration message to send to the plugin
        :type configmess: XplMessage
        :param nstMess: the XPL message which will be sent by the cron job
        :type nstMess: XplMessage
        :param frequence: int
        :type frequence: the frequence of the signal (in seconds).
        :param duration: the number of pulse to live.
        :type duration: int
        :return: the state sent by cron plugin : "started"|"stopped"|"halted"
        :rtype: str

        '''
        if frequence == 0:
            return False
        configmess = XplMessage()
        configmess.set_type("xpl-cmnd")
        configmess.set_schema("timer.basic")
        configmess.add_data({"action" : "start"})
        configmess.add_data({"device" : device})
        configmess.add_data({"devicetype" : "timer"})
        configmess.add_data({"frequence" : frequence})
        if duration != 0:
            configmess.add_data({"duration" : duration})
        return self.start_job(device, configmess, nstmess)
コード例 #7
0
 def _command_cb(self, f):
     ''' Called by the plcbus library when a command has been sent.
     If the commands need an ack, this callback will be called only after the ACK has been received
     @param : plcbus frame as an array
     '''
     if f["d_command"] == "GET_ALL_ID_PULSE":
         print("elif fd_command =GET ALL  PULSE ")
         #           data = int("%s%s" % (f["d_data1"], f["d_data2"]))
         #	    Workaround with autodetection problem force data to 511
         #	    to consider discover of device with value from 0 to 9
         #	    Could also be set to 4095 to force from 0 to F
         data = 511
         house = f["d_home_unit"][0]
         for i in range(0, 16):
             unit = data >> i & 1
             code = "%s%s" % (house, i + 1)
             if unit and not code in self._probe_status:
                 self._probe_status[code] = ""
                 self.log.info("New device discovered : %s" % code)
             elif (not unit) and code in self._probe_status:
                 del self._probe_status[code]
     elif f["d_command"] == "GET_ALL_ON_ID_PULSE":
         print("elif fd_command =GET ALL ON ID PULSE ")
         data = "%s%s" % (bin(f["d_data1"])[2:].zfill(8), bin(f["d_data2"])[2:].zfill(8))
         print("f : %s" % f)
         print("data : %s" % data)
         house = f["d_home_unit"][0]
         item = 16
         for c in data:
             unit = int(c)
             code = "%s%s" % (house, item)
             print("Etat : %s " % code, unit)
             if code in self._probe_status and (self._probe_status[code] != str(unit)):
                 print('DEBUG in rentre dans le IF detection GET_ALL_ON')
                 self._probe_status[code] = str(unit)
                 if unit == 1:
                     command = 1
                 else:
                     command = 0
                 self.log.info("New status for device : %s is now %s " % (code, command))
                 mess = XplMessage()
                 mess.set_type('xpl-trig')
                 mess.set_schema('plcbus.basic')
                 mess.add_data({"address": code, "level": command})
                 self.myxpl.send(mess)
                 print("message XPL : %s" % mess)
             item = item - 1
     else:
         print("else")
         if f["d_command"] == "ON":
             command = 1
         else:
             command = 0
         mess = XplMessage()
         mess.set_type('xpl-trig')
         mess.set_schema('plcbus.basic')
         mess.add_data({"usercode": f["d_user_code"], "address": f["d_home_unit"],
                        "level": command, "data1": f["d_data1"], "data2": f["d_data2"]})
         self.myxpl.send(mess)
         print("message XPL : %s" % mess)
コード例 #8
0
ファイル: cron_test.py プロジェクト: wookiesh/domogik
 def test_610_list_dawnalarm1(self):
     message = XplMessage()
     message.set_type("xpl-cmnd")
     message.set_schema("timer.basic")
     message.add_data({"action" :  "list"})
     keys = ['devices']
     self.assertTrue(self.query("device", message, keys))
コード例 #9
0
ファイル: earth_test.py プロジェクト: capof/domogik
 def test_050_gateway(self):
     message = XplMessage()
     message.set_type("xpl-cmnd")
     message.set_schema("earth.request")
     message.add_data({"command" :  "gateway"})
     keys = ['type-list','act-list','cmd-list','stat-list']
     self.assertTrue(self.query_many("host",message,keys))
コード例 #10
0
ファイル: earth_test.py プロジェクト: capof/domogik
 def test_020_bad_gateway(self):
     message = XplMessage()
     message.set_type("xpl-cmnd")
     message.set_schema("earth.request")
     message.add_data({"command" :  "gateway"})
     keys = ['bad-list']
     self.assertFalse(self.query_many("host",message,keys))
コード例 #11
0
ファイル: earth_test.py プロジェクト: capof/domogik
 def test_310_memory(self):
     message = XplMessage()
     message.set_type("xpl-cmnd")
     message.set_schema("earth.request")
     message.add_data({"command" :  "memory"})
     keys = ['memory']
     self.assertTrue(self.query_many("memory",message,keys))
コード例 #12
0
ファイル: cron_query.py プロジェクト: wookiesh/domogik
    def halt_job(self, device, extkey="state"):
        """
        Stop a job and delete the device. Job is permanently deleted.

        :param device: the device/job to halt
        :type device: str
        :param  extkey: the message key to look for ("state" by default)
        :type  extkey: str
        :return: the state sent by cron plugin : "started"|"stopped"|"halted"
        :rtype: str

        """
        configmess = XplMessage()
        configmess.set_type("xpl-cmnd")
        configmess.set_schema("timer.basic")
        configmess.add_data({"action": "halt"})
        configmess.add_data({"device": device})
        try:
            res = self.query(device, configmess, extkey=extkey)
            #print res
            return res
        except:
            if self.log != None:
                self.log.error("cron_query : %s" % (traceback.format_exc()))
            return False
コード例 #13
0
ファイル: dbmgr.py プロジェクト: kopec77/domogik
 def _send_config(self, plugin, hostname, key, value, element=None):
     '''
     Send a config value message for an element's config item
     @param plugin : the plugin of the element
     @param hostname : hostname
     @param element :  the name of the element
     @param key : the key or list of keys of the config tuple(s) to fetch
     @param value : the value or list of values corresponding to the key(s)
     '''
     msg = "Response h=%s, t=%s, k=%s, v=%s" % (hostname, plugin, key,
                                                value)
     print(msg)
     self.log.debug(msg)
     mess = XplMessage()
     mess.set_type('xpl-stat')
     mess.set_schema('domogik.config')
     mess.add_data({'plugin': plugin})
     mess.add_data({'hostname': hostname})
     if element:
         mess.add_data({'element': element})
     # If key/value are lists, then we add a key=value for each item
     if isinstance(key, list):
         for (_key, _val) in zip(key, value):
             mess.add_data({_key: _val})
     else:
         mess.add_data({key: value})
     # mess.set_conf_key('target', plugin)
     self.myxpl.send(mess)
コード例 #14
0
ファイル: ozwave.py プロジェクト: manu35500/domogik
 def sendxPL_trig(self, msgtrig):
     """Envoie un message trig sur le hub xPL"""
     mess = XplMessage()
     if 'info' in msgtrig:
         self.log.error ("Error : Node %s unreponsive" % msgtrig['node'])
     elif 'Find' in msgtrig:
         print("node enregistré : %s" % msgtrig['Find'])
     elif 'typexpl' in msgtrig:
         mess.set_type(msgtrig['typexpl'])
         mess.set_schema(msgtrig['schema'])
         if msgtrig['genre'] == 'actuator' :
             if msgtrig['level'] in [0, 'False', False] : cmd ="off"
             elif msgtrig['level'] in [255, 'True',  True]: cmd ="on"
             else: cmd ='level'
             mess.add_data({'device' : msgtrig['device'],
                         'command' : cmd,
                         'level': msgtrig['level']})
             if msgtrig.has_key('type'): mess.add_data({'type' : msgtrig['type'] })
         elif msgtrig['genre'] == 'sensor' :  # tout sensor
             if msgtrig['type'] =='status' :  # gestion du sensor binary pour widget binary
                 mess.add_data({'device' : msgtrig['device'],
                         'type' : msgtrig['type'] ,
                         'current' : 'true' if msgtrig['value']   else 'false'})
             else : mess.add_data({'device' : msgtrig['device'],  
                         'type' : msgtrig['type'] ,
                         'current' : msgtrig['value'] })
         if msgtrig.has_key('units') and msgtrig['units'] !='' : mess.add_data({'units' : msgtrig['units'] })
         print mess
         self.myxpl.send(mess)
     elif 'command' in msgtrig and msgtrig['command'] == 'Info':
         print("Home ID is %s" % msgtrig['Home ID'])
コード例 #15
0
ファイル: lighting.py プロジェクト: capof/domogik
 def cmnd_register(self, myxpl, command, message):
     """
     Register a client
     command=register
     client=name
     activate=activate
     deactivate=deactivate
     """
     mess = XplMessage()
     mess.set_type("xpl-trig")
     mess.set_schema("lighting.config")
     mess.add_data({"command" : command})
     client = None
     if 'client' in message.data:
         client = message.data['client']
     activate = None
     if 'activate' in message.data:
         activate = message.data['activate']
     deactivate = None
     if 'deactivate' in message.data:
         deactivate = message.data['deactivate']
     if client == None:
         self.log.error("Command = %s : Missing parameter _ client _." % (command))
         mess.add_data({"error" : "Missing parameter : client"})
     elif not self.clients.is_valid(client):
         mess.add_data({"client" : client})
         mess.add_data({"error" : "Client already registered : %s" % client})
         self.log.error("Command = %s : Client _ %s _ already registered." % (command, client))
     else:
         self.clients.add_client(client, activate, deactivate)
         mess.add_data({"client" : client})
     myxpl.send(mess)
コード例 #16
0
    def send_xpl(self, frame):
        ''' Send a frame from teleinfo device to xpl
        @param frame : a dictionnary mapping teleinfo informations
        '''
        known_keys = []  # used to filter duplicate keys (it happens)
        my_temp_message = XplMessage()
        my_temp_message.set_type("xpl-stat")
        if "ADIR1" in frame:
            my_temp_message.set_schema("teleinfo.short")
        else:
            my_temp_message.set_schema("teleinfo.basic")

        try:
            key = None
            val = None
            for entry in frame:
                key = re.sub('[^\w\.]', '', entry["name"].lower())
                val = re.sub('[^\w\.]', '', entry["value"].lower())
                if key not in known_keys:
                    my_temp_message.add_data({key: val})
                    known_keys.append(key)
            my_temp_message.add_data({"device": "teleinfo"})
        except:
            self.log.error(
                u"Error while creating xpl message : {0} ; key : {1} ; val : {2}. Error is : {3}"
                .format(my_temp_message, key, val, traceback.formar_exc()))

        try:
            self.myxpl.send(my_temp_message)
        except XplMessageError:
            #We ignore the message if some values are not correct because it can happen with teleinfo ...
            self.log.debug(
                u"Bad xpl message to send. This may happen due to some invalid teleinfo data. Xpl message is : {0}"
                .format(str(my_temp_message)))
            pass
コード例 #17
0
    def cmnd_scnlist(self, myxpl, message):
        """
        Return the list of scenes
        @param myxpl : The XPL sender
        @param message : The XPL message

        lighting.request

        This allows a sender to learn about capabilities, networks, scenes and scene that can be controlled and addressed

         request=[gateinfo|netlist|netinfo|devlist|devinfo|devstate|scnlist|scninfo]
         [network=ID]
         [[scene=ID]|[scene=ID]][channel=#]

        lighting.devlist

        Enumerates the valid scenes on a network

         network=ID
         status=[ok|not-found]
         scene-count=#
         scene=ID,ID,ID,ID...

        """
        #print "scene list"
        mess = XplMessage()
        mess.set_type("xpl-stat")
        mess.set_schema("lighting.config")
        if 'client' in message.data:
            mess.add_data({"client": message.data['client']})
        mess.add_data({"command": "scnlist"})
        mess.add_data({"scenes": self.scenes()})
        mess.add_data({"scene-count": self.count()})
        mess.add_data({"status": "ok"})
        myxpl.send(mess)
コード例 #18
0
ファイル: lighting.py プロジェクト: wookiesh/domogik
 def cmnd_register(self, myxpl, command, message):
     """
     Register a client
     command=register
     client=name
     activate=activate
     deactivate=deactivate
     """
     mess = XplMessage()
     mess.set_type("xpl-trig")
     mess.set_schema("lighting.config")
     mess.add_data({"command": command})
     client = None
     if 'client' in message.data:
         client = message.data['client']
     activate = None
     if 'activate' in message.data:
         activate = message.data['activate']
     deactivate = None
     if 'deactivate' in message.data:
         deactivate = message.data['deactivate']
     if client == None:
         self.log.error("Command = %s : Missing parameter _ client _." %
                        (command))
         mess.add_data({"error": "Missing parameter : client"})
     elif not self.clients.is_valid(client):
         mess.add_data({"client": client})
         mess.add_data({"error": "Client already registered : %s" % client})
         self.log.error("Command = %s : Client _ %s _ already registered." %
                        (command, client))
     else:
         self.clients.add_client(client, activate, deactivate)
         mess.add_data({"client": client})
     myxpl.send(mess)
コード例 #19
0
ファイル: dawndusk.py プロジェクト: wookiesh/domogik
 def dawndusk_trig_cb(self, message):
     """
     General callback for all command messages
     @param message : an XplMessage object
     """
     self.log.debug("dawndusk.dawndusk_trig_cb() : Start ...")
     mtype = None
     if 'type' in message.data:
         mtype = message.data['type']
     status = None
     if 'status' in message.data:
         status = message.data['status']
     self.log.debug("dawndusk.dawndusk_trig_cb :  type %s received \
         with status %s" % (mtype, status))
     if mtype == "dawndusk" and status != None:
         #We receive a trig indicating that the dawn or dus has occured.
         #We need to schedule the next one
         self.add_next_event()
         for dev in self.devices:
             self.log.debug("sendMessages() : Send message to device %s" %
                            dev)
             mess = XplMessage()
             mess.set_type(self.devices[dev]["xpltype"])
             mess.set_schema(self.devices[dev]["schema"])
             mess.add_data({self.devices[dev]["command"] : \
                 self.devices[dev][status]})
             mess.add_data({self.devices[dev]["addname"]: dev})
             self.myxpl.send(mess)
     self.log.debug("dawndusk.dawndusk_trig_cb() : Done :)")
コード例 #20
0
ファイル: light_scene.py プロジェクト: capof/domogik
    def cmnd_scnlist(self, myxpl, message):
        """
        Return the list of scenes
        @param myxpl : The XPL sender
        @param message : The XPL message

        lighting.request

        This allows a sender to learn about capabilities, networks, scenes and scene that can be controlled and addressed

         request=[gateinfo|netlist|netinfo|devlist|devinfo|devstate|scnlist|scninfo]
         [network=ID]
         [[scene=ID]|[scene=ID]][channel=#]

        lighting.devlist

        Enumerates the valid scenes on a network

         network=ID
         status=[ok|not-found]
         scene-count=#
         scene=ID,ID,ID,ID...

        """
        #print "scene list"
        mess = XplMessage()
        mess.set_type("xpl-stat")
        mess.set_schema("lighting.config")
        if 'client' in message.data:
            mess.add_data({"client" : message.data['client']})
        mess.add_data({"command" : "scnlist"})
        mess.add_data({"scenes" : self.scenes()})
        mess.add_data({"scene-count" : self.count()})
        mess.add_data({"status" : "ok"})
        myxpl.send(mess)
コード例 #21
0
    def send_xpl(self, frame):
        ''' Send a frame from teleinfo device to xpl
        @param frame : a dictionnary mapping teleinfo informations
        '''
        known_keys = []   # used to filter duplicate keys (it happens)
        my_temp_message = XplMessage()
        my_temp_message.set_type("xpl-stat")
        if "ADIR1" in frame:
            my_temp_message.set_schema("teleinfo.short")
        else:
            my_temp_message.set_schema("teleinfo.basic")

        try:
            key = None
            val = None
            for entry in frame:
                key = re.sub('[^\w\.]','',entry["name"].lower())
                val = re.sub('[^\w\.]','',entry["value"].lower())
                if key not in known_keys:
                    my_temp_message.add_data({ key : val })
                    known_keys.append(key)
            my_temp_message.add_data({"device": "teleinfo"})
        except :
            self.log.error(u"Error while creating xpl message : {0} ; key : {1} ; val : {2}. Error is : {3}".format(my_temp_message, key, val, traceback.formar_exc()))

        try:
            self.myxpl.send(my_temp_message)
        except XplMessageError:
            #We ignore the message if some values are not correct because it can happen with teleinfo ...
            self.log.debug(u"Bad xpl message to send. This may happen due to some invalid teleinfo data. Xpl message is : {0}".format(str(my_temp_message)))
            pass
コード例 #22
0
ファイル: send.py プロジェクト: thefrip/domogik
 def forge_message(self):
     '''
     Create the message based on script arguments
     '''
     message = XplMessage()
     message.set_type(self.options.type)
     if self.options.source != None:
         print(u"Source forced : %s" % self.options.source)
         message.set_source(self.options.source)
     if self.options.target != None:
         print(u"Target forced : %s" % self.options.target)
         message.set_target(self.options.target)
     message.set_schema(self.options.schema)
     datas = self.options.message.split(',')
     for data in datas:
         if "=" not in data:
             self.log.error(u"Bad formatted commands. Must be key=value")
             self.usage()
             exit(4)
         else:
             message.add_data({
                 data.split("=", 1)[0].strip():
                 data.split("=", 1)[1].strip()
             })
     return message
コード例 #23
0
ファイル: dbmgr.py プロジェクト: capof/domogik
 def _send_config(self, plugin, hostname, key, value, element = None):
     '''
     Send a config value message for an element's config item
     @param plugin : the plugin of the element
     @param hostname : hostname
     @param element :  the name of the element
     @param key : the key or list of keys of the config tuple(s) to fetch
     @param value : the value or list of values corresponding to the key(s)
     '''
     msg = "Response h=%s, t=%s, k=%s, v=%s" % (hostname, plugin, key, value)
     print(msg)
     self.log.debug(msg)
     mess = XplMessage()
     mess.set_type('xpl-stat')
     mess.set_schema('domogik.config')
     mess.add_data({'plugin' :  plugin})
     mess.add_data({'hostname' :  hostname})
     if element:
         mess.add_data({'element' :  element})
     # If key/value are lists, then we add a key=value for each item
     if isinstance(key, list):
         for (_key, _val) in zip(key, value):
             mess.add_data({_key :  _val})
     else:
         mess.add_data({key :  value})
     # mess.set_conf_key('target', plugin)
     self.myxpl.send(mess)
コード例 #24
0
ファイル: dawndusk.py プロジェクト: capof/domogik
 def dawndusk_trig_cb(self, message):
     """
     General callback for all command messages
     @param message : an XplMessage object
     """
     self.log.debug("dawndusk.dawndusk_trig_cb() : Start ...")
     mtype = None
     if 'type' in message.data:
         mtype = message.data['type']
     status = None
     if 'status' in message.data:
         status = message.data['status']
     self.log.debug("dawndusk.dawndusk_trig_cb :  type %s received \
         with status %s" % (mtype, status))
     if mtype == "dawndusk" and status != None:
         #We receive a trig indicating that the dawn or dus has occured.
         #We need to schedule the next one
         self.add_next_event()
         for dev in self.devices:
             self.log.debug("sendMessages() : Send message to device %s"%dev)
             mess = XplMessage()
             mess.set_type(self.devices[dev]["xpltype"])
             mess.set_schema(self.devices[dev]["schema"])
             mess.add_data({self.devices[dev]["command"] : \
                 self.devices[dev][status]})
             mess.add_data({self.devices[dev]["addname"] : dev})
             self.myxpl.send(mess)
     self.log.debug("dawndusk.dawndusk_trig_cb() : Done :)")
コード例 #25
0
 def send_xplStat(self, data):
     """ Send xPL cmd message on network
     """
     msg = XplMessage()
     msg.set_type("xpl-stat")
     msg.set_schema("sensor.basic")
     msg.add_data(data)
     self.myxpl.send(msg)
コード例 #26
0
ファイル: cronquery_test.py プロジェクト: ripleyXLR8/domogik
 def test_420_add_bad_interval(self):
     self.cronquery.halt_job("testjob1")
     message = XplMessage()
     message.set_type("xpl-trig")
     message.set_schema("sensor.basic")
     message.add_data({"current": "high"})
     message.add_data({"device": "tsjob1"})
     self.assertTrue(self.cronquery.start_interval_job("testjob1", message) != True)
コード例 #27
0
 def send_xplStat(self, data):
     """ Send xPL cmd message on network
     """
     msg = XplMessage()
     msg.set_type("xpl-stat")
     msg.set_schema("ir.basic")
     msg.add_data(data)
     self.myxpl.send(msg)
コード例 #28
0
ファイル: earth_test.py プロジェクト: capof/domogik
 def test_700_list(self):
     message = XplMessage()
     message.set_type("xpl-cmnd")
     message.set_schema("earth.request")
     message.add_data({"command" :  "list"})
     keys = ['count','evnt-list']
     keyvalss = {}
     self.assertTrue(self.query_many("count",message,keys,keyvalss))
コード例 #29
0
 def test_260_add_duplicate_testjob1(self):
     message = XplMessage()
     message.set_type("xpl-trig")
     message.set_schema("sensor.basic")
     message.add_data({"current": "high"})
     message.add_data({"device": "tsjob1"})
     self.assertFalse(
         self.cronquery.start_timer_job("testjob1", message, 45))
コード例 #30
0
ファイル: earth_test.py プロジェクト: capof/domogik
 def test_640_status_dusk(self):
     message = XplMessage()
     message.set_type("xpl-cmnd")
     message.set_schema("earth.request")
     message.add_data({"command" :  "status"})
     message.add_data({"query" :  "dawndusk"})
     keys = []
     keyvalss = {'type' : 'dawndusk','status':'dusk'}
     self.assertTrue(self.query_many("type",message,keys,keyvalss))
コード例 #31
0
ファイル: earth_test.py プロジェクト: capof/domogik
 def test_310_parameter_get(self):
     message = XplMessage()
     message.set_type("xpl-cmnd")
     message.set_schema("earth.request")
     message.add_data({"command" :  "get"})
     message.add_data({"param" :  "dawndusk"})
     keys = ['value']
     keyvalss = {"param" :  "dawndusk"}
     self.assertTrue(self.query_many("param",message,keys,keyvalss))
コード例 #32
0
ファイル: cron_test.py プロジェクト: wookiesh/domogik
 def test_310_info_interval1(self):
     message = XplMessage()
     message.set_type("xpl-cmnd")
     message.set_schema("timer.basic")
     message.add_data({"action" :  "status"})
     message.add_data({"device" :  "interval1"})
     keys = ['devicetype']
     keyvalss = {"device":"interval1", "devicetype":"interval", "state":"started"}
     self.assertTrue(self.query("device",message,keys,keyvalss))
コード例 #33
0
ファイル: cron_test.py プロジェクト: wookiesh/domogik
 def test_410_stop_cron1(self):
     message = XplMessage()
     message.set_type("xpl-cmnd")
     message.set_schema("timer.basic")
     message.add_data({"action" :  "stop"})
     message.add_data({"device" :  "cron1"})
     keys = ['devicetype']
     keyvalss = {"device":"cron1", "devicetype":"cron", "state":"stopped"}
     self.assertTrue(self.query("device",message,keys,keyvalss))
コード例 #34
0
 def send_xplTrig(self, data):
     """ Send xPL message on network
     """
     self.log.debug("Xpl Trig for {0}".format(data))
     msg = XplMessage()
     msg.set_type("xpl-trig")
     msg.set_schema("ir.basic")
     msg.add_data(data)
     self.myxpl.send(msg)
コード例 #35
0
ファイル: earth_test.py プロジェクト: capof/domogik
 def test_450_status_moonphase(self):
     message = XplMessage()
     message.set_type("xpl-cmnd")
     message.set_schema("earth.request")
     message.add_data({"command" :  "status"})
     message.add_data({"query" :  "moonphase"})
     keys = []
     keyvalss = {'type' : 'moonphase','status':'newmoon'}
     self.assertTrue(self.query_many("type",message,keys,keyvalss))
コード例 #36
0
ファイル: cron_test.py プロジェクト: wookiesh/domogik
 def test_940_halt_dawnalarm4(self):
     message = XplMessage()
     message.set_type("xpl-cmnd")
     message.set_schema("timer.basic")
     message.add_data({"action" :  "halt"})
     message.add_data({"device" :  "alarm4"})
     keys = ['device']
     keyvalss = {"device":"alarm4", "state":"halted"}
     self.assertTrue(self.query("device", message, keys, keyvalss))
コード例 #37
0
ファイル: earthzmq_test.py プロジェクト: wookiesh/domogik
 def test_460_simulate_lastquarter(self):
     message = XplMessage()
     message.set_type("xpl-trig")
     message.set_schema("earth.basic")
     message.add_data({"type": "lastquarter"})
     message.add_data({"current": "fired"})
     keys = ['uptime', 'fullruntime', 'runtime', 'runs', 'next']
     keyvalss = {"type": "lastquarter", 'current': "started"}
     self.assertTrue(self.query("type", message, keys, keyvalss))
コード例 #38
0
 def test_520_add_bad_date(self):
     self.cronquery.halt_job("testjob1")
     message = XplMessage()
     message.set_type("xpl-trig")
     message.set_schema("sensor.basic")
     message.add_data({"current": "high"})
     message.add_data({"device": "tsjob1"})
     self.assertTrue(self.cronquery.start_date_job("testjob1",message,\
         datetime.datetime.today() - datetime.timedelta(seconds=120)) != True)
コード例 #39
0
 def test_420_add_bad_interval(self):
     self.cronquery.halt_job("testjob1")
     message = XplMessage()
     message.set_type("xpl-trig")
     message.set_schema("sensor.basic")
     message.add_data({"current": "high"})
     message.add_data({"device": "tsjob1"})
     self.assertTrue(
         self.cronquery.start_interval_job("testjob1", message) != True)
コード例 #40
0
ファイル: earth_test.py プロジェクト: capof/domogik
 def test_630_status_moonphase_not_changed(self):
     message = XplMessage()
     message.set_type("xpl-cmnd")
     message.set_schema("earth.request")
     message.add_data({"command" :  "status"})
     message.add_data({"query" :  "moonphase"})
     keys = []
     keyvalss = {'type' : 'moonphase','status':'firstquarter'}
     self.assertFalse(self.query_many("type",message,keys,keyvalss))
コード例 #41
0
ファイル: earthzmq_test.py プロジェクト: capof/domogik
 def test_230_simulate_dawn(self):
     message = XplMessage()
     message.set_type("xpl-trig")
     message.set_schema("earth.basic")
     message.add_data({"type" :  "dawn"})
     message.add_data({"current" :  "fired"})
     keys = ['uptime', 'fullruntime', 'runtime', 'runs', 'next']
     keyvalss = {"type":"dawn", "delay":"0", 'current' : "started"}
     self.assertTrue(self.query("type", message, keys, keyvalss))
コード例 #42
0
ファイル: earth_test.py プロジェクト: capof/domogik
 def test_130_info(self):
     message = XplMessage()
     message.set_type("xpl-cmnd")
     message.set_schema("earth.request")
     message.add_data({"command" :  "info"})
     message.add_data({"type" :  "fullmoon"})
     keys = ['delay', 'current', 'uptime', 'fullruntime', 'runtime', 'runs', 'next']
     keyvalss = {"type" : "fullmoon", "delay":"0"}
     self.assertTrue(self.query_many("type",message,keys,keyvalss))
コード例 #43
0
ファイル: cron_test.py プロジェクト: wookiesh/domogik
 def test_510_resume_dawnalarm1(self):
     message = XplMessage()
     message.set_type("xpl-cmnd")
     message.set_schema("timer.basic")
     message.add_data({"action" :  "resume"})
     message.add_data({"device" :  "alarm1"})
     keys = ['devicetype']
     keyvalss = {"device":"alarm1", "devicetype":"dawnalarm", "state":"started"}
     self.assertTrue(self.query("device", message, keys, keyvalss))
コード例 #44
0
 def send_xpl(self, type, schema, data):
     """ Send xPL message on network
     """
     self.log.debug("{0} for {1}".format(type, data))
     msg = XplMessage()
     msg.set_type(type)
     msg.set_schema(schema)
     msg.add_data(data)
     self.myxpl.send(msg)
コード例 #45
0
ファイル: rest.py プロジェクト: wookiesh/domogik
 def _discover_hosts(self):
     """ Send a hbeat.request to discover managers
     """
     mess = XplMessage()
     mess.set_type('xpl-cmnd')
     mess.set_target("*")
     mess.set_schema('hbeat.request')
     mess.add_data({'command': 'request'})
     self.myxpl.send(mess)
コード例 #46
0
ファイル: earth_test.py プロジェクト: capof/domogik
 def test_460_simulate_lastquarter(self):
     message = XplMessage()
     message.set_type("xpl-trig")
     message.set_schema("earth.basic")
     message.add_data({"type" :  "lastquarter"})
     message.add_data({"current" :  "fired"})
     keys = ['uptime', 'fullruntime', 'runtime', 'runs', 'next']
     keyvalss = {"type":"lastquarter", 'current' : "started"}
     self.assertTrue(self.query_many("type", message, keys, keyvalss))
コード例 #47
0
ファイル: bluez_test.py プロジェクト: wookiesh/domogik
 def test_710_status(self):
     message = XplMessage()
     message.set_type("xpl-cmnd")
     message.set_schema(self.schema)
     message.add_data({"action" :  "status"})
     message.add_data({"device" :  "bluez"})
     keys = None
     keyvalss = {"device":"bluez", "status":"started"}
     self.assertTrue(self.query("device", message, keys, keyvalss))
コード例 #48
0
ファイル: plcbus.py プロジェクト: wookiesh/domogik
 def _command_cb(self, f):
     ''' Called by the plcbus library when a command has been sent.
     If the commands need an ack, this callback will be called only after the ACK has been received
     @param : plcbus frame as an array
     '''
     if f["d_command"] == "GET_ALL_ID_PULSE":
         data = int("%s%s" % (f["d_data1"], f["d_data2"]))
         house = f["d_home_unit"][0]
         for i in range(0, 16):
             unit = data >> i & 1
             code = "%s%s" % (house, i + 1)
             if unit and not code in self._probe_status:
                 self._probe_status[code] = ""
                 self.log.info("New device discovered : %s" % code)
             elif (not unit) and code in self._probe_status:
                 del self._probe_status[code]
     elif f["d_command"] == "GET_ALL_ON_ID_PULSE":
         data = "%s%s" % (bin(f["d_data1"])[2:].zfill(8), bin(
             f["d_data2"])[2:].zfill(8))
         print("f : %s" % f)
         print("data : %s" % data)
         house = f["d_home_unit"][0]
         item = 16
         for c in data:
             unit = int(c)
             code = "%s%s" % (house, item)
             print("Etat : %s " % code, unit)
             if code in self._probe_status and (self._probe_status[code] !=
                                                str(unit)):
                 print('DEBUG in rentre dans le IF detection GET_ALL_ON')
                 self._probe_status[code] = str(unit)
                 if unit == 1:
                     command = "ON"
                 else:
                     command = "OFF"
                 mess = XplMessage()
                 mess.set_type('xpl-trig')
                 mess.set_schema('plcbus.basic')
                 mess.add_data({
                     "usercode": f["d_user_code"],
                     "device": code,
                     "command": command
                 })
                 self.myxpl.send(mess)
             item = item - 1
     else:
         mess = XplMessage()
         mess.set_type('xpl-trig')
         mess.set_schema('plcbus.basic')
         mess.add_data({
             "usercode": f["d_user_code"],
             "device": f["d_home_unit"],
             "command": f["d_command"],
             "data1": f["d_data1"],
             "data2": f["d_data2"]
         })
         self.myxpl.send(mess)
コード例 #49
0
ファイル: earth_test.py プロジェクト: capof/domogik
 def test_907_resume_newmoon(self):
     message = XplMessage()
     message.set_type("xpl-cmnd")
     message.set_schema("earth.basic")
     message.add_data({"action" :  "resume"})
     message.add_data({"type" :  "newmoon"})
     keys = ['uptime', 'fullruntime', 'runtime', 'runs', 'next']
     keyvalss = {"type":"newmoon", 'current' : 'started', 'delay' : '0'}
     self.assertTrue(self.query_many("type", message, keys, keyvalss))
コード例 #50
0
ファイル: earth_test.py プロジェクト: capof/domogik
 def test_920_halt_firstquarter(self):
     message = XplMessage()
     message.set_type("xpl-cmnd")
     message.set_schema("earth.basic")
     message.add_data({"action" :  "halt"})
     message.add_data({"type" :  "firstquarter"})
     keys = ['uptime', 'fullruntime', 'runtime', 'runs', 'next']
     keyvalss = {"type" : "firstquarter", 'current' : 'halted', 'delay' : '0'}
     self.assertTrue(self.query_many("type", message, keys, keyvalss))
コード例 #51
0
 def send_xpl(self, schema, data):
     """ Send xPL message on network
     """
     self.log.info("schema:%s, data:%s" % (schema, data))
     msg = XplMessage()
     msg.set_type("xpl-trig")
     msg.set_schema(schema)
     for key in data:
         msg.add_data({key: data[key]})
     self.myxpl.send(msg)
コード例 #52
0
ファイル: demodata.py プロジェクト: kopec77/domogik
 def send_cid_basic(self, device, calltype, phone_number):
     # Notice that device is not used in this xpl schema
     mess = "cid.basic : calltype=%s, phone=%s" % (calltype, phone_number)
     print(mess)
     self.log.debug(mess)
     msg = XplMessage()
     msg.set_type("xpl-trig")
     msg.set_schema("cid.basic")
     msg.add_data({ 'calltype' : calltype })
     msg.add_data({ 'phone' : phone_number })
     self.myxpl.send(msg)
コード例 #53
0
ファイル: rest.py プロジェクト: wookiesh/domogik
    def _get_installed_packages_from_manager(self):
        """ Send a xpl message to all managers to get installed packages list
        """

        ### Send xpl message to get list
        message = XplMessage()
        message.set_type("xpl-cmnd")
        message.set_schema("domogik.package")
        message.add_data({"command": "installed-packages-list"})
        message.add_data({"host": "*"})
        self.myxpl.send(message)