Exemple #1
0
 def test_set_color_not_possible(self):
     """Test setting the color of a non light without color."""
     # pylint: disable=invalid-name
     xknx = XKNX()
     light = Light(xknx, name="TestLight", group_address_switch="1/2/3")
     with patch("logging.Logger.warning") as mock_warn:
         self.loop.run_until_complete(light.set_color((23, 24, 25)))
         self.assertEqual(xknx.telegrams.qsize(), 0)
         mock_warn.assert_called_with("Colors not supported for device %s",
                                      "TestLight")
Exemple #2
0
 def test_set_color_rgbw_not_possible(self):
     """Test setting RGBW value of a non light without color."""
     # pylint: disable=invalid-name
     xknx = XKNX(loop=self.loop)
     light = Light(xknx,
                   name="TestLight",
                   group_address_switch='1/2/3',
                   group_address_color='1/2/4')
     with patch('logging.Logger.warning') as mock_warn:
         self.loop.run_until_complete(asyncio.Task(light.set_color((23, 24, 25), 26)))
         self.assertEqual(xknx.telegrams.qsize(), 0)
         mock_warn.assert_called_with('RGBW not supported for device %s', 'TestLight')
Exemple #3
0
 def test_set_color(self):
     """Test setting the color of a Light."""
     xknx = XKNX(loop=self.loop)
     light = Light(xknx,
                   name="TestLight",
                   group_address_switch='1/2/3',
                   group_address_color='1/2/5')
     self.loop.run_until_complete(asyncio.Task(light.set_color((23, 24, 25))))
     self.assertEqual(xknx.telegrams.qsize(), 1)
     telegram = xknx.telegrams.get_nowait()
     self.assertEqual(telegram,
                      Telegram(GroupAddress('1/2/5'), payload=DPTArray((23, 24, 25))))
     self.assertEqual(light.current_color, ((23, 24, 25), None))
Exemple #4
0
 def test_set_color(self):
     """Test setting the color of a Light."""
     xknx = XKNX()
     light = Light(
         xknx,
         name="TestLight",
         group_address_switch="1/2/3",
         group_address_color="1/2/5",
     )
     self.loop.run_until_complete(light.set_color((23, 24, 25)))
     self.assertEqual(xknx.telegrams.qsize(), 1)
     telegram = xknx.telegrams.get_nowait()
     self.assertEqual(
         telegram,
         Telegram(GroupAddress("1/2/5"), payload=DPTArray((23, 24, 25))))
     self.loop.run_until_complete(xknx.devices.process(telegram))
     self.assertEqual(light.current_color, ((23, 24, 25), None))
Exemple #5
0
 def test_set_color_rgbw(self):
     """Test setting RGBW value of a Light."""
     xknx = XKNX(loop=self.loop)
     light = Light(
         xknx,
         name="TestLight",
         group_address_switch="1/2/3",
         group_address_color="1/2/4",
         group_address_rgbw="1/2/5",
     )
     self.loop.run_until_complete(light.set_color((23, 24, 25), 26))
     self.assertEqual(xknx.telegrams.qsize(), 1)
     telegram = xknx.telegrams.get_nowait()
     self.assertEqual(
         telegram,
         Telegram(GroupAddress("1/2/5"),
                  payload=DPTArray((23, 24, 25, 26, 0, 15))),
     )
     self.loop.run_until_complete(xknx.devices.process(telegram))
     self.assertEqual(light.current_color, ([23, 24, 25], 26))