def test_from_knx_binary_heat_cool(self):
     """Test from_knx function with invalid payload."""
     xknx = XKNX()
     remote_value = RemoteValueBinaryHeatCool(
         xknx, controller_mode=HVACControllerMode.HEAT)
     with self.assertRaises(CouldNotParseTelegram):
         remote_value.from_knx(DPTArray((0x9, 0xF)))
 def test_to_process_error_heat_cool(self):
     """Test process errornous telegram."""
     xknx = XKNX()
     remote_value = RemoteValueBinaryHeatCool(
         xknx,
         group_address=GroupAddress("1/2/3"),
         controller_mode=HVACControllerMode.COOL,
     )
     with self.assertRaises(CouldNotParseTelegram):
         telegram = Telegram(
             destination_address=GroupAddress("1/2/3"),
             payload=GroupValueWrite(DPTArray((0x01,))),
         )
         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))
 def test_to_knx_heat_cool_error(self):
     """Test to_knx function with wrong controller mode."""
     xknx = XKNX()
     remote_value = RemoteValueBinaryHeatCool(
         xknx, controller_mode=HVACControllerMode.HEAT)
     with self.assertRaises(ConversionError):
         remote_value.to_knx(HVACOperationMode.STANDBY)
 def test_to_knx_heat_cool(self):
     """Test to_knx function with normal operation."""
     xknx = XKNX()
     remote_value = RemoteValueBinaryHeatCool(
         xknx, controller_mode=HVACControllerMode.HEAT)
     assert remote_value.to_knx(HVACControllerMode.HEAT) == DPTBinary(True)
     assert remote_value.to_knx(HVACControllerMode.COOL) == DPTBinary(False)
 def test_from_knx_heat_cool(self):
     """Test from_knx function with normal operation."""
     xknx = XKNX()
     remote_value = RemoteValueBinaryHeatCool(
         xknx, controller_mode=HVACControllerMode.HEAT)
     self.assertEqual(remote_value.from_knx(DPTBinary(True)),
                      HVACControllerMode.HEAT)
     self.assertEqual(remote_value.from_knx(DPTBinary(False)),
                      HVACControllerMode.COOL)
Ejemplo n.º 6
0
 def test_to_knx_heat_cool(self):
     """Test to_knx function with normal operation."""
     xknx = XKNX()
     remote_value = RemoteValueBinaryHeatCool(
         xknx, operation_mode=HVACOperationMode.HEAT)
     self.assertEqual(remote_value.to_knx(HVACOperationMode.HEAT),
                      DPTBinary(True))
     self.assertEqual(remote_value.to_knx(HVACOperationMode.COOL),
                      DPTBinary(False))
 def test_from_knx_unknown_operation_mode(self):
     """Test from_knx function with unsupported operation."""
     xknx = XKNX()
     with self.assertRaises(ConversionError):
         RemoteValueBinaryHeatCool(xknx, controller_mode=None)
Ejemplo n.º 8
0
    def __init__(
        self,
        xknx,
        name,
        group_address_operation_mode=None,
        group_address_operation_mode_state=None,
        group_address_operation_mode_protection=None,
        group_address_operation_mode_night=None,
        group_address_operation_mode_comfort=None,
        group_address_operation_mode_standby=None,
        group_address_controller_status=None,
        group_address_controller_status_state=None,
        group_address_controller_mode=None,
        group_address_controller_mode_state=None,
        group_address_heat_cool=None,
        group_address_heat_cool_state=None,
        operation_modes=None,
        controller_modes=None,
        device_updated_cb=None,
    ):
        """Initialize ClimateMode class."""
        # pylint: disable=too-many-arguments, too-many-locals, too-many-branches, too-many-statements
        super().__init__(xknx, name, device_updated_cb)

        self.remote_value_operation_mode = RemoteValueClimateMode(
            xknx,
            group_address=group_address_operation_mode,
            group_address_state=group_address_operation_mode_state,
            sync_state=True,
            device_name=name,
            feature_name="Operation mode",
            climate_mode_type=RemoteValueClimateMode.ClimateModeType.HVAC_MODE,
            after_update_cb=None,
        )
        self.remote_value_controller_mode = RemoteValueClimateMode(
            xknx,
            group_address=group_address_controller_mode,
            group_address_state=group_address_controller_mode_state,
            sync_state=True,
            device_name=name,
            feature_name="Controller mode",
            climate_mode_type=RemoteValueClimateMode.ClimateModeType.
            HVAC_CONTR_MODE,
            after_update_cb=None,
        )
        self.remote_value_controller_status = RemoteValueClimateMode(
            xknx,
            group_address=group_address_controller_status,
            group_address_state=group_address_controller_status_state,
            sync_state=True,
            device_name=name,
            feature_name="Controller status",
            climate_mode_type=RemoteValueClimateMode.ClimateModeType.
            CONTROLLER_STATUS,
            after_update_cb=None,
        )

        self.remote_value_operation_mode_comfort = RemoteValueBinaryOperationMode(
            xknx,
            group_address=group_address_operation_mode_comfort,
            group_address_state=group_address_operation_mode_comfort,
            sync_state=True,
            device_name=name,
            feature_name="Operation mode Comfort",
            operation_mode=HVACOperationMode.COMFORT,
            after_update_cb=None,
        )
        self.remote_value_operation_mode_standby = RemoteValueBinaryOperationMode(
            xknx,
            group_address=group_address_operation_mode_standby,
            group_address_state=group_address_operation_mode_standby,
            sync_state=True,
            device_name=name,
            feature_name="Operation mode Standby",
            operation_mode=HVACOperationMode.STANDBY,
            after_update_cb=None,
        )
        self.remote_value_operation_mode_night = RemoteValueBinaryOperationMode(
            xknx,
            group_address=group_address_operation_mode_night,
            group_address_state=group_address_operation_mode_night,
            sync_state=True,
            device_name=name,
            feature_name="Operation mode Night",
            operation_mode=HVACOperationMode.NIGHT,
            after_update_cb=None,
        )
        self.remote_value_operation_mode_protection = RemoteValueBinaryOperationMode(
            xknx,
            group_address=group_address_operation_mode_protection,
            group_address_state=group_address_operation_mode_protection,
            sync_state=True,
            device_name=name,
            feature_name="Operation mode Protection",
            operation_mode=HVACOperationMode.FROST_PROTECTION,
            after_update_cb=None,
        )
        self.remote_value_heat_cool = RemoteValueBinaryHeatCool(
            xknx,
            group_address=group_address_heat_cool,
            group_address_state=group_address_heat_cool_state,
            sync_state=True,
            device_name=name,
            feature_name="Heat/Cool",
            controller_mode=HVACControllerMode.HEAT,
            after_update_cb=None,
        )

        self.operation_mode = HVACOperationMode.STANDBY
        self.controller_mode = HVACControllerMode.HEAT

        self._operation_modes = []
        if operation_modes is None:
            self._operation_modes = self.gather_operation_modes()
        else:
            for mode in operation_modes:
                if isinstance(mode, str):
                    self._operation_modes.append(HVACOperationMode(mode))
                elif isinstance(mode, HVACOperationMode):
                    self._operation_modes.append(mode)

        self._controller_modes = []
        if controller_modes is None:
            self._controller_modes = self.gather_controller_modes()
        else:
            for mode in controller_modes:
                if isinstance(mode, str):
                    self._controller_modes.append(HVACControllerMode(mode))
                elif isinstance(mode, HVACControllerMode):
                    self._controller_modes.append(mode)

        self.supports_operation_mode = any(
            operation_mode.initialized
            for operation_mode in self._iter_byte_operation_modes()) or any(
                operation_mode.initialized
                for operation_mode in self._iter_binary_operation_modes())
        self.supports_controller_mode = any(
            operation_mode.initialized
            for operation_mode in self._iter_controller_remote_values())

        self._use_binary_operation_modes = any(
            operation_mode.initialized
            for operation_mode in self._iter_binary_operation_modes())
Ejemplo n.º 9
0
 def test_from_knx_unsupported_operation_mode(self):
     """Test from_knx function with unsupported operation."""
     xknx = XKNX()
     with self.assertRaises(ConversionError):
         RemoteValueBinaryHeatCool(xknx,
                                   operation_mode=HVACOperationMode.NODEM)
 def test_from_knx_unsupported_operation_mode(self):
     """Test from_knx function with unsupported operation."""
     xknx = XKNX()
     with pytest.raises(ConversionError):
         RemoteValueBinaryHeatCool(xknx,
                                   controller_mode=HVACControllerMode.NODEM)