I think I know the answer, but does anyone know if there is a way of telling whether a hub is online or not using the REST API? There seems to be a websocket endpoint for this, but in my testing I was unable to get it to trigger. It also seems that it doesn’t confirm what the state is upon first connection.
I think (I’m guessing here) the answer to my own question lies in the fact that these details are not available to unauthorized users of the API (i.e. they can only be accessed by the station owner). In which case the Oauth2 flow is required.
@dsj sorry to badger when you are busy with Tempest, but can you comment on what progress has been made with this? Is it possible to implement Oauth2 authorization in a third party application yet?
The answer is No. If you recall, there was a discussion months ago about the amount of time that the servers would indicate that the station was offline from the last data received.
This may help.
I can’t remember if I took medicine at 2pm but I remembered this conversation.
Thanks for sharing this, Gary. That discussion happened when I was away down South so it must have slipped under my radar!
I thought it was mid 2019 but at least I remembered it. I don’t know if David had the change put in place. If I can help in any way please feel free to ask.
There is not, but there should be. We will add the station and device status (online/offline) to the existing “/stations” endpoint in an upcoming API build. That should happen in the next week or two.
Great! That’s good to know . Is there any chance you could also add “last seen” times for the station and the devices? That way we can choose a custom time interval after which a station/device is deemed offline
Peter, those times are index 0 of each observation and status.
Doh - of course that’s true for the observations! I am not thinking straight yet this morning. I’m not sure about the hub status though (from the viewpoint of the Websocket/API rather than UDP). There isn’t a hub status endpoint, so having a “last seen” time and status would be useful in the stations/ end point.
The Hub is a device so that time is in the status packet.
Sorry Gary, but I must be missing something. If you use the device API endpoint with a hub device id (https://swd.weatherflow.com/swd/rest/observations/?device_id=1109&api_key=20c70eae-e62f-4d3b-b3a4-8586e90f3ac8) you don’t get anything useful:
Also if you start listening on the websocket with a hub device id nothing is sent. Am I missing something obvious?
We will be adding a diagnostic service to the API soon that will give you the Hub’s “last seen” along with lots of other info. Coming soon!
And for what it’s worth, we use the latest observation time (from the sensor devices) to determine whether a station is online or offline. That’s because a station with a working hub but no working sensor devices is, for all practical purposes, offline.