custom event trigger json output possible?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
_Cyber_
Normal user
Posts: 115
Joined: 20 Oct 2019, 09:46

custom event trigger json output possible?

#1 Post by _Cyber_ » 16 Apr 2022, 18:45

hello,

is there a possibility to get a json-output by http for a custom event triggered?

e.g.: http://192.168.10.242/control?cmd=event,poweroff

reply is "OK" - which is in nodered then not with the same nodes parseable as e.g. http://192.168.10.242/json?view=sensorupdate&tasknr=4 or http://192.168.10.242/control?cmd=GPIO,2,0

thanks. :-)

BR
Alois

User avatar
chromo23
Normal user
Posts: 827
Joined: 10 Sep 2020, 16:02
Location: germany

Re: custom event trigger json output possible?

#2 Post by chromo23 » 16 Apr 2022, 19:01

Hi alois,

what json output you would like to see for a custom event since a lot can happen in an event?

when i need a html feedback i use a command like yours:
e.g.: http://<espip>/control?cmd=event,toogle

and then do another request for the response:
e.g.: http://<espip>/csv?tasknr=1&valuenr=1&header=0

(i use this for shortcuts in ios to toggle a relay..so i get the state of the relay as a feedback. in this example a simple 1 or 0)

_Cyber_
Normal user
Posts: 115
Joined: 20 Oct 2019, 09:46

Re: custom event trigger json output possible?

#3 Post by _Cyber_ » 17 Apr 2022, 10:52

the "OK" would be already enough output, but it is not json.

so if it would be e.g.:
{
"reply": "OK"
}

or, to be distinguishable e.g.:
{
"event,<eventname>": "OK"
}

it would be parseable with a "generic" HTTP request node in nodered where also other commands (with valid json output - see above) are fed in.

_Cyber_
Normal user
Posts: 115
Joined: 20 Oct 2019, 09:46

Re: custom event trigger json output possible?

#4 Post by _Cyber_ » 19 Apr 2022, 14:21

another small issue with json-replys, is this already known?

http://192.168.10.243/control?cmd=GPIO,2,0

reply with build ESP_Easy_mega_20220328_normal_ESP8266_4M1M:
{
"log": ": port#2: set to 0",
"plugin": 1,
"pin": 2,
"mode": "output",
"state": 0
}

while build ESP_Easy_mega_20210114 replied:
{
"log": "port#2: set to 0",
"plugin": 1,
"pin": 2,
"mode": "output",
"state": 0
}

note the additional ": " in the beginning of "log"-string

Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests