Sonoff Rule On System#Boot not working

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
thalesmaoa
Normal user
Posts: 31
Joined: 07 Dec 2020, 15:33

Sonoff Rule On System#Boot not working

#1 Post by thalesmaoa » 07 Dec 2020, 15:42

Hi there,
Everytime my sonoff reboot it send relay to 1.

I've configured a rule inside my espeasy / Sonoff basic to force it to low:

Code: Select all

on System#Wake do
  gpio,12,0
endon
However the relay keeps going to 1.

I've made a test wih

Code: Select all

on MQTT#Connected do
  gpio,12,0
endon
and is working.

After some digging I found this issue https://github.com/arendst/Tasmota/issues/7552 in github.

Based on that, my questions:

Git Build: mega-20200721
The issue is older than my build. Is update needed or am I doing something wrong? Sonoff have limited space so I need to disassembly it to upgrade. Too much trouble.
Is there a way just to remember and keep last pin state (this would be better)?

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Sonoff Rule On System#Boot not working

#2 Post by Ath » 07 Dec 2020, 17:16

thalesmaoa wrote: 07 Dec 2020, 15:42 After some digging I found this issue https://github.com/arendst/Tasmota/issues/7552 in github.

Based on that, my questions:

Git Build: mega-20200721
The issue is older than my build. Is update needed or am I doing something wrong? Sonoff have limited space so I need to disassembly it to upgrade. Too much trouble.
Is there a way just to remember and keep last pin state (this would be better)?
That bug looks like a specific Tasmota bug, en this is not Tasmota...

You can upgrade to a more current build, AFAICS my Sonoff's are executing the System#Boot event using a 20201022 build (I'm setting some 'constants' from there). Newer releases can ofc. also be used.

The ESP's don't have real NV (non-volatile) memory, the stuff call 'NVRAM' in the docs is only preserved during a warm reboot, not over a power cycle.
ESPEasy's Dummy Device values are saved to the NVRAM periodically, and restored after boot, so they will survive a warm reboot.
/Ton (PayPal.me)

thalesmaoa
Normal user
Posts: 31
Joined: 07 Dec 2020, 15:33

Re: Sonoff Rule On System#Boot not working

#3 Post by thalesmaoa » 07 Dec 2020, 18:18

System#Boot event using a 20201022
I was afraid you would say that. Can you provide an example? Here is my full code:

Code: Select all

on button#switch do
  if [button#switch]=1
   gpio,12,1
  else
   gpio,12,0
  endif
 endon 

 on relay#switch do
  if [relay#switch]=1 //change this [relay#switch]=0 for LED off when relay is closed
   gpio,13,0 //or pwm,13,700
  else
   gpio,13,1 //or pwm,13,10
  endif
 endon 

on System#Boot do
  gpio,12,0
endon
Can you upgrade using web interface? AFAIK, that is not possible.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Sonoff Rule On System#Boot not working

#4 Post by TD-er » 07 Dec 2020, 19:15

Also, do you use any controller, or perhaps a plugin like the Domoticz MQTT helper?

For Domoticz Helper, please also have a look at the documentation here: https://espeasy.readthedocs.io/en/lates ... z%20helper

Do you have switch tasks defined?
Is one of them configured to "send boot state" ?

thalesmaoa
Normal user
Posts: 31
Joined: 07 Dec 2020, 15:33

Re: Sonoff Rule On System#Boot not working

#5 Post by thalesmaoa » 07 Dec 2020, 22:03

No, I don't. Simple switch button and the rules presented.

Image

None of them send boot state.

I'm not sure what Domoticz MQTT helper is, but I only have openhab mqtt configured.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Sonoff Rule On System#Boot not working

#6 Post by TD-er » 07 Dec 2020, 22:15

Domoticz MQTT helper is something only needed for... wait for it .... Domoticz :)

Can you show the configuration of the "button" task ?
Is it a toggle button or a "normal" switch?
GPIO-0 does have a pull-up resistor, or else the ESP will not boot at all.
So a button may only pull it down to GND when pressed.

The last state of the switch is stored in RTC memory, so the state is restored at boot. (not a power cycle)

How is the switch (or relay) integrated with OpenHAB?
I do see the switch tasks themselves are not assigned any controller, so it doesn't seem like it should interact with OpenHAB. Is that correct?

thalesmaoa
Normal user
Posts: 31
Joined: 07 Dec 2020, 15:33

Re: Sonoff Rule On System#Boot not working

#7 Post by thalesmaoa » 08 Dec 2020, 01:04

lol... I will google it.
Image

I guess a normal switch.

About MQQT it only receive 1 or 0. Retain is set to false.
Image

Image

I can't understand why this is happening.

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Sonoff Rule On System#Boot not working

#8 Post by ThomasB » 08 Dec 2020, 02:49

It's not clear why you added the Relay as a switch input task. The relay is controlled by your gpio rules and no plugin is needed to do that. But if for some reason you need the Relay to be a Switch Input Task, then I suggest increasing the debounce time. Currently it is zero, which is too short.

The Openhab MQTT broker has persistence cache. Therefore the relay's state could be changed by the broker when ESPEasy subscribes during the boot. If you are using Mosquitto MQTT then try deleting the retained messages as explained here: https://community.openhab.org/t/clearin ... ages/58221

To further debug this I think it will require using the serial log. The log messages may explain what is going on.

- Thomas

thalesmaoa
Normal user
Posts: 31
Joined: 07 Dec 2020, 15:33

Re: Sonoff Rule On System#Boot not working

#9 Post by thalesmaoa » 08 Dec 2020, 15:50

After your suggestions I found the problem, however I don't know how to fix it.

As it seems, GPIO-0 toogles at boot time. Since I have this rule to check the button state, ESPEasy understand that is a press button event and turn the lights on.

If I comment the rule, the light doesn't turn on.

Code: Select all

//on button#switch do
//  if [button#switch]=1
//   gpio,12,1
//  else
//   gpio,12,0
//  endif
// endon 
Tried debounce and Safe button, none of them worked. Plus, is there a way to change state of GPIO inside ESPEasy?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Sonoff Rule On System#Boot not working

#10 Post by TD-er » 08 Dec 2020, 16:01

The state is kept and restored after reboot.

So what you can do is not rely on the switch state (as it seems to be configured as toggle mode) but keep a state in a variable or maybe even simpler, just look at the state of the relay instead of the state of the switch.

For example:
Change button to "normal switch" mode and only trigger in the rules on a single state of the button#switch event.

Untested:

Code: Select all

on button#switch do
  if [button#switch]=1 // button is pressed
    gpio,12,![relay#switch]  // write the "inverted" value of the relay state (leading '!')
  endif
endon 

on System#Boot do
  gpio,12,0
endon

thalesmaoa
Normal user
Posts: 31
Joined: 07 Dec 2020, 15:33

Re: Sonoff Rule On System#Boot not working

#11 Post by thalesmaoa » 08 Dec 2020, 16:06

Thank you! I think that will fix my problem.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 28 guests