mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
round output values (#6657)
This commit is contained in:
parent
e75a66ed20
commit
959dd29c90
@ -99,11 +99,13 @@ class ComedHourlyPricingSensor(Entity):
|
|||||||
if self.type == CONF_FIVE_MINUTE:
|
if self.type == CONF_FIVE_MINUTE:
|
||||||
url_string = _RESOURCE + '?type=5minutefeed'
|
url_string = _RESOURCE + '?type=5minutefeed'
|
||||||
response = get(url_string, timeout=10)
|
response = get(url_string, timeout=10)
|
||||||
self._state = float(response.json()[0]['price']) + self.offset
|
self._state = round(
|
||||||
|
float(response.json()[0]['price']) + self.offset, 2)
|
||||||
elif self.type == CONF_CURRENT_HOUR_AVERAGE:
|
elif self.type == CONF_CURRENT_HOUR_AVERAGE:
|
||||||
url_string = _RESOURCE + '?type=currenthouraverage'
|
url_string = _RESOURCE + '?type=currenthouraverage'
|
||||||
response = get(url_string, timeout=10)
|
response = get(url_string, timeout=10)
|
||||||
self._state = float(response.json()[0]['price']) + self.offset
|
self._state = round(
|
||||||
|
float(response.json()[0]['price']) + self.offset, 2)
|
||||||
else:
|
else:
|
||||||
self._state = STATE_UNKNOWN
|
self._state = STATE_UNKNOWN
|
||||||
except (RequestException, ValueError, KeyError):
|
except (RequestException, ValueError, KeyError):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user