Closed mstovenour closed 4 years ago
Thanks for catching this Michael. I will ook at the code tomorrow, and send out a fix. Agree with your fix, but I just want to check the IO module, and see if we can't avoid the error before it hits HA.
You could do something in the python library, but it doesn't seem unreasonable to have an "undefined" value for some of the parameters. It also doesn't seem unreasonable for the HA integration to defensively handle undefined values. The smart weather API is going to constantly evolve and the code could use a lot of belt-and-suspenders defensive measures.
Good point. I will fix it tomorrow.
Your fix has been implemented. 2.0.4 is out, containing this. Thanks.
Thanks. HACS updated to the new release. It seems to work well.
This line of code creates an exception when lightning_strike_last_epoch is not returned by the API. https://github.com/briis/smartweather/blob/1fa3d00a8445daff60710e3362f3306566cc7dd4/custom_components/smartweather/sensor.py#L197
I added a check to see what was going on:
And found the culprit:
I pulled the API with:
I took a peak at the library code and client.py intentionally returns None if lightning_strike_last_epoch is not present: briis/pysmartweatherio: /pysmartweatherio/client.py#L209
I recommend that this line: https://github.com/briis/smartweather/blob/1fa3d00a8445daff60710e3362f3306566cc7dd4/custom_components/smartweather/sensor.py#L196
Be changed to: