Rules with combining logic
Posted: 05 Apr 2017, 12:08
Hi all,
I am planning to use a SONOFF with a BH1750 luminosity sensor to control a secondary lamp in a bath room. The ESP will be used without an external controller but with the internal rules.
What I understand is the following example rule:
The problem is that the trigger level for turning off is higher than the trigger level for turning on. Thus, I need to take also the current state into consideration. The device monitoring the relais IO is called relais. So I would like to use something like this:
But I already crashed the config once and the brightness sensor connected to the SONOFF uses the (disabled) RX and TX lines so I need to re-flach each time I mess up the config .
Could you tell me if my idea with a combining "and" is possible? Would it be possible to interleave two if loops?
Please help
I am planning to use a SONOFF with a BH1750 luminosity sensor to control a secondary lamp in a bath room. The ESP will be used without an external controller but with the internal rules.
What I understand is the following example rule:
Code: Select all
On brightness#lux do
if [brighness#lux]>1 // Master light switched on, so turn on relais
gpio,12,1
gpio,13,0
endif
endon
On brightness#lux do
if [brighness#lux]<50 // Master light switched off but light connected to relais still on, so turn off relais
gpio,12,0
gpio,13,1
endif
endon
Code: Select all
On brightness#lux do
if [brighness#lux]>1 and [relais#relais] == 0 // Master light switched on, so turn on relais
gpio,12,1
gpio,13,0
endif
endon
On brightness#lux do
if [brighness#lux]<50 and [relais#relais] != 0 // Master light switched off but light connected to relais still on, so turn off relais
gpio,12,0
gpio,13,1
endif
endon
Could you tell me if my idea with a combining "and" is possible? Would it be possible to interleave two if loops?
Please help