Allow decimal numbers (Thanks @luxus)
This commit is contained in:
parent
7da104af4e
commit
a32229b4ce
1 changed files with 9 additions and 6 deletions
|
@ -108,12 +108,15 @@ class CommandSensor(Entity):
|
|||
self.data.update()
|
||||
value = self.data.value
|
||||
|
||||
if value is not None:
|
||||
if self._corr_factor is not None:
|
||||
self._state = round((int(value) * self._corr_factor),
|
||||
self._decimal_places)
|
||||
else:
|
||||
self._state = value
|
||||
try:
|
||||
if value is not None:
|
||||
if self._corr_factor is not None:
|
||||
self._state = round((float(value) * self._corr_factor),
|
||||
self._decimal_places)
|
||||
else:
|
||||
self._state = value
|
||||
except ValueError:
|
||||
self._state = value
|
||||
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue