Page 1 of 1
custom event trigger json output possible?
Posted: 16 Apr 2022, 18:45
by _Cyber_
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
Re: custom event trigger json output possible?
Posted: 16 Apr 2022, 19:01
by chromo23
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)
Re: custom event trigger json output possible?
Posted: 17 Apr 2022, 10:52
by _Cyber_
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.
Re: custom event trigger json output possible?
Posted: 19 Apr 2022, 14:21
by _Cyber_
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