def test_set_controller_mode(self):
     """Test setting value."""
     xknx = XKNX()
     remote_value = RemoteValueControllerMode(
         xknx,
         group_address=GroupAddress("1/2/3"),
     )
     self.loop.run_until_complete(remote_value.set(HVACControllerMode.COOL))
     self.assertEqual(xknx.telegrams.qsize(), 1)
     telegram = xknx.telegrams.get_nowait()
     self.assertEqual(
         telegram,
         Telegram(
             destination_address=GroupAddress("1/2/3"),
             payload=GroupValueWrite(DPTArray((0x03, ))),
         ),
     )
     self.loop.run_until_complete(
         remote_value.set(HVACControllerMode.NIGHT_PURGE))
     self.assertEqual(xknx.telegrams.qsize(), 1)
     telegram = xknx.telegrams.get_nowait()
     self.assertEqual(
         telegram,
         Telegram(
             destination_address=GroupAddress("1/2/3"),
             payload=GroupValueWrite(DPTArray((0x04, ))),
         ),
     )
 def test_process_controller_mode(self):
     """Test process telegram."""
     xknx = XKNX()
     remote_value = RemoteValueControllerMode(
         xknx,
         group_address=GroupAddress("1/2/3"),
     )
     telegram = Telegram(
         destination_address=GroupAddress("1/2/3"),
         payload=GroupValueWrite(DPTArray((0x00, ))),
     )
     self.loop.run_until_complete(remote_value.process(telegram))
     self.assertEqual(remote_value.value, HVACControllerMode.AUTO)
 def test_to_knx_error_controller_mode(self):
     """Test to_knx function with wrong parameter."""
     xknx = XKNX()
     remote_value = RemoteValueControllerMode(xknx)
     with self.assertRaises(ConversionError):
         remote_value.to_knx(256)
     with self.assertRaises(ConversionError):
         remote_value.to_knx("256")
     with self.assertRaises(ConversionError):
         remote_value.to_knx(HVACOperationMode.NIGHT)
 async def test_process_controller_mode(self):
     """Test process telegram."""
     xknx = XKNX()
     remote_value = RemoteValueControllerMode(
         xknx, group_address=GroupAddress("1/2/3"))
     telegram = Telegram(
         destination_address=GroupAddress("1/2/3"),
         payload=GroupValueWrite(DPTArray((0x00, ))),
     )
     await remote_value.process(telegram)
     assert remote_value.value == HVACControllerMode.AUTO
 def test_to_process_error_controller_mode(self):
     """Test process errornous telegram."""
     xknx = XKNX()
     remote_value = RemoteValueControllerMode(
         xknx,
         group_address=GroupAddress("1/2/3"),
     )
     with self.assertRaises(CouldNotParseTelegram):
         telegram = Telegram(
             destination_address=GroupAddress("1/2/3"),
             payload=GroupValueWrite(DPTBinary(1)),
         )
         self.loop.run_until_complete(remote_value.process(telegram))
     with self.assertRaises(CouldNotParseTelegram):
         telegram = Telegram(
             destination_address=GroupAddress("1/2/3"),
             payload=GroupValueWrite(DPTArray((
                 0x64,
                 0x65,
             ))),
         )
         self.loop.run_until_complete(remote_value.process(telegram))
 async def test_to_process_error_controller_mode(self):
     """Test process errornous telegram."""
     xknx = XKNX()
     remote_value = RemoteValueControllerMode(
         xknx, group_address=GroupAddress("1/2/3"))
     with pytest.raises(CouldNotParseTelegram):
         telegram = Telegram(
             destination_address=GroupAddress("1/2/3"),
             payload=GroupValueWrite(DPTBinary(1)),
         )
         await remote_value.process(telegram)
     with pytest.raises(CouldNotParseTelegram):
         telegram = Telegram(
             destination_address=GroupAddress("1/2/3"),
             payload=GroupValueWrite(DPTArray((0x64, 0x65))),
         )
         await remote_value.process(telegram)
 async def test_set_controller_mode(self):
     """Test setting value."""
     xknx = XKNX()
     remote_value = RemoteValueControllerMode(
         xknx, group_address=GroupAddress("1/2/3"))
     await remote_value.set(HVACControllerMode.COOL)
     assert xknx.telegrams.qsize() == 1
     telegram = xknx.telegrams.get_nowait()
     assert telegram == Telegram(
         destination_address=GroupAddress("1/2/3"),
         payload=GroupValueWrite(DPTArray((0x03, ))),
     )
     await remote_value.set(HVACControllerMode.NIGHT_PURGE)
     assert xknx.telegrams.qsize() == 1
     telegram = xknx.telegrams.get_nowait()
     assert telegram == Telegram(
         destination_address=GroupAddress("1/2/3"),
         payload=GroupValueWrite(DPTArray((0x04, ))),
     )
 def test_from_knx_controller_mode(self):
     """Test from_knx function with normal operation."""
     xknx = XKNX()
     remote_value = RemoteValueControllerMode(xknx)
     self.assertEqual(remote_value.from_knx(DPTArray((0x02, ))),
                      HVACControllerMode.MORNING_WARMUP)
 def test_to_knx_controller_mode(self):
     """Test to_knx function with normal operation."""
     xknx = XKNX()
     remote_value = RemoteValueControllerMode(xknx, )
     self.assertEqual(remote_value.to_knx(HVACControllerMode.HEAT),
                      DPTArray((0x01, )))