Switch and countdown Rules function
Posted: 25 Nov 2022, 10:10
Hello,
I need your help, I'm not very good, that's not to be proven anymore, but I'm improving
I'm trying to do something simple but I can't understand how Timer works.
Example
I have a switch
If I learn on it, it activate a lamp (GPIO,13,0) for example and it send a message (MQTT or oled, oledframedcmd,3, "light On")
then I keep GPIO,13,0 in the state during a certain time (30 seconds)
Then at the end of the countdown I switch back the GPIO,13,1 to turn off everything sends a message (MQTT or oled, oledframedcmd,3, "light Off").
I understand that to do this operation, I can not understand how the instructions timerSet, Timer, etc..
Which seems to be the one to use.
With this code
I can change the message on the Oled, but as soon as I release the switch it goes back to Off, which is normal since I have no notion of time to wait and go to the next instruction.
I know that it must be simple, but my brain blocks on the understanding of the timer to delay a loop.
The mechanism is
Switch = on
Send message and MQTT
Start Countdon
If End Countdown
Switch = Off
Send message and MQTT
It is the Countdown function that is blocking me.
Would you have a simple example to propose to me so that I can understand and apply it and adapt it to my needs?
Regards
I need your help, I'm not very good, that's not to be proven anymore, but I'm improving
I'm trying to do something simple but I can't understand how Timer works.
Example
I have a switch
If I learn on it, it activate a lamp (GPIO,13,0) for example and it send a message (MQTT or oled, oledframedcmd,3, "light On")
then I keep GPIO,13,0 in the state during a certain time (30 seconds)
Then at the end of the countdown I switch back the GPIO,13,1 to turn off everything sends a message (MQTT or oled, oledframedcmd,3, "light Off").
I understand that to do this operation, I can not understand how the instructions timerSet, Timer, etc..
Which seems to be the one to use.
With this code
Code: Select all
// Oled Message change on MQTT value (OK)
On Switch_House#State do
If [Switch_Chaudiere#State]=0
oledframedcmd,3, "Boiler On
Else
oledframedcmd,3, "Boiler Off
Endif
Endon
I know that it must be simple, but my brain blocks on the understanding of the timer to delay a loop.
The mechanism is
Switch = on
Send message and MQTT
Start Countdon
If End Countdown
Switch = Off
Send message and MQTT
It is the Countdown function that is blocking me.
Would you have a simple example to propose to me so that I can understand and apply it and adapt it to my needs?
Regards