From c899e72029af78aa768a912c2d7ad87a9ab8ef3f Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon, 21 Nov 2022 10:13:22 +0100 Subject: [PATCH] Code quality improvements for `dsmr` (#82443) --- homeassistant/components/dsmr/sensor.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/dsmr/sensor.py b/homeassistant/components/dsmr/sensor.py index aa01c798072..02a14601cc3 100644 --- a/homeassistant/components/dsmr/sensor.py +++ b/homeassistant/components/dsmr/sensor.py @@ -559,6 +559,7 @@ class DSMREntity(SensorEntity): @property def native_value(self) -> StateType: """Return the state of sensor, if available, translate if needed.""" + value: StateType if (value := self.get_dsmr_object_attr("value")) is None: return None @@ -573,10 +574,7 @@ class DSMREntity(SensorEntity): float(value), self._entry.data.get(CONF_PRECISION, DEFAULT_PRECISION) ) - if value is not None: - return value - - return None + return value @property def native_unit_of_measurement(self) -> str | None: