Hello everyone, I have some problems with the implementation of a rule, I have to read a value on a web page and if the value is 1 change the status of the items in ON if 0 in OFF, every 5 seconds I have to read the status on the page .
You might want to look at what you actually get in response to your http request. It certainly won’t be numeric 1 or zero. It will come in string form. But most likely there’ll be other web-pagey padding as well, and you will have to parse out the part you are interested in.
rule “Stato Sonoff5”
when
Time cron “3 * * * * ?”
then
var String stato5 = getHttpRequest(“http://192.168.1.90/stato.php?idx=43”)
if (stato5 == "1") Sonoff5.sendCommand(ON)
if (stato5 == "0") Sonoff5.sendCommand(OFF)
end
You could do that with a transformation
Make sure the MAP transform is installed in the paperUI
Create a file called httpsonoff.map in the transform folder with the following content:
0=ON
1=OFF
Then your rule:
rule “Stato Sonoff5”
when
Time cron “3 * * * * ?”
then
Sonoff5.sendCommand(transform("MAP", "httpsonoff.map", getHttpRequest(“http://192.168.1.90/stato.php?idx=43))
end