looking for syntax to activate output of an easp easy by input of another esp easy
Moderators: grovkillen, Stuntteam, TD-er
looking for syntax to activate output of an easp easy by input of another esp easy
Hi!
I am using lots of esp easy devices.
Many doorlocks are equipped with sensor to monitor if a door is locked in addition to be closed.
In my corridor (way to bedroom) there is a LED showing status of frontdoor to advise me if door has been locked when going to bed.
Now I want to add another LED from same device which is activated once a doorlock is active somewhere else in the house. That lock has its own esp easy.
I assume this kind of communication can be achieved using port 8266 but how?
TIA
-Bart
I am using lots of esp easy devices.
Many doorlocks are equipped with sensor to monitor if a door is locked in addition to be closed.
In my corridor (way to bedroom) there is a LED showing status of frontdoor to advise me if door has been locked when going to bed.
Now I want to add another LED from same device which is activated once a doorlock is active somewhere else in the house. That lock has its own esp easy.
I assume this kind of communication can be achieved using port 8266 but how?
TIA
-Bart
Re: looking for syntax to activate output of an easp easy by input of another esp easy
Please have a look at the ESPEasy p2p controller: https://espeasy.readthedocs.io/en/lates ... mong-nodes
Re: looking for syntax to activate output of an easp easy by input of another esp easy
Hi TD-er,
Thanks for yr reply. A bit to theoretical for me. I googled further and found the sendto command which makes sense.
What I achieved for now (just trials)
using commandline of esp 1 (having unit 6#) sending to esp unit # 1:
sendto 1, "gpio 15,1" whereas gpio 15 has been configured as switch-input
this works fine sendto 1, "gpio 15,1" for on and sendto 1, "gpio 15,0" for off
I tried configuring gpio 15 as output (mqtt helper) but no result. So asuming such cannot work in this way. So I must create a rule which controls an output based upon gpio 15.
A pitfal might be in the above case once the unit #1 has received the sendto command resulting in unit# 1 set gpio 15 to on. But what is happening if the unit #6 breaks down?
In such a case I should like to set unit#1 gpio 15 to 0. Is that possible ? Or should I do something like using a timer and ask for the data of unit #6 regular? If so, how to achieve such?
In real life the unit#6 will send the status of an input using the sendto towards unit#1.
TIA
-Bart
Thanks for yr reply. A bit to theoretical for me. I googled further and found the sendto command which makes sense.
What I achieved for now (just trials)
using commandline of esp 1 (having unit 6#) sending to esp unit # 1:
sendto 1, "gpio 15,1" whereas gpio 15 has been configured as switch-input
this works fine sendto 1, "gpio 15,1" for on and sendto 1, "gpio 15,0" for off
I tried configuring gpio 15 as output (mqtt helper) but no result. So asuming such cannot work in this way. So I must create a rule which controls an output based upon gpio 15.
A pitfal might be in the above case once the unit #1 has received the sendto command resulting in unit# 1 set gpio 15 to on. But what is happening if the unit #6 breaks down?
In such a case I should like to set unit#1 gpio 15 to 0. Is that possible ? Or should I do something like using a timer and ask for the data of unit #6 regular? If so, how to achieve such?
In real life the unit#6 will send the status of an input using the sendto towards unit#1.
TIA
-Bart
Re: looking for syntax to activate output of an easp easy by input of another esp easy
You could for example send a timer command that is longer than the interval of the command itself. So if the unit#6 is not available anymore the rules-timer finishes and could set the gpio to 0.BartSr wrote: ↑30 Mar 2022, 22:27 A pitfal might be in the above case once the unit #1 has received the sendto command resulting in unit# 1 set gpio 15 to on. But what is happening if the unit #6 breaks down?
In such a case I should like to set unit#1 gpio 15 to 0. Is that possible ? Or should I do something like using a timer and ask for the data of unit #6 regular? If so, how to achieve such?
code unit#6:
Code: Select all
on System#Boot do
loopTimerSet,1,10
endon
on Rules#Timer=1 do
sendto,1,"timerset,1,20"
endon
code on unit#1
Code: Select all
on Rules#Timer=1 do
gpio,15,0
endon
Re: looking for syntax to activate output of an easp easy by input of another esp easy
A more reliable solution would be to leave any 'protective' measures to the node receiving the command. So instead of sending (and knowing) GPIO pins to a specific state, you could also execute events on the receiving node, f.e. one for enabling and another for disabling a specific feature.
I've used that in my 'remote doorbell system', that is connected to the doorbell button, and also to a door-contact activated if the door is open more than a few cm. and where the receivers are several Sonoff S20's, some of which have a buzzer added, but others use the few available GPIO's for a sensor. So all receive an event called "DoorChimeStart" when the doorbell button is pressed, and "DoorChimeStop" when the button is released. As I also use that same event to alert the Door-Open state, and I don't want that buzzer to keep buzzing while the door is open, I have a timer activated by DoorChimeStart that repeats a short buzz every 10 or 15 seconds (depends on the Sonoff...) and also slow-flash the extra LED. The DoorChimeStop event just stops the timer. I currently haven't implemented a 'protection-timer' to turn off the signal after some time, as I want to be kept alerted while the door is open
Partial code, that also has a Dummy task to keep state and an inhibit option to stay quiet when needed
And there is similar code for the shed-door (that is located at the street-side of my house, and not always locked ), though that door doesn't have a doorbell-button , but with a different timing, to be able to distinguish what door was opened.
I've used that in my 'remote doorbell system', that is connected to the doorbell button, and also to a door-contact activated if the door is open more than a few cm. and where the receivers are several Sonoff S20's, some of which have a buzzer added, but others use the few available GPIO's for a sensor. So all receive an event called "DoorChimeStart" when the doorbell button is pressed, and "DoorChimeStop" when the button is released. As I also use that same event to alert the Door-Open state, and I don't want that buzzer to keep buzzing while the door is open, I have a timer activated by DoorChimeStart that repeats a short buzz every 10 or 15 seconds (depends on the Sonoff...) and also slow-flash the extra LED. The DoorChimeStop event just stops the timer. I currently haven't implemented a 'protection-timer' to turn off the signal after some time, as I want to be kept alerted while the door is open
Partial code, that also has a Dummy task to keep state and an inhibit option to stay quiet when needed
Code: Select all
on DoorChimeStart do
LongPulse_mS,13,0,3000
TaskValueSet,9,2,1 // Set status to active
if [Status#Quiet] = 0 or [Status#Quiet] = 2
tone,1,300,300
gpio,1,1 // force off
delay,50
tone,1,300,300
gpio,1,1 // force off
endif
if [Relay#State]=0 and [Status#Quiet] = 2
pulse,12,1,100 // 2nd LED
pulse,12,0,100
pulse,12,1,100
endif
TimerSet,2,15 // Repeat in 15 seconds
endon
on DoorChimeStop do
TaskValueSet,9,2,0 // Reset status
TimerSet,2,0
endon
on Rules#Timer=2 do
event,DoorChimeStart // Redo from start
endon
/Ton (PayPal.me)
Re: looking for syntax to activate output of an easp easy by input of another esp easy
Another solution could be the ping-plugin wich was made for this purpose (https://espeasy.readthedocs.io/en/lates ... #p089-page).
But it is in testing and i have never used it myself.
Edit: refers to my last post....
But it is in testing and i have never used it myself.
Edit: refers to my last post....
Last edited by chromo23 on 31 Mar 2022, 11:51, edited 1 time in total.
Re: looking for syntax to activate output of an easp easy by input of another esp easy
Most testing plugins are in fact quite stable, I think many of them could drop the testing moniker, but some users may expect these to appear in the Normal builds, but that is not technically feasible, because of the huge number of plugins currently available
/Ton (PayPal.me)
Re: looking for syntax to activate output of an easp easy by input of another esp easy
Hi Chromo23 and Ath,
Thanks for your insights!
I have to study those because I am not that familar with all possibilities in rules.
And my old brains quite easy forget lessons learnt after a few weeks
-Bart
Thanks for your insights!
I have to study those because I am not that familar with all possibilities in rules.
And my old brains quite easy forget lessons learnt after a few weeks
-Bart
Re: looking for syntax to activate output of an easp easy by input of another esp easy
ok, I managed in test operation with a unit#1 (gpio 5) simulating the sensor-input and unit#2 (gpio 14) representing the monitoring part.
Every 20 seconds the status of #1 is updated and sent to #2 and in case unit#1 fails for > 30 seconds unit#2 gpio 14 is 'reset'to 0. So far so good.
Now I wonder if this code can be better. For instance, how to only do a sendto 2 if the input of #1 realy has changed.
I feel this must be possible. But howto?
TIA
-Bart
Every 20 seconds the status of #1 is updated and sent to #2 and in case unit#1 fails for > 30 seconds unit#2 gpio 14 is 'reset'to 0. So far so good.
Now I wonder if this code can be better. For instance, how to only do a sendto 2 if the input of #1 realy has changed.
I feel this must be possible. But howto?
TIA
-Bart
Code: Select all
on System#Boot do
loopTimerSet,1,30
loopTimerSet,2,20
endon
on Rules#Timer=2 do
if [Plugin#GPIO#Pinstate#5]=0
sendto, 2, "gpio 14,1"
endif
if [Plugin#GPIO#Pinstate#5]=1
sendto, 2, "gpio 14,0"
endif
endon
on Rules#Timer=1 do
sendto,2,"timerset,1,30"
endon
Re: looking for syntax to activate output of an easp easy by input of another esp easy
Great work!BartSr wrote: ↑06 Apr 2022, 22:49 ok, I managed in test operation with a unit#1 (gpio 5) simulating the sensor-input and unit#2 (gpio 14) representing the monitoring part.
Every 20 seconds the status of #1 is updated and sent to #2 and in case unit#1 fails for > 30 seconds unit#2 gpio 14 is 'reset'to 0. So far so good.
Sure, I've updated the code to use that
Code on unit 1:
Code: Select all
on System#Boot do
monitor,gpio,5 // Get an event if the pin-state changes
endon
on GPIO#5 do
let,1,!%eventvalue1% // Get the _inverted_ value by using the ! before the argument variable
sendto, 2, "event,setstate=%v1%"
endon
// Safeguard timer moved to receiving unit
Code: Select all
on setstate do
TimerSet,1,0 // Inhibit guard timer
gpio,14,%eventvalue1% // Switch GPIO
if %eventvalue1%=1 // Assumed that 1 = on
TimerSet,1,30 // Guard timer max. 30 seconds on
endif
endon
on Rules#Timer=1 do
gpio,14,0 // Off
endon
/Ton (PayPal.me)
Re: looking for syntax to activate output of an easp easy by input of another esp easy
Hi Ath, thanks for improved code. But I'm sorry to say that it's not working as expected.
The guard timer in unit 2 is setting gpio 14 to 0 indepent of loss of unit 1. In other words always 30 sec. after gpio 14 was set to 1.
So I think that there must stay a timer on unit 1 active to act like hartbeat. Or do I miss something?
The guard timer in unit 2 is setting gpio 14 to 0 indepent of loss of unit 1. In other words always 30 sec. after gpio 14 was set to 1.
So I think that there must stay a timer on unit 1 active to act like hartbeat. Or do I miss something?
Re: looking for syntax to activate output of an easp easy by input of another esp easy
Yep you must then send the message from unit 1 at a higher rate than unit 2's timer will expire.
For example, send the message to unit 2 every 20 sec with the safeguard timer on unit 2 set to 30 sec.
Still this may be a bit too short if for whatever reason either unit looses connection to the network and has a hard time reconnecting to the access point.
For example, send the message to unit 2 every 20 sec with the safeguard timer on unit 2 set to 30 sec.
Still this may be a bit too short if for whatever reason either unit looses connection to the network and has a hard time reconnecting to the access point.
Re: looking for syntax to activate output of an easp easy by input of another esp easy
TD-er,
in that case I better stick to my code (see before Ath's reply) which Asked improved
in that case I better stick to my code (see before Ath's reply) which Asked improved
Re: looking for syntax to activate output of an easp easy by input of another esp easy
Then I may have misunderstood your requirement here, I intended to turn off the gpio after it has been on for a max. amount of time, but if you need it being used as a keep-alive mechanism, then indeed the "timer 1" related code of unit 1 should be restoredBartSr wrote: ↑07 Apr 2022, 10:01 Hi Ath, thanks for improved code. But I'm sorry to say that it's not working as expected.
The guard timer in unit 2 is setting gpio 14 to 0 indepent of loss of unit 1. In other words always 30 sec. after gpio 14 was set to 1.
So I think that there must stay a timer on unit 1 active to act like hartbeat. Or do I miss something?
Code: Select all
// in on system#boot do:
loopTimerSet,1,30
// Re-add event handler:
on Rules#Timer=1 do
sendto,2,"timerset,1,30" // (This could also be "event,keepAlive" with matching event in unit 2)
endon
/Ton (PayPal.me)
Re: looking for syntax to activate output of an easp easy by input of another esp easy
Ath, no problem at all. Meanwhile I went through your code it teached me very well. Especially the comments are very helpfull.
Thanks!
-Bart
Thanks!
-Bart
Re: looking for syntax to activate output of an easp easy by input of another esp easy
Well, helping someone with that is what I'm aiming for, so, great
You're welcome.
/Ton (PayPal.me)
Who is online
Users browsing this forum: No registered users and 99 guests