Skip to content

Commit

Permalink
Add forecast precipitation probability. Fix state sensor to None when…
Browse files Browse the repository at this point in the history
… web service returns -9999 if data is not available at that moment.
  • Loading branch information
Danieldiazi committed Oct 9, 2022
1 parent df79a8e commit 23b12a2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion custom_components/meteogalicia/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,13 @@ async def async_update(self):
item = data.get("predConcello")["listaPredDiaConcello"][
self.forecast_day
]
state = item.get("tMax", "null")
if (
state < 0
): # Sometimes, web service returns -9999 if data is not available at this moment.
state = None

self._state = item.get("tMax", "null")
self._state = state

self._attr = {
"information": information,
Expand Down Expand Up @@ -282,6 +287,11 @@ async def async_update(self):
field = "noite" # night field: 21-6 h
state = item.get("pchoiva", "null")[field]

if (
state < 0
): # Sometimes, web service returns -9999 if data is not available at this moment.
state = None

self._state = state

self._attr = {
Expand Down

0 comments on commit 23b12a2

Please sign in to comment.