Fix wallbox sensor rounding (#73310)

pull/73334/head
hesselonline 2022-06-10 20:55:55 +02:00 committed by Paulus Schoutsen
parent c6b68ed916
commit f98f7f2022
2 changed files with 6 additions and 6 deletions

View File

@ -4,10 +4,6 @@
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/wallbox",
"requirements": ["wallbox==0.4.9"],
"ssdp": [],
"zeroconf": [],
"homekit": {},
"dependencies": [],
"codeowners": ["@hesselonline"],
"iot_class": "cloud_polling",
"loggers": ["wallbox"]

View File

@ -167,8 +167,12 @@ class WallboxSensor(WallboxEntity, SensorEntity):
@property
def native_value(self) -> StateType:
"""Return the state of the sensor."""
if (sensor_round := self.entity_description.precision) is not None:
"""Return the state of the sensor. Round the value when it, and the precision property are not None."""
if (
sensor_round := self.entity_description.precision
) is not None and self.coordinator.data[
self.entity_description.key
] is not None:
return cast(
StateType,
round(self.coordinator.data[self.entity_description.key], sensor_round),