def test_message_callback_extended():
    """Test message callback extended."""
    callbacks = MessageCallback()
    callbacktest = "test callback"
    address = '1a2b3c'
    target = '4d5e6f'

    template_ext_on = ExtendedReceive.template(
        commandtuple=COMMAND_LIGHT_ON_0X11_NONE,
        userdata=Userdata({'d1': 0x02}))
    callbacks.add(template_ext_on, callbacktest)
    msg1 = ExtendedReceive(address,
                           target,
                           COMMAND_LIGHT_ON_0X11_NONE,
                           Userdata({'d1': 0x02}),
                           cmd2=0xff)
    msg2 = ExtendedReceive(address,
                           target,
                           COMMAND_LIGHT_ON_0X11_NONE,
                           Userdata({
                               'd1': 0x03,
                               'd2': 0x02
                           }),
                           cmd2=0xff)

    callback1 = callbacks.get_callbacks_from_message(msg1)
    callback2 = callbacks.get_callbacks_from_message(msg2)

    assert callback1[0] == callbacktest
    assert not callback2
示例#2
0
    def _register_messages(self):
        mode_status_msg = StandardReceive.template(
            commandtuple=COMMAND_THERMOSTAT_MODE_STATUS_0X70_NONE,
            address=self._address,
            flags=MessageFlags.template(MESSAGE_TYPE_DIRECT_MESSAGE, None),
        )
        mode_change_fan_on_ack = StandardReceive.template(
            commandtuple=COMMAND_THERMOSTAT_CONTROL_ON_FAN_0X6B_0X07,
            address=self._address,
            flags=MessageFlags.template(MESSAGE_TYPE_DIRECT_MESSAGE_ACK),
        )
        mode_change_fan_auto_ack = StandardReceive.template(
            commandtuple=COMMAND_THERMOSTAT_CONTROL_OFF_FAN_0X6B_0X08,
            address=self._address,
            flags=MessageFlags.template(MESSAGE_TYPE_DIRECT_MESSAGE_ACK),
        )
        mode_change_off_ack = StandardReceive.template(
            commandtuple=COMMAND_THERMOSTAT_CONTROL_OFF_ALL_0X6B_0X09,
            address=self._address,
            flags=MessageFlags.template(MESSAGE_TYPE_DIRECT_MESSAGE_ACK),
        )
        ext_status_recd = ExtendedReceive.template(
            commandtuple=COMMAND_EXTENDED_GET_SET_0X2E_0X00,
            cmd2=0x02,
            userdata=Userdata.template({"d1": 0x01}),
        )

        self._message_callbacks.add(mode_status_msg, self._status_received)
        self._message_callbacks.add(mode_change_fan_on_ack,
                                    self._mode_change_ack)
        self._message_callbacks.add(mode_change_fan_auto_ack,
                                    self._mode_change_ack)
        self._message_callbacks.add(mode_change_off_ack, self._mode_change_ack)
        self._message_callbacks.add(ext_status_recd, self._ext_status_received)
示例#3
0
 def _register_messages(self):
     ext_msg_aldb_record = ExtendedReceive.template(
         address=self._address,
         commandtuple=COMMAND_EXTENDED_READ_WRITE_ALDB_0X2F_0X00,
         userdata=Userdata.template({'d2': 1}),
         flags=MessageFlags.template(
             messageType=MESSAGE_TYPE_DIRECT_MESSAGE, extended=1))
     std_msg_pre_nak = StandardReceive.template(flags=MessageFlags.template(
         messageType=MESSAGE_FLAG_DIRECT_MESSAGE_NAK_0XA0),
                                                cmd2=0xfc)
     ext_msg_pre_nak = ExtendedReceive.template(flags=MessageFlags.template(
         messageType=MESSAGE_FLAG_DIRECT_MESSAGE_NAK_0XA0),
                                                cmd2=0xfc)
     self._message_callbacks.add(ext_msg_aldb_record,
                                 self._handle_aldb_record_received)
     self._message_callbacks.add(std_msg_pre_nak, self._handle_pre_nak)
     self._message_callbacks.add(ext_msg_pre_nak, self._handle_pre_nak)
示例#4
0
    def _register_messages(self):
        temp_msg = StandardReceive.template(
            commandtuple=COMMAND_THERMOSTAT_TEMPERATURE_STATUS_0X6E_NONE,
            address=self._address,
            flags=MessageFlags.template(MESSAGE_TYPE_DIRECT_MESSAGE, None))

        self._message_callbacks.add(temp_msg, self._temp_received)
        ext_status_recd = ExtendedReceive.template(
            commandtuple=COMMAND_EXTENDED_GET_SET_0X2E_0X00,
            cmd2=0x02,
            userdata=Userdata.template({"d1": 0x01}))
        self._message_callbacks.add(ext_status_recd, self._ext_status_received)
示例#5
0
 def _register_messages(self):
     cool_set_point_status = StandardReceive.template(
         address=self._address,
         commandtuple=COMMAND_THERMOSTAT_COOL_SET_POINT_STATUS_0X71_NONE,
         flags=MessageFlags.template(MESSAGE_TYPE_DIRECT_MESSAGE, False))
     self._message_callbacks.add(cool_set_point_status,
                                 self._status_message_received)
     ext_status_recd = ExtendedReceive.template(
         commandtuple=COMMAND_EXTENDED_GET_SET_0X2E_0X00,
         cmd2=0x02,
         userdata=Userdata.template({"d1": 0x01}))
     self._message_callbacks.add(ext_status_recd, self._ext_status_received)
示例#6
0
 def _register_messages(self):
     super()._register_messages()
     template_status_recd = ExtendedReceive.template(
         address=self._address,
         commandtuple=COMMAND_EXTENDED_GET_SET_0X2E_0X00,
         # flags=MessageFlags.template(MESSAGE_TYPE_DIRECT_MESSAGE,
         #                             True),
         userdata={
             'd1': self._group,
             'd2': 0x01
         })
     self._message_callbacks.add(template_status_recd,
                                 self._status_extended_message_received)
示例#7
0
 def _register_messages(self):
     _LOGGER.debug('Starting HeatSetPoint register_messages')
     heat_set_point_status = StandardReceive.template(
         address=self._address,
         commandtuple=COMMAND_THERMOSTAT_HEAT_SET_POINT_STATUS_0X72_NONE,
         flags=MessageFlags.template(MESSAGE_TYPE_DIRECT_MESSAGE, False))
     self._message_callbacks.add(heat_set_point_status,
                                 self._status_message_received)
     ext_status_recd = ExtendedReceive.template(
         commandtuple=COMMAND_EXTENDED_GET_SET_0X2E_0X00,
         cmd2=0x02,
         flags=MessageFlags.template(MESSAGE_TYPE_DIRECT_MESSAGE, True),
         userdata=Userdata.template({"d1": 0x01}))
     _LOGGER.debug('Reg Ext Status: %s', ext_status_recd)
     self._message_callbacks.add(ext_status_recd, self._ext_status_received)