mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 10:17:51 +00:00
Code quality improvements for dsmr
(#82443)
This commit is contained in:
parent
982e75a15f
commit
c899e72029
@ -559,6 +559,7 @@ class DSMREntity(SensorEntity):
|
|||||||
@property
|
@property
|
||||||
def native_value(self) -> StateType:
|
def native_value(self) -> StateType:
|
||||||
"""Return the state of sensor, if available, translate if needed."""
|
"""Return the state of sensor, if available, translate if needed."""
|
||||||
|
value: StateType
|
||||||
if (value := self.get_dsmr_object_attr("value")) is None:
|
if (value := self.get_dsmr_object_attr("value")) is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -573,10 +574,7 @@ class DSMREntity(SensorEntity):
|
|||||||
float(value), self._entry.data.get(CONF_PRECISION, DEFAULT_PRECISION)
|
float(value), self._entry.data.get(CONF_PRECISION, DEFAULT_PRECISION)
|
||||||
)
|
)
|
||||||
|
|
||||||
if value is not None:
|
return value
|
||||||
return value
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_unit_of_measurement(self) -> str | None:
|
def native_unit_of_measurement(self) -> str | None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user