Rules in ESPeasy
Moderators: grovkillen, Stuntteam, TD-er
Re: Rules in ESPeasy
OK, so you did understand the question
I will try to create some rules for you.
I will try to create some rules for you.
Re: Rules in ESPeasy
thank you/ it's should be godd
Re: Rules in ESPeasy
I think this is just about all you need:
Disinfection start procedure:
set flag indicating we did start the procedure (set variable #1 to '1')
GPIO,27,1
2500 ms
LongPulse_mS,32,1,500,500,0
2500 ms
LongPulse_mS,13,1,500,500,0
Disinfection stop procedure:
GPIO,27,0
clear flag indicating we did stop the procedure (set variable #1 to '0')
Start periods disinfection:
06:00 to 07:30
18:00 to 19:30
End disinfection:
90 minutes after starting
Requirements:
Disinfection & boiler not together
Not sure if the pump should also be enabled???
Boiler controlled by temperature
What we need to do:
If in start period disinfection, check if boiler is active.
When boiler not active, perform "Disinfection start procedure" + set stop timer for 90 minutes
The only thing I was wondering is, what happens when the pump is turned off and the disinfection procedure is still active?
Should it be turned off immediately?
I also added the temperature checks, temp#water without hysteresis, as it seemed like this would be integer degrees?
The other with the hysteresis of 0.5 degree.
You should check for yourself whether it needs 2 if..endif checks (with hysteresis) or an if...else...endif check (without hysteresis)
Disinfection start procedure:
set flag indicating we did start the procedure (set variable #1 to '1')
GPIO,27,1
2500 ms
LongPulse_mS,32,1,500,500,0
2500 ms
LongPulse_mS,13,1,500,500,0
Disinfection stop procedure:
GPIO,27,0
clear flag indicating we did stop the procedure (set variable #1 to '0')
Start periods disinfection:
06:00 to 07:30
18:00 to 19:30
End disinfection:
90 minutes after starting
Requirements:
Disinfection & boiler not together
Not sure if the pump should also be enabled???
Boiler controlled by temperature
What we need to do:
If in start period disinfection, check if boiler is active.
When boiler not active, perform "Disinfection start procedure" + set stop timer for 90 minutes
Code: Select all
on Clock#Time=All,**:** do
if [int#1]=0
if %systm_hm_0% >=06:00 And %systm_hm_0% <=07:30
asyncevent,startDisinfection
endif
if %systm_hm_0% >=18:00 And %systm_hm_0% <=19:30
asyncevent,startDisinfection
endif
endif
endon
on startDisinfection do
if [int#1]=0
// TD-er: Should also check for pump state?
if [boiler#boiler]=0 // and [pump#pump]=1
let,1,1 // set variable #1 to '1'
gpio,27,1
TimerSet_ms,1,2500
TimerSet,3,5400 // 90 minutes timer to stop disinfection run
endif
endif
endon
On Rules#Timer=1 do // Press 1st button to activate disinfection
LongPulse_mS,32,1,500,500,0
TimerSet_ms,2,2500
Endon
On Rules#Timer=2 do // Press 2nd button to activate disinfection
LongPulse_mS,13,1,500,500,0
Endon
On Rules#Timer=3 do // Stop disinfection procedure
GPIO,27,0
let,1,0 // clear flag indicating we did stop the procedure (set variable #1 to '0')
Endon
on temp#water do
if %eventvalue1% <=25.00
// темп. воды в бассдля вкл. обогрева
GPIO,12,1
gpio,33,1
else
// темп. воды в бассдля выкл. обогрева
GPIO,12,0
endif
Endon
on temp#air do
if %eventvalue1% <=-0.5
// темп. воздуха вкл. греющ. кабеля
GPIO,25,1
endif
if %eventvalue1% >=0.0
// темп. воздуха выкл. греющ.кабеля
GPIO,25,0
endif
Endon
Should it be turned off immediately?
I also added the temperature checks, temp#water without hysteresis, as it seemed like this would be integer degrees?
The other with the hysteresis of 0.5 degree.
You should check for yourself whether it needs 2 if..endif checks (with hysteresis) or an if...else...endif check (without hysteresis)
Re: Rules in ESPeasy
Thanks a lot. I'll try a little later.
and the pump is always running, the water must constantly circulate. only from 22.00 to 02.00 I turn it off. but if the water temperature drops, then the boiler turns on and the pump also turns on
now I see why it was easier for you to write the code yourself than to explain to me
and the pump is always running, the water must constantly circulate. only from 22.00 to 02.00 I turn it off. but if the water temperature drops, then the boiler turns on and the pump also turns on
now I see why it was easier for you to write the code yourself than to explain to me
Last edited by dr.zorg82 on 06 Feb 2023, 10:43, edited 1 time in total.
Re: Rules in ESPeasy
The timer to turn off the pump is not included, but that can be added to the
on Clock#Time=All,**:** do
part.
on Clock#Time=All,**:** do
part.
Code: Select all
on Clock#Time=All,**:** do
if [int#1]=0
if %systm_hm_0% >=06:00 And %systm_hm_0% <=07:30
asyncevent,startDisinfection
endif
if %systm_hm_0% >=18:00 And %systm_hm_0% <=19:30
asyncevent,startDisinfection
endif
endif
if %systm_hm_0% <22:00 And %systm_hm_0% >02:00
// Turn pump on (GPIO 33?)
else
// Turn pump off (GPIO 33?)
endif
endon
Re: Rules in ESPeasy
Fine. I understand. Thank you. I will study the code and try in practice.
By the way, I'll get back to you. I will need to make control of the current in the circuit and adjust the speed of rotation of the collector motor. and I feel like I can't do it myself. but this is later, while I'm waiting for a current sensor (acs712) from China
By the way, I'll get back to you. I will need to make control of the current in the circuit and adjust the speed of rotation of the collector motor. and I feel like I can't do it myself. but this is later, while I'm waiting for a current sensor (acs712) from China
Re: Rules in ESPeasy
That's just a simple hall-effect sensor, outputting an analog value, right?
No idea what you try to measure, but make sure you also check the signal from it using a multimeter and preferably some oscilloscope or using a multimeter which can also give some info on whether it is an AC or DC signal coming from this sensor.
No idea what you try to measure, but make sure you also check the signal from it using a multimeter and preferably some oscilloscope or using a multimeter which can also give some info on whether it is an AC or DC signal coming from this sensor.
Re: Rules in ESPeasy
or maybe you will recommend another current sensor that will be easier to set up in espeasy? my task is to measure the direct current in the circuit and, according to the values of this current, increase or decrease the speed of the collector motor
Re: Rules in ESPeasy
Not sure if the current is a good indicator to control speed.
For example if the thing that needs to be driven by this motor is somehow stuck or experiencing a lot more friction, then the current will also go up. But trying to increase the "speed" may even be damaging to the motor.
IMHO, feedback from a tacho will be better to control the speed of a motor.
The current measurement would then still be useful, but more like to protect the motor instead of driving it harder.
For example if the thing that needs to be driven by this motor is somehow stuck or experiencing a lot more friction, then the current will also go up. But trying to increase the "speed" may even be damaging to the motor.
IMHO, feedback from a tacho will be better to control the speed of a motor.
The current measurement would then still be useful, but more like to protect the motor instead of driving it harder.
Re: Rules in ESPeasy
I'll try to explain. disinfection of water in the pool is carried out using a device that produces chlorine from a 10% salt solution (NaCl). but the solution is not always the same, sometimes there is more water, sometimes more salt, and the current in the reactor of the device and, accordingly, the amount of chlorine depend on this. salt solution is supplied by a peristaltic pump. so I want to measure the direct current in the reactor (maximum 10A) and thereby regulate the speed of rotation of the peristaltic pump motor. that is, if the salt concentration is low, the current in the reactor decreases and the pump speed must be increased to increase the salt concentration
seems to be able to explain
all this so that there is no excess consumption of salt and the concentration of chlorine in the water is the same.
seems to be able to explain
all this so that there is no excess consumption of salt and the concentration of chlorine in the water is the same.
Re: Rules in ESPeasy
The reason I started about the current measurement you plan on doing is about whether you're measuring AC or DC current.
A simple Hall Effect sensor measures the magnetic field.
But since this is an analog sensor, it may very quickly respond to changes in current. (no idea whether the chip used in that sensor also tries to 'flatten' this signal)
Both AC and DC motors generate a quite complex current. Brushed DC motors even more complex than others.
So if the sensor doesn't 'average' the signal, you need to average it yourself before measuring.
Otherwise you need an incredible high sampling rate to make sense of the current being drawn.
That's why I mentioned you should be able to 'look' at the signal output of the sensor before trying to make sense of it using rules.
I do think using a contact-less way of measuring the current is a good idea, from a safety point of view.
So if you can make it work using such a sensor, then that would be the preferred way.
However, as always;
Measuring is knowing, only if you know what you're measuring.
A simple Hall Effect sensor measures the magnetic field.
But since this is an analog sensor, it may very quickly respond to changes in current. (no idea whether the chip used in that sensor also tries to 'flatten' this signal)
Both AC and DC motors generate a quite complex current. Brushed DC motors even more complex than others.
So if the sensor doesn't 'average' the signal, you need to average it yourself before measuring.
Otherwise you need an incredible high sampling rate to make sense of the current being drawn.
That's why I mentioned you should be able to 'look' at the signal output of the sensor before trying to make sense of it using rules.
I do think using a contact-less way of measuring the current is a good idea, from a safety point of view.
So if you can make it work using such a sensor, then that would be the preferred way.
However, as always;
Measuring is knowing, only if you know what you're measuring.
Re: Rules in ESPeasy
If I understand you correctly, I will answer: this sensor has an analog signal at the output. for every ampere of current it produces 100 mV of DC voltage. that is, on my 10a, the output of this sensor will be 1 v.
and the speed of the collector motor (12 volts) will be regulated using a field effect transistor, which will be controlled by PWM
Re: Rules in ESPeasy
Yes, but the question is, how 'constant' is this 10A of current?
And how quickly does the sensor respond to changes in current?
If for example the motor is a brushed DC motor, the current will change every time the brush connects to the next coil and the currents will be 'all over the scale'. Maybe even spike >100A for a very short time.
So it all depends on what will be on the output of the Hall effect sensor, to see if we can use the signal at all.
Especially if you control the motor using PWM, the signal will be extremely noisy.
If this sensor does reply immediately, then its raw output voltage should first be filtered before we can use it.
That's why I mention you should be able to 'view' this signal using some scope or something like that as I suspect it will not be a nice flat signal coming out of this sensor given the source you will try to measure.
And how quickly does the sensor respond to changes in current?
If for example the motor is a brushed DC motor, the current will change every time the brush connects to the next coil and the currents will be 'all over the scale'. Maybe even spike >100A for a very short time.
So it all depends on what will be on the output of the Hall effect sensor, to see if we can use the signal at all.
Especially if you control the motor using PWM, the signal will be extremely noisy.
If this sensor does reply immediately, then its raw output voltage should first be filtered before we can use it.
That's why I mention you should be able to 'view' this signal using some scope or something like that as I suspect it will not be a nice flat signal coming out of this sensor given the source you will try to measure.
Re: Rules in ESPeasy
No. motor current does not need to be measured. brine enters the reactor. a constant voltage is applied to the reactor and chlorine is produced. the more salt solution, the greater the current. current must be measured in the reactor. and the motor of the peristaltic pump is powered by a different voltage source. that is, we measure the current in the reactor, and change the voltage on the pump motor. if the current in the reactor decreases, then you need to increase the voltage on the pump so that it increases the supply of brine. if the supply of salt solution increases, then the current in the reactor will increase.
the artist, like the programmer, is not very good of me, but I hope it turned out clearly the current sensor, of course, through the esp32 affects the speed of the pump.
Re: Rules in ESPeasy
Ah, now I understand... it is the current through the liquid, not the current drawn by the motor.
I guess that would be a rather constant current indeed.
Not sure if this will cause some gas to be formed, as I can imagine this might constantly change the contact area of the electrodes, causing changes in current.
So maybe you still might need to add some light filtering on the measured signal. For example a small capacitor could be enough.
I guess that would be a rather constant current indeed.
Not sure if this will cause some gas to be formed, as I can imagine this might constantly change the contact area of the electrodes, causing changes in current.
So maybe you still might need to add some light filtering on the measured signal. For example a small capacitor could be enough.
Re: Rules in ESPeasy
https://letscontrolit.com/forum/viewtop ... 958#p62958
Good afternoon. finally I got the second module and the analog current sensor. and I can keep asking questions I need to maintain a stable current in the reactor by using a salt pump. that is, if the current in the reactor is lower than the required value, then needed to increase the speed of the pump, and if the current is higher, then needed to reduce the speed of the pump. configured analog input. This is where my knowledge ends. please tell me how to make the pump speed increase (decrease) until the current reaches the specified level? the response of the current to the pump speed is almost instantaneous. for example, during normal operation, the analog input should be 1000,. and if the analog input is 500, then the PWM(gpio 25) should increase until the input becomes 1000
Is it enough in my case to do so?
Good afternoon. finally I got the second module and the analog current sensor. and I can keep asking questions I need to maintain a stable current in the reactor by using a salt pump. that is, if the current in the reactor is lower than the required value, then needed to increase the speed of the pump, and if the current is higher, then needed to reduce the speed of the pump. configured analog input. This is where my knowledge ends. please tell me how to make the pump speed increase (decrease) until the current reaches the specified level? the response of the current to the pump speed is almost instantaneous. for example, during normal operation, the analog input should be 1000,. and if the analog input is 500, then the PWM(gpio 25) should increase until the input becomes 1000
Is it enough in my case to do so?
Code: Select all
ON garag#analog do
if %eventvalue1% < 1000.00
PWM,25,++2
if %eventvalue1% > 1000.00
PWM,25,--2
EndIf
endon
Re: Rules in ESPeasy
doesn't work like that.dr.zorg82 wrote: ↑19 Mar 2023, 17:01
Is it enough in my case to do so?Code: Select all
ON garag#analog do if %eventvalue1% < 1000.00 PWM,25,++2 if %eventvalue1% > 1000.00 PWM,25,--2 EndIf endon
Re: Rules in ESPeasy
At first you need an interval for "garag#analog" ..like 1s,
then you need a value for PWM you can refer to:
This value you can get from here: [plugin#gpio#pinstate#25] (to use this you must have set pin25 to a pwm value elsewhere before)
And maybe it is a good idea to give the whole thing a hysteresis.
And last but not least: every "If" needs an "Endif" unless you want to use an "Elseif" ...https://espeasy.readthedocs.io/en/lates ... lseif-else
Edit: but to be honest, i doubt that your approach will work very well...
then you need a value for PWM you can refer to:
Code: Select all
PWM,25,[Value]+2 //where two is a fairly low value...
And maybe it is a good idea to give the whole thing a hysteresis.
And last but not least: every "If" needs an "Endif" unless you want to use an "Elseif" ...https://espeasy.readthedocs.io/en/lates ... lseif-else
Code: Select all
On garag#analog Do
If %eventvalue1% < 900.00
PWM,25,[plugin#gpio#pinstate#25]+2
Elseif %eventvalue1% > 1000.00
PWM,25,[plugin#gpio#pinstate#25]+2
Endif
Endon
Re: Rules in ESPeasy
Good morning. Thanks, I'll try it tonight.
but why do you think it won't work very well?
Fine. if you forget about my project. how to make smooth adjustment of the LED in espeasy? For example, in C++ it can be done like this (taken from the Internet):
Code: Select all
#define LED_PIN 25
void setup() {
pinMode(LED_PIN, OUTPUT);
}
void loop() {
for(int i=0;i<=255;i++) {
analogWrite(LED_PIN, i);
delay(5);
}
for(int i=255;i>=0;i--) {
analogWrite(LED_PIN, i);
delay(5);
}
}
Re: Rules in ESPeasy
I actually don’t know... it was more of a hunch without really knowing how your system works and how fast it needs to react.
Give it a try.
Inline calculations doesn’t seem to work, so you should do the math before and put it in a variable...
...and you probably should add some limits since the pwm-value can be set out of range:
Code: Select all
On garag#analog Do
If %eventvalue1% < 900.00 And [plugin#gpio#pinstate#25] <= 1021
Let,1,[plugin#gpio#pinstate#25]+2
PWM,25,[int#1]
Elseif %eventvalue1% > 1000.00 And [plugin#gpio#pinstate#25] >= 2
Let,1,[plugin#gpio#pinstate#25]-2
PWM,25,[int#1]
Endif
Endon
Re: Rules in ESPeasy
For inline calculations, you may want to prepend an "=".
However this may not be used everywhere, thus storing it in a variable is a safe way to make sure the values are always calculated.
Code: Select all
PWM,25,=[plugin#gpio#pinstate#25]+2
Re: Rules in ESPeasy
Thanks a lot. works.
but one second is long Can you please tell me if it is possible to reduce the polling time of an analog sensor? it is impossible to take a big step to increase the PWM . now i increased from 2 to 20
Re: Rules in ESPeasy
That was part of my hunch...
Sorry, but you can’t. At least not that i know of. Maybe you should do the controlling with a dedicated microcontroller like an atmega328 or something similar.
Or somebody writes a plugin for ESPeasy with exactly this purpose
Re: Rules in ESPeasy
and hello again. I have part of the code
after timer 2 should start executing garag#analog. i.e. part of the code is it correct?
Code: Select all
On down#gerkon Do
if %eventvalue1%=1
GPIO,21,1
GPIO,26,1
TimerSet,1,900
Endif
Endon
On Rules#Timer=1 do
GPIO,4,1
PWM,25,500
TimerSet,2,50
Endon
On Rules#Timer=2 Do
[garag#analog]
Endon
On garag#analog Do
If %eventvalue1% < 999.00 And [plugin#gpio#pinstate#25] <= 1010
Let,1,[plugin#gpio#pinstate#25]+20
PWM,25,[int#1]
Elseif %eventvalue1% > 1000.00 And [plugin#gpio#pinstate#25] >= 500
Let,1,[plugin#gpio#pinstate#25]-20
PWM,25,[int#1]
Endif
Endon
Code: Select all
On Rules#Timer=2 Do
[garag#analog]
Endon
Re: Rules in ESPeasy
It seems to be correct. If you want to see what is going on, you can always head over to the log-viewer in the /tools tab.
Edit: And you can also always put a "LogEntry" in your code for your own messages. This will then be displayed in the Logviewer.
Example:
(adding all the hyphen gives a better readability, especially when a lot of entries are scrolling through the log-viewer)
Edit: And you can also always put a "LogEntry" in your code for your own messages. This will then be displayed in the Logviewer.
Example:
(adding all the hyphen gives a better readability, especially when a lot of entries are scrolling through the log-viewer)
Code: Select all
LogEntry,'----------------------------initial value: [var#1]'
Last edited by chromo23 on 22 Mar 2023, 13:32, edited 1 time in total.
Re: Rules in ESPeasy
That will only try to execute the value of [garag#analog] as a command, (I) don't expect that to do anything useful.dr.zorg82 wrote: ↑22 Mar 2023, 13:12 after timer 2 should start executing garag#analog. i.e. part of the codeis it correct?Code: Select all
On Rules#Timer=2 Do [garag#analog] Endon
If you want to 'run' the garag task, use this command:
Code: Select all
TaskRun,garag
/Ton (PayPal.me)
Re: Rules in ESPeasy
I think it was used as a placeholder for the code.
If not, then @Ath is right. But then it is probably anyway better to activate and deactivate the whole task with:
Code: Select all
TaskDisable,[number of the analog device]
TaskEnable,[number of the analog device]
Code: Select all
On System#Boot Do
TaskDisable,1
Endon
On Rules#Timer=2 Do
TaskEnable,1
Endon
Re: Rules in ESPeasy
thank you for your patience and help. but i have a new problem the analog sensor polling time is 1 second, and timer 3 sets the delay to 60 seconds. and in the log I see that the timer is reset every second and pin 23 will not turn on in any way please tell me what am i doing wrong?
Code: Select all
On garag#analog Do
If %eventvalue1% < 999.00 And [plugin#gpio#pinstate#25] <= 1010
Let,1,[plugin#gpio#pinstate#25]+20
PWM,25,[int#1]
Elseif %eventvalue1% > 1000.00 And [plugin#gpio#pinstate#25] >= 500
Let,1,[plugin#gpio#pinstate#25]-20
PWM,25,[int#1]
Endif
If %eventvalue1% < 100.00
TimerSet,3,60
Endif
Endon
On Rules#Timer=3 do
GPIO,23,1
Endon
Re: Rules in ESPeasy
Check this code in your rule:
The event is called with %eventvalue1% = 0, so that is true every second (the Interval for the garag task), so the timer will be reset...
Not sure why that value is 0 though.
Code: Select all
If %eventvalue1% < 100.00
TimerSet,3,60
Endif
Not sure why that value is 0 though.
/Ton (PayPal.me)
Re: Rules in ESPeasy
Set a variable to run TimerSet only once and set i back when %eventvalue% is not <100
Code: Select all
On garag#analog Do
If %eventvalue1% < 999.00 And [plugin#gpio#pinstate#25] <= 1010
Let,1,[plugin#gpio#pinstate#25]+20
PWM,25,[int#1]
Elseif %eventvalue1% > 1000.00 And [plugin#gpio#pinstate#25] >= 500
Let,1,[plugin#gpio#pinstate#25]-20
PWM,25,[int#1]
Endif
If %eventvalue1% < 100.00 And [var#2] = 0
TimerSet,3,60
Let,2,1
Elseif %eventvalue1% >= 100.00
TimerSet,3,0
Let,2,0
Endif
Endon
On Rules#Timer=3 do
GPIO,23,1
Endon
Last edited by chromo23 on 22 Mar 2023, 17:38, edited 1 time in total.
Re: Rules in ESPeasy
I just saw, that i used the same variable than that which was already in code... i corrected it now
Re: Rules in ESPeasy
Good afternoon. I have a problem again but this time with a long button press. I have a simple rule
but with a long press, it works first GPIO16 and only then GPIO17. please tell me how to fix it
somewhere I found such a solution (did not try it), but maybe there is a more convenient one?
Code: Select all
On qq#qq Do
If %eventvalue1%=1
GPIO 16,1
Elseif %eventvalue1%=11
GPIO 17,1
Endif
Endon
somewhere I found such a solution (did not try it), but maybe there is a more convenient one?
Code: Select all
on Switch1#switch1=1 do
timerSet,1,1
EndOn
On Rules#Timer=1 do
Publish sometopic/switch1,single
timerSet,1,0
endon
on Switch1#switch1=3 do
Publish sometopic/switch1,double
timerSet,1,0
EndOn
on Switch1#switch1=11 do
Publish sometopic/switch1,long
timerSet,1,0
endon
Re: Rules in ESPeasy
Yes, it´s a problem. The short press event (1) is always fired fist.
To get around this , there are different valid approaches.
I can show you mine:
Code: Select all
On Button#State Do
If %eventvalue%=1
LoopTimerSet_ms,1,100,50
Elseif %eventvalue%=0
If [var#4] >= 25 and [var#4] < 35
AsyncEvent,wifiap
Elseif [var#4] >= 10
AsyncEvent,longpress
Elseif [var#4] < 6
AsyncEvent,shortpress
Endif
TimerSet,4,0
Let,4,0
Endif
Endon
On Rules#Timer=4 Do
Let,4,%eventvalue2%
If %eventvalue2% >= 35
NeoPixelAll,255,0,255
AsyncEvent,Resetevent
Elseif %eventvalue2% >= 25
NeoPixelAll,255,255,0
Elseif %eventvalue2% >= 10
NeoPixelAll,0,255,0
Elseif %eventvalue2% < 6
NeoPixelAll,0,255,255
Endif
Endon
-when the button is pressed a loop timer is started and stores its number of loops in a variable
-when the button is released an event is called depending on the number of loops
- if you want the longpress event to be fired without releasing the button put it in the rules#timer block (see: AsyncEvent,Resetevent)
- for visual feedback i use a neopixel where you can see when it is time to release the button...
to shorten it for you:
Code: Select all
On Button#State Do
If %eventvalue%=1
LoopTimerSet_ms,1,100,50
Elseif %eventvalue%=0
If [var#4] < 6
GPIO 16,1 //shortpress
Endif
TimerSet,4,0
Let,4,0
Endif
Endon
On Rules#Timer=4 Do
Let,4,%eventvalue2%
If %eventvalue2% >=10
GPIO 17,1 //longpress
Endif
Endon
Re: Rules in ESPeasy
Or simpler since you probably won´t need multiple long press with different length:
Code: Select all
On Button#State Do
If %eventvalue%=1
TimerSet,1,1
Elseif %eventvalue%=0
If [var#1] = 0
GPIO 16,1 //shortpress
Endif
TimerSet,1,0
Let,1,0
Endif
Endon
On Rules#Timer=1 Do
Let,1,1
GPIO 17,1 //longpress
Endon
I guess not.
Re: Rules in ESPeasy
Yeah. not so simple thank you.
i have three options :
how i did
Code: Select all
on qq#qq=1 do
TimerSet,1,1
Endon
On Rules#Timer=1 do
GPIO,16,1
TimerSet,1,0
endon
on qq#qq=11 do
GPIO,17,1
TimerSet,1,0
endon
Code: Select all
On qq#qq Do
If %eventvalue1%=1
let,1,0
Elseif %eventvalue1%=11
GPIO,17,1
let,1,1
Elseif %eventvalue1%=0 and %v1%=0
GPIO,16,1
Endif
Endon
Is there any difference between them in the operation of the device?
Re: Rules in ESPeasy
Yes.
This one is the least responsive example since it only fires a shortpress after one second....
Code: Select all
on qq#qq=1 do
TimerSet,1,1
Endon
On Rules#Timer=1 do
GPIO,16,1
TimerSet,1,0
endon
on qq#qq=11 do
GPIO,17,1
TimerSet,1,0
endon
Mine ist actually the same as the latter one. The only difference it, that my suggestion is independent of the settings of the switch plugin.
So for you the latter one in your last post makes the most sense...
Re: Rules in ESPeasy
The reason the "short press" event is fired first is to make it more responsive.
You can also act on the specific values as you do in your latest code, but keep in mind the rules parsing stops when a matching event block is found.
So have the most restrictive version first.
on qq#qq=1 do // << more restrictive
on qq#qq do // << less restrictive
You can also act on the specific values as you do in your latest code, but keep in mind the rules parsing stops when a matching event block is found.
So have the most restrictive version first.
on qq#qq=1 do // << more restrictive
on qq#qq do // << less restrictive
Re: Rules in ESPeasy
and yet I don’t understand why this option is bad, except that a short press will work after one second
Code: Select all
on qq#qq=1 do
TimerSet,1,1
Endon
On Rules#Timer=1 do
GPIO,16,1
TimerSet,1,0
endon
on qq#qq=11 do
GPIO,17,1
TimerSet,1,0
endon
Re: Rules in ESPeasy
For your use case this isn't bad.
It is still possible the timer will be handled before the long press event is fired.
It depends on how critical the timer is compared to the set delay to consider it a longpulse.
So if GPIO 16 should not be set when 17 is set, you may want to tweak those timings or even set the GPIO 16 to 0 when dealing with the longpulse.
It is still possible the timer will be handled before the long press event is fired.
It depends on how critical the timer is compared to the set delay to consider it a longpulse.
So if GPIO 16 should not be set when 17 is set, you may want to tweak those timings or even set the GPIO 16 to 0 when dealing with the longpulse.
Who is online
Users browsing this forum: Google [Bot] and 5 guests