def test_set_operation_mode(self):
     """Test setting value."""
     xknx = XKNX()
     remote_value = RemoteValueOperationMode(
         xknx,
         group_address=GroupAddress("1/2/3"),
         climate_mode_type=RemoteValueOperationMode.ClimateModeType.
         HVAC_MODE,
     )
     self.loop.run_until_complete(remote_value.set(HVACOperationMode.NIGHT))
     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(HVACOperationMode.FROST_PROTECTION))
     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_from_knx_operation_mode(self):
     """Test from_knx function with normal operation."""
     xknx = XKNX()
     remote_value = RemoteValueOperationMode(
         xknx,
         climate_mode_type=RemoteValueOperationMode.ClimateModeType.
         HVAC_MODE)
     self.assertEqual(remote_value.from_knx(DPTArray((0x02, ))),
                      HVACOperationMode.STANDBY)
 def test_to_knx_operation_mode(self):
     """Test to_knx function with normal operation."""
     xknx = XKNX()
     remote_value = RemoteValueOperationMode(
         xknx,
         climate_mode_type=RemoteValueOperationMode.ClimateModeType.
         HVAC_MODE)
     self.assertEqual(remote_value.to_knx(HVACOperationMode.COMFORT),
                      DPTArray((0x01, )))
 def test_to_knx_error_operation_mode(self):
     """Test to_knx function with wrong parameter."""
     xknx = XKNX()
     remote_value = RemoteValueOperationMode(
         xknx,
         climate_mode_type=RemoteValueOperationMode.ClimateModeType.
         HVAC_MODE)
     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(HVACControllerMode.HEAT)
 def test_process_operation_mode(self):
     """Test process telegram."""
     xknx = XKNX()
     remote_value = RemoteValueOperationMode(
         xknx,
         group_address=GroupAddress("1/2/3"),
         climate_mode_type=RemoteValueOperationMode.ClimateModeType.
         HVAC_MODE,
     )
     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, HVACOperationMode.AUTO)
 async def test_process_operation_mode(self):
     """Test process telegram."""
     xknx = XKNX()
     remote_value = RemoteValueOperationMode(
         xknx,
         group_address=GroupAddress("1/2/3"),
         climate_mode_type=RemoteValueOperationMode.ClimateModeType.
         HVAC_MODE,
     )
     telegram = Telegram(
         destination_address=GroupAddress("1/2/3"),
         payload=GroupValueWrite(DPTArray((0x00, ))),
     )
     await remote_value.process(telegram)
     assert remote_value.value == HVACOperationMode.AUTO
 async def test_to_process_error_operation_mode(self):
     """Test process errornous telegram."""
     xknx = XKNX()
     remote_value = RemoteValueOperationMode(
         xknx,
         group_address=GroupAddress("1/2/3"),
         climate_mode_type=RemoteValueOperationMode.ClimateModeType.
         HVAC_MODE,
     )
     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_operation_mode(self):
     """Test setting value."""
     xknx = XKNX()
     remote_value = RemoteValueOperationMode(
         xknx,
         group_address=GroupAddress("1/2/3"),
         climate_mode_type=RemoteValueOperationMode.ClimateModeType.
         HVAC_MODE,
     )
     await remote_value.set(HVACOperationMode.NIGHT)
     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(HVACOperationMode.FROST_PROTECTION)
     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_operation_mode_error(self):
     """Test from_knx function with invalid payload."""
     xknx = XKNX()
     with self.assertRaises(ConversionError):
         RemoteValueOperationMode(xknx, climate_mode_type=None)