Exemplo n.º 1
0
async def main():
    """Connect to KNX/IP bus and run scene."""
    xknx = XKNX()
    await xknx.start()
    scene = Scene(xknx, name="Romantic", group_address="7/0/9", scene_number=23)
    await scene.run()
    await xknx.stop()
Exemplo n.º 2
0
 def test_scene(self):
     """Test string representation of scene object."""
     xknx = XKNX()
     scene = Scene(xknx, name="Romantic", group_address="1/2/3", scene_number=23)
     assert (
         str(scene)
         == '<Scene name="Romantic" scene_value=<1/2/3, None, [], None /> scene_number="23" />'
     )
Exemplo n.º 3
0
 def test_unique_id(self):
     """Test unique id functionality."""
     xknx = XKNX()
     scene = Scene(xknx,
                   "TestScene",
                   group_address="1/2/1",
                   scene_number=23)
     assert scene.unique_id == "1/2/1_23"
Exemplo n.º 4
0
 def test_config_scene(self):
     """Test reading Scene from config file."""
     self.assertEqual(
         TestConfig.xknx.devices["Romantic"],
         Scene(TestConfig.xknx,
               "Romantic",
               group_address="7/0/1",
               scene_number=23),
     )
Exemplo n.º 5
0
 def test_has_group_address(self):
     """Test has_group_address."""
     xknx = XKNX()
     scene = Scene(xknx,
                   "TestScene",
                   group_address="1/2/1",
                   scene_number=23)
     assert scene.has_group_address(GroupAddress("1/2/1"))
     assert not scene.has_group_address(GroupAddress("2/2/2"))
Exemplo n.º 6
0
 def test_has_group_address(self):
     """Test has_group_address."""
     xknx = XKNX(loop=self.loop)
     scene = Scene(xknx,
                   'TestScene',
                   group_address='1/2/1',
                   scene_number=23)
     self.assertTrue(scene.has_group_address(GroupAddress('1/2/1')))
     self.assertFalse(scene.has_group_address(GroupAddress('2/2/2')))
Exemplo n.º 7
0
 def test_has_group_address(self):
     """Test has_group_address."""
     xknx = XKNX(loop=self.loop)
     scene = Scene(xknx,
                   "TestScene",
                   group_address="1/2/1",
                   scene_number=23)
     self.assertTrue(scene.has_group_address(GroupAddress("1/2/1")))
     self.assertFalse(scene.has_group_address(GroupAddress("2/2/2")))
Exemplo n.º 8
0
 def test_config_scene(self):
     """Test reading Scene from config file."""
     self.assertEqual(
         TestConfig.xknx.devices["Romantic"],
         Scene(TestConfig.xknx,
               "Romantic",
               group_address='7/0/1',
               scene_number=23,
               device_updated_cb=TestConfig.xknx.devices.device_updated))
Exemplo n.º 9
0
 def test_sync(self):
     """Test sync function / sending group reads to KNX bus."""
     xknx = XKNX(loop=self.loop)
     scene = Scene(xknx,
                   'TestScene',
                   group_address='1/2/1',
                   scene_number=23)
     self.loop.run_until_complete(asyncio.Task(scene.sync(False)))
     self.assertEqual(xknx.telegrams.qsize(), 0)
Exemplo n.º 10
0
 def test_sync(self):
     """Test sync function / sending group reads to KNX bus."""
     xknx = XKNX(loop=self.loop)
     scene = Scene(xknx,
                   "TestScene",
                   group_address="1/2/1",
                   scene_number=23)
     self.loop.run_until_complete(scene.sync())
     self.assertEqual(xknx.telegrams.qsize(), 0)
Exemplo n.º 11
0
 async def test_sync(self):
     """Test sync function / sending group reads to KNX bus."""
     xknx = XKNX()
     scene = Scene(xknx,
                   "TestScene",
                   group_address="1/2/1",
                   scene_number=23)
     await scene.sync()
     assert xknx.telegrams.qsize() == 0
Exemplo n.º 12
0
 def test_config_scene(self):
     """Test reading Scene from config file."""
     xknx = XKNX(config='xknx.yaml', loop=self.loop)
     self.assertEqual(
         xknx.devices["Romantic"],
         Scene(xknx,
               "Romantic",
               group_address='7/0/1',
               scene_number=23,
               device_updated_cb=xknx.devices.device_updated))
Exemplo n.º 13
0
 async def test_run(self):
     """Test running scene."""
     xknx = XKNX()
     scene = Scene(xknx, "TestScene", group_address="1/2/1", scene_number=23)
     await scene.run()
     assert xknx.telegrams.qsize() == 1
     telegram = xknx.telegrams.get_nowait()
     assert telegram == Telegram(
         destination_address=GroupAddress("1/2/1"),
         payload=GroupValueWrite(DPTArray(0x16)),
     )
Exemplo n.º 14
0
 def test_scene(self):
     """Test string representation of scene object."""
     xknx = XKNX(loop=self.loop)
     scene = Scene(xknx,
                   name='Romantic',
                   group_address='1/2/3',
                   scene_number=23)
     self.assertEqual(
         str(scene),
         '<Scene name="Romantic" scene_value="GroupAddress("1/2/3")/None/None/None" scene_number="23" />'
     )
Exemplo n.º 15
0
 def test_wrong_do(self):
     """Test wrong do command."""
     xknx = XKNX(loop=self.loop)
     scene = Scene(
         xknx,
         'TestScene',
         group_address='1/2/1',
         scene_number=23)
     with patch('logging.Logger.warning') as mockWarn:
         self.loop.run_until_complete(asyncio.Task(scene.do("execute")))
         mockWarn.assert_called_with('Could not understand action %s for device %s', 'execute', 'TestScene')
     self.assertEqual(xknx.telegrams.qsize(), 0)
Exemplo n.º 16
0
 def test_run(self):
     """Test running scene."""
     xknx = XKNX(loop=self.loop)
     scene = Scene(xknx,
                   'TestScene',
                   group_address='1/2/1',
                   scene_number=23)
     self.loop.run_until_complete(asyncio.Task(scene.run()))
     self.assertEqual(xknx.telegrams.qsize(), 1)
     telegram = xknx.telegrams.get_nowait()
     self.assertEqual(
         telegram, Telegram(GroupAddress('1/2/1'), payload=DPTArray(0x16)))
Exemplo n.º 17
0
 def test_do(self):
     """Test running scene with do command."""
     xknx = XKNX(loop=self.loop)
     scene = Scene(xknx,
                   "TestScene",
                   group_address="1/2/1",
                   scene_number=23)
     self.loop.run_until_complete(scene.do("run"))
     self.assertEqual(xknx.telegrams.qsize(), 1)
     telegram = xknx.telegrams.get_nowait()
     self.assertEqual(
         telegram, Telegram(GroupAddress("1/2/1"), payload=DPTArray(0x16)))
Exemplo n.º 18
0
 def test_wrong_do(self):
     """Test wrong do command."""
     xknx = XKNX(loop=self.loop)
     scene = Scene(xknx,
                   "TestScene",
                   group_address="1/2/1",
                   scene_number=23)
     with patch("logging.Logger.warning") as mockWarn:
         self.loop.run_until_complete(scene.do("execute"))
         mockWarn.assert_called_with(
             "Could not understand action %s for device %s", "execute",
             "TestScene")
     self.assertEqual(xknx.telegrams.qsize(), 0)
Exemplo n.º 19
0
 def test_run(self):
     """Test running scene."""
     xknx = XKNX()
     scene = Scene(xknx,
                   "TestScene",
                   group_address="1/2/1",
                   scene_number=23)
     self.loop.run_until_complete(scene.run())
     self.assertEqual(xknx.telegrams.qsize(), 1)
     telegram = xknx.telegrams.get_nowait()
     self.assertEqual(
         telegram,
         Telegram(
             destination_address=GroupAddress("1/2/1"),
             payload=GroupValueWrite(DPTArray(0x16)),
         ),
     )