• 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
Triggering device at specific time or sunrise if sunrise is after
Hello all,
I'm trying to find a way to start a bash script after sunrise, but earliest at 7:30h in case of summer when sunrise is before this time. In the winter time the bash script will be started after sunrise, means as well after 7:30h.

To simplify it, here a code how it could look like in a bash script. For sure it will not work. It is only for better understanding.

if sunrice < $time
   then trigger device at $time
else trigger device at sunrise

How can I handle this by using a rule? I tried this, but AT is not supported.
"IF (sunstate.sunrise < (datetime.hour == 07 AND datetime.minute == 30 AND datetime.second == 00)) switch DEVICE script TO running AT (datetime.hour == 07 AND datetime.minute == 30 AND datetime.second == 00)",

"IF (sunstate.sunrise > (datetime.hour == 07 AND datetime.minute == 30 AND datetime.second == 00)) switch DEVICE script TO running AT sunstate.sunrise",

Maybe something like this will work bedind a AFTER -> "time - sunrise = minutes to wait", but how to format the time? I'm lost in "formatation Wink"...
Nobody an idea?

I'm running version 7.0 (stable).
You could try something like this (the rule is valid, but I did not test it!)

"IF (sunstate.sunrise < 7.30  AND datetime.hour == 7 AND datetime.minute == 30 AND datetime.second == 0) OR (sunstate.sunrise >= 7.30  AND sunstate.sunrise == (datetime.hour + datetime.minute / 100) AND datetime.second == 0) THEN switch DEVICE script TO running"
Hey thanks you made my day!
Now when I see it, it seems to be simple Tongue.
I put your variant into the config.json and the GUI is reachable. That is a good step forward.


Possibly Related Threads...
Thread Author Replies Views Last Post
  [Solved] On and Off for one device in one rule Oliver 3 449 10-28-2019, 06:55 PM
Last Post: Oliver
  Can't switch Relay device by rules: Error switch.lua:77 wobbi 6 1,094 07-31-2018, 06:25 AM
Last Post: curlymo
  Rule with&without device. One working not the other... Tamadite 9 1,396 07-24-2018, 08:55 AM
Last Post: curlymo
  Rule Sunset works, Sunrise not apartmedia 1 1,189 12-05-2017, 07:09 PM
Last Post: apartmedia
  Always trigger event on any device state Phil 8 2,422 03-22-2017, 07:30 PM
Last Post: Phil
  Rule executed at wrong time philipp81 1 967 02-25-2017, 10:43 PM
Last Post: curlymo
  [Solved ]Turn off device at random time manmetdehamer 4 2,211 07-27-2016, 03:35 PM
Last Post: manmetdehamer
  event at randomized time after another event Emiks5 3 1,616 05-07-2016, 09:10 AM
Last Post: Thunder84
  Time interval between two rule checks muecke 3 1,941 04-21-2016, 02:31 PM
Last Post: pilino1234
  ERROR: rule #21 invalid: variable "label" of device "WindMax" cannot be used in even koos147 2 1,915 04-02-2016, 10:24 PM
Last Post: koos147

Forum Jump:

Browsing: 1 Guest(s)