General question about Binding activation and refresh

Hi folks,

I’ve a tricky question. If I have a binding with a refresh 1 day (the binding will call the APIs once per day), when I disable then re-enable the binding, shall I trigger again the API call?

Let me clarify with Openuv binding:

Thing uvreport home "Local UV" [ location="xx.xxxxxx,x.xxxxx", refresh=1440 ]{

the refresh of the entire binding should be triggered every 1440 mins, means 1 day

If I send a command like:

sendHttpPutRequest("", "application/json", 'false')

I will disable that Binding. But if I send a command like:

sendHttpPutRequest("", "application/json", 'true')

I re-enable the binding. Consider I do this process twice, for Binding perspective the “refresh” counter is starting again from 0?

Hope the question is clear enough :slight_smile:
thanks for your support


I have no answer for your question but you can change the refresh time to only a few minuets, open a browser with frontail log running then send your commands and watch the logs to get an answer.

Depends completely on the binding author.

Why are you disabling a Thing anyway? It’s not normal practice.

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?

  1. 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"
    Time cron "0 0 0/1 1/1 * ? *"
    val currHour = now.getHourOfDay
    if (currHour <= 7 || currHour >= 19) {
        sendHttpPutRequest("", "application/json", 'false')
        logInfo("OpenUV Rule", "OpenUV is disabled")
    else {
        sendHttpPutRequest("", "application/json", 'true')
        logInfo("OpenUV Rule", "OpenUV is enabled")

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.

  1. 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:

  1. 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 )
  1. try to use the rule above to enable and disable the entire Binding, to do the single call when needed

What do you think?