Fix missing linked device on Overkiz integration (#114006)

* Fix missing linked device (#112731)

* Update homeassistant/components/overkiz/executor.py

Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>

---------

Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
This commit is contained in:
Jeremy TRUFIER 2024-03-23 10:21:20 +01:00 committed by GitHub
parent 39c44ad5b7
commit 4f22c85e39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 33 additions and 14 deletions

View File

@ -143,7 +143,9 @@ class AtlanticElectricalHeaterWithAdjustableTemperatureSetpoint(
@property
def current_temperature(self) -> float | None:
"""Return the current temperature."""
if temperature := self.temperature_device.states[OverkizState.CORE_TEMPERATURE]:
if self.temperature_device is not None and (
temperature := self.temperature_device.states[OverkizState.CORE_TEMPERATURE]
):
return temperature.value_as_float
return None

View File

@ -95,7 +95,9 @@ class AtlanticElectricalTowelDryer(OverkizEntity, ClimateEntity):
@property
def current_temperature(self) -> float | None:
"""Return the current temperature."""
if temperature := self.temperature_device.states[OverkizState.CORE_TEMPERATURE]:
if self.temperature_device is not None and (
temperature := self.temperature_device.states[OverkizState.CORE_TEMPERATURE]
):
return cast(float, temperature.value)
return None

View File

@ -69,7 +69,9 @@ class AtlanticHeatRecoveryVentilation(OverkizEntity, ClimateEntity):
@property
def current_temperature(self) -> float | None:
"""Return the current temperature."""
if temperature := self.temperature_device.states[OverkizState.CORE_TEMPERATURE]:
if self.temperature_device is not None and (
temperature := self.temperature_device.states[OverkizState.CORE_TEMPERATURE]
):
return cast(float, temperature.value)
return None

View File

@ -108,7 +108,9 @@ class AtlanticPassAPCHeatingZone(OverkizEntity, ClimateEntity):
@property
def current_temperature(self) -> float | None:
"""Return the current temperature."""
if temperature := self.temperature_device.states[OverkizState.CORE_TEMPERATURE]:
if self.temperature_device is not None and (
temperature := self.temperature_device.states[OverkizState.CORE_TEMPERATURE]
):
return cast(float, temperature.value)
return None

View File

@ -24,7 +24,7 @@ OVERKIZ_MODE_TO_PRESET_MODES: dict[str, str] = {
PRESET_MODES_TO_OVERKIZ = {v: k for k, v in OVERKIZ_MODE_TO_PRESET_MODES.items()}
TEMPERATURE_ZONECONTROL_DEVICE_INDEX = 1
TEMPERATURE_ZONECONTROL_DEVICE_INDEX = 20
# Those device depends on a main probe that choose the operating mode (heating, cooling, ...)
@ -65,10 +65,15 @@ class AtlanticPassAPCZoneControlZone(AtlanticPassAPCHeatingZone):
"""Return hvac operation ie. heat, cool, dry, off mode."""
if (
self.zone_control_device is not None
and (
state := self.zone_control_device.states[
OverkizState.IO_PASS_APC_OPERATING_MODE
]
) is not None and (value := state.value_as_str) is not None:
)
is not None
and (value := state.value_as_str) is not None
):
return OVERKIZ_TO_HVAC_MODE[value]
return HVACMode.OFF

View File

@ -166,7 +166,9 @@ class SomfyHeatingTemperatureInterface(OverkizEntity, ClimateEntity):
@property
def current_temperature(self) -> float | None:
"""Return the current temperature."""
if temperature := self.temperature_device.states[OverkizState.CORE_TEMPERATURE]:
if self.temperature_device is not None and (
temperature := self.temperature_device.states[OverkizState.CORE_TEMPERATURE]
):
return temperature.value_as_float
return None

View File

@ -104,7 +104,9 @@ class SomfyThermostat(OverkizEntity, ClimateEntity):
@property
def current_temperature(self) -> float | None:
"""Return the current temperature."""
if temperature := self.temperature_device.states[OverkizState.CORE_TEMPERATURE]:
if self.temperature_device is not None and (
temperature := self.temperature_device.states[OverkizState.CORE_TEMPERATURE]
):
return cast(float, temperature.value)
return None

View File

@ -91,7 +91,9 @@ class ValveHeatingTemperatureInterface(OverkizEntity, ClimateEntity):
@property
def current_temperature(self) -> float | None:
"""Return the current temperature."""
if temperature := self.temperature_device.states[OverkizState.CORE_TEMPERATURE]:
if self.temperature_device is not None and (
temperature := self.temperature_device.states[OverkizState.CORE_TEMPERATURE]
):
return temperature.value_as_float
return None

View File

@ -41,9 +41,9 @@ class OverkizExecutor:
"""Return Overkiz device linked to this entity."""
return self.coordinator.data[self.device_url]
def linked_device(self, index: int) -> Device:
def linked_device(self, index: int) -> Device | None:
"""Return Overkiz device sharing the same base url."""
return self.coordinator.data[f"{self.base_device_url}#{index}"]
return self.coordinator.data.get(f"{self.base_device_url}#{index}")
def select_command(self, *commands: str) -> str | None:
"""Select first existing command in a list of commands."""