Small cleanups to shelly (#124758)
This commit is contained in:
parent
a63c5e6725
commit
f9bf7f7e05
3 changed files with 13 additions and 11 deletions
|
@ -488,7 +488,7 @@ class ShellyRestAttributeEntity(CoordinatorEntity[ShellyBlockCoordinator]):
|
|||
@property
|
||||
def attribute_value(self) -> StateType:
|
||||
"""Value of sensor."""
|
||||
if callable(self.entity_description.value):
|
||||
if self.entity_description.value is not None:
|
||||
self._last_value = self.entity_description.value(
|
||||
self.block_coordinator.device.status, self._last_value
|
||||
)
|
||||
|
@ -518,7 +518,7 @@ class ShellyRpcAttributeEntity(ShellyRpcEntity, Entity):
|
|||
id_key = key.split(":")[-1]
|
||||
self._id = int(id_key) if id_key.isnumeric() else None
|
||||
|
||||
if callable(description.unit):
|
||||
if description.unit is not None:
|
||||
self._attr_native_unit_of_measurement = description.unit(
|
||||
coordinator.device.config[key]
|
||||
)
|
||||
|
@ -544,7 +544,7 @@ class ShellyRpcAttributeEntity(ShellyRpcEntity, Entity):
|
|||
@property
|
||||
def attribute_value(self) -> StateType:
|
||||
"""Value of sensor."""
|
||||
if callable(self.entity_description.value):
|
||||
if self.entity_description.value is not None:
|
||||
# using "get" here since subkey might not exist (e.g. "errors" sub_key)
|
||||
self._last_value = self.entity_description.value(
|
||||
self.status.get(self.entity_description.sub_key), self._last_value
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue