Round sensor readings for bom (#39513)

pull/39692/head
springstan 2020-09-02 19:59:21 +02:00 committed by GitHub
parent 5fafaa3c4f
commit e3354895f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -231,7 +231,11 @@ class BOMCurrentData:
through the entire BOM provided dataset.
"""
condition_readings = (entry[condition] for entry in self._data)
return next((x for x in condition_readings if x != "-"), None)
reading = next((x for x in condition_readings if x != "-"), None)
if isinstance(reading, (int, float)):
return round(reading, 2)
return reading
def should_update(self):
"""Determine whether an update should occur.