Exemplo n.º 1
0
    def test_process_dimm(self):
        xknx = XKNX(self.loop, start=False)
        light = Light(xknx,
                      name="TestLight",
                      group_address_switch='1/2/3',
                      group_address_dimm='1/2/4',
                      group_address_brightness='1/2/5')
        self.assertEqual(light.brightness, 0)

        telegram = Telegram(Address('1/2/5'), payload=DPTArray(23))
        light.process(telegram)
        self.assertEqual(light.brightness, 23)
Exemplo n.º 2
0
    def test_process_switch_callback(self):
        # pylint: disable=no-self-use
        xknx = XKNX(self.loop, start=False)
        light = Light(xknx,
                      name="TestLight",
                      group_address_switch='1/2/3',
                      group_address_dimm='1/2/4',
                      group_address_brightness='1/2/5')

        after_update_callback = Mock()
        light.after_update_callback = after_update_callback

        telegram = Telegram(Address('1/2/3'), payload=DPTBinary(1))
        light.process(telegram)

        after_update_callback.assert_called_with(light)
Exemplo n.º 3
0
    def test_process_switch(self):
        xknx = XKNX(self.loop, start=False)
        light = Light(xknx,
                      name="TestLight",
                      group_address_switch='1/2/3',
                      group_address_dimm='1/2/4',
                      group_address_brightness='1/2/5')
        self.assertEqual(light.state, False)

        telegram = Telegram(Address('1/2/3'), payload=DPTBinary(1))
        light.process(telegram)
        self.assertEqual(light.state, True)

        telegram = Telegram(Address('1/2/3'), payload=DPTBinary(0))
        light.process(telegram)
        self.assertEqual(light.state, False)