mirror of
https://github.com/home-assistant/core.git
synced 2025-08-05 21:55:10 +02:00
If decimal_places is 0, cast to int after rounding
This commit is contained in:
@@ -132,6 +132,8 @@ class ArestSensor(Entity):
|
||||
value = float(value) * float(self._corr_factor)
|
||||
if self._decimal_places is not None:
|
||||
value = round(value, self._decimal_places)
|
||||
if self._decimal_places == 0:
|
||||
value = int(value)
|
||||
return value
|
||||
else:
|
||||
return values.get(self._variable, 'n/a')
|
||||
|
@@ -79,6 +79,8 @@ class CommandSensor(Entity):
|
||||
value = float(value) * float(self._corr_factor)
|
||||
if self._decimal_places is not None:
|
||||
value = round(value, self._decimal_places)
|
||||
if self._decimal_places == 0:
|
||||
value = int(value)
|
||||
self._state = value
|
||||
except ValueError:
|
||||
self._state = value
|
||||
|
@@ -140,6 +140,8 @@ class RestSensor(Entity):
|
||||
value = float(value) * float(self._corr_factor)
|
||||
if self._decimal_places is not None:
|
||||
value = round(value, self._decimal_places)
|
||||
if self._decimal_places == 0:
|
||||
value = int(value)
|
||||
self._state = value
|
||||
except ValueError:
|
||||
self._state = RestSensor.extract_value(value, self._variable)
|
||||
|
Reference in New Issue
Block a user