Rules in ESPeasy
Moderators: grovkillen, Stuntteam, TD-er
Rules in ESPeasy
Hello Everybody,
i would like to do the following thing with the ESPeasy. I would like to build a thermostat which should have a fixed value when starting and when the connection to the mqtt server is lost. I would then like to be able to change the setpoint via mqtt. The actual value comes from a DS18b20 temp sensor. I could build this in node red without problems, but I would like the control to be on the ESP, because if the connection to node red is lost, I will not have hot water to shower the next morning. and that could cause problems with my wife. Can someone give me a suggestion on how best to start this? Or where is there a good tutorial on rules?
many Greetings
Frank
i would like to do the following thing with the ESPeasy. I would like to build a thermostat which should have a fixed value when starting and when the connection to the mqtt server is lost. I would then like to be able to change the setpoint via mqtt. The actual value comes from a DS18b20 temp sensor. I could build this in node red without problems, but I would like the control to be on the ESP, because if the connection to node red is lost, I will not have hot water to shower the next morning. and that could cause problems with my wife. Can someone give me a suggestion on how best to start this? Or where is there a good tutorial on rules?
many Greetings
Frank
Re: Rules in ESPeasy
A few questions:
- Can we assume the DB18b20 is directly connected to the ESP?
- How are you going to validate/check the current setpoint value when MQTT or WiFi isn't available?
- How are you manually going to change the setpoint value in a disconnected situation?
- Can we assume the DB18b20 is directly connected to the ESP?
- How are you going to validate/check the current setpoint value when MQTT or WiFi isn't available?
- How are you manually going to change the setpoint value in a disconnected situation?
/Ton (PayPal.me)
Re: Rules in ESPeasy
The "level" plugin allows to set a threshold, but it does write the settings every time you change the value.
So I would rather not change it too often or you run into issues.
You can also store the set value in a dummy, which will be kept even after a reboot or crash. As long as you don't have a power cycle... but then you probably also would have lost the settings on your thermostat, so your wife will probably accept that as an excuse
So I would rather not change it too often or you run into issues.
You can also store the set value in a dummy, which will be kept even after a reboot or crash. As long as you don't have a power cycle... but then you probably also would have lost the settings on your thermostat, so your wife will probably accept that as an excuse
Re: Rules in ESPeasy
Look here:
https://www.youtube.com/watch?v=1ef6tRinOQ4
You can define fixed value for thermostat in boot section ( TaskValueSet,2,2 ) :
In case of controller failure, it will remember last received value.
And if you need change it, then simply connect to rules tab on web page of your ESP, change initial setpoint
to required value and reboot.
https://www.youtube.com/watch?v=1ef6tRinOQ4
You can define fixed value for thermostat in boot section ( TaskValueSet,2,2 ) :
Code: Select all
On System#Boot do
gpio,13,1
gpio,12,0
TaskValueSet,2,2,10 // initial Setpoint
TaskValueSet,2,3,0
TaskValueSet,2,4,0 //mode
TaskValueSet,2,1,0 //HDO
timerSet,1,60
endon
In case of controller failure, it will remember last received value.
And if you need change it, then simply connect to rules tab on web page of your ESP, change initial setpoint
to required value and reboot.
Re: Rules in ESPeasy
You can explain in more detail how to configure and maintain a value in a fictitious mode. I, too, would be a hotel to change the settings of the margin through MQTT. And so that after turning off the power, they remain on the ESP.
This is what the code looks like now. There is an alarm, with an uncontrolled decrease and temperature increase. In case the contacts of the relay are sticking or vice versa, contact will disappear.
In principle, everything suits me. But to make it perfect, I would like to change values through MQTT.
Code: Select all
On System#Boot do
let,1,0
tone,3,1500,500
loopTimerSet,1,60
loopTimerSet,2,1
endon
on sensor#temperature do
if %eventvalue1% < 22.00
let,1,1
endif
if %eventvalue1% < 27.00
gpio,0,0
endif
if %eventvalue1% > 28.15
gpio,0,1
let,1,0
endif
if %eventvalue1% > 30.0
let,1,2
endif
endon
on Rules#Timer=1 do
if [int#1]=1
tone,3,1000,50
endif
endon
on Rules#Timer=2 do
if [int#1]=2
tone,3,1000,100
endif
endon
Re: Rules in ESPeasy
You should have a look at P109: Display - ThermoOLED, that does exactly what you need, but requires a 128x64 pixel SSD1306/SH1106 OLed display (I2C) to be used. Using the MQTT Import plugin you can use the "thermo,setpoint,<temperature>" command to change the setpoint.
Documentation for that plugin is quite slim (non-existent), but configuration is quite straightforward. It saves the setpoint temp. as few times as possible to reduce the Flash wearing out. Settings can easily be changed using a few push buttons.
This PR #4098 has a lot of info about that plugin and how to use/configure it.
Documentation for that plugin is quite slim (non-existent), but configuration is quite straightforward. It saves the setpoint temp. as few times as possible to reduce the Flash wearing out. Settings can easily be changed using a few push buttons.
This PR #4098 has a lot of info about that plugin and how to use/configure it.
/Ton (PayPal.me)
Re: Rules in ESPeasy
Thank you friend!
To be honest, for my solution of my problem, this approach is redundant. It's more visual and informative with the display, but I don't need it, the mqtt app on the MQTT Dash phone is enough. It is very simple and probably this is its minus, at the same time it is also a plus.
I am puzzling over the fact that the changed values are not written immediately to the flash, but with a time delay (later I will check whether the value has changed, to allow or prohibit re-recording). I tried this rule. Yes, it doesn't work and I guessed it. But how to do this right?
Code: Select all
On heater#ustlow do
logentry,"MQTT import ustlow: %eventvalue1%"
loopTimerSet,3,10
//TaskValueSet 3,1,[floor#temperature]%eventvalue1%
endon
on Rules#Timer=3 do
TaskValueSet 3,1,[floor#temperature]%eventvalue1%
loopTimerSet,3,0
endon
Re: Rules in ESPeasy
Code: Select all
On heater#ustlow do
logentry,"MQTT import ustlow: %eventvalue1%"
loopTimerSet,3,10
//TaskValueSet 3,1,[floor#temperature]%eventvalue1%
endon
on Rules#Timer=3 do
TaskValueSet 3,1,[floor#temperature]%eventvalue1%
loopTimerSet,3,0
endon
Code: Select all
On heater#ustlow do
logentry,"MQTT import ustlow: %eventvalue1%"
loopTimerSet,3,10
//TaskValueSet 3,1,[floor#temperature]%eventvalue1%
endon
on Rules#Timer=3 do
TaskValueSet 3,1,[floor#temperature]%eventvalue1%
// loopTimerSet,3,0 // TD-er: Not needed
endon
Code: Select all
TaskValueSet 3,1,[floor#temperature]%eventvalue1%
Also the "[floor#temperature]%eventvalue1%" is probably not what you would want.
Imagine "[floor#temperature]" is "20.0" and "%eventvalue1%" (or more likely you want [heater#ustlow] ) is "10"
Then [floor#temperature]%eventvalue1% would be replaced with 20.010 before it is being parsed.
Re: Rules in ESPeasy
Please excuse me, I didn't understand you well (Google translit). Or I don't speak well... I need to set thresholds for turning on and off the thermostat from the application in the phone, using the mqtt protocol. To do this, I created a dummy device where two variables are low and high, how can I substitute these variables into the rules where I have 27.00 and 28.00?
I hope I was able to explain what I want to do. I would like to do it...
Code: Select all
On System#Boot do
let,1,0
tone,3,1000,250
loopTimerSet,1,60
loopTimerSet,2,1
endon
on sensor#temperature do
if %eventvalue1% < 22.00
let,1,1
endif
if %eventvalue1% <27.00//how can I substitute the value from the low variable, a dummy device, here?
gpio,0,0
endif
if %eventvalue1% > 28.00//how can I substitute the value from the high variable, a dummy device, here?
gpio,0,1
let,1,0
endif
if %eventvalue1% > 30.00
let,1,2
endif
endon
on Rules#Timer=1 do
if [int#1]=1
tone,3,1000,50
endif
endon
on Rules#Timer=2 do
if [int#1]=2
tone,3,1000,100
endif
endon
On heater#ustlow do
logentry,"MQTT import ustlow: %eventvalue1%"
TaskValueSet 3,1,[floor#temperature]%eventvalue1%
endon
On heater#usthigh do
logentry,"MQTT import usthigh: %eventvalue1%"
TaskValueSet 3,2,[floor#temperature]%eventvalue1%
endon
Last edited by igorka on 07 Dec 2022, 15:24, edited 1 time in total.
Re: Rules in ESPeasy
That should be something like this:
Code: Select all
On System#Boot do
let,1,0
tone,3,1000,250
loopTimerSet,1,60
loopTimerSet,2,1
endon
on sensor#temperature do
if %eventvalue1% < 22.00
let,1,1
endif
if %eventvalue1% < [telephone#low]
gpio,0,0
endif
if %eventvalue1% > [telephone#high]
gpio,0,1
let,1,0
endif
if %eventvalue1% > 30.00
let,1,2
endif
endon
on Rules#Timer=1 do
if [int#1]=1
tone,3,1000,50
endif
endon
on Rules#Timer=2 do
if [int#1]=2
tone,3,1000,100
endif
endon
On heater#ustlow do
logentry,"MQTT import ustlow: %eventvalue1%"
TaskValueSet telephone,low,%eventvalue1%
endon
On heater#usthigh do
logentry,"MQTT import usthigh: %eventvalue1%"
TaskValueSet telephone,high,%eventvalue1%
endon
/Ton (PayPal.me)
Re: Rules in ESPeasy
Thanks! That's exactly what I wanted.
So I made a re-write protection if the value has not changed:
Code: Select all
On heater#ustlow do
logentry,"MQTT import ustlow: %eventvalue1%"
if [telephone#low] = %eventvalue1%
tone,3,150,100
else
TaskValueSet 3,1,[floor#temperature]%eventvalue1%
tone,3,1000,100
endif
endon
On heater#usthigh do
logentry,"MQTT import usthigh: %eventvalue1%"
if [telephone#high] = %eventvalue1%
tone,3,150,100
else
TaskValueSet 3,2,[floor#temperature]%eventvalue1%
tone,3,1000,100
endif
endon
Re: Rules in ESPeasy
That's not correct (I corrected it in my sample code), should be:igorka wrote: ↑07 Dec 2022, 16:32Code: Select all
On heater#ustlow do TaskValueSet 3,1,[floor#temperature]%eventvalue1%
Code: Select all
TaskValueSet 3,1,%eventvalue1%
/Ton (PayPal.me)
Re: Rules in ESPeasy
I have corrected according to your example. Now everything is correct.
This is the right question! I mistakenly assumed that after the power was turned off, the contents of the variables low [telephone#low] and high [telephone#high] would remain in flash memory. It turned out that it works only after a reboot, and if you completely remove the power, the data will disappear! And since I thought that the values of variables are stored in flash, I made a rule from unnecessary entries... I am very disappointed with this fact. You will have to set the temperature again every time after a power outage, or prescribe it rigidly in the rules as you did from the very beginning. Maybe I'm wrong, correct me?
Re: Rules in ESPeasy
I can recommend the Level-Control plugin to you.
You can set a temperature. It get´s stored permanently and you can change the setpoint with a command like you already did.
The only downside is, that you can set the hysteresis only in the plugin itself. Usually this is not an issues but maybe you have some special needs.
https://espeasy.readthedocs.io/en/lates ... #p021-page
You can set a temperature. It get´s stored permanently and you can change the setpoint with a command like you already did.
The only downside is, that you can set the hysteresis only in the plugin itself. Usually this is not an issues but maybe you have some special needs.
https://espeasy.readthedocs.io/en/lates ... #p021-page
Re: Rules in ESPeasy
Thanks. I will definitely try to test this plugin!
Another question: I have reverse control, logical zero is included, logical unit is disabled. Is it possible to set these parameters in this plugin? Or will I have to do an inversion at the output through the rules?
Another question: I have reverse control, logical zero is included, logical unit is disabled. Is it possible to set these parameters in this plugin? Or will I have to do an inversion at the output through the rules?
Re: Rules in ESPeasy
Can you elaborate? I don’t understand what you mean.Another question: I have reverse control, logical zero is included, logical unit is disabled. Is it possible to set these parameters in this plugin? Or will I have to do an inversion at the output through the rules?
Re: Rules in ESPeasy
That power off issue doesn't exist when using P109, ThermoOLED, that seems to do what you want, and you can still control from MQTT states via rules...
/Ton (PayPal.me)
Re: Rules in ESPeasy
It's very simple. I use the ESP-01S module, with an expansion board for it (relay module). By default, the relay is controlled by GPIO.0, and the circuit design of the relay module is such that in order to turn on the relay, on the GPIO.0 you need to submit "0". In my understanding, this is the reverse control logic (inverse). On, it's "0", off, it's "1". I hope you understand me. You can ask a question why I use these modules. I answer, I have "a lot" of them and their "power" is more than enough for me, so everything in the house works for them... In general, it turned out as I thought, if you enable direct GPIO control in the plugin settings.0, everything works the other way around. I wrote a simple rule and now it works correctly:
Code: Select all
on thermostat#relay do
if %eventvalue1% = 1
GPIO,0,0
else
GPIO,0,1
endif
if %eventvalue1% = 0
GPIO,0,1
else
GPIO,0,0
endif
endon
My build ESPEasy_ESP82xx_mega-20220616 does not have this plugin.Or not for a 1 MB flash.
Last edited by igorka on 08 Dec 2022, 09:23, edited 1 time in total.
Re: Rules in ESPeasy
That plugin is only available in the Display build, but that is not available for 1MB devices. You can create a Custom build that includes the P109 plugin, documented here. If you are unable to create a Custom build, you can request it here, and I'll try to build it for you, later this evening (CET).
/Ton (PayPal.me)
Re: Rules in ESPeasy
I will be grateful and grateful to you if you create an assembly for me. But after all, the plugin can be used without a display? I don't have it and I just don't need it in this product.
Re: Rules in ESPeasy
As does the Level Control Plugin as far a i can remember. Why would igorka need P109?
Re: Rules in ESPeasy
You can try this:
***removed***
***removed***
Last edited by chromo23 on 08 Dec 2022, 10:11, edited 2 times in total.
Re: Rules in ESPeasy
The difference is that the Level plugin can only save immediately, with a fixed delay, or not at all and you have to schedule your own (delayed) save action.
But P109 also doesn't support inverted Relay pin behavior, but that would be a nice addition. I'll work on that soon.
IMHO P109 should run fine without a display connected.
/Ton (PayPal.me)
Re: Rules in ESPeasy
Ahh true.. i forgot..
@igorka i´ll send you an updated binary with P109
Re: Rules in ESPeasy
There is a problem with setting the value using the configuration command. The picture shows the settings of my plugin:
I enter the command config,task,thermostat,28.00,temperature:
The value does not change. As it was 24, so it became, the temperature is also maintained at 24 degrees. Also in my "old" build there is no possibility of choosing the time of auto-save.Re: Rules in ESPeasy
The correct command would be:
Code: Select all
config,task,thermostat,SetLevel,28
So look at my post before and download the new binary with P109
Re: Rules in ESPeasy
Thanks! I will definitely do it later.
Re: Rules in ESPeasy
In this particular case, the solution with this plugin is completely suitable for me. But let me express my opinion or even wishes. It would be very convenient to be able to (command) save user variables "Let" in flash. After all, there is certainly a need to work - to operate not only with temperature, but with arbitrary values. I am sure that if it is possible, the functionality of the rules will be greatly expanded.
Re: Rules in ESPeasy
gd. firmware ESP_Easy_mega_20221224_energy_ESP32_4M316k Dec 24 2022, modul esp32 wroom 32d. here is part of the code: at 17:37, with a time delay, the 32nd pin is pressed, then the 13th, and only then the 27th turns on. please tell me how to make it so that 27 is turned on first, and then everything else?
what if you swap 32 and 13, then the turn-on queue also changes, but from 27 it doesn’t work like that
Code: Select all
On Clock#Time=All,17:37 do // каждый день вкл. химия
If [boiler#boiler]=0 and [pump#pump]=1
gpio,27,1
delay,2500
Pulse,32,1,500
delay,2500
Pulse,13,1,500
Else
gpio,27,0
Endif
endon
what if you swap 32 and 13, then the turn-on queue also changes, but from 27 it doesn’t work like that
Re: Rules in ESPeasy
Just to make 1 important thing very clear:
DO NOT USE DELAY IN RULES
That is the cause of the erratic behavior, as delay is BLOCKING the entire ESP for that amount of time.
You can use timers (there are 128 available) to have planned delays in execution.
Your intended code would translate to this:
(Also added some indentation for readability)
DO NOT USE DELAY IN RULES
That is the cause of the erratic behavior, as delay is BLOCKING the entire ESP for that amount of time.
You can use timers (there are 128 available) to have planned delays in execution.
Your intended code would translate to this:
Code: Select all
On Clock#Time=All,17:37 do // every day on chemistry (Google translated...)
If [boiler#boiler]=0 and [pump#pump]=1
gpio,27,1
TimerSet_ms,1,2500
Else
gpio,27,0
Endif
Endon
On Rules#Timer=1 do // timer 1 action
Pulse,32,1,500
TimerSet_ms,2,2500
Endon
On Rules#Timer=2 do // timer 2 action
Pulse,13,1,500
Endon
/Ton (PayPal.me)
Re: Rules in ESPeasy
Is there an espeasy emulator for windows? it would be great not having a module, configure and test the rules. for example, I don’t have Wi-Fi at work and I don’t really want to carry a module with me to write rules. and so I would set everything up on the computer and then transfer it to the module
Re: Rules in ESPeasy
Not as far as we know, but if you're into emulators, you're welcome to write one
There are (at least) 3 ways to check the syntax of rules:
- The EasyColorCode highlighter included in the Rules editor, (highlighting is available in most ESPEasy builds that have access to internet)
- The EasyColorCode highlighter test environment, provided by the author of the highlighter, over here
- The Notepad++ syntax highlighter plugin, available from here (Notepad++ is available for Windows only)
/Ton (PayPal.me)
Re: Rules in ESPeasy
it's not that. for example if i write this code
Code: Select all
On [boiler#boiler]=0 do // every day on chemistry (Google translated...)
If %systm_hm_0% >22:00 And %systm_hm_0% < 02:00
gpio,27,1
Else
gpio,27,0
Endif
Endon
that is, I need to perform the following task: if in the time interval from 22:00 to 02:00 [boiler#boiler]=0, then pin 27 should be 1.
but so far there is not enough time to figure out what is wrong
Re: Rules in ESPeasy
Yes, I fully appreciate your original question
but as we don't have anything that even looks like an emulator, the IMHO best suggestion is to use syntax highlighting/checks as a helper.
/Ton (PayPal.me)
Re: Rules in ESPeasy
And the fix to your rules problem is very simple:
There is never a time during the day being both before 2 in the morning and past 22h.
Just fipped the compares and the states of the GPIO commands.
The other option would be to change the "and" to an "or".
Boolean logic dictates:
!(A or B) == !A and !B
Code: Select all
On [boiler#boiler]=0 do // every day on chemistry (Google translated...)
If %systm_hm_0% <22:00 And %systm_hm_0% > 02:00
gpio,27,0
Else
gpio,27,1
Endif
Endon
Just fipped the compares and the states of the GPIO commands.
The other option would be to change the "and" to an "or".
Boolean logic dictates:
!(A or B) == !A and !B
Re: Rules in ESPeasy
it's me again ihave part of the code:
according to the code, pin 27 turns on at 18:00 and turns off at 19:30. but heating can work at the same time ([boiler#boiler]=1). but I don't need pin 27 and [boiler#boiler] to work at the same time, so I write that if [boiler#boiler]=0 in the period from 18:00 to 19:30, then pin 27 should turn on at 5400000(one and a half hours). for example, the heating will turn off ([boiler#boiler]=0) at 19:25, then pin 27 will turn off at 19:30, and not after an hour and a half.how to prioritize timer execution (if timer is enabled)?
it is difficult to explain in a non-native language, but I hope you understand me
Code: Select all
On Clock#Time=All,18:00 do // каждый день вкл химия
If [boiler#boiler]=0 and [pump#pump]=1
gpio,27,1
TimerSet_ms,1,2500
Else
gpio,27,0
Endif
Endon
On Rules#Timer=1 do // timer 1 action
Pulse,32,1,500
TimerSet_ms,2,2500
Endon
On Rules#Timer=2 do // timer 2 action
Pulse,13,1,500
Endon
On Clock#Time=All,19:30 do // каждый день выкл. химия
gpio,27,0
endon
On [boiler#boiler] = 0 do // включает химию после выключения нагрева, если нагрев был , когда должна вкл химия
If %systm_hm_0% >=18:00 And %systm_hm_0% <=19:30
gpio,27,1
TimerSet_ms,1,2500
TimerSet_ms,3,5400000
Endif
Endon
On Rules#Timer=3 do
gpio,27,0
Endon
it is difficult to explain in a non-native language, but I hope you understand me
Re: Rules in ESPeasy
Without really thoroughly reading what you want to do, I already spotted a syntax error in your rules:
With on...do you don't use []
So
Should be changed to:
And maybe even better:
With on...do you don't use []
So
Code: Select all
On [boiler#boiler] = 0 do
Code: Select all
On boiler#boiler=0 do
Code: Select all
On boiler#boiler do
if %eventvalue1%=0
...
endif
endon
Re: Rules in ESPeasy
One other thing...
the "pulse" command is a blocking command.
Meaning the rules execution (and anything else) in ESPEasy is blocked as long as this command is being executed.
It would be better to use LongPulse_mS as this does return immediately after setting the initial pin state and schedules itself to switch the pin state again.
See: https://espeasy.readthedocs.io/en/lates ... ernal-gpio
The problem with "blocking commands" is that you may effectively miss some time critical events.
One more tip for debugging rules...
Try using the LogEntry command.
It may be very useful in seeing if some parts of your rules are actually being called and with which values.
Also the part between On ... Do in the rules act on events.
So if an event is never 'fired', those will never be called.
For example the "On boiler#boiler Do" suggests there is a task with taskname "boiler" and taskvalue name "boiler" which is called every now and then.
For example a switch task.
But if a task has a long interval (for example > 60 sec), then you may get conflicting situations as it may also take some time between sending the event and the event actually being handled.
What I mean is that you have a separate rules block for exactly 19:30 and also do the exact opposite action using the same time in another rules block.
So for example events matching the 2 examples below are being sent in this exact order, less than 1 minute apart:
The first will turn GPIO 27 to 0
The second one will turn GPIO 27 to 1.
The same applies to the 18:00 timestamp.
the "pulse" command is a blocking command.
Meaning the rules execution (and anything else) in ESPEasy is blocked as long as this command is being executed.
It would be better to use LongPulse_mS as this does return immediately after setting the initial pin state and schedules itself to switch the pin state again.
See: https://espeasy.readthedocs.io/en/lates ... ernal-gpio
The problem with "blocking commands" is that you may effectively miss some time critical events.
One more tip for debugging rules...
Try using the LogEntry command.
It may be very useful in seeing if some parts of your rules are actually being called and with which values.
Also the part between On ... Do in the rules act on events.
So if an event is never 'fired', those will never be called.
For example the "On boiler#boiler Do" suggests there is a task with taskname "boiler" and taskvalue name "boiler" which is called every now and then.
For example a switch task.
But if a task has a long interval (for example > 60 sec), then you may get conflicting situations as it may also take some time between sending the event and the event actually being handled.
What I mean is that you have a separate rules block for exactly 19:30 and also do the exact opposite action using the same time in another rules block.
So for example events matching the 2 examples below are being sent in this exact order, less than 1 minute apart:
Code: Select all
Clock#Time=All,19:30
boiler#boiler=0
The second one will turn GPIO 27 to 1.
The same applies to the 18:00 timestamp.
Re: Rules in ESPeasy
thanks for the clarification. I'm trying to figure out the rest.
Re: Rules in ESPeasy
I'm sorry, but I don't understand. I will try to explain again: the main setting is to turn on pin 27 at 18:00 and turn it off at 19:30. but the boiler can work during this period of time, so I need to shift the work of pin 27. but pin 27 should work for an hour and a half, despite the fact that the main setting disables pin 27.
is it possible to do this?
is it possible to do this?
Re: Rules in ESPeasy
Maybe you can first tell which pin should perform what.
- GPIO 27 = 1 => boiler enabled?
- GPIO 32 pulse for 500 ms = what?
- GPIO 13 pulse for 500 ms = what?
What kind of task do you have which is called boiler#boiler? Is this an input switch? output switch? something else?
When we have this clear, please explain the 'normal' mode, like:
At 18:00:
- turn on whatever GPIO-27 controls
- Timer for 2500ms => pulse Gpio32
- Timer for 2500ms => pulse Gpio13
At 19:30:
- turn off whatever GPIO-27 controls
Now the not normal mode, something with a pump?
What kind of task is pump#pump?
Should the pump state only be checked at 18:00?
- GPIO 27 = 1 => boiler enabled?
- GPIO 32 pulse for 500 ms = what?
- GPIO 13 pulse for 500 ms = what?
What kind of task do you have which is called boiler#boiler? Is this an input switch? output switch? something else?
When we have this clear, please explain the 'normal' mode, like:
At 18:00:
- turn on whatever GPIO-27 controls
- Timer for 2500ms => pulse Gpio32
- Timer for 2500ms => pulse Gpio13
At 19:30:
- turn off whatever GPIO-27 controls
Now the not normal mode, something with a pump?
What kind of task is pump#pump?
Should the pump state only be checked at 18:00?
Re: Rules in ESPeasy
Code: Select all
on Time#Initialized do
If %systm_hm_0% <=22:00 And %systm_hm_0% >= 02:00
gpio,33,1
gpio,12,1
else
gpio,33,0
endif
endon
On Clock#Time=All,22:00 do // каждый день выкл. насос
If [boiler#boiler]=1
gpio,33,1
else
gpio,33,0
Endif
endon
On Clock#Time=All,02:00 do // каждый день вкл. нас
gpio,33,1
endon
on temp#water<=25.00 do // темп. воды в бассдля вкл. обогрева
GPIO,12,1
gpio,33,1
Endon
on temp#water>=26.00 do // темп. воды в бассдля выкл. обогрева
GPIO,12,0
Endon
on temp#air<=-0.5 do // темп. воздуха вкл. греющ. кабеля
GPIO,25,1
Endon
on temp#air>=0.0 do // темп. воздуха выкл. греющ.кабеля
GPIO,25,0
Endon
On Clock#Time=All,06:00 do // каждый день вкл химия
If [boiler#boiler]=0 and [pump#pump]=1
gpio,27,1
TimerSet_ms,1,2500
Else
gpio,27,0
Endif
Endon
On Rules#Timer=1 do // timer 1 action
LongPulse_mS,32,1,500,500,0
TimerSet_ms,2,2500
Endon
On Rules#Timer=2 do // timer 2 action
LongPulse_mS,13,1,500,500,0
Endon
On Clock#Time=All,07:30 do // каждый день выкл. химия
gpio,27,0
endon
On Clock#Time=All,18:00 do // каждый день вкл химия
If [boiler#boiler]=0 and [pump#pump]=1
gpio,27,1
TimerSet_ms,1,2500
Else
gpio,27,0
Endif
Endon
On Rules#Timer=1 do // timer 1 action
LongPulse_mS,32,1,500,500,0
TimerSet_ms,2,2500
Endon
On Rules#Timer=2 do // timer 2 action
LongPulse_mS,13,1,500,500,0
Endon
On Clock#Time=All,19:30 do // каждый день выкл. химия
gpio,27,0
endon
On boiler#boiler do // включает химию после выключения нагрева, если нагрев был , когда должна вкл химия
if %eventvalue1%=0
If %systm_hm_0% >=06:00 And %systm_hm_0% <=07:30 or %systm_hm_0% >=18:00 And %systm_hm_0% <=19:30
gpio,27,1
TimerSet_ms,1,2500
TimerSet_ms,3,5400000
Endif
Endon
On Rules#Timer=3 do
gpio,27,0
Endon
temp#air this is a parallel task and does not apply to the pool. with this code, everything works as intended (at least on the layout), only disinfection is disabled by this command
Code: Select all
On Clock#Time=All,19:30 do // каждый день выкл. химия
gpio,27,0
endon
Re: Rules in ESPeasy
Ok a few more questions then.
Which are actually "inputs" and which are "outputs"?
For example when switching an output pin, then there will not be an event, but if you have some inputs then it may trigger an event when you configured it as a switch task.
Another approach can be to enable "monitor" on a specific pin, so you will always get an event when the state changes.
Just one more thing that's probably causing issues here as it requires some ()
But this can be done with more clean code, which I will show you later.
First I need to know which GPIO pins will be input and need to be acted on.
Which are actually "inputs" and which are "outputs"?
For example when switching an output pin, then there will not be an event, but if you have some inputs then it may trigger an event when you configured it as a switch task.
Another approach can be to enable "monitor" on a specific pin, so you will always get an event when the state changes.
Just one more thing that's probably causing issues here as it requires some ()
Code: Select all
If (%systm_hm_0% >=06:00 And %systm_hm_0% <=07:30) or (%systm_hm_0% >=18:00 And %systm_hm_0% <=19:30)
First I need to know which GPIO pins will be input and need to be acted on.
Re: Rules in ESPeasy
unfortunately I didn't understand the question . pin 26 is an input (temperature sensor), pin 12.13.27.32.33 is an output, they control devices. at the moment there are no more pins involved. use esp32 wroom32d.
Who is online
Users browsing this forum: No registered users and 3 guests