Rules triggering on startup

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
chevrolux
New user
Posts: 3
Joined: 16 Aug 2018, 02:26
Location: New Zealand

Rules triggering on startup

#1 Post by chevrolux » 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')

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
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:

Code: Select all

on System#Wake do
Delay 5000
endon

on System#Boot do
Delay 5000
endon
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.

kenkoknz
Normal user
Posts: 64
Joined: 03 Jul 2018, 23:46
Location: New Zealand

Re: Rules triggering on startup

#2 Post by kenkoknz » 17 Sep 2018, 03:47

Hi,
Depending on which FW ver u use, the delay may not work.

chevrolux
New user
Posts: 3
Joined: 16 Aug 2018, 02:26
Location: New Zealand

Re: Rules triggering on startup

#3 Post by chevrolux » 17 Sep 2018, 03:53

Interesting. So here is what is on the info page under firmware:

Build 20102 - Mega
Libraries ESP82xx Core 2_4_1, NONOS SDK 2.2.1(cfd48f3), LWIP: 2.0.3
GIT version mega-20180809
Plugins 48 [Normal]
Build Md5 4bcbad21e4eb40a8354487ca57cab72
Md5 check passed.
Build time Aug 9 2018 02:15:47
Binary filename ESP_Easy_mega-20180809_normal_ESP8266_1024.bin


So if delay is not an option, is there another way to fix this?

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Rules triggering on startup

#4 Post by grovkillen » 17 Sep 2018, 06:57

Use a month old release and try. We're doing a lot of changes to how commands are being processed and some of them are not working 100%.

We're fixing it ;)
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests