Is it possible to use a rule to get a JSON value once a day, rather than use the http binding which only has a frequency? I have a JSON value that I want to retrieve around midnight once a day and store it, something like:
I can’t find any code examples of getting values via http from a rule, just that most people use the http binding. I only need this value once a day, and it would be wasteful to keep polling it.
But in this case you can call any transformation from Rules using the transform Action.
transform("JSONPATH", "$.path.to.data", value)
I have no idea what you are trying to do with the value.persist though. perisist only is valid for Items. getHttpRequest returns a String. So you will need to create a new Item to hold your value and postUpdate to it in your rule:
The device is a CT50 thermostat. It maintains an elapsed counter of the total amount of time the thermostat is on for the day, but it gets cleared at midnight every day. It looks like this:
So I want to read out and store this value just before it gets cleared for the next day, which is why the time I poll it is important.I guess what I can do is long-poll the “yesterday” value which is the previous day. No matter when it hits I’ll have a solid value, but I thought there might be a way to get the current “today” value just before midnight.