Exemplo n.º 1
0
    def test_proceed_enocean(self):
        enocean_id = 0x05555555

        device = _MockDevice()
        config = {
            CONFKEY_ENOCEAN_TARGET: enocean_id,
            CONFKEY_MQTT_CHANNEL_STATE: "channel",
            CONFKEY_ENOCEAN_SENDER: 1234,
        }
        device.set_config(config)

        time_1 = datetime.datetime.now(tz=get_localzone())

        message = EnoceanMessage(
            payload=PickleTools.unpickle(PACKET_WIN_TILTED),
            enocean_id=enocean_id)
        device.now = time_1
        device.process_enocean_message(message)

        sent_data = json.loads(device.sent_message)
        self.assertEqual(
            sent_data, {
                'device': 'mock',
                'timestamp': time_1.isoformat(),
                'since': time_1.isoformat(),
                'status': 'tilted'
            })
Exemplo n.º 2
0
 def test_extract_on_33(self):
     packet = PickleTools.unpickle(PACKET_STATUS_ON_33)
     data = Fud61Eep.get_props_from_packet(packet)
     data.pop('LNRB', None)  # depends on enocean version
     self.assertEqual(data, {
         'CMD': 2,
         'EDIM': 33,
         'RMP': 0,
         'EDIMR': 0,
         'STR': 0,
         'SW': 1
     })
Exemplo n.º 3
0
 def test_extract_off_0(self):
     packet = PickleTools.unpickle(PACKET_STATUS_OFF_0)
     # data = Fud61Eep.get_props_from_packet(packet, Fud61Command.DIMMING)
     data = Fud61Eep.get_props_from_packet(packet)
     data.pop('LNRB', None)  # depends on enocean version
     self.assertEqual(data, {
         'CMD': 2,
         'EDIM': 0,
         'RMP': 0,
         'EDIMR': 0,
         'STR': 0,
         'SW': 0
     })
Exemplo n.º 4
0
    def test_proceed_enocean(self):
        device = self.device

        packet = PickleTools.unpickle(PACKET_STATUS_ON_33)
        message = EnoceanMessage(payload=packet,
                                 enocean_id=device._enocean_target)

        device.process_enocean_message(message)

        self.assertEqual(len(device.messages), 1)
        result = json.loads(device.messages[0])

        compare = {
            'timestamp': '2020-01-01T02:02:03+00:00',
            'status': 'on',
            'dimStatus': 33,
            'device': 'mock'
        }
        self.assertEqual(result, compare)
    def test_open(self):
        packet = PickleTools.unpickle(PACKET_WIN_OPEN)

        comp = {'WIN': 2, 'T21': 1, 'NU': 0}
        data = EnoceanTools.extract_packet_props(packet, self.eep)
        self.assertEqual(data, comp)