Fill all dummy sensor entries in one json
Moderators: grovkillen, Stuntteam, TD-er
-
- Normal user
- Posts: 531
- Joined: 07 Jun 2018, 06:47
- Location: Gdynia/Poland
Fill all dummy sensor entries in one json
Is it possible to fill all entries in quad dummy sensor in one json HTTP call from server to ESP instead fill it one by one (4 singe jason calls).
Re: Fill all dummy sensor entries in one json
Not jet.
What exact call do you make right now to fill each value?
What exact call do you make right now to fill each value?
-
- Normal user
- Posts: 531
- Joined: 07 Jun 2018, 06:47
- Location: Gdynia/Poland
Re: Fill all dummy sensor entries in one json
Code: Select all
http://<ip>/control?cmd=TaskValueSet,<sensor_number>,<position_number>,<value>
Re: Fill all dummy sensor entries in one json
OK, this isn't a JSON call, just a simple HTTP GET url.
Still doesn't make it possible to set multiple values in one call, but at least I now know what you're talking about as I really couldn't imagine how you were sending JSON via HTTP to fill the dummy values.
Still doesn't make it possible to set multiple values in one call, but at least I now know what you're talking about as I really couldn't imagine how you were sending JSON via HTTP to fill the dummy values.
-
- Normal user
- Posts: 531
- Joined: 07 Jun 2018, 06:47
- Location: Gdynia/Poland
Re: Fill all dummy sensor entries in one json
OK. THX If it is impossible, then it is impossible...
Re: Fill all dummy sensor entries in one json
I just thought of a way that could make it possible.
You could send an event and the event can have upto 4 eventvalues.
Such an event will then be dealt with in the rules and in there you can split the eventvalues into 4 separate commands to set the values to a dummy task.
You could send an event and the event can have upto 4 eventvalues.
Such an event will then be dealt with in the rules and in there you can split the eventvalues into 4 separate commands to set the values to a dummy task.
-
- Normal user
- Posts: 531
- Joined: 07 Jun 2018, 06:47
- Location: Gdynia/Poland
Re: Fill all dummy sensor entries in one json
I think that it is not solution of my problem.
In my case, ESP sends to Domoticz SendToHTTP request. This cause "push" of virtual button. LUA script associated with this button takes from Domoticz DB 8 parameters and sends one by one (via WGET HTTP) to ESP, placing them in the individual positions of two dummy sensors.
These parameters are displayed on a 20x4 LCD in the form of "pages" switched with the button.
So ESP has to handle 9 HTTP calls in a short amount of time.
However, the HTTP calls seems to be taking a long time of CPU. And if accidentally the moment of pressing the button coincides with the HTTP calls series, the device reacts either with a significant delay or (because I also use the double click function) it reacts incorrectly.
Hence, I would like to reduce the number of HTTP calls.
In my case, ESP sends to Domoticz SendToHTTP request. This cause "push" of virtual button. LUA script associated with this button takes from Domoticz DB 8 parameters and sends one by one (via WGET HTTP) to ESP, placing them in the individual positions of two dummy sensors.
These parameters are displayed on a 20x4 LCD in the form of "pages" switched with the button.
So ESP has to handle 9 HTTP calls in a short amount of time.
However, the HTTP calls seems to be taking a long time of CPU. And if accidentally the moment of pressing the button coincides with the HTTP calls series, the device reacts either with a significant delay or (because I also use the double click function) it reacts incorrectly.
Hence, I would like to reduce the number of HTTP calls.
Re: Fill all dummy sensor entries in one json
Have you tried it?
So in the GET url you send an event like this:
And in the rules you must then act on the "eventname" like this:
So in the GET url you send an event like this:
Code: Select all
AsyncEvent,eventname=1,2,3,4
Code: Select all
on eventname do
LogEntry,'Values %eventvalue1% %eventvalue2% %eventvalue3% %eventvalue4%'
endon
-
- Normal user
- Posts: 531
- Joined: 07 Jun 2018, 06:47
- Location: Gdynia/Poland
Re: Fill all dummy sensor entries in one json
OK, THX. Will try. Is it new feature? I ask because I use ESPEasy_mega-20191208.
Re: Fill all dummy sensor entries in one json
Asyncevent is new, but "event" isn't.
So if asyncevent is not working, then event can be used.
I used "asyncevent" in my suggestion as it is not blocking and you experience delays when sending multiple calls.
So if asyncevent is not working, then event can be used.
I used "asyncevent" in my suggestion as it is not blocking and you experience delays when sending multiple calls.
-
- Normal user
- Posts: 531
- Joined: 07 Jun 2018, 06:47
- Location: Gdynia/Poland
Re: Fill all dummy sensor entries in one json
Yes, "event" works. "Asyncevent" will try tomorrow.
-
- Normal user
- Posts: 531
- Joined: 07 Jun 2018, 06:47
- Location: Gdynia/Poland
Re: Fill all dummy sensor entries in one json
Asyncevent works properly in mega-20191208. For test needs I created two simple events:
than, I run it from server using commands:
And as expected, LCD backlight could be turn off/on remotely. Of course LCD commands could be trigger directly from server but this is only test.
I digged a little bit in docu, but can not understand syntax of Your proposal. Probably because of my age (64 years) - sorry...
So, if I want to assign remotely value of variables or content of dummy sensor in ESP using script containing command:
where $val1, $val2, $val3,$val4 are values calculated by script running on server.
and on ESP site something like this:
Be so kind to inspect the code above and correct one.
Code: Select all
On display_off do
LCDCMD,off
endon
On display_on do
LCDCMD,on
endon
Code: Select all
wget -O - "http://<ESP_IP>/control?cmd=asyncevent,display_off"
and
wget -O - "http://<ESP_IP>/control?cmd=asyncevent,display_on"
I digged a little bit in docu, but can not understand syntax of Your proposal. Probably because of my age (64 years) - sorry...
So, if I want to assign remotely value of variables or content of dummy sensor in ESP using script containing command:
Code: Select all
wget -O - "http://<ESP_IP>/control?cmd=AsyncEvent,parameters=$val1,$val2,$val3,$val4"
and on ESP site something like this:
Code: Select all
On parameters do
// dont know what to do
Let,10,<dont_know_what>
Let,11,<dont_know_what>
Let,12,<dont_know_what>
Let,13,<dont_know_what>
// dont know what to do
endon
Re: Fill all dummy sensor entries in one json
Just like this:
Code: Select all
On parameters do
Let,10,%eventvalue1%
Let,11,%eventvalue2%
Let,12,%eventvalue3%
Let,13,%eventvalue4%
endon
-
- Normal user
- Posts: 531
- Joined: 07 Jun 2018, 06:47
- Location: Gdynia/Poland
Re: Fill all dummy sensor entries in one json
THX. Will try when my grandson allows
Re: Fill all dummy sensor entries in one json
Just let him do it
(minimal age for operating ESPEasy appears to be roughly 6 yrs old)
-
- Normal user
- Posts: 531
- Joined: 07 Jun 2018, 06:47
- Location: Gdynia/Poland
Re: Fill all dummy sensor entries in one json
One more question.What is the limitation of amount parameters that could be passed in single asyncevent request? Eight is not too much?
Re: Fill all dummy sensor entries in one json
Only the first 4 arguments will be passed on to the event, so only %eventvalue1% to eventvalue4% are available. Please note that %eventvalue% (as seen in many documentation examples) is the alias for %eventvalue1%.
And, as noted earlier, only numerical values can be passed (to event and asyncevent).
And, as noted earlier, only numerical values can be passed (to event and asyncevent).
/Ton (PayPal.me)
-
- Normal user
- Posts: 531
- Joined: 07 Jun 2018, 06:47
- Location: Gdynia/Poland
Re: Fill all dummy sensor entries in one json
Once thanks for very helpful infos !
Re: Fill all dummy sensor entries in one json
I would also like to transfer values from Domoticz to EspEasy. The purpose is to request EspEasy for the last temperature settings from Domoticz when restarting and then save them into dummy variables. The process is clear for me, but I am missing this corresponding LUA-script for Domoticz.mackowiakp wrote: ↑26 Sep 2020, 13:25 I think that it is not solution of my problem.
In my case, ESP sends to Domoticz SendToHTTP request. This cause "push" of virtual button. LUA script associated with this button takes from Domoticz DB 8 parameters and sends one by one (via WGET HTTP) to ESP, placing them in the individual positions of two dummy sensors.
-
- Normal user
- Posts: 531
- Joined: 07 Jun 2018, 06:47
- Location: Gdynia/Poland
Re: Fill all dummy sensor entries in one json
In fact, I use LUA script to call BASH script. Why? Because I not so clever in LUA.
So LUA script looks like:
And BASH script (part of them) named /home/pi/Pobrane/get_temp1 for downloading parameters to ESP quad dummy sensor:
So LUA script looks like:
Code: Select all
local sensor = '<name_of_virt_switch>'
commandArray = {}
if (devicechanged[sensor] == 'On') then
os.execute ("/home/pi/Pobrane/get_temp1")
os.execute ("/usr/bin/wget -q -O - http://localhost:8080/json.htm?type=command¶m=switchlight&idx=,<idx_of_virt_switch>&switchcmd=Off")
end
return commandArray
Code: Select all
wyn1=`wget -q -O - "http://localhost:8080/json.htm?type=devices&rid=$idx_dallas_no_1" |grep Data|/usr/bin/awk '{print $3}'|/bin/sed 's/"//'`
wyn2=`wget -q -O - "http://localhost:8080/json.htm?type=devices&rid=$idx_dallas_no_2" |grep Data|/usr/bin/awk '{print $3}'|/bin/sed 's/"//'`
wyn3=`wget -q -O - "http://localhost:8080/json.htm?type=devices&rid=$idx_DTH22" |grep Data|/usr/bin/awk '{print $3}'|/bin/sed 's/"//'` # returns temperature
wyn4=`wget -q -O - "http://localhost:8080/json.htm?type=devices&rid=$idx_DTH22" |grep Data|/usr/bin/awk '{print $5}'` # returns humidity
wget -q -O - "http://<ESP_IP>/control?cmd=AsyncEvent,Parameters2=$wyn1,$wyn2,$wyn3,$wyn4"
Who is online
Users browsing this forum: No registered users and 112 guests