Thanks for this. How often are you seeing updates on the socket from the Tempest socket? Right now I am using a polling driver set to 5 minutes from @snell and it's works well. I was reading online that observation reporting with a fully charged battery is about 1 minute and then during storms that there are events per lighting report/strike.
Installed it this morning and watching my logs but so far looks like this will complement the REST API implementation:
UPDATE: I am seeing the arrival of data vis a the websocket every minute so at this arrival rate I think it's going to be great for real-time alerting without overloading the hub.
I've updated the driver to include a strikeDistance attribute. The strikeDetected will still have the epoch.
Unfortunately there's no way for me to manually trigger/test the event and we don't get much lightning in my neck of the woods. Let me know if it works out okay!
Thanks for the update. I'll keep an eye on it since we have been seeing a few late afternoon lightning reports this week. Question is that after the update I don't see strike attributes in my device or dashboard tile attribute:
Ok so it appears that the lightening strike works but still concerned that custom attriubte doesn't show up for dashboard support until a strike is reported:
Glad the strike events worked! Thanks for letting me know.
I just pushed an update to the driver that will initialize the strike attributes to zero so that that will appear on the device page the first time observations are processed. I believe this is why they were not showing up for the dashboards.
I found something interesting with the the WebSocket last night. Around midnight my router received a software update that took about 15 minutes to install and reboot. When it came back up it the data for your driver was way out of wack. For example the luminance should have been very low but overnight it had a value in the 30k range when I checked my dashboard this morning.
I wonder if there is a something in the reconnect logic that didn't work or something in the way WebSockets handling is done by Hubitat. I went into the device this morning and just hit "initialize" and all the values updated.
Ok checked the logs and did see other devices like ecobee have issues at the same time but no socket errors until later in the morning, looks like WeatherFlow took something offline 2:00 am. So now I don't know if it was a combination of the router update and the WeatherFlow servers being offline individually. I'll keep monitoring it to see if these type of events happen again.
2020-07-10 02:01:08.428 am [info](http://ha-hubitat-home.vargofamily.com/device/edit/428)websocket is open
[dev:428](http://ha-hubitat-home.vargofamily.com/logs/past#dev428)2020-07-10 02:01:08.236 am [info](http://ha-hubitat-home.vargofamily.com/device/edit/428)initialize() called
[dev:428](http://ha-hubitat-home.vargofamily.com/logs/past#dev428)2020-07-10 02:00:52.209 am [warn](http://ha-hubitat-home.vargofamily.com/device/edit/428)failure message from web socket failure: No route to host (Host unreachable)
[dev:428](http://ha-hubitat-home.vargofamily.com/logs/past#dev428)2020-07-10 02:00:50.407 am [info](http://ha-hubitat-home.vargofamily.com/device/edit/428)initialize() called
[dev:428](http://ha-hubitat-home.vargofamily.com/logs/past#dev428)2020-07-10 02:00:42.340 am [warn](http://ha-hubitat-home.vargofamily.com/device/edit/428)failure message from web socket failure: No route to host (Host unreachable)
[dev:428](http://ha-hubitat-home.vargofamily.com/logs/past#dev428)2020-07-10 02:00:39.214 am [info](http://ha-hubitat-home.vargofamily.com/device/edit/428)initialize() called
[dev:428](http://ha-hubitat-home.vargofamily.com/logs/past#dev428)2020-07-10 02:00:35.196 am [warn](http://ha-hubitat-home.vargofamily.com/device/edit/428)failure message from web socket failure: No route to host (Host unreachable)
[dev:428](http://ha-hubitat-home.vargofamily.com/logs/past#dev428)2020-07-10 02:00:34.156 am [info](http://ha-hubitat-home.vargofamily.com/device/edit/428)initialize() called
[dev:428](http://ha-hubitat-home.vargofamily.com/logs/past#dev428)2020-07-10 02:00:32.110 am [warn](http://ha-hubitat-home.vargofamily.com/device/edit/428)failure message from web socket failure: sent ping but didn't receive pong within 30000ms (after 868 successful ping/pongs)
Interesting. The WeatherFlow API was acting strange for me yesterday, so perhaps that's part of it. From your logs, it looks like the WebSocket never actually connected, but also did not result in a failure. Automatic reconnects are triggered on failures.
Perhaps I need to add a health check that periodically makes sure we're connected and receiving data, if not run initialize again. I'll have to think on this a bit.
I just pushed an update that adds a health check. It runs every 5 minutes and checks to see if we have received an observation within the last 3 minutes. If not, it will issue a reconnect.
I've been monitoring this for a few days and I've noticed the WeatherFlow API will stop sending data or have connection errors, usually sometime in the late evening for 5-10 minutes. The health check will keep retrying and eventually get things reconnected.
Just want to say this has been running great for a week now. I did have a couple of unexpected data quality issues with what was returned by their websocket such as a huge swing in luminance and temperature in a few data pushes which scared the crap out of me when my "freeze" warning came on in the middle the summer and lights turned on in the middle of the day.
I am looking at your code and I am trying to think of a way to deal with out of bounds data reads like using a 5 minute rolling average and compare the new values to that before publishing the value changed event. This issues is what is an acceptable delta? I have such sanity measures in our applications at work for real time eventing.
I will keep thinking about this and maybe brush up on my groovy skills and do some prototypes.
I noticed a similar issue when writing my “open the windows” app. WeatherUnderground would sometimes send me temps that were wildly off, so I started to record the last event and then discard any over a certain delta. Temperatures can change rapidly, especially in the evenings, so you would have to be careful how you created your averaging logic.
For inspiration, you can use this averager from Hubitat:
I figured out a way to make it work. I used their REST API to generate an auth token for my station which I then supply as the API key. Now if only HE added UDP broadcast support then we could make this thing local!!!
Glad you got it working! So no changes were needed to the code? Their docs say you have to specify the token differently, but their docs aren’t always the most up to date.