home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.96k stars 30.52k forks source link

wunderground - no data validation #8801

Closed bbrendon closed 6 years ago

bbrendon commented 7 years ago

Hass 0.50.2

I found this in the database stored for my pws_temp_f entity while I was researching data reliability issues from wunderground (value based). I wasn't expecting to find a string where there is usually (should only be) float.

 <function WUCurrentConditionsSensorConfig.__init__.<locals>.<lambda> at 0x7f0d6a20d6a8>

| sensor.pws_temp_f | <function WUCurrentConditionsSensorConfig.__init__.<locals>.<lambda> at 0x7f0d6a20d6a8> | 2017-08-02 11:37:41 | 2017-08-02 11:37:41 |

Where I would expect something like:
| sensor.pws_temp_f | 96.4   | 2017-08-02 22:12:50 | 2017-08-02 22:12:50 |
| sensor.pws_temp_f | 95.0   | 2017-08-02 22:18:00 | 2017-08-02 22:18:00 |

It appears wunderground sensor doesn't make sure its storing a float in the database. It just dumps whatever.

fronzbot commented 7 years ago

Currently running 0.52.1 and seeing the same behavior. Wundergound sensor just throws whatever the API gives it:

image

EDIT - A restart fixes the issue. For what it's worth, this is the first time I've ever noticed this problem. I am seeing a similar problem in the logs after restart, but the sensor data (that I use, anyways) looks OK right now.

Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/aiohttp/web_protocol.py", line 422, in start
    resp = yield from self._request_handler(request)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/aiohttp/web.py", line 306, in _handle
    resp = yield from handler(request)
  File "/usr/lib/python3.4/asyncio/coroutines.py", line 143, in coro
    res = yield from res
  File "/usr/lib/python3.4/asyncio/coroutines.py", line 143, in coro
    res = yield from res
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/http/ban.py", line 58, in ban_middleware_handler
    return (yield from handler(request))
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/http/__init__.py", line 421, in handle
    result = handler(request, **request.match_info)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/api.py", line 186, in get
    return self.json(request.app['hass'].states.async_all())
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/http/__init__.py", line 363, in json
    result, sort_keys=True, cls=rem.JSONEncoder).encode('UTF-8')
  File "/usr/lib/python3.4/json/__init__.py", line 237, in dumps
    **kw).encode(obj)
  File "/usr/lib/python3.4/json/encoder.py", line 192, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.4/json/encoder.py", line 250, in iterencode
    return _iterencode(o, 0)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/remote.py", line 141, in default
    return json.JSONEncoder.default(self, o)
  File "/usr/lib/python3.4/json/encoder.py", line 173, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <function WUDailySimpleForecastSensorConfig.__init__.<locals>.<lambda> at 0x6e3812b8> is not JSON serializable
2017-09-09 16:29:31 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/remote.py", line 132, in default
    return json.JSONEncoder.default(self, o)
  File "/usr/lib/python3.4/json/encoder.py", line 173, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <function WUDailySimpleForecastSensorConfig.__init__.<locals>.<lambda> at 0x6e3812b8> is not JSON serializable
arsaboo commented 7 years ago

I am also seeing these in Wunderground. This looks relevant in the logs:

2017-09-11 13:04:34 ERROR (Thread-35) [homeassistant.sensor.wunderground] Check WUnderground API ('Expecting value: line 2 column 1 (char 1)',)