Page 1 of 1

Possible to use previoustate in rules ?

Posted: 10 Jan 2019, 17:48
by DaveS
Hi Chaps,

ESPeasy is monitoring my rain water tanks and controlling 2 latching solenoid valves - one on tank supply to house and another on the council water feed.

I use the rules below but the solenoids are pulsed every few seconds even if their state does not need to change.

Code: Select all

On WaterLevel#Litres>10 do
gpio,13,1   //status LED
gpio,14,0  // status LED
Pulse,4,1,500  // pulse solenoid valve 1
endon

On WaterLevel#Litres<10 do
gpio,14,1
gpio,13,0
Pulse,5,1,500  // pulse solenoid valve 2
endon
Is there a "previousstate" type command that can be used in rules to disable the rule unless the solenoid needs to change state ?

Cheers

Re: Possible to use previoustate in rules ?

Posted: 10 Jan 2019, 19:19
by iron
Hello,

gpiotoggle,<pin#>

will toggle the state of the pin if this is what you are asking ?

-D

Re: Possible to use previoustate in rules ?

Posted: 10 Jan 2019, 19:26
by DaveS
Hi,
Thanks for the reply,however I am trying to configure the rules so they trigger once only when the waterlevel#litres>10 and again when waterlevel#litres<10 condition is met,not pulse the solenoid control IO's over and over.

Re: Possible to use previoustate in rules ?

Posted: 10 Jan 2019, 19:45
by iron
How about ?

On WaterLevel#Litres>10 and gpio#13=0 do

Not even sure if you can you use AND/OR in the event, but you can try and let us know.

If not :

On WaterLevel#Litres>10 do
If gpio#13=0
gpio,13,1 //status LED
gpio,14,0 // status LED
Pulse,4,1,500 // pulse solenoid valve 1
endif
endon

On WaterLevel#Litres<10 do
if gpio#13=1
gpio,14,1
gpio,13,0
Pulse,5,1,500 // pulse solenoid valve 2
endif
endon

-D

Re: Possible to use previoustate in rules ?

Posted: 11 Jan 2019, 19:59
by DaveS
Thanks iron for the idea,rule below working perfectly, I was thinking of setting up a dummy item but this is a simpler method ..

On WaterLevel#Litres>220 do
if [TankSolenoid#State]=0
gpio,13,1
gpio,14,0
Pulse,4,1,500
endon

On WaterLevel#Litres<220 do
if [MuniSolenoid#State]=0
gpio,14,1
gpio,13,0
Pulse,5,1,500
endon

Cheers