Esempio n. 1
0
    def test_device_by_group_address(self):
        """Test get devices by group address."""
        xknx = XKNX()
        devices = Devices()

        light1 = Light(xknx,
                       "Living-Room.Light_1",
                       group_address_switch="1/6/7")
        devices.add(light1)

        sensor1 = BinarySensor(xknx,
                               "DiningRoom.Motion.Sensor",
                               group_address_state="3/0/1")
        devices.add(sensor1)

        sensor2 = BinarySensor(xknx,
                               "DiningRoom.Motion.Sensor",
                               group_address_state="3/0/1")
        devices.add(sensor2)

        light2 = Light(xknx,
                       "Living-Room.Light_2",
                       group_address_switch="1/6/8")
        devices.add(light2)

        self.assertEqual(
            tuple(devices.devices_by_group_address(GroupAddress("1/6/7"))),
            (light1, ))
        self.assertEqual(
            tuple(devices.devices_by_group_address(GroupAddress("1/6/8"))),
            (light2, ))
        self.assertEqual(
            tuple(devices.devices_by_group_address(GroupAddress("3/0/1"))),
            (sensor1, sensor2),
        )
Esempio n. 2
0
    def test_device_by_group_address(self):
        """Test get devices by group address."""
        xknx = XKNX(loop=self.loop)
        devices = Devices()

        light1 = Light(xknx,
                       'Living-Room.Light_1',
                       group_address_switch='1/6/7')
        devices.add(light1)

        sensor1 = BinarySensor(xknx,
                               'DiningRoom.Motion.Sensor',
                               group_address_state='3/0/1')
        devices.add(sensor1)

        sensor2 = BinarySensor(xknx,
                               'DiningRoom.Motion.Sensor',
                               group_address_state='3/0/1')
        devices.add(sensor2)

        light2 = Light(xknx,
                       'Living-Room.Light_2',
                       group_address_switch='1/6/8')
        devices.add(light2)

        self.assertEqual(
            tuple(devices.devices_by_group_address(GroupAddress('1/6/7'))),
            (light1, ))
        self.assertEqual(
            tuple(devices.devices_by_group_address(GroupAddress('1/6/8'))),
            (light2, ))
        self.assertEqual(
            tuple(devices.devices_by_group_address(GroupAddress('3/0/1'))),
            (sensor1, sensor2))
Esempio n. 3
0
    def test_device_by_group_address(self):
        """Test get devices by group address."""
        xknx = XKNX()
        devices = Devices()

        light1 = Light(xknx, "Livingroom", group_address_switch="1/6/7")
        sensor1 = BinarySensor(xknx, "Diningroom", group_address_state="3/0/1")
        sensor2 = BinarySensor(xknx, "Diningroom", group_address_state="3/0/1")
        light2 = Light(xknx, "Livingroom", group_address_switch="1/6/8")
        devices.add(light1)
        devices.add(sensor1)
        devices.add(sensor2)
        devices.add(light2)

        assert tuple(devices.devices_by_group_address(
            GroupAddress("1/6/7"))) == (light1, )
        assert tuple(devices.devices_by_group_address(
            GroupAddress("1/6/8"))) == (light2, )
        assert tuple(devices.devices_by_group_address(
            GroupAddress("3/0/1"))) == (
                sensor1,
                sensor2,
            )
Esempio n. 4
0
    def test_device_by_group_address(self):
        """Test get devices by group address."""
        xknx = XKNX(loop=self.loop)
        devices = Devices()

        light1 = Light(xknx,
                       'Living-Room.Light_1',
                       group_address_switch='1/6/7')
        devices.add(light1)

        sensor1 = BinarySensor(xknx,
                               'DiningRoom.Motion.Sensor',
                               group_address_state='3/0/1',
                               significant_bit=2)
        devices.add(sensor1)

        sensor2 = BinarySensor(xknx,
                               'DiningRoom.Motion.Sensor',
                               group_address_state='3/0/1',
                               significant_bit=3)
        devices.add(sensor2)

        light2 = Light(xknx,
                       'Living-Room.Light_2',
                       group_address_switch='1/6/8')
        devices.add(light2)

        self.assertEqual(
            tuple(devices.devices_by_group_address(GroupAddress('1/6/7'))),
            (light1,))
        self.assertEqual(
            tuple(devices.devices_by_group_address(GroupAddress('1/6/8'))),
            (light2,))
        self.assertEqual(
            tuple(devices.devices_by_group_address(GroupAddress('3/0/1'))),
            (sensor1, sensor2))
Esempio n. 5
0
 def test_modification_of_device(self):
     """Test if devices object does store references and not copies of objects."""
     xknx = XKNX(loop=self.loop)
     devices = Devices()
     light1 = Light(xknx,
                    'Living-Room.Light_1',
                    group_address_switch='1/6/7')
     devices.add(light1)
     for device in devices:
         self.loop.run_until_complete(asyncio.Task(device.set_on()))
     self.assertTrue(light1.state)
     device2 = devices["Living-Room.Light_1"]
     self.loop.run_until_complete(asyncio.Task(device2.set_off()))
     self.assertFalse(light1.state)
     for device in devices.devices_by_group_address(GroupAddress('1/6/7')):
         self.loop.run_until_complete(asyncio.Task(device.set_on()))
     self.assertTrue(light1.state)
Esempio n. 6
0
 def test_modification_of_device(self):
     """Test if devices object does store references and not copies of objects."""
     xknx = XKNX(loop=self.loop)
     devices = Devices()
     light1 = Light(xknx,
                    'Living-Room.Light_1',
                    group_address_switch='1/6/7')
     devices.add(light1)
     for device in devices:
         self.loop.run_until_complete(asyncio.Task(device.set_on()))
     self.assertTrue(light1.state)
     device2 = devices["Living-Room.Light_1"]
     self.loop.run_until_complete(asyncio.Task(device2.set_off()))
     self.assertFalse(light1.state)
     for device in devices.devices_by_group_address(GroupAddress('1/6/7')):
         self.loop.run_until_complete(asyncio.Task(device.set_on()))
     self.assertTrue(light1.state)