I’m keeping track of the river height for a near by river using the USGS API. Currently I have a custom script which parses the JSON response and just inserts rows into the states
table. This has worked well for me for quite a while now, but I was thinking of making it a bit less hacky, and using a MQTT autodiscovery sensor for this instead.
My problem is that the API publishes data on a lag, and only once an hour. The hourly updates include several data points for the preceding hour. If I only send one MQTT message when the API updates I’ll be losing out on data.
Is there any way to set the event time for a MQTT sensor? If not, is there any other way I could do this? Something like writing to a local file?
Here’s an example of the data:
https://waterdata.usgs.gov/nwis/uv?01463620
And the API:
https://waterservices.usgs.gov/nwis/iv/?format=json&sites=01463620&period=PT6H¶meterCd=00065&siteStatus=all