def test_extract_release(self):
     packet = PickleTools.unpickle_packet(PACKET_RELEASE)
     device = _MockDevice()
     extracted = EnoceanTools.extract_packet_props(packet, device._eep)
     action = RockerAction(press=RockerPress.RELEASE)
     expected = RockerSwitchTools.create_props(action)
     self.assertEqual(extracted, expected)
    def test_ft55(self):
        packet = PickleTools.unpickle_packet(PACKET_FT55_21L)

        # f6-02-02
        eep = Eep(rorg=0xf6, func=0x02, type=0x02)

        data = EnoceanTools.extract_props(packet, eep)
        self.assertTrue(data)
Ejemplo n.º 3
0
    def test_extract_1_off(self):
        packet = PickleTools.unpickle_packet(_PACKET_1_OFF)

        device = _MockDevice()
        data = EnoceanTools.extract_packet_props(packet,
                                                 _MockDevice.DEFAULT_EEP)

        notification = device.extract_notification(data)
        self.assertEqual(notification.channel, 1)
        self.assertEqual(notification.switch_state, SwitchStatus.OFF)
    def test_all(self):
        dest = 0xffffffff
        sender = 0x0594f8e9

        test_items = [
            (PACKET_1, Fsb61State(type=Fsb61StateType.CLOSED, time=4.2, destination=dest, sender=sender, rssi=-74)),
            (PACKET_2, Fsb61State(type=Fsb61StateType.OPENING, destination=dest, sender=sender, rssi=-58)),
            (PACKET_3, Fsb61State(type=Fsb61StateType.OPENED, time=2.6, destination=dest, sender=sender, rssi=-64)),
            (PACKET_4, Fsb61State(type=Fsb61StateType.STOPPED, destination=dest, sender=sender, rssi=-61)),
            (PACKET_5, Fsb61State(type=Fsb61StateType.CLOSING, destination=dest, sender=sender, rssi=-57)),
        ]
        for pickeled_packet, expected_status in test_items:
            packet = PickleTools.unpickle_packet(pickeled_packet)
            status = Fsb61StateConverter.extract_packet(packet)
            self.assertEqual(status, expected_status)
Ejemplo n.º 5
0
    def test_packet_roundtrip(self):
        props_in = {'R1': 1, 'EB': 1, 'R2': 0, 'SA': 0, 'T21': 1, 'NU': 1}

        eep = Eep(rorg=0xf6, func=0x02, type=0x02)
        packet_in = EnoceanPacketFactory.create_packet(
            eep=eep,
            destination=EnoceanTools.int_to_byte_list(0xffffffff),
            learn=False,
            **props_in
        )

        text = PickleTools.pickle_packet(packet_in)
        packet_out = PickleTools.unpickle_packet(text)

        self.assertEqual(packet_out, packet_in)
    def test_extract_press(self):
        loop_data = [
            (PACKET_0_PRESS, RockerButton.ROCK0),
            (PACKET_1_PRESS, RockerButton.ROCK1),
            (PACKET_2_PRESS, RockerButton.ROCK2),
            (PACKET_3_PRESS, RockerButton.ROCK3),
        ]

        for i in range(0, 3):
            packet = PickleTools.unpickle_packet(loop_data[i][0])
            device = _MockDevice()
            extracted = EnoceanTools.extract_packet_props(packet, device._eep)
            action = RockerAction(press=RockerPress.PRESS_SHORT,
                                  button=loop_data[i][1])
            expected = RockerSwitchTools.create_props(action)
            self.assertEqual(extracted, expected)
 def test_ignore_unknown(self):
     packet = PickleTools.unpickle_packet(PACKET_UNKNOWN_1)
     status = Fsb61StateConverter.extract_packet(packet)
     self.assertEqual(status.type, Fsb61StateType.UNKNOWN)