rules sending data

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
dangu
Normal user
Posts: 11
Joined: 14 Jan 2018, 18:09

rules sending data

#1 Post by dangu » 24 Feb 2018, 11:55

Hello
I get value on the serial port of esp that are sent by arduino with the TaskValueSet command to esp in a Dummy component.
it works very well.
:D
  how to send the data received to domoticz only at the reception, without having an automatic sending configured by the (delay).
I did some tests with examples in the rules, but I can not send the data.
which command can do that in the rules, without using SendToHTTP! :?:

example: arduino send the value 10 a esp, esp sees this value 10 received, then send the value to domoticz once, until the arrival of a new value.


Thanks for your help

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

Re: rules sending data

#2 Post by TD-er » 24 Feb 2018, 17:34

What version of the ESPeasy do you use?

There have been some issues reported regaring MQTT and rules.
See https://github.com/letscontrolit/ESPEasy/issues/828

kimot
Normal user
Posts: 190
Joined: 12 Oct 2017, 20:46

Re: rules sending data

#3 Post by kimot » 25 Feb 2018, 13:45

I am not tested it, but I recommend:

Create dummy device in ESPeasy, mark "Send to Controller" with correct IDX.

And by rules, copy received value from serial port to this dummy device.
ESPEasy send mechanism then sends this value to Domoticz.

dangu
Normal user
Posts: 11
Joined: 14 Jan 2018, 18:09

Re: rules sending data

#4 Post by dangu » 26 Feb 2018, 01:37

Hello
what type of fictitious device should be created ?? or create a new plugin ??

Transferring values to another device through a rules is very easy. ;)
I block on the sending only, the datas are transmitted at regular intervals according to (delay), but I do not want that. :cry:
the data must be sent after reception, then no further sending until another reception of the data .......
I search, I dig, ???? :?:
If you have an idea..

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: rules sending data

#5 Post by toffel969 » 26 Feb 2018, 06:36

double post
Last edited by toffel969 on 26 Feb 2018, 11:24, edited 1 time in total.
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: rules sending data

#6 Post by toffel969 » 26 Feb 2018, 11:23

Why can't you use SendToHTTP? Seems to be the only option.

https://www.letscontrolit.com/wiki/inde ... th_own_IDX

Watch out for the work -around of the parsing error.
https://www.letscontrolit.com/wiki/inde ... SendToHTTP

Create an event in rules named domsend that contains the SendToHTTP command for your two dummy values.

Code: Select all

on domsend do
  SendToHTTP 192.168.1.2,8080,/json.htm?type=command&param=udevice&idx=654321&nvalue=0&svalue=[dummy#dummy1] //Own made up IDX 654321
   SendToHTTP 192.168.1.2,8080,/json.htm?type=command&param=udevice&idx=654322&nvalue=0&svalue=[dummy#dummy2] //Own made up IDX 654322

endon
where you replace IP of your domoticz server and IDX of virtual sensor on Domoticz.

On arduino, after sending the data with TaskValueSet to esp dummy, call the event domsend

Code: Select all

Serial.print ("event,domsend")
You can make delay of dummy very high now, reduces load. Disable "send to controller" on dummy device to avoid the periodic updates.
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

kimot
Normal user
Posts: 190
Joined: 12 Oct 2017, 20:46

Re: rules sending data

#7 Post by kimot » 26 Feb 2018, 14:37

Maybe his Domoticz is password protected.
SendToHTTP cannot handle it, I think.

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: rules sending data

#8 Post by toffel969 » 26 Feb 2018, 14:56

Then using fixed ip with exception in domoticz for that ip seems an option
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

dangu
Normal user
Posts: 11
Joined: 14 Jan 2018, 18:09

Re: rules sending data

#9 Post by dangu » 27 Feb 2018, 16:36

Hello
thank you for all your help
I donated the SendToHTTP which does not return info to domoticz.
here is the configuration:

the dummy sensor that receives datas serie
download/file.php?mode=view&id=2071

the dummy sensor that sends to domoticz
download/file.php?mode=view&id=2066&sid ... f792a52e2f

the rules
download/file.php?mode=view&id=2072

here is the arduino code sent to esp8266-12
download/file.php?mode=view&id=2074


when the value if [ks300 # val2] = 3 is = a 3 then TaskValueSet 2.1, [ks300 # val1]
then send with SendToHTTP.
All this works, except that SendToHTTP sends nothing to domoticz.
the only send that is valid is the one generated by the dummy plugin's delay.



here an automatic sending by the plugin when the delay is run (60 sec)

Dummy: value 1: 48.00
Dummy: value 2: 0.00
Dummy: value 3: 0.00
Dummy: value 4: 0.00
EVENT: envoi#envoi1=48.00
EVENT: envoi#envoi2=0.00
EVENT: envoi#=0.00
EVENT: envoi#=0.00
HTTP : connecting to 192.168.1.100 using port 8080
/json.htm?type=command&param=udevice&idx=6&svalue=48.00
HTTP/1.1 200 OK

HTTP : Success
Content-Length: 53

Content-Type: application/json;charset=UTF-8

Cache-Control: no-cache

Pragma: no-cache

Access-Control-Allow-Origin: *



{
"status" : "OK",
"title" : "Update Device"
}
HTTP : closing connection

here the log domoticz file which shows that the reception is done well every minute, and not when the value is equal to 3
download/file.php?mode=view&id=2076





here a shipment flown by the rules (if [ks300 # val2] = 3)

Dummy: value 1: 48.00
Dummy: value 2: 3.00
Dummy: value 3: 0.00
Dummy: value 4: 0.00
EVENT: ks300#val1=48.00
EVENT: ks300#val2=3.00--------value 3 triggers the action
ACT : TaskValueSet 2,1,48.00
ACT : SendToHTTP 192.168.1.100:8080/json.htm?
ACT : type=command⸮m=udevice&idx=6&nvalue=1&svalue=48.00

EVENT: ks300#=0.00
EVENT: ks300#=0.00
>TaskValueSet,1,1,49.00
------------------------------------------------------------------------no connecxion to domoticz
Ok
>TaskValueSet,1,2,4.00

Ok
Dummy: value 1: 49.00
Dummy: value 2: 4.00

-domoticz does not have a login and no password.

I do not know if my job is clear to you, but here's what I'm trying to do exactly.

a value 1 is received, test in the rules, if val = 1 then sending a value, then the value 1 is reset to 0, and waiting for a new value to 1 to restart the cycle.
it's the same principle as for a switch that sends its state when the change, but not sent by the delay of the plugin.

I think you understand better what I am trying to do.

Thanks for your help
dummy envoi.jpg
dummy envoi.jpg (67.24 KiB) Viewed 14699 times
The attachment dummy ks300.jpg is no longer available
The attachment dummy envoi.jpg is no longer available
The attachment domoticz.jpg is no longer available
The attachment arduino.jpg is no longer available
Last edited by dangu on 27 Feb 2018, 18:36, edited 1 time in total.

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: rules sending data

#10 Post by toffel969 » 27 Feb 2018, 16:55

dangu wrote: 27 Feb 2018, 16:36 Hello
thank you for all your help
I donated the SendToHTTP which does not return info to domoticz.
here is the configuration:

the dummy sensor that receives datas serie
download/file.php?mode=view&id=2071

the dummy sensor that sends to domoticz
download/file.php?mode=view&id=2066&sid ... f792a52e2f

the rules
download/file.php?mode=view&id=2072

here is the arduino code sent to esp8266-12
download/file.php?mode=view&id=2074


when the value if [ks300 # val2] = 3 is = a 3 then TaskValueSet 2.1, [ks300 # val1]
then send with SendToHTTP.
All this works, except that SendToHTTP sends nothing to domoticz.
the only send that is valid is the one generated by the dummy plugin's delay.



here an automatic sending by the plugin when the delay is run (60 sec)

Dummy: value 1: 48.00
Dummy: value 2: 0.00
Dummy: value 3: 0.00
Dummy: value 4: 0.00
EVENT: envoi#envoi1=48.00
EVENT: envoi#envoi2=0.00
EVENT: envoi#=0.00
EVENT: envoi#=0.00
HTTP : connecting to 192.168.1.100 using port 8080
/json.htm?type=command&param=udevice&idx=6&svalue=48.00
HTTP/1.1 200 OK

HTTP : Success
Content-Length: 53

Content-Type: application/json;charset=UTF-8

Cache-Control: no-cache

Pragma: no-cache

Access-Control-Allow-Origin: *



{
"status" : "OK",
"title" : "Update Device"
}
HTTP : closing connection

here the log domoticz file which shows that the reception is done well every minute, and not when the value is equal to 3
download/file.php?mode=view&id=2076





here a shipment flown by the rules (if [ks300 # val2] = 3)

Dummy: value 1: 48.00
Dummy: value 2: 3.00
Dummy: value 3: 0.00
Dummy: value 4: 0.00
EVENT: ks300#val1=48.00
EVENT: ks300#val2=3.00--------value 3 triggers the action
ACT : TaskValueSet 2,1,48.00
ACT : SendToHTTP 192.168.1.100:8080/json.htm?
ACT : type=command⸮m=udevice&idx=6&nvalue=1&svalue=48.00

EVENT: ks300#=0.00
EVENT: ks300#=0.00
>TaskValueSet,1,1,49.00
------------------------------------------------------------------------no connecxion to domoticz
Ok
>TaskValueSet,1,2,4.00

Ok
Dummy: value 1: 49.00
Dummy: value 2: 4.00

-domoticz does not have a login and no password.

I do not know if my job is clear to you, but here's what I'm trying to do exactly.

a value 1 is received, test in the rules, if val = 1 then sending a value, then the value 1 is reset to 0, and waiting for a new value to 1 to restart the cycle.
it's the same principle as for a switch that sends its state when the change, but not sent by the delay of the plugin.

I think you understand better what I am trying to do.

Thanks for your help
Hi
I cannot see your attachements, maybe just post rules as text. However, itlooks like the known parsing problem:

Code: Select all

ACT : SendToHTTP 192.168.1.100:8080/json.htm?
ACT : type=command⸮m=udevice&idx=6&nvalue=1&svalue=48.00
definitly looks like it


Try to swap the order of command of the SendtoHTTP around like discribed here:

https://www.letscontrolit.com/wiki/inde ... SendToHTTP that should fix the problem
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

dangu
Normal user
Posts: 11
Joined: 14 Jan 2018, 18:09

Re: rules sending data

#11 Post by dangu » 04 Mar 2018, 00:41

Hello
Following your advice I did a simple test with sending state of a virtual switch in domoticz and copy of this switch in another virtual switch domoticz.

rules
on bp#varbp do
if [bp#varbp]=1
SendToHTTP 192.168.1.100,8080,/json.htm?type=commandśm=switchlight&idx=21&switchcmd=On
else
SendToHTTP 192.168.1.100,8080,
/json.htm?type=param=switchlight&command&idx=21&switchcmd=Off
endif
endon
the test is simple: when the switch idx 22 changes state, SendToHTTP send to the other switch idx 21.
Here is the result:
SW : State 0
EVENT: bp#varbp=0.00
ACT : SendToHTTP 192.168.1.100,8080,
ACT : /json.htm?type=param=switchlight&command&idx=21&switchcmd=Off
HTTP : connecting to 192.168.1.100 using port 8080
/json.htm?type=command&param=switchlight&idx=22&switchcmd=Off
HTTP/1.1 200 OK

HTTP : Success
Content-Length: 51
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "OK",
"title" : "SwitchLight"
}
HTTP : closing connection
WD : Uptime 1 ConnectFailures 0 FreeMem 27248
WD : Uptime 1 ConnectFailures 0 FreeMem 27248
WD : Uptime 2 ConnectFailures 0 FreeMem 27232
SW : State 1
EVENT: bp#varbp=1.00
ACT : SendToHTTP 192.168.1.100,8080,/json.htm?type=command⸮m=switchlight&idx=21&switchcmd=On
HTTP/1.1 200 OK

HTTP : connecting to 192.168.1.100 using port 8080
/json.htm?type=command&param=switchlight&idx=22&switchcmd=On
HTTP/1.1 200 OK
HTTP : Success
Content-Length: 51
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "OK",
"title" : "SwitchLight"
}
HTTP : closing connection
WD : Uptime 2 ConnectFailures 0 FreeMem 27104
WD : Uptime 3 ConnectFailures 0 FreeMem 27104
WD : Uptime 3 ConnectFailures 0 FreeMem 27104

this test is performed by crossing the 2 idx in order to receive the correct status.
no loggin and password in easyesp and domoticz.
I discovered that in the rules it is necessary to put the command on a complete line without returning to the line.

the analysis of the sending above shows that the SendToHTTP is well executed in the second part, with return "HTTP / 1.1 200 OK" but no status in return.


here is the domoticz log

2018-03-04 00:11:17.275 User: Admin initiated a switch command (22/INTER 22/On)
2018-03-04 00:11:17.282 (capteurs virtuels dummy) Light/Switch (INTER 22)
2018-03-04 00:11:22.624 User: Admin initiated a switch command (22/INTER 22/Off)
2018-03-04 00:11:22.633 (capteurs virtuels dummy) Light/Switch (INTER 22)

https://www.letscontrolit.com/wiki/inde ... SendToHTTP that should fix the problem

I followed in detail the known problem, but that does not solve my problem.
SendToHTTP does not return anything to domoticz.
Why ????
I think easyesp is very powerful,
but has serious problems sending SendToHTTP!

I also did a test in easyesp / tools / command on the module page, then
sending several commands with the SendToHTTP, it says just ok but nothing happens at the sending.
this is normal ????
All tests are done on ESP-12 (512ko) build 147, core version 2-3-0.

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

Re: rules sending data

#12 Post by TD-er » 04 Mar 2018, 16:48

build 147 is very old.
Problem is that the newer Mega does not fit 512k.

dangu
Normal user
Posts: 11
Joined: 14 Jan 2018, 18:09

Re: rules sending data

#13 Post by dangu » 04 Mar 2018, 18:59

Hello
this is not a problem of version 147 with ESP-12.
SendToHTT finally works!
in the end it is the problem known, except that with: instead of, it works much less well.
I did a test with switchligt and a temperature hygrometry and it works.
below the trace of the shipment by esp-12
SW : State 1
EVENT: bp#varbp=1.00
ACT : SendToHTTP 192.168.1.100,8080,/json.htm?param=udevice&type=command&idx=23&nvalue=0&svalue=25;90;1
HTTP/1.1 200 OK

ACT : SendToHTTP 192.168.1.100,8080,/json.htm?param=switchlight&type=command&idx=21&switchcmd=On
HTTP/1.1 200 OK

HTTP : connecting to 192.168.1.100 using port 8080
/json.htm?type=command&param=switchlight&idx=22&switchcmd=On
HTTP/1.1 200 OK

HTTP : Success
Content-Length: 51
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *

{
"status" : "OK",
"title" : "SwitchLight"
}
HTTP : closing connection
here is exactly the sending
SwitchLight --------- SendToHTTP 192.168.1.100,8080,/json.htm?param=switchlight&type=command&idx=21&switchcmd=On

temperature hygrometry -------- SendToHTTP 192.168.1.100,8080,/json.htm?param=udevice&type=command&idx=23&nvalue=0&svalue=25;90;1

finally a problem of resolved, I will be able to advance!
Last edited by dangu on 05 Mar 2018, 22:39, edited 1 time in total.

dangu
Normal user
Posts: 11
Joined: 14 Jan 2018, 18:09

Re: rules sending data

#14 Post by dangu » 04 Mar 2018, 23:24

I knew that you do not need a password and login to login in domoticz and send with SendToHTTP.
I tried to put a password and an identifier to try and here is the result. :arrow:

SW : State 0
EVENT: bp#varbp=0.00
ACT : SendToHTTP 192.168.1.100,8080,/json.htm?param=switchlight&type=command&idx=21&switchcmd=Off :|
HTTP : connecting to 192.168.1.100 using port 8080
/json.htm?type=command&param=switchlight&idx=22&switchcmd=Off ;)
HTTP/1.1 200 OK

HTTP : Success
Content-Length: 51
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
:arrow: Set-Cookie: SID=0778732fc057b5d36936da794cebc149_MzE4MDI4NTItNDFlMi00OTUwLThjND
{
"status" : "OK",
"title" : "SwitchLight"
}
HTTP : closing connection
the idx 21 is not sent, while the idx 22 is sent.
idx 22 is declared in switch.

then this line appeared: ......... SID=0778732fc057b5d36936da794cebc149_MzE4MDI4NTItNDFlMi00OTUwLThjND
this line is part of the security sent by JSON.
The security is not important to receive datas meteo, temperature, water meter ............
it is important when one monitors the state of the doors, or sending remote commands, house plan with state of the windows and lots of things.

it is for this reason that I would like to combine the 2 security and sending datas with the rules.

so I understood the operation by activating the security.
what is the method for sending values with the rules, having kept the security? :?:

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: rules sending data

#15 Post by toffel969 » 05 Mar 2018, 13:53

dangu wrote: 04 Mar 2018, 23:24 I knew that you do not need a password and login to login in domoticz and send with SendToHTTP.
I tried to put a password and an identifier to try and here is the result. :arrow:

SW : State 0
EVENT: bp#varbp=0.00
ACT : SendToHTTP 192.168.1.100,8080,/json.htm?param=switchlight&type=command&idx=21&switchcmd=Off :|
HTTP : connecting to 192.168.1.100 using port 8080
/json.htm?type=command&param=switchlight&idx=22&switchcmd=Off ;)
HTTP/1.1 200 OK

HTTP : Success
Content-Length: 51
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
:arrow: Set-Cookie: SID=0778732fc057b5d36936da794cebc149_MzE4MDI4NTItNDFlMi00OTUwLThjND
{
"status" : "OK",
"title" : "SwitchLight"
}
HTTP : closing connection
the idx 21 is not sent, while the idx 22 is sent.
idx 22 is declared in switch.

then this line appeared: ......... SID=0778732fc057b5d36936da794cebc149_MzE4MDI4NTItNDFlMi00OTUwLThjND
this line is part of the security sent by JSON.
The security is not important to receive datas meteo, temperature, water meter ............
it is important when one monitors the state of the doors, or sending remote commands, house plan with state of the windows and lots of things.

it is for this reason that I would like to combine the 2 security and sending datas with the rules.

so I understood the operation by activating the security.
what is the method for sending values with the rules, having kept the security? :?:
I think setting fixed IP, MAC-Adress Filter in AccessPoint and allow only that IP in Domoticz is the best you can do.
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 30 guests