Rules On System#Boot

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Petit_Malin
New user
Posts: 4
Joined: 20 Dec 2019, 12:59

Rules On System#Boot

#1 Post by Petit_Malin » 20 Dec 2019, 14:32

Hi everyone,

I set up ESP01S with relays to manage my pilot wire for my heating. As you know the problems of unexpected restarting "Hardware watchdog".
I wanted to set up a rule of return in the state for the GPIO0. To do this on restarting by using a variable with a "Generic - Dummy Device".
Except that my rule is applied even if the condition is false.

Here is the rule:

Code: Select all

On System#Boot do    
timerSet,1,10      //Set Timer 1 for the next event in 10 seconds
endon
On Rules#Timer=1 do  
  if [switch#Switch]=1 and [dummy#value]=0 // Test condition
    gpio,0,0 // Power ON on GPIO 0
  endif
endon
And This is a second rule to interact with my Domotic:

Code: Select all

on radia1_on do //Jeedom request to Power ON
   gpio,0,0     //Power ON GPIO0
   TaskValueSet 2,1,0  // Set Dummy/Value to 0 
endon
on radia1_off do //Jeedom request to Power OFF
   gpio,0,1 //Power OFF GPIO0
   TaskValueSet 2,1,1 // Set Dummy/Value to 1
endon
:!: when i remove the first rule, if the GPIO0 was ON at reboot the Dummy/Value is correct (set to 0) and the GPIO0 set to 1

FYI weirdly the states are reversed on ESP01S (0 to ON and 1 to OFF)

Tested with ESP_Easy_mega-20191113_normal_ESP8266_1M and ESP_Easy_mega-20180914_normal_ESP8266_1024 (the last is more stable on unexpected restarting)

Would anyone have an idea :roll:

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

Re: Rules On System#Boot

#2 Post by TD-er » 20 Dec 2019, 15:18

Why not set the GPIO state in the System#Boot event?
Then you know for sure no other event has happened before you made the test.

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

Re: Rules On System#Boot

#3 Post by grovkillen » 20 Dec 2019, 15:25

I need to understand your setup. Do you have a physical switch or is the switch plugin used for the relay?
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:

Petit_Malin
New user
Posts: 4
Joined: 20 Dec 2019, 12:59

Re: Rules On System#Boot

#4 Post by Petit_Malin » 20 Dec 2019, 16:00

TD-er wrote: 20 Dec 2019, 15:18 Why not set the GPIO state in the System#Boot event?
Then you know for sure no other event has happened before you made the test.
Thank's for you replys.

Because i don't no if it was ON before a unexpected reboot (See the details below)
grovkillen wrote: 20 Dec 2019, 15:25 I need to understand your setup. Do you have a physical switch or is the switch plugin used for the relay?
Ok more details:
I use a Domotic system (Jeedom) to control 4 heaters with 4 Oregon temperature sensor, for each one i have 4 ESP01S + Relay conncted to the pilot wire of the heater

On the Jeedom i have a scenario:
Example for the Room1 : If Temp room1 (Oregon temp sensor) is <20 then "http://IP_of_the_ESP1S/control?cmd=event,radia1_on" (action to power ON the heater)

On the ESP01S i use 2 devices : 1 x "Switch input - Switch" to control the GPIO0 and 1 x "Generic - Dummy Device" to have the last state on a unexpected reboot

So with the rule if the ESP01S reboot unexpectedly, it will check the last state and return if he needs it

I hope it's more clear ;)

This is the ESP01S + Relay that i use
Image

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

Re: Rules On System#Boot

#5 Post by grovkillen » 20 Dec 2019, 19:49

Code: Select all

On System#Boot do    
 GPIO,0,[dummy#value]
endon
That would do it right?
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:

Petit_Malin
New user
Posts: 4
Joined: 20 Dec 2019, 12:59

Re: Rules On System#Boot

#6 Post by Petit_Malin » 20 Dec 2019, 20:19

grovkillen wrote: 20 Dec 2019, 19:49

Code: Select all

On System#Boot do    
 GPIO,0,[dummy#value]
endon
That would do it right?
Nice try and so simple, but... it doesn't work.

Test: Set Power ON on ESP01 => Value and state = 0 if i power off and power on, at boot the GPIO0 change to state 0 (normal is the rule defined)
Set Power OFF on ESP01 => Value and state = 1 if i power off and power on, at boot the GPIO0 change also to state 0 :evil:

It's weird...
What i see on devices the Value and state are twice on 0 on the test Power OFF, as if the second rule had been played:

Code: Select all

on radia1_on do //Jeedom request to Power ON
   gpio,0,0     //Power ON GPIO0
   TaskValueSet 2,1,0  // Set Dummy/Value to 0 
endon
on radia1_off do //Jeedom request to Power OFF
   gpio,0,1 //Power OFF GPIO0
   TaskValueSet 2,1,1 // Set Dummy/Value to 1
endon
It's the only way to set and change the value of the dummy...

Edit: Not at all, i set Power OFF on ESP01 => Value and state = 1, deleted the second rule, power off and power on, at boot the GPIO0 change also to state 0 (and the Value and state are twice on 0)

Something else, to work with ESP01S the relay need to be shorted with a resistor (100 Ohms) between GPIO0 and Vcc and shorted with a cable between CH_PD and Vcc

Is there a cause and effect link ?

Edit2: Ok I think I have found out why : i have changed the first rule to see what append to this :

Code: Select all

On System#Boot do    
timerSet,1,30      //Set Timer 1 for the next event in 30 seconds
endon
On Rules#Timer=1 do  //When Timer1 expires, do 
GPIO,0,[dummy#value]
endon
To have time to see the value, and ohh surprise the dummy/value return to 0 even if he was set to 1

Is it normal ?

Petit_Malin
New user
Posts: 4
Joined: 20 Dec 2019, 12:59

Re: Rules On System#Boot

#7 Post by Petit_Malin » 21 Dec 2019, 12:40

Finally it's normal, settings will be lost during a power OFF("Hardware watchdog") but not during a manual reboot (warm reboot)

I had already thought of a solution via the domotic Jeedom :

Store the state in a virtual on Jeedom during the ON/OFF request with a reverse action http from ESP01S
And check in a scenario Jeedom the state between the relay and the virtual

Code: Select all

on radia3_on do //Jeedom request to Power ON
   gpio,0,0     //Power ON GPIO0
   SendToHTTP #IPJeedom#,80,/core/api/jeeApi.php?plugin=virtual&apikey=#APIVirtual#&type=virtual&id=#VirtualIDState#&value=1 // To set the state 1 in a virtual Jeedom
endon
on radia3_off do //Jeedom request to Power OFF
   gpio,0,1 //Power OFF GPIO0
   SendToHTTP #IPJeedom#,80,/core/api/jeeApi.php?plugin=virtual&apikey=#APIVirtual#&type=virtual&id=#VirtualIDState#&value=0 // To set the state 0 in a virtual Jeedom
endon


Other discussion found on the forum about that: viewtopic.php?t=5692

Hoping that we can do it in future versions

Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests