Because there is no other way to do what I’m looking for.
Long story short: OpenUV reduced the number of calls per day, so now you have 50 free calls/day. How to manage it properly?
- Workaround A
I’ve created a rule to disable the Thing during a certain period of time (before 8 AM and after 7 PM). The remaining hours are 11, so you can refresh the Binding every 15 minutes (4 calls per hour, 44 calls per day). Here the rule:
rule "OpenUV Timeslot"
when
Time cron "0 0 0/1 1/1 * ? *"
then
val currHour = now.getHourOfDay
if (currHour <= 7 || currHour >= 19) {
sendHttpPutRequest("http://192.168.10.3:8080/rest/things/openuv:uvreport:local:home/enable", "application/json", 'false')
logInfo("OpenUV Rule", "OpenUV is disabled")
}
else {
sendHttpPutRequest("http://192.168.10.3:8080/rest/things/openuv:uvreport:local:home/enable", "application/json", 'true')
logInfo("OpenUV Rule", "OpenUV is enabled")
}
end
But this is not good enough, if you restart OH few times you are already out of calls. I would like to use the Binding better.
- Workaround B
The idea is to say:
-
when the UV is 0, don’t call
-
if the UV is below 3, call every hour
-
if the UV is between 3 and 8, call every 20 mins
-
if the UV is above 8, call every 5 mins
First idea, I think I can use the Expire Binding and the Astro Binding.
When, for example, the radiation is 0, just call 1 time to have the items up to date, then don’t call till the radiation won’t be more than 0 (period between sunset and sunrise).
Then use the Expire Binding in this way: if the value of radiation is between x and y, start an expire item (depends on the values of x and y), and when the item “expires” call and update the Openuv items.
For doing that, two ways maybe:
- use the “REFRESH” way (but I suspect every refresh means a call to Openuv, so this can work only for one item, like UV index).
myItem.sendCommand( RefreshType.REFRESH )
- try to use the rule above to enable and disable the entire Binding, to do the single call when needed
What do you think?
Andrea