Allow decimal numbers (Thanks @luxus)

This commit is contained in:
Fabian Affolter 2015-09-19 11:46:22 +02:00
parent 7da104af4e
commit a32229b4ce

View file

@ -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