Пример #1
0
    def test_0110_send_code_standard(self):
        """ check if the xpl messages about get_switch_state are OK
            Sample message : 
            xpl-trig
            {
            hop=1
            source=domogik-daikcode.domogik-vm1
            target=*
            }
            irtrans.basic
            {
            device=/home
            device=Daikin remote 1
            current=19465224
            }
        dmg_send xpl-cmnd irtrans.basic "device=IRTrans_1,command=send,datatype=IRTrans standard,code=a22222,timing=a45454"   
            
        """

        global device_id
        global xpl_plugin

        # do the test
        print(u"********** start testing xpl command send standard code IR.")
        command = TestCommand(self, device_id, 'send_standard')
        print(u'try to send xpl_cmnd fake....'
              )  # "command" : "send",  "datatype" : "IRTrans standard",
        self.assertTrue(
            command.test_XplCmd({
                "code": CODE_IR,
                "timing": TIMING
            }, {"result": "ok"}))
        msg1_time = datetime.now()
        time.sleep(8)
    def test_feature(self, address, unit, device_id, command, rest_command):
        """ Do the tests 
            @param address : device address
            @param unit : device unit
            @param device_id : device id
            @param command
            @param rest_command
        """

        # test 
        print(u"Device address = {0}".format(address))
        print(u"Device unit = {0}".format(unit))
        print(u"Device id = {0}".format(device_id))

        print(u"Call REST to send an '{0}'  command".format(rest_command))
        tc = TestCommand(device_id, "switch_lighting2")
        # send command
        tc.send_command(rest_command)
        print(u"Check that a message with command = 'off' is sent.")
        
        self.assertTrue(self.wait_for_xpl(xpltype = "xpl-trig",
                                          xplschema = "ac.basic",
                                          xplsource = "domogik-{0}.{1}".format(self.name, get_sanitized_hostname()),
                                          data = {"command" : command,
                                                  "address" : address,
                                                  "unit" : unit},
                                          timeout = 60))
        print(u"Check that the value of the xPL message has been inserted in database")
        sensor = TestSensor(device_id, "switch_lighting2")
        print(sensor.get_last_value())
        from domogik_packages.plugin_rfxcom.conversion.from_off_on_to_DT_Switch import from_off_on_to_DT_Switch
        # the data is converted to be inserted in database
        self.assertTrue(int(sensor.get_last_value()[1]) == from_off_on_to_DT_Switch(self.xpl_data.data['command']))
Пример #3
0
    def test_0110_get_switch_state(self):
        """ check if the xpl messages about get_switch_state are OK
            Sample message : 
            xpl-trig
            {
            hop=1
            source=domogik-daikcode.domogik-vm1
            target=*
            }
            sensor.basic
            {
            device=/home
            device=Daikin remote 1
            current=19465224
            }
        """
        global device_id
        global xpl_plugin

        # do the test
        print(u"********** start testing xpl command set_power.")
        command = TestCommand(self, device_id, 'set_power')
        print(u'try to send xpl_cmnd fake....')
        self.assertTrue(
            command.test_XplCmd({
                "command": "switch",
                "power": "On"
            }, {"state": "On"}))
        msg1_time = datetime.now()
        time.sleep(8)
        print(u"********** start testing xpl command set_setpoint.")
        command2 = TestCommand(self, device_id, 'set_setpoint')
        self.assertTrue(
            command2.test_XplCmd({
                "command": "setpoint",
                "temp": 23
            }, {"temp": 23}))
        time.sleep(8)