How to disable rule at a specific time ?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
DaveS
Normal user
Posts: 25
Joined: 12 Feb 2018, 17:35

How to disable rule at a specific time ?

#1 Post by DaveS » 22 Aug 2018, 19:02

Hi All,

How can I disable the rule below every saturday from 16:00 till 23:00 only,every other day rule must be active.

on Pir_Sensor#Pir=1 do
if [LDR#Analog]<500
Publish RGB/0017F169/color/set,200,200,200
Publish RGB/0017F169/brightness/set,200
else
Publish RGB/0017F169/brightness/set,0
endif
endon

NTP has been setup and has synched with internet time server.

Thanks to all the devs for this brilliant firmware,have many nodes running espeasy and all are rock solid !

Thanks

Dave

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

Re: How to disable rule at a specific time ?

#2 Post by TD-er » 23 Aug 2018, 02:19

Maybe this entry on the wiki can be helpful for you?
https://www.letscontrolit.com/wiki/inde ... Rules#Time

DaveS
Normal user
Posts: 25
Joined: 12 Feb 2018, 17:35

Re: How to disable rule at a specific time ?

#3 Post by DaveS » 23 Aug 2018, 17:59

I saw that but it details how to enable a rule or some operation,not disabling a rule.
I understand the day and time configuration but do not know how to implement the disabling of the rule between the 2 times
I will search further then.

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

Re: How to disable rule at a specific time ?

#4 Post by grovkillen » 23 Aug 2018, 18:19

Can't you use a dummy variable and a if statement that will execute the rule of the dummy variable is set to zero?
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:

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

Re: How to disable rule at a specific time ?

#5 Post by TD-er » 23 Aug 2018, 18:50

DaveS wrote: 23 Aug 2018, 17:59 I saw that but it details how to enable a rule or some operation,not disabling a rule.
I understand the day and time configuration but do not know how to implement the disabling of the rule between the 2 times
I will search further then.
Can't you use a "else" part?
Like "if <sunday> do... else ..." ?
I am not really familiar in the rules language.

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: How to disable rule at a specific time ?

#6 Post by papperone » 24 Aug 2018, 08:46

I think the rules are ok for simple timing setup, when it comes to more complex and/or weekly I prefer to move out from ESPeasy as it's not as flexible as needed and the rules can becaome way too complex and probably cosume lots of CPU.
As well without nested IFs the overall setup of combined criteria is as well not somethign easy to write and maintain.

PS: having all my devices communicating via MQTT setup on my RaspPi, I installed as well NodeRed and with this last one creating complex rules is a piece of cake !
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: How to disable rule at a specific time ?

#7 Post by toffel969 » 24 Aug 2018, 09:45

grovkillen wrote: 23 Aug 2018, 18:19 Can't you use a dummy variable and a if statement that will execute the rule of the dummy variable is set to zero?
I agree that's a viable route

Lets assume a dummy device on Task 8, called Sat#dummy


Code: Select all


On Clock#Time=Sat,16:00 do 
Taskvalueset,8,1,1
Endon

On Clock#Time=Sat,23:00 do 
Taskvalueset,8,1,0
Endon


on Pir_Sensor#Pir=1 do
if [LDR#Analog]<500 AND [Sat#dummy]=0
Publish RGB/0017F169/color/set,200,200,200
Publish RGB/0017F169/brightness/set,200 
else
Publish RGB/0017F169/brightness/set,0 
endif
endon
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

DaveS
Normal user
Posts: 25
Joined: 12 Feb 2018, 17:35

Re: How to disable rule at a specific time ?

#8 Post by DaveS » 24 Aug 2018, 17:35

Thank you Toffel969,
That is exactly what I want to achieve.
Will try it.
Regards
Dave

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: How to disable rule at a specific time ?

#9 Post by papperone » 24 Aug 2018, 20:01

it works as far as the module does not reboot for any given reason on saturday between 16:00 and 23:00 :|
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone

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

Re: How to disable rule at a specific time ?

#10 Post by grovkillen » 24 Aug 2018, 20:21

I would do a check right on system#boot and set the dummy accordingly.
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:

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: How to disable rule at a specific time ?

#11 Post by toffel969 » 24 Aug 2018, 22:53

papperone wrote: 24 Aug 2018, 20:01 it works as far as the module does not reboot for any given reason on saturday between 16:00 and 23:00 :|
Agreed, thats a flaw.
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

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

Re: How to disable rule at a specific time ?

#12 Post by grovkillen » 24 Aug 2018, 23:04

toffel969 wrote: 24 Aug 2018, 22:53
papperone wrote: 24 Aug 2018, 20:01 it works as far as the module does not reboot for any given reason on saturday between 16:00 and 23:00 :|
Agreed, thats a flaw.

Code: Select all

On System#Boot do
 TaskValueSet,8,2,[%sysweekday%][%syshour%]
 Event,SetDummy
EndOn

On SetDummy do
 If [Set#Dummy2]<116 OR [Set#Dummy2]>123
  TaskValueSet,8,2,1
 Else
  TaskValueSet,8,2,0
 EndIf
EndOn
Last edited by grovkillen on 24 Aug 2018, 23:15, edited 1 time in total.
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:

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

Re: How to disable rule at a specific time ?

#13 Post by grovkillen » 24 Aug 2018, 23:14

Maybe change system#boot to

Code: Select all

Time#Initialized
?
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:

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: How to disable rule at a specific time ?

#14 Post by toffel969 » 24 Aug 2018, 23:16

grovkillen wrote: 24 Aug 2018, 23:04
toffel969 wrote: 24 Aug 2018, 22:53
papperone wrote: 24 Aug 2018, 20:01 it works as far as the module does not reboot for any given reason on saturday between 16:00 and 23:00 :|
Agreed, thats a flaw.

Code: Select all

On System#Boot do
 TaskValueSet,8,2,[%sysweekday%]
 TaskValueSet,8,3,[%syshour%]
 TaskValueSet,8,4,[Sat#Dummy2][Sat#Dummy3]
 Event,SetDummy
EndOn

On SetDummy do
 If [Set#Dummy]<716 AND [Set#Dummy]>723
  TaskValueSet,8,2,1
 Else
  TaskValueSet,8,2,0
 EndIf
EndOn
Isn't that only triggered on boot ? So you need this rule in addition to the before mentioned. Also I think the taskvalueset should be 8,1,1/0

Other than that it makes the setup a lot more robust. It's an elegant way to achieve reboot proof behaviour. I was thinking about a clock#time=Sat,**:** combined with systime check to set the dummy.... " ESP on Saturdays you must check every minute if it's between 7 or 23 o clock and set the dummy :mrgreen: :ugeek:
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

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

Re: How to disable rule at a specific time ?

#15 Post by grovkillen » 24 Aug 2018, 23:17

I updated the post and suggested the Time#Initialized event instead :)
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:

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

Re: How to disable rule at a specific time ?

#16 Post by grovkillen » 24 Aug 2018, 23:18

And it's a add on to your splendid rule that you suggested. Thumbs up!
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:

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

Re: How to disable rule at a specific time ?

#17 Post by grovkillen » 24 Aug 2018, 23:29

And please bear in mind that this is me "coding" a rule on my phone on a Friday evening after two beers down :P
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:

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: How to disable rule at a specific time ?

#18 Post by toffel969 » 24 Aug 2018, 23:31

grovkillen wrote: 24 Aug 2018, 23:29 And please bear in mind that this is me "coding" a rule on my phone on a Friday evening after two beers down :P
:-) almost the same here. Just have a check on the taskvalueset,8,2,1 at the and. I'm almost sure it must be 8,1,1
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: How to disable rule at a specific time ?

#19 Post by toffel969 » 24 Aug 2018, 23:32

grovkillen wrote: 24 Aug 2018, 23:18 And it's a add on to your splendid rule that you suggested. Thumbs up!
As splendid as sophisticated :lol:
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

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

Re: How to disable rule at a specific time ?

#20 Post by grovkillen » 25 Aug 2018, 07:47

Code: Select all

On Time#Initialized do
 TaskValueSet,8,2,[%sysweekday%][%syshour%][%sysmin%]
 Event,SetDummy
EndOn

On SetDummy do
 If [Set#Dummy2]<71600 OR [Set#Dummy2]>72300
  TaskValueSet,8,1,1
 Else
  TaskValueSet,8,1,0
 EndIf
EndOn

On Clock#Time=Sat,16:00 do 
 Taskvalueset,8,1,1
Endon

On Clock#Time=Sat,23:00 do 
 Taskvalueset,8,1,0
Endon

on Pir_Sensor#Pir=1 do
 if [LDR#Analog]<500 AND [Sat#dummy]=0
  Publish RGB/0017F169/color/set,200,200,200
  Publish RGB/0017F169/brightness/set,200 
 else
  Publish RGB/0017F169/brightness/set,0 
 endif
endon
That would be the entire rule set? :)
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:

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: How to disable rule at a specific time ?

#21 Post by toffel969 » 25 Aug 2018, 09:49

grovkillen wrote: 25 Aug 2018, 07:47

Code: Select all

On Time#Initialized do
 TaskValueSet,8,2,[%sysweekday%][%syshour%][%sysmin%]
 Event,SetDummy
EndOn

On SetDummy do
 If [Set#Dummy2]<71600 OR [Set#Dummy2]>72300
  TaskValueSet,8,1,1
 Else
  TaskValueSet,8,1,0
 EndIf
EndOn

On Clock#Time=Sat,16:00 do 
 Taskvalueset,8,1,1
Endon

On Clock#Time=Sat,23:00 do 
 Taskvalueset,8,1,0
Endon

on Pir_Sensor#Pir=1 do
 if [LDR#Analog]<500 AND [Sat#dummy]=0
  Publish RGB/0017F169/color/set,200,200,200
  Publish RGB/0017F169/brightness/set,200 
 else
  Publish RGB/0017F169/brightness/set,0 
 endif
endon
That would be the entire rule set? :)
Looks perfect to me.
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

DaveS
Normal user
Posts: 25
Joined: 12 Feb 2018, 17:35

Re: How to disable rule at a specific time ?

#22 Post by DaveS » 27 Aug 2018, 17:56

Code: Select all

On Clock#Time=Sat,16:00 do
TaskValueSet 3, 1, 1
endon

On Clock#Time=Sat,22:00 do
TaskValueSet 3, 1, 0
endon


on Pir_Sensor#Pir=1 do
   if [LDR#Analog]>1000 AND [Saturday#Inhibit]=0
     Publish RGB/0017F169/color/set,200,200,200
     Publish RGB/0017F169/brightness/set,200      
   endif
 endon

on Pir_Sensor#Pir=0 do
   if [LDR#Analog]>1000 AND [Saturday#Inhibit]=0
      Publish RGB/0017F169/state/set,OFF
  endif
endon
The rule above is working,good point regarding the node rebooting,will sort that.
Edited original rule a bit as I need to publish Publish RGB/0017F169/state/set,OFF when the PIR timed out after no motion detected.
This rule publishes all the time whether PIR state is 0 or 1
Can this constant spamming of the broker cause slower response time or is that not going to be a problem ?
There are 3 other nodes that publish frequently on my network also.
Thanks for the advise.

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: How to disable rule at a specific time ?

#23 Post by toffel969 » 27 Aug 2018, 23:52

DaveS wrote: 27 Aug 2018, 17:56

Code: Select all

On Clock#Time=Sat,16:00 do
TaskValueSet 3, 1, 1
endon

On Clock#Time=Sat,22:00 do
TaskValueSet 3, 1, 0
endon


on Pir_Sensor#Pir=1 do
   if [LDR#Analog]>1000 AND [Saturday#Inhibit]=0
     Publish RGB/0017F169/color/set,200,200,200
     Publish RGB/0017F169/brightness/set,200      
   endif
 endon

on Pir_Sensor#Pir=0 do
   if [LDR#Analog]>1000 AND [Saturday#Inhibit]=0
      Publish RGB/0017F169/state/set,OFF
  endif
endon
The rule above is working,good point regarding the node rebooting,will sort that.
Edited original rule a bit as I need to publish Publish RGB/0017F169/state/set,OFF when the PIR timed out after no motion detected.
This rule publishes all the time whether PIR state is 0 or 1
Can this constant spamming of the broker cause slower response time or is that not going to be a problem ?
There are 3 other nodes that publish frequently on my network also.
Thanks for the advise.
What is the delay setting on the PIR switch device? If it is not 0, thats what will happen.
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

DaveS
Normal user
Posts: 25
Joined: 12 Feb 2018, 17:35

Re: How to disable rule at a specific time ?

#24 Post by DaveS » 28 Aug 2018, 17:50

The PIR delay is set to 1 as I wanted a quick response once motion is detected.
Will this constant publishing slow broker response down at all ?
Openhab and mosquitto broker is running on a Pi 2.
Thanks again for the help chaps !

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

Re: How to disable rule at a specific time ?

#25 Post by grovkillen » 28 Aug 2018, 17:53

The publishing will not be a problem for the broker. BUT if you set the delay to 0 (i.e. disable) will make the unit publish a change instantaneous.
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:

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: How to disable rule at a specific time ?

#26 Post by toffel969 » 29 Aug 2018, 07:48

DaveS wrote: 28 Aug 2018, 17:50 The PIR delay is set to 1 as I wanted a quick response once motion is detected.
Will this constant publishing slow broker response down at all ?
Openhab and mosquitto broker is running on a Pi 2.
Thanks again for the help chaps !
Ya just set that delay to 0 and the unit will behave the way you want.
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

DaveS
Normal user
Posts: 25
Joined: 12 Feb 2018, 17:35

Re: How to disable rule at a specific time ?

#27 Post by DaveS » 28 Sep 2018, 20:08

Code: Select all

on Pir_Sensor#Pir=1 do
     if [LDR#Analog]>1000 AND [Saturday#Inhibit]=0
     Publish RGB/0017F169/color/set,200,200,200
     Publish RGB/0017F169/brightness/set,200      
   endif
 endon

on Pir_Sensor#Pir=0 do
      if [LDR#Analog]>1000 AND [Saturday#Inhibit]=0
      Publish RGB/0017F169/state/set,OFF
  endif
endon

These rules are working well but publish all the time to broker.
Is there a way to change the rules so that ESP easy will only publish once on Pir_Sensor state change ?
Thanks

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

Re: How to disable rule at a specific time ?

#28 Post by grovkillen » 28 Sep 2018, 21:19

You could use a dummy and toggle that one only if the pir changes from 1->0 or 0->1. So prior to publish check that dummy and if it is 1 publish and then set it to 0.
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:

DaveS
Normal user
Posts: 25
Joined: 12 Feb 2018, 17:35

Re: How to disable rule at a specific time ?

#29 Post by DaveS » 01 Oct 2018, 17:45

Good idea,will set it up like that.
Thank you

Post Reply

Who is online

Users browsing this forum: No registered users and 36 guests