New fields in websocket messages

I haven’t looked in detail at the websocket messages recently, but noticed today that a lot more information is being sent compared to what is documented. For example, the documentation shows that the obs_air message should look like this:

{
  "type":"obs_air",
  "device_id":1110,
  "obs":[[1493164835,835.0,10.0,45,0,0,3.46,1]]
}

but what is actually sent looks like this:

{
  'status': {'status_code': 0, 'status_message': 'SUCCESS'}, 
  'device_id': 16391, 
  'type': 'obs_air', 
  'source': 'cache', 
  'summary': {'pressure_trend': 'rising', 'pressure_high_24h': 1000.9, 'pressure_low_24h': 994.1, 'strike_count_3h': 0, 'strike_last_dist': 24, 'strike_last_epoch': 1556295986}, 
  'obs': [[1556357769, 996.6, 9, 68, 0, 0, 3.44, 1]]
}

Does anyone know when these changes were made? Are they a stable change? Can we use the extra fields without risk that WF are going to remove them as they are undocumented? @dsj perhaps you can shed some light on this, and apologies if I missed some sort of announcement.

the later has been the case for a long time, I suggest its just the Docs that need updating?

That’s good to hear. It is certainly very useful to have the summary fields in the websocket messages. Hopefully WF will get round to updating the documentation :smiley:

These summary fields have evolved over time to support our app requirements. We left them out of the documentation because we don’t consider them stable. They will likely go away after a while so I would not count on them!

OK, understood. Thanks for clarifying. The summary fields are incredibly useful though, so if you do decide to keep them in, I’m sure developers would appreciate it.

Edit: for you info, keeping the summary fields will also tend to reduce the load on your servers. For example, as the PiConsole doesn’t store data locally, if I can’t get the time of the last lightning strike or the number of lightning strikes in the last 3 hours from the Air websocket message, I need to use additional API requests to get this data instead. This means for the number of lightning strikes in the last 3 hours, I am requesting the last three hours worth of data every minute.

3 Likes

I hear you, Peter. And the truth is, once you have something in there, even if its unofficial, it’s very hard to remove it!