Wallbox remove unnecessary try..except (#68636)

This commit is contained in:
hesselonline 2022-03-24 22:09:59 +01:00 committed by GitHub
parent a566d3943c
commit 5fffe9b22f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -169,14 +169,8 @@ class WallboxSensor(WallboxEntity, SensorEntity):
def native_value(self) -> StateType:
"""Return the state of the sensor."""
if (sensor_round := self.entity_description.precision) is not None:
try:
return cast(
StateType,
round(
self.coordinator.data[self.entity_description.key], sensor_round
),
)
except TypeError:
_LOGGER.debug("Cannot format %s", self._attr_name)
return None
return cast(
StateType,
round(self.coordinator.data[self.entity_description.key], sensor_round),
)
return cast(StateType, self.coordinator.data[self.entity_description.key])