Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The 'vars' were not working from one rule to another because the declaration of the variable was not global and was being lost.
Problem shows when trying to make a thermostat as follows.
Inital config:
On console:
Turn on rules
rule 1
check temp every minute
teleperiod 60
use power1 on mqtt messages
setoption26 1
dont save relay status on eeprom
setoption0 0
start all relays off
poweronstate 0
Rule:
On boot enable thermostat and enable start check of temp sensor connection
rule on system#boot do backlog event enabled=1; ruletimer1 70 endon
Set thermostat enable variable
on event#enabled do backlog var1; power2 %value%; ledpower %var% endon
An available button is configured as button2 and set also a relay 2 on any unused pin (to be used as a toggle memory to turn on and off the thermostat)
on power2#state do event enabled=%value% endon
check temp sensor connection. If fails, set to off and turn off thermostat. Also continue checking
on rules#timer=1 do backlog event enabled=0; ruletimer1 70; power1 0 endon
Resets checking timer if temperature is connected
on tele-am2301-12#temperature do ruletimer1 70 endon
Thermostat control - upper limit and lower limit
on tele-am2301-12#temperature>25 do power1 0 endon
on tele-am2301-12#temperature<24 do power1 %var1% endon
Thermostat can be turned on by:
event enabled=1
publish cmnd/topic/EVENT ENABLED=1
publish cmnd/topic/EVENT ENABLED=1
Thermostat can be turned Off or by
event enabled=0
publish cmnd/topic/EVENT ENABLED=0
publish cmnd/topic/EVENT ENABLED=0
Everything together:
INITIAL CONFIG:
backlog rule 1; teleperiod 60; setoption26 1; setoption0 0; poweronstate 0
RULES:
rule on system#boot do backlog event enabled=1; ruletimer1 70 endon on on event#enabled do backlog var1; power2 %value%; ledpower %var% endon on power2#state do event enabled=%value% endon on rules#timer=1 do backlog event enabled=0; ruletimer1 70; power1 0 endon on tele-am2301-12#temperature do ruletimer1 70 endon on tele-am2301-12#temperature>25 do power1 0 endon on tele-am2301-12#temperature<24 do power1 %var1% endon