Rules triggering on startup
Posted: 17 Sep 2018, 00:08
Mods - apologies if I have put this in the wrong place.
Have one very small issue I just can't seem to work out. I am wondering if I should just be doing this automation in Node-RED, but that seems kind of counter-intuitive when there is a whole rules
The set up is a Sonoff Basic switch, and then the existing light switches wired in to GPIO 14 & 13 (I took the LED off to use the PIN) so people can still use the wall switches.
My rules section currently looks like this (under 'Rules Set 1')
But I've come across one really annoying thing. When the Sonoff reboots, it triggers this rule, and toggles the relay meaning that lighting circuit will turn on for a few seconds and turn off again.
This makes sense as the switch state has "changed" so the rule should trigger, but still really annoying. But I am seriously struggling to do this sort of basic logic.
I've tried setting GPIO 12 to low under the hardware section, but it still gets toggled because the switch event runs at boot.
So some more googling, and I find the there is an event called 'System#Boot' & System#Wake you can run rules on. So I've tried simple delay rules, but they don't fix my issue either:
I assume I am not the first person to come across this, but my google-fu is seriously failing me here to find any fix to the issue. I did come across using 'Timers' in my rules, but I don't think they work how I need them to work for this scenario.
Have one very small issue I just can't seem to work out. I am wondering if I should just be doing this automation in Node-RED, but that seems kind of counter-intuitive when there is a whole rules
The set up is a Sonoff Basic switch, and then the existing light switches wired in to GPIO 14 & 13 (I took the LED off to use the PIN) so people can still use the wall switches.
My rules section currently looks like this (under 'Rules Set 1')
Code: Select all
on ext_sw#Switch do
if [relay#state]=1
event switchoff
else
event switchon
endif
endon
on ext_sw2#Switch do
if [relay#state]=1
event switchoff
else
event switchon
endif
endon
on switchon do
gpio 12,1
endon
on switchoff do
gpio 12,0
endon
This makes sense as the switch state has "changed" so the rule should trigger, but still really annoying. But I am seriously struggling to do this sort of basic logic.
I've tried setting GPIO 12 to low under the hardware section, but it still gets toggled because the switch event runs at boot.
So some more googling, and I find the there is an event called 'System#Boot' & System#Wake you can run rules on. So I've tried simple delay rules, but they don't fix my issue either:
Code: Select all
on System#Wake do
Delay 5000
endon
on System#Boot do
Delay 5000
endon