This object is in archive! 

perform an action at 6:30 am but not before sunrise

W. Evens shared this question 8 years ago
Need Answer

Hi, I tried to create a rule that has to open my blinds at 6:30 am but only if it's not before sunrise (via virtual weather station). In other words: if it's still "dark" at 6:30 my blinds have to stay shut. (They will be controlled by another rule then)

Unfortunately, it is not possible to select sunrise (or sunset) from the attributes of the virtual wheather station.

My rule would look like this:

  1. When scheduler [6:30, every day]
  2. IF now > [virtual wheather meter: sunrise]
  3. [action to open blinds]
  4. ...

In the virtual wheather meter, there are 9 attributes available in the drop down, but not sunrise or sunset although I can use the latter 2 in the scheduler, but that's not the case in this rule)

Any idea how I could make my rule work?

Best Answer
photo

Hey,


here an other idea:

I use a virtual switch for "daylight". It is set in the morning to on with the scheduler sunrise and off at evening by sundown (2 rules). I have a lot of rules which use "daylight". Now you have a simple rule for your problem:


if time =06:30 and daylight = on

action

end if

Replies (6)

photo
1

You can select sunrise in the scheduler. So you have to do it the other way.

Create a variable.

create 2 rules.

First rule:

When sunrise

time(now)->variable;

Second rule:

Your rule with the variable

photo
1

Thanks John. I tried your advice but got an error message when saving the 2nd rule:

First rule looks like this:


  1. When Scheduler [Sunrise]
  2. Set Variable ZONSOPGANG To TIME OF: NOW
  3. ...

Second rule:

  1. When Scheduler [=6:30/everyday]
  2. If NOW > Variable "Zonsopgang"
  3. ...

Gives Error message:

FAIL: javac: The method CompareTo(java.util.Calendar) in the type java.util.Calendar is not applicable for the arguments (double)

After saving, the 2nd rule is marked as invalid.

Any idea?

photo
1

I tried another syntax in rule 2. At least, it doesn't give the error message anymore.

  1. When Scheduler [=6:30/everyday]
  2. If NOW > TIME OF Variable "Zonsopgang"
  3. ...

I'll provide feed back tomorrow wheather the rule works.

photo
1

I am not sure about this but NOW is i think has a date/time type. So it is always better to use time(now)

photo
1

Hey,


here an other idea:

I use a virtual switch for "daylight". It is set in the morning to on with the scheduler sunrise and off at evening by sundown (2 rules). I have a lot of rules which use "daylight". Now you have a simple rule for your problem:


if time =06:30 and daylight = on

action

end if

photo
1

Thank you guys! Both are good solutions. Maybe Andreas' proposition is preferrable (in order to not have issues with the time format).

Leave a Comment
 
Attach a file