mirror of
https://github.com/home-assistant/core.git
synced 2026-09-04 10:05:34 -05:00
Remove unnecessary None checks in Renault numbers and binary sensors (#167271)
This commit is contained in:
@@ -84,15 +84,12 @@ class RenaultBinarySensor(
|
||||
|
||||
def _plugged_in_value_lambda(self: RenaultBinarySensor) -> bool | None:
|
||||
"""Return true if the vehicle is plugged in."""
|
||||
|
||||
data = self.coordinator.data
|
||||
plug_status = data.get_plug_status() if data else None
|
||||
|
||||
if plug_status is not None:
|
||||
if (plug_status := self.coordinator.data.get_plug_status()) is not None:
|
||||
return plug_status == PlugState.PLUGGED
|
||||
|
||||
charging_status = data.get_charging_status() if data else None
|
||||
if charging_status is not None and charging_status in _PLUG_FROM_CHARGE_STATUS:
|
||||
if (
|
||||
charging_status := self.coordinator.data.get_charging_status()
|
||||
) is not None and charging_status in _PLUG_FROM_CHARGE_STATUS:
|
||||
return True
|
||||
|
||||
return None
|
||||
|
||||
@@ -43,9 +43,7 @@ async def _set_charge_limit_min(entity: RenaultNumberEntity, value: float) -> No
|
||||
|
||||
The target SOC is required to set the minimum SOC, so we need to fetch it first.
|
||||
"""
|
||||
if (data := entity.coordinator.data) is None or (
|
||||
target_soc := data.socTarget
|
||||
) is None:
|
||||
if (target_soc := entity.coordinator.data.socTarget) is None:
|
||||
raise ServiceValidationError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="battery_soc_unavailable",
|
||||
@@ -58,7 +56,7 @@ async def _set_charge_limit_target(entity: RenaultNumberEntity, value: float) ->
|
||||
|
||||
The minimum SOC is required to set the target SOC, so we need to fetch it first.
|
||||
"""
|
||||
if (data := entity.coordinator.data) is None or (min_soc := data.socMin) is None:
|
||||
if (min_soc := entity.coordinator.data.socMin) is None:
|
||||
raise ServiceValidationError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="battery_soc_unavailable",
|
||||
|
||||
Reference in New Issue
Block a user