JSON multiple devices

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Dick60
Normal user
Posts: 40
Joined: 11 Feb 2018, 17:35

JSON multiple devices

#1 Post by Dick60 » 27 Sep 2019, 20:08

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?

Dick60
Normal user
Posts: 40
Joined: 11 Feb 2018, 17:35

Re: JSON multiple devices

#2 Post by Dick60 » 29 Sep 2019, 12:23

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?

Dick60
Normal user
Posts: 40
Joined: 11 Feb 2018, 17:35

Re: JSON multiple devices

#3 Post by Dick60 » 29 Sep 2019, 14:09

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.

Dick60
Normal user
Posts: 40
Joined: 11 Feb 2018, 17:35

Re: JSON multiple devices

#4 Post by Dick60 » 29 Sep 2019, 19:21

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!

User avatar
grovkillen
Core team member
Posts: 3303
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: JSON multiple devices

#5 Post by grovkillen » 29 Sep 2019, 19:28

ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
grovkillen
Core team member
Posts: 3303
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: JSON multiple devices

#6 Post by grovkillen » 29 Sep 2019, 19:29

Plus, have you considered using MQTT? HTTP is one to one. MQTT is ideal for this scenario with multiple listeners to an event.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Dick60
Normal user
Posts: 40
Joined: 11 Feb 2018, 17:35

Re: JSON multiple devices

#7 Post by Dick60 » 29 Sep 2019, 21:27

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?

TD-er
Core team member
Posts: 1809
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: JSON multiple devices

#8 Post by TD-er » 29 Sep 2019, 22:28

Does the URL work like you expect when executed from the browser?

Dick60
Normal user
Posts: 40
Joined: 11 Feb 2018, 17:35

Re: JSON multiple devices

#9 Post by Dick60 » 29 Sep 2019, 22:43

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)

TD-er
Core team member
Posts: 1809
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: JSON multiple devices

#10 Post by TD-er » 29 Sep 2019, 23:13

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests