• 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:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sunriseset rule question
#1
Hi, struggling with rule syntax. Could someone explain to me why this works:
Code:
"IF (sunriseset.sunset == DATE_FORMAT(datetime, %H.%M)) THEN switch DEVICE tuinverlichting TO on AFTER RANDOM(0, 5) MINUTE FOR RANDOM(45, 60) MINUTE"

and this doesn't:

Code:
"IF (sunriseset.sunset == DATE_FORMAT(datetime, %H.%M.%S)) THEN switch DEVICE tuinverlichting TO on AFTER RANDOM(0, 5) MINUTE FOR RANDOM(45, 60) MINUTE"

The reason I want to add the second is that if I check the log I see this happening for every second in that minute. So my reasoning was to force a check on the second precise.

Code:
[Jul 07 19:57:00:772898] pilight-daemon: INFO: executed rule: tuin1
[Jul 07 19:57:00:776517] pilight-daemon: INFO: started "switch" action for device "tuinverlichting"
[Jul 07 19:57:01:777377] pilight-daemon: INFO: stopped "switch" action for device "tuinverlichting"
[Jul 07 19:57:01:778704] pilight-daemon: INFO: executed rule: tuin1
[Jul 07 19:57:01:780521] pilight-daemon: INFO: started "switch" action for device "tuinverlichting"
[Jul 07 19:57:02:781249] pilight-daemon: INFO: stopped "switch" action for device "tuinverlichting"
[Jul 07 19:57:02:782491] pilight-daemon: INFO: executed rule: tuin1
[Jul 07 19:57:02:784573] pilight-daemon: INFO: started "switch" action for device "tuinverlichting"
[Jul 07 19:57:03:785371] pilight-daemon: INFO: stopped "switch" action for device "tuinverlichting"
[Jul 07 19:57:03:786710] pilight-daemon: INFO: executed rule: tuin1
[Jul 07 19:57:03:788482] pilight-daemon: INFO: started "switch" action for device "tuinverlichting"

In the error log I see an error message of integer comparison error. Why is this not a problem with just %H.%M?

Thanks!
 
Reply
#2
First of all, please edit your post and incoorporate code tags. That being said.

sunriseset.sunset translates to e.g. XX.XX
DATE_FORMAT(datetime, %H.%M)) translates to XX.XX
DATE_FORMAT(datetime, %H.%M.%S)) translates to XX.XX.XX

You see that XX.XX.XX != XX.XX while XX.XX == XX.XX

If you want to execute once use:

Code:
IF (sunriseset.sunset == DATE_FORMAT(datetime, %H.%M) AND datetime.second == 0) THEN switch DEVICE tuinverlichting TO on AFTER RANDOM(0, 5) MINUTE FOR RANDOM(45, 60) MINUTE
 
Reply
#3
Thank you. Will do.
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  Rule triggers twice Thorben653 12 115 Yesterday, 12:53 PM
Last Post: Thorben653
  [Solved] On and Off for one device in one rule Oliver 3 307 10-28-2019, 06:55 PM
Last Post: Oliver
  [solved] sunset rule doesn't work fleisch 4 289 10-26-2019, 07:05 AM
Last Post: fleisch
  Rule with&without device. One working not the other... Tamadite 9 1,135 07-24-2018, 08:55 AM
Last Post: curlymo
  rule executed once at start up segalion 3 631 07-12-2018, 05:28 PM
Last Post: curlymo
  Problem with executing bash script via rule/program dYna 1 929 02-15-2018, 09:06 PM
Last Post: dYna
  Rule Sunset works, Sunrise not apartmedia 1 1,101 12-05-2017, 07:09 PM
Last Post: apartmedia
  Problem with a Rule for a One Button Switch martin-dj 1 1,263 03-06-2017, 12:01 PM
Last Post: pilino1234
  Rule executed at wrong time philipp81 1 896 02-25-2017, 10:43 PM
Last Post: curlymo
  Sunriseset problem switches on at 0:00 kgulti 13 3,878 12-26-2016, 08:08 PM
Last Post: PekkaLahtela

Forum Jump:


Browsing: 1 Guest(s)