ariela
(Andrea Riela)
August 11, 2019, 7:50pm
1
Hi folks,
is there a way to set the refresh interval and ask a binding to send the http GET only during the day (means from 8 AM to 8 PM)?
or a way to activate the binding only during that period of time?
Any follow up from https://github.com/home-assistant/home-assistant/issues/19931 ?
thanks
Andrea
rossko57
(Rossko57)
August 11, 2019, 8:43pm
2
You can disable and enable the openHAB Things used by a v2.x binding under the control of rules.
ariela
(Andrea Riela)
August 11, 2019, 8:54pm
3
how? I’m trying to find a way to do so.
via sendHttpPutRequest is the only way?
Andrea
rossko57
(Rossko57)
August 11, 2019, 9:00pm
4
ariela:
how?
Ha! I found a solution. Seems like my openHAB2 needs other parameters.
Disable Thing:
sendHttpPutRequest("http://<ip>:8080/rest/things/<thinguid>/enable", "application/json", 'enabled')
Enable Thing:
sendHttpPutRequest("http://<ip>:8080/rest/things/<thinguid>/enable", "application/json", 'true')
Thanks for your help!
As you say, it uses sendHttpPutRequest
1 Like
ariela
(Andrea Riela)
August 11, 2019, 11:15pm
5
question. I’ve tried with this rule:
rule "OpenUV Timeslot"
when
Time cron "0 0 0/1 1/1 * ? *"
then
val currHour = now.getHourOfDay
if (currHour > 8 || currHour < 19) {
sendHttpPutRequest("http://192.168.10.1:8080/rest/things/openuv:uvreport:local:home/enable", "application/json", 'true')
logInfo("OpenUV Rule", "OpenUV is enabled")
}
else {
sendHttpPutRequest("http://192.168.10.1:8080/rest/things/openuv:uvreport:local:home/enable", "application/json", 'false')
logInfo("OpenUV Rule", "OpenUV is disabled")
}
end
But even at 1 AM I see “openUV is enabled” in my logs.
What I’m missing?
Andrea
rossko57
(Rossko57)
August 12, 2019, 12:04am
6
1 is less than 19
Wouldn’t you want > 7 && < 20 for 08:00 to 19:59 ?
1 Like
ariela
(Andrea Riela)
August 12, 2019, 8:37am
7
I need to enable from 9 (>7) to 18.59 (<19).
So 1 should be disabled. But this is matching the the rule (and I don’t know why)
Andrea
ariela
(Andrea Riela)
August 12, 2019, 9:04am
8
ahahaha right, I got the point
Sorry for that Just changed a bit
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.1:8080/rest/things/openuv:uvreport:local:home/enable", "application/json", 'false')
logInfo("OpenUV Rule", "OpenUV is disabled")
}
else {
sendHttpPutRequest("http://192.168.10.1:8080/rest/things/openuv:uvreport:local:home/enable", "application/json", 'true')
logInfo("OpenUV Rule", "OpenUV is enabled")
}
end
ariela
(Andrea Riela)
August 21, 2019, 9:01am
9
@rossko57 it seems I have an issue. In facts when I disable the binding, in PaperUI I lose also the link between item and thing … and when the binding is back online, I don’t have my items populated.
I will try manually, to see if this is an issue with PaperUI.
Andrea