• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pilight eventing rules
#1
I am trying the maximal possibilities of the rules at the moment for regulate my terrarium.
There are some feature requests that would make the rule-feature perfect for me:

sleep:
For wait xx sec in rule or pause rule for xx sec.
Usage: humidity and temperature check and actions
Code:
"IF .. THEN switch DEVICE humidifier TO on AND sleep [wait xx sec here] AND switch DEVICE humidifier TO off"
"IF .. THEN .. AND sleep [wait xx sec before recalling the rule]"

loop:
Loop a command in the rule xx times.
Usage: interaction from humidifier and fan to spread the fog
Code:
"IF DEVICE humidifier.state IS on THEN loop [loop for xx times] (switch DEVICE fan1 TO on SLEEP [wait xx sec here] AND switch DEVICE fan1 TO off AND sleep [wait xx sec here])"

step by step dimlevel:
For regulating temperature and simulating sunrise/sunset Wink
Code:
"IF temp1.temperature > 55 THEN dim DEVICE spot1 MINUS 1 AND sleep [pause rule for xx sec]"
"IF temp1.temperature < 35 THEN dim DEVICE spot1 PLUS 1 AND sleep [pause rule for xx sec]"
"IF datetime.hour IS 20 THEN dim DEVICE spot1 MINUS 1 AND sleep [pause rule for xx sec]"

If this coud be realized i do not need python and crontabs anymore...
 
Reply
#2
1. Sleep, it's this what you want (not implemented yet):
Code:
IF ... THEN switch DEVICE ... TO on FOR 2m

2. Loop, not sure why this is usefull. Why not (not implemented yet)::
Code:
IF humidifier state IS off AND ... THEN switch DEVICE humidifier TO on FOR 2m
IF humidifier.state IS on THEN switch DEVICE fan TO on FOR 2m

3.Sleep, a rule just executes as long as the conditions apply. You can adapt them to (not implemented yet):
Code:
"IF temp1.temperature > 55 AND spot1.dimlevel > 10 THEN dim DEVICE spot1 MINUS 1"
"IF temp1.temperature > 55 AND spot1.dimlevel < 5 THEN dim DEVICE spot1 MINUS 1"
"IF datetime.hour IS 20 AND datetime.minute IS 0 AND datetime.second IS 0 AND spot1.dimlevel > 10 THEN dim DEVICE spot1"
 
Reply
#3
Sleep
FOR is exactly what i need here. (timing in seconds would be perfect)
After FOR is running out the device state wents back?


Loop
Is needed because the fan should run only a few seconds to spread the fog of the humidifier for special fx and then pause for a few seconds to get enough fog for the next run.
I just found an issue for this:
Code:
"IF datetime.second == 10 OR datetime.second == 20 OR datetime.second == 30 OR ..... AND humidifier.state IS on THEN switch DEVICE fogfan TO on"
The same could be done with switch off.
This will get a very long rule but works.
Would here a shorter form be possible like this:
Code:
"IF datetime.second == (10, 20, 30, 40, 50,..) AND fog.state IS on THEN switch DEVICE airfog TO on"
"IF datetime.second == (15, 25, 35, 45, 55,..) AND airfog.state IS on THEN switch DEVICE airfog TO off"


sunrise/sunset:
For a slow sunrise/-set i have to generate one rule per dim-step at the moment but if pausing rules is not possible this would be not the problem and can be used so.
If the variables from the code above would be possible it could be also done like this and would be more overseeable to config:
Code:
"IF datetime.hour == 20 AND datetime.minute == (5, 10, 15, 20, 25, ...) AND spot.dimlevel != 0 THEN dim DEVICE spot MINUS 1"
"IF datetime.hour == 20 AND datetime.minute == (5, 10, 15, 20, 25, ...) AND spot.dimlevel != 15 THEN dim DEVICE spot PLUS 1"

So it seems that FOR, usability of multiple values and PLUS/MINUS for dim will solve all my requests here.

As soon as these things are implemented my python files can apply for a pension Wink
 
Reply
#4
Sleep: Yes, it should revert the state backup to were it was.
Loop: Good catch! Long rules don't matter Smile
Sunrise/set: The only option is to create a long rule Smile
 
Reply
#5
Are there any proceedings with the operators "MINUS 1", "PLUS 1 " and "FOR"? in pilight rules?
 
Reply
#6
Nope. My goal is to release pilight 6 soon. If i constantly add stuff i also risking the introduction of new bugs.
 
Reply
#7
No problem. Should i open seperate feature requests for this to keep them in memory?
 
Reply
#8
Ow well, why not Smile Do it!
 
Reply
#9
Hi,

is there any possibility now, to switch on a device only for several seconds (a sprinkler inside a terrarium)?
There are temperature and humidity sensors (433mhz) inside, they only send every 30 minutes (to save battery) an so i can't make a rule e.g.:
IF rlf1.humidity > plannedrlf.dimlevel THEN .... TO on
IF rlf1.humidity <= plannedrlf.dimlevel THEN .... TO off

Here would be the FOR command perfekt! Or is there any other possibility now?
 
Reply
#10
No, maybe you can try the external timer protocol developed by one of our users.
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  [8.1.2] variables in rules -> error terrar 1 793 09-14-2018, 05:28 PM
Last Post: curlymo
  Rules wont work bdb 2 1,124 08-12-2018, 06:25 PM
Last Post: bdb
  Can't switch Relay device by rules: Error switch.lua:77 wobbi 6 1,567 07-31-2018, 06:25 AM
Last Post: curlymo
  Strange behavior of rules currock 4 1,355 06-28-2018, 05:57 PM
Last Post: currock
  pilight service not starting vlatko.jordanov 2 993 05-26-2018, 01:42 PM
Last Post: vlatko.jordanov
  feature request: switching rules terrar 7 1,904 05-05-2018, 09:23 PM
Last Post: trader23
  variable "label" not allowed in rules Niek 4 2,980 09-30-2017, 06:39 PM
Last Post: curlymo
  tabs on pilight SeLi 5 3,067 05-31-2017, 09:25 PM
Last Post: NormBot
  Eventing intervalls via webgui Shorf 3 2,030 08-30-2016, 06:18 AM
Last Post: Shorf
  option "all" not sent in rules muecke 5 2,513 07-01-2016, 11:37 AM
Last Post: Niek

Forum Jump:


Browsing: 3 Guest(s)