sthiemt
(sthiemt)
May 8, 2018, 5:05pm
#1
Hello everyone,
I want to create a rule that is opening the blinds when I arrive home. However, it should not open the blinds when it is already dark outside.
To realize that a use the astrobinding (with SUN as a thing) and the following items:
DateTime NightStart {channel="astro:sun:7a324540:night#start"}
and then I use this comparision:
if (now.isAfter(NightStart))
{....}
but i get a type missmatch. How do I convert “NightStart” so that this works.
Thanks for your help
-sthiemt
vzorglub
(Vincent Regaud)
May 8, 2018, 10:05pm
#2
I suggest you use this design pattern:
NOTE: I’ve added an openHAB 2 Astro 2.0 binding version at the end.
NOTE: I’ve added an openHAB 2.2 version to the end which avoids the deprecation warnings on getCalendar()
Another transfer of a Design Pattern from the great big Design Pattern thread . I move them over to a new separate thread as I need to reference them in an answer to a question. NOTE: the rules have been extensively reworked to make them shorter and simpler.
Problem Statement
Often in home automation one has certain rule…
Good luck
rlkoshak
(Rich Koshak)
May 9, 2018, 12:52am
#3
As the author of the link Vincent posted I agree with his suggestion.
However, your specific problem in the code you posted includes:
halloween
(Hallo Ween)
May 30, 2018, 11:06am
#4
I have a working solution, but it is deprecated. Maybe it helps you.
Hi,
how can i compare a given time from the astro-binding with now?
I want to make a cron-job. Then the rule should compare, if now is before or after the astro-time and do different things.
Maybe conjob at 7 o´clock --> look if sunrise was already.
I now do this with 2 separate rules and a proxy item, but i think it should work with a simple compare, too?
This is my astro item:
DateTime Sonnenaufgang_Start "Sonnenaufgang [%1$tH:%1$tM]" <sunrise> (gAstro) { channel="astro:sun:home:rise#sta…
I hope someone can tell me the new format for my rule.