Skip to content

Commit

Permalink
Update climate.py BenPru#245
Browse files Browse the repository at this point in the history
BenPru#255 BenPru#245 
* Try fix warning 'implicitly supports the turn_on/turn_off methods'
  • Loading branch information
BenPru authored Sep 28, 2024
1 parent e801237 commit 08d3b37
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion custom_components/luxtronik/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@
hvac_action_mapping=HVAC_ACTION_MAPPING_HEAT,
preset_modes=[PRESET_NONE, PRESET_AWAY, PRESET_BOOST],
supported_features=ClimateEntityFeature.PRESET_MODE
| ClimateEntityFeature.TURN_OFF # noqa: W503
| ClimateEntityFeature.TURN_ON # noqa: W503
| ClimateEntityFeature.TARGET_TEMPERATURE, # noqa: W503
luxtronik_key=LuxParameter.P0003_MODE_HEATING,
# luxtronik_key_current_temperature=LuxCalculation.C0227_ROOM_THERMOSTAT_TEMPERATURE,
Expand All @@ -126,7 +128,9 @@
hvac_mode_mapping=HVAC_MODE_MAPPING_COOL,
hvac_action_mapping=HVAC_ACTION_MAPPING_COOL,
preset_modes=[PRESET_NONE],
supported_features=ClimateEntityFeature.TARGET_TEMPERATURE,
supported_features=ClimateEntityFeature.TURN_OFF
| ClimateEntityFeature.TURN_ON # noqa: W503
| ClimateEntityFeature.TARGET_TEMPERATURE, # noqa: W503
luxtronik_key=LuxParameter.P0108_MODE_COOLING,
# luxtronik_key_current_temperature=LuxCalculation.C0227_ROOM_THERMOSTAT_TEMPERATURE,
luxtronik_key_target_temperature=LuxParameter.P0110_COOLING_OUTDOOR_TEMP_THRESHOLD,
Expand Down Expand Up @@ -223,6 +227,7 @@ def __init__(
self._attr_temperature_unit = description.temperature_unit
self._attr_hvac_modes = description.hvac_modes
self._attr_preset_modes = description.preset_modes
self._enable_turn_on_off_backwards_compatibility = False
self._attr_supported_features = description.supported_features

self._sensor_data = get_sensor_data(
Expand Down Expand Up @@ -310,6 +315,12 @@ async def async_set_temperature(self, **kwargs: Any) -> None:
self._attr_target_temperature = kwargs[ATTR_TEMPERATURE]
super()._handle_coordinator_update()

async def async_turn_off(self) -> None:
await self.async_set_hvac_mode(HVACMode.OFF)

async def async_turn_on(self) -> None:
await self.async_set_hvac_mode(self.entity_description.hvac_mode_mapping[LuxMode.automatic.value])

async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
"""Set new target hvac mode."""
self._attr_hvac_mode = hvac_mode
Expand Down

0 comments on commit 08d3b37

Please sign in to comment.