Exemple #1
0
    def test_sync_state_address(self):
        """Test sync function / sending group reads to KNX bus. Testing with a Light with dimm functionality."""
        xknx = XKNX(loop=self.loop)
        light = Light(xknx,
                      name="TestLight",
                      group_address_switch='1/2/3',
                      group_address_switch_state='1/2/4',
                      group_address_brightness='1/2/5',
                      group_address_brightness_state='1/2/6',
                      group_address_color='1/2/7',
                      group_address_color_state='1/2/8')
        self.loop.run_until_complete(asyncio.Task(light.sync(False)))

        self.assertEqual(xknx.telegrams.qsize(), 3)

        telegram1 = xknx.telegrams.get_nowait()
        self.assertEqual(
            telegram1, Telegram(GroupAddress('1/2/4'),
                                TelegramType.GROUP_READ))
        telegram2 = xknx.telegrams.get_nowait()
        self.assertEqual(
            telegram2, Telegram(GroupAddress('1/2/8'),
                                TelegramType.GROUP_READ))
        telegram3 = xknx.telegrams.get_nowait()
        self.assertEqual(
            telegram3, Telegram(GroupAddress('1/2/6'),
                                TelegramType.GROUP_READ))
Exemple #2
0
    def test_sync(self):
        """Test sync function / sending group reads to KNX bus. Testing with a Light without dimm functionality."""
        xknx = XKNX()
        light = Light(
            xknx,
            name="TestLight",
            group_address_switch_state="1/2/3",
            group_address_brightness_state="1/2/5",
            group_address_color_state="1/2/6",
            group_address_tunable_white_state="1/2/7",
            group_address_color_temperature_state="1/2/8",
            group_address_rgbw_state="1/2/9",
        )
        self.loop.run_until_complete(light.sync())

        self.assertEqual(xknx.telegrams.qsize(), 6)

        telegrams = []
        for _ in range(6):
            telegrams.append(xknx.telegrams.get_nowait())

        test_telegrams = [
            Telegram(GroupAddress("1/2/3"), TelegramType.GROUP_READ),
            Telegram(GroupAddress("1/2/5"), TelegramType.GROUP_READ),
            Telegram(GroupAddress("1/2/6"), TelegramType.GROUP_READ),
            Telegram(GroupAddress("1/2/7"), TelegramType.GROUP_READ),
            Telegram(GroupAddress("1/2/8"), TelegramType.GROUP_READ),
            Telegram(GroupAddress("1/2/9"), TelegramType.GROUP_READ),
        ]

        self.assertEqual(len(set(telegrams)), 6)
        self.assertEqual(set(telegrams), set(test_telegrams))
Exemple #3
0
    def test_sync_state_address(self):
        """Test sync function / sending group reads to KNX bus. Testing with a Light with dimm functionality."""
        xknx = XKNX(loop=self.loop)
        light = Light(xknx,
                      name="TestLight",
                      group_address_switch='1/2/3',
                      group_address_switch_state='1/2/4',
                      group_address_brightness='1/2/5',
                      group_address_brightness_state='1/2/6',
                      group_address_color='1/2/7',
                      group_address_color_state='1/2/8',
                      group_address_tunable_white='1/2/9',
                      group_address_tunable_white_state='1/2/10',
                      group_address_color_temperature='1/2/11',
                      group_address_color_temperature_state='1/2/12',
                      group_address_rgbw='1/2/13',
                      group_address_rgbw_state='1/2/14')
        self.loop.run_until_complete(asyncio.Task(light.sync()))

        self.assertEqual(xknx.telegrams.qsize(), 6)

        telegrams = []
        for _ in range(6):
            telegrams.append(xknx.telegrams.get_nowait())

        test_telegrams = [
            Telegram(GroupAddress('1/2/4'), TelegramType.GROUP_READ),
            Telegram(GroupAddress('1/2/6'), TelegramType.GROUP_READ),
            Telegram(GroupAddress('1/2/8'), TelegramType.GROUP_READ),
            Telegram(GroupAddress('1/2/10'), TelegramType.GROUP_READ),
            Telegram(GroupAddress('1/2/12'), TelegramType.GROUP_READ),
            Telegram(GroupAddress('1/2/14'), TelegramType.GROUP_READ)
        ]

        self.assertEqual(len(set(telegrams)), 6)
        self.assertEqual(set(telegrams), set(test_telegrams))