mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00:00
Bugfix for Plugwise, small code optimization (#131990)
This commit is contained in:
parent
521505f9b5
commit
bd8cd87fae
@ -78,19 +78,18 @@ class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity):
|
|||||||
self._attr_extra_state_attributes = {}
|
self._attr_extra_state_attributes = {}
|
||||||
self._attr_unique_id = f"{device_id}-climate"
|
self._attr_unique_id = f"{device_id}-climate"
|
||||||
|
|
||||||
|
self._devices = coordinator.data.devices
|
||||||
|
self._gateway = coordinator.data.gateway
|
||||||
|
gateway_id: str = self._gateway["gateway_id"]
|
||||||
|
self._gateway_data = self._devices[gateway_id]
|
||||||
|
|
||||||
self._location = device_id
|
self._location = device_id
|
||||||
if (location := self.device.get("location")) is not None:
|
if (location := self.device.get("location")) is not None:
|
||||||
self._location = location
|
self._location = location
|
||||||
|
|
||||||
self.cdr_gateway = coordinator.data.gateway
|
|
||||||
gateway_id: str = coordinator.data.gateway["gateway_id"]
|
|
||||||
self.gateway_data = coordinator.data.devices[gateway_id]
|
|
||||||
# Determine supported features
|
# Determine supported features
|
||||||
self._attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
self._attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
||||||
if (
|
if self._gateway["cooling_present"] and self._gateway["smile_name"] != "Adam":
|
||||||
self.cdr_gateway["cooling_present"]
|
|
||||||
and self.cdr_gateway["smile_name"] != "Adam"
|
|
||||||
):
|
|
||||||
self._attr_supported_features = (
|
self._attr_supported_features = (
|
||||||
ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
||||||
)
|
)
|
||||||
@ -116,10 +115,10 @@ class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity):
|
|||||||
"""
|
"""
|
||||||
# When no cooling available, _previous_mode is always heating
|
# When no cooling available, _previous_mode is always heating
|
||||||
if (
|
if (
|
||||||
"regulation_modes" in self.gateway_data
|
"regulation_modes" in self._gateway_data
|
||||||
and "cooling" in self.gateway_data["regulation_modes"]
|
and "cooling" in self._gateway_data["regulation_modes"]
|
||||||
):
|
):
|
||||||
mode = self.gateway_data["select_regulation_mode"]
|
mode = self._gateway_data["select_regulation_mode"]
|
||||||
if mode in ("cooling", "heating"):
|
if mode in ("cooling", "heating"):
|
||||||
self._previous_mode = mode
|
self._previous_mode = mode
|
||||||
|
|
||||||
@ -166,17 +165,17 @@ class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity):
|
|||||||
def hvac_modes(self) -> list[HVACMode]:
|
def hvac_modes(self) -> list[HVACMode]:
|
||||||
"""Return a list of available HVACModes."""
|
"""Return a list of available HVACModes."""
|
||||||
hvac_modes: list[HVACMode] = []
|
hvac_modes: list[HVACMode] = []
|
||||||
if "regulation_modes" in self.gateway_data:
|
if "regulation_modes" in self._gateway_data:
|
||||||
hvac_modes.append(HVACMode.OFF)
|
hvac_modes.append(HVACMode.OFF)
|
||||||
|
|
||||||
if "available_schedules" in self.device:
|
if "available_schedules" in self.device:
|
||||||
hvac_modes.append(HVACMode.AUTO)
|
hvac_modes.append(HVACMode.AUTO)
|
||||||
|
|
||||||
if self.cdr_gateway["cooling_present"]:
|
if self._gateway["cooling_present"]:
|
||||||
if "regulation_modes" in self.gateway_data:
|
if "regulation_modes" in self._gateway_data:
|
||||||
if self.gateway_data["select_regulation_mode"] == "cooling":
|
if self._gateway_data["select_regulation_mode"] == "cooling":
|
||||||
hvac_modes.append(HVACMode.COOL)
|
hvac_modes.append(HVACMode.COOL)
|
||||||
if self.gateway_data["select_regulation_mode"] == "heating":
|
if self._gateway_data["select_regulation_mode"] == "heating":
|
||||||
hvac_modes.append(HVACMode.HEAT)
|
hvac_modes.append(HVACMode.HEAT)
|
||||||
else:
|
else:
|
||||||
hvac_modes.append(HVACMode.HEAT_COOL)
|
hvac_modes.append(HVACMode.HEAT_COOL)
|
||||||
@ -192,17 +191,21 @@ class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity):
|
|||||||
self._previous_action_mode(self.coordinator)
|
self._previous_action_mode(self.coordinator)
|
||||||
|
|
||||||
# Adam provides the hvac_action for each thermostat
|
# Adam provides the hvac_action for each thermostat
|
||||||
if (control_state := self.device.get("control_state")) == "cooling":
|
if self._gateway["smile_name"] == "Adam":
|
||||||
return HVACAction.COOLING
|
if (control_state := self.device.get("control_state")) == "cooling":
|
||||||
if control_state == "heating":
|
return HVACAction.COOLING
|
||||||
return HVACAction.HEATING
|
if control_state == "heating":
|
||||||
if control_state == "preheating":
|
return HVACAction.HEATING
|
||||||
return HVACAction.PREHEATING
|
if control_state == "preheating":
|
||||||
if control_state == "off":
|
return HVACAction.PREHEATING
|
||||||
|
if control_state == "off":
|
||||||
|
return HVACAction.IDLE
|
||||||
|
|
||||||
return HVACAction.IDLE
|
return HVACAction.IDLE
|
||||||
|
|
||||||
heater: str = self.coordinator.data.gateway["heater_id"]
|
# Anna
|
||||||
heater_data = self.coordinator.data.devices[heater]
|
heater: str = self._gateway["heater_id"]
|
||||||
|
heater_data = self._devices[heater]
|
||||||
if heater_data["binary_sensors"]["heating_state"]:
|
if heater_data["binary_sensors"]["heating_state"]:
|
||||||
return HVACAction.HEATING
|
return HVACAction.HEATING
|
||||||
if heater_data["binary_sensors"].get("cooling_state", False):
|
if heater_data["binary_sensors"].get("cooling_state", False):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user