Exemplo n.º 1
0
 def setUp(self):
     self.hex_user_data = "0102030405060708090a0b0c0d0e"
     self.bytes_user_data = unhexlify(self.hex_user_data)
     self.user_data = UserData(unhexlify(self.hex_user_data))
     self.empty_user_data = create_empty()
     self.emtpy_none_user_data = create_empty(None)
     self.values_user_data = create_empty()
     self._data = {
         "d1": 0xB1,
         "d2": 0xB2,
         "d3": 0xB3,
         "d4": 0xB4,
         "d5": 0xB5,
         "d6": 0xB6,
         "d7": 0xB7,
         "d8": 0xB8,
         "d9": 0xB9,
         "d10": 0xBA,
         "d11": 0xBB,
         "d12": 0xBC,
         "d13": 0xBD,
         "d14": 0xBE,
     }
     self.dict_user_data = UserData(self._data)
     for itm in range(1, 15):
         key = "d{}".format(itm)
         self.values_user_data[key] = itm + 0xA0
     set_log_levels(
         logger="info",
         logger_pyinsteon="info",
         logger_messages="info",
         logger_topics=False,
     )
Exemplo n.º 2
0
def create_std_ext_msg(address, flags, cmd1, cmd2, user_data=None, target=None, ack=0):
    """Create a standard or extended message."""
    from pyinsteon.protocol.messages.user_data import UserData

    address = Address(address)
    data = bytearray()
    data.append(0x02)
    if target:
        target = Address(target)
        msg_type = 0x51 if user_data else 0x50
    else:
        msg_type = 0x62
    data.append(msg_type)
    data.append(address.high)
    data.append(address.middle)
    data.append(address.low)
    if target:
        data.append(target.high)
        data.append(target.middle)
        data.append(target.low)
    data.append(flags)
    data.append(cmd1)
    data.append(cmd2)
    if user_data:
        user_data = UserData(user_data)
        for byte in user_data:
            data.append(user_data[byte])
    if ack:
        data.append(ack)
    return bytes(data)
Exemplo n.º 3
0
    def setUp(self):
        """Test set up."""
        self.hex = "0262010203140506a1a2a3a4a5a6a7a8a9aaabacadae"
        self.message_id = MessageId.SEND_EXTENDED
        self.address = Address("010203")
        self.flags = MessageFlags(0x14)
        self.cmd1 = int(0x05)
        self.cmd2 = int(0x06)
        self.user_data = UserData(unhexlify(self.hex)[8:])

        kwargs = {
            "address": self.address,
            "flags": self.flags,
            "cmd1": self.cmd1,
            "cmd2": self.cmd2,
            "user_data": self.user_data,
        }

        super(TestSendExtended, self).base_setup(MessageId.SEND_EXTENDED,
                                                 unhexlify(self.hex), **kwargs)
        set_log_levels(
            logger="info",
            logger_pyinsteon="info",
            logger_messages="info",
            logger_topics=False,
        )
Exemplo n.º 4
0
    def setUp(self):
        """Set up the test."""
        self.hex_data = "0251112233445566778899a1a2a3a4a5a6a7a8a9aaabacadae"
        self.message_id = 0x51
        self.bytes_data = bytearray(unhexlify(self.hex_data))
        self.address = Address("112233")
        self.target = Address("445566")
        self.flags = MessageFlags(0x77)
        self.cmd1 = int(0x88)
        self.cmd2 = int(0x99)
        self.user_data = UserData(unhexlify("a1a2a3a4a5a6a7a8a9aaabacadae"))

        self.msg, self.msg_bytes = hex_to_inbound_message(self.hex_data)
        set_log_levels(
            logger="info",
            logger_pyinsteon="info",
            logger_messages="info",
            logger_topics=False,
        )
Exemplo n.º 5
0
    def setUp(self):
        """Test set up."""
        self.buffer = True
        self.hex_data = "0262010203140506a1a2a3a4a5a6a7a8a9aaabacadae06"
        self.bytes_data = bytearray(unhexlify(self.hex_data))
        self.message_id = MessageId.SEND_EXTENDED.value
        self.address = Address("010203")
        self.flags = MessageFlags(0x14)
        self.cmd1 = int(0x05)
        self.cmd2 = int(0x06)
        self.user_data = UserData(unhexlify("a1a2a3a4a5a6a7a8a9aaabacadae"))
        self.ack = MESSAGE_ACK

        self.msg, self.msg_bytes = hex_to_inbound_message(self.hex_data)
        set_log_levels(
            logger="info",
            logger_pyinsteon="info",
            logger_messages="info",
            logger_topics=False,
        )
Exemplo n.º 6
0
    async def test_data_update(self):
        """Test data updates."""

        self._properties["prop3"] = self._epm.create("prop3", 1, 3, None, None)
        self._properties["prop4"] = self._epm.create("prop4", 1, 4, None, None)
        self._properties["prop5"] = self._epm.create("prop5", 1, 5, None, None)
        self._properties["prop6"] = self._epm.create("prop6", 1, 6, None, None)
        self._properties["prop7"] = self._epm.create("prop7", 1, 7, None, None)
        self._properties["prop8"] = self._epm.create("prop8", 1, 8, None, None)
        self._properties["prop9"] = self._epm.create("prop9", 1, 9, None, None)
        self._properties["prop100"] = self._epm.create("prop100", 1, 10, 0,
                                                       None)
        self._properties["prop101"] = self._epm.create("prop101", 1, 10, 1,
                                                       None)
        self._properties["prop102"] = self._epm.create("prop102", 1, 10, 2,
                                                       None)
        self._properties["prop103"] = self._epm.create("prop103", 1, 10, 3,
                                                       None)

        user_data = UserData({
            "d1": 0x01,
            "d2": 0x01,
            "d3": 0x03,
            "d4": 0x04,
            "d5": 0x05,
            "d6": 0x06,
            "d7": 0x07,
            "d8": 0x08,
            "d9": 0x09,
            "d10": 0x0A,
            "d11": 0x0B,
            "d12": 0x0C,
            "d13": 0x0D,
            "d14": 0x0E,
        })
        ack = build_topic(
            prefix="ack",
            topic=EXTENDED_GET_SET,
            address=self._address,
            message_type="direct",
        )
        dir_ack = build_topic(topic=EXTENDED_GET_SET,
                              address=self._address,
                              message_type="direct_ack")
        resp = build_topic(topic=EXTENDED_GET_RESPONSE,
                           address=self._address,
                           message_type="direct")

        topic_ack = TopicItem(
            ack, cmd_kwargs(0x2E, 0x00, UserData({
                "d1": 0,
                "d2": 1
            })), 1)
        topic_dir_ack = TopicItem(
            dir_ack, cmd_kwargs(0x2E, 0x00, None, target="030405"), 0.1)
        topic_resp = TopicItem(
            resp, cmd_kwargs(0x2E, 0x00, user_data, target="030405"), 0.2)
        send_topics([topic_ack, topic_dir_ack, topic_resp])
        result = await self._epm.async_read(group=1)
        assert int(result) == 1
        await asyncio.sleep(1)
        assert self._properties["prop3"].value == 0x03
        assert self._properties["prop9"].value == 0x09
        assert self._properties["prop101"].value
        assert not self._properties["prop102"].value