Code quality improvements for dsmr (#82443)

This commit is contained in:
Marc Mueller 2022-11-21 10:13:22 +01:00 committed by GitHub
parent 982e75a15f
commit c899e72029
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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: