Page 1 of 1

JSON multiple devices

Posted: 27 Sep 2019, 20:08
by Dick60
I want to execute this script http://ip:port/json.htm?type=command&param=clearlightlog&idx=<idx> using a button in domoticz. Pushing the "ON" it must execute this script for multiple devices. It works for one already (http://ip:port/json.htm?type=command&param=clearlightlog&idx=200) but now i want to execute it also for IDX 24 . I can I get that working?

Re: JSON multiple devices

Posted: 29 Sep 2019, 12:23
by Dick60
Temporary solution for me is a selector switch to start the "
http://127.0.0.1:8080/json.htm?type=com ... log&idx=29"
for each individual idx. Again has somebody any clue how to hget these individual JSON entries
"http://127.0.0.1:8080/json.htm?type=com ... log&idx=29"
in one LUA script?

Re: JSON multiple devices

Posted: 29 Sep 2019, 14:09
by Dick60
is this the right direction to solve this problem:

--log cleanup
If (devicechanged['logSwitch']== "On") then

os.execute('curl -s "http://127.0.0.1:8080/json.htm?type=com ... log&idx=20" &')


end
return commandArray


It does not work but still trying to find a solution.

Re: JSON multiple devices

Posted: 29 Sep 2019, 19:21
by Dick60
now I tried to place them in RULES of my esp like this

On clean_log#state do
[GPIO12#State] = 1
SendToHTTP 127.0.0.1,8080,/json.htm?type=command&param=clearlightlog&idx=29
endon

But still no luck.
Any advise is welcome!

Re: JSON multiple devices

Posted: 29 Sep 2019, 19:28
by grovkillen

Re: JSON multiple devices

Posted: 29 Sep 2019, 19:29
by grovkillen
Plus, have you considered using MQTT? HTTP is one to one. MQTT is ideal for this scenario with multiple listeners to an event.

Re: JSON multiple devices

Posted: 29 Sep 2019, 21:27
by Dick60
Thanks for the reply and yes I have already read the Rules documentation several time but, this evening again. Perhaps you are right to start with MQTT. I must find a good starting point for MQQT in combi with ESP. Will put some effort in it the upcoming week.
About the rules, this I what I have for now

On clean_logs#state=1 do
SendToHTTP 127.0.0.1,8080,/json.htm?type=command&param=clearlightlog&idx=29
endon

and the HTTP is send out by the ESP, the ipx is correct and the name of the button as well. If I launch this rule, I see in Domoticz no errors but nothing happens. Because with this JSON command, a logfile need to be cleaned.
Any idea?

Re: JSON multiple devices

Posted: 29 Sep 2019, 22:28
by TD-er
Does the URL work like you expect when executed from the browser?

Re: JSON multiple devices

Posted: 29 Sep 2019, 22:43
by Dick60
Good point. tested and Result=OK.
Also mentioned that in Domoticz an switch is working if turned on using
http://127.0.0.1:8080/json.htm?type=com ... log&idx=29

But in a rule it does not work (adjusted to the Rules requirements)

Re: JSON multiple devices

Posted: 29 Sep 2019, 23:13
by TD-er
Can you als test if it is working when calling it from a http controller?
If so, then it may be another example of the sendtohttp which needs to wait for a reply/acknowledgement.