Astro-binding; trigger latest & earliest daylight/night

I used astro2 binding for some time and with 2.1 it worked like this:

astro.things

astro:sun:home   [ geolocation="44.4444, 11.1111", interval=300 ] {
	Channels:
		Type rangeEvent : night#start [
			earliest="21:30",
			latest="22:30"
		]
		Type rangeEvent : night#end [
			earliest="06:00",
			latest="06:30"
		]
		Type rangeEvent : daylight#start [
			earliest="06:00",
			latest="07:30"
		]
		Type rangeEvent : daylight#end [
			earliest="16:00",
			latest="21:30"
		]
}

What I’d like to achieve is to have a “nightstate” and a “lightstate” from the binding - but for the earliest and latest times:

astro.rules

rule "Update NightState ON"
when
    Channel 'astro:sun:home:night#event' triggered START
then
	postUpdate(Nightstate, ON)
end

rule "Update NightState ON"
when
    Channel 'astro:sun:home:night#event' triggered END
then
	postUpdate(Nightstate, OFF)
end

rule "Update dunkel draußen ON"
when
	Channel 'astro:sun:home:daylight#event' triggered START
then
	postUpdate(Darkoutside, OFF)
end

rule "Update dunkel draußen OFF"
when
	Channel 'astro:sun:home:daylight#event' triggered END
then
	postUpdate(Darkoutside, ON)
end

What happens is that I get no updates anymore…?
What’s wrong with my approach?

also: if there’s a better way to achieve this besides those rules… I’m here for learning! :wink:

My Astro triggers also stopped working after 2.2 update. It worked again, after I changed Astro rule file and saved again (only inserted 1 more empty line).

Strange thing is, I made several server reboots before, without any luck.

ok, I’ll try that!

Did this work for you?

Yesterday i made a openhab restart (restart service) and today in the morning my blinds didn´t open in the morning.

There was no log-info in the openhab log - i made some loggings inside the astro-rule, when the trigger is fired from the astro binding.

This is the head of my rollo-rule:

// Rollos morgens Astro hoch - wenn nach xx Uhr
rule "Rollos Astro hoch"
when
    Channel 'astro:sun:home-offset:rise#event' triggered START
then
...

Thanks for reminding me. No, it didn’t work out… As a matter of fact I already completely ditched my OH2 and installed the system from scratch.
After analyzing my events.log, I’m even more clueless:

remember, with my Things-Definition:

  • night should star earliest at 21:30
  • daylight should end earliest at 16:00
2017-12-29 18:25:00.006 [vent.ChannelTriggeredEvent] - astro:sun:home:night#event triggered START
2017-12-29 16:26:00.007 [vent.ChannelTriggeredEvent] - astro:sun:home:set#event triggered START

at my location, those are the “normal” times, without my rangeEvent configurations in the things-definition.

What’s bothering me, is the configuration I see in PaperUI:
for “Night Start” i see this one:
image

for “Range Event” I see this one:
image

So I’m not quite sure, what that means…

I’m still playing around with this and it just won’t do… either it is a bug - or a feature. I’m in for either a bug - or a misconception on my side?

So, is there anybody here, who has also the need for a simple “latest” or “earliest” trigger for astro-events? Because I can either use latest OR earliest for one event, but not both at a time?

I don’t get it either. When I try to set earlier/latest in the PaperUI of the astro:sun:local:daylight#event, how can I define different limits for START and END?

I would even do this in the .things file (I’m not bound to PaperUI), but even there I did not manage to get this working…

Same problem over here. I’ve set earliest/latest for astro:sun:local:rise#end (06:00 - 07:00) and astro:sun:local:set#start (22:00 - 23:00) in the PaperUI and created bindings to items. In the “Control” tab the both values respect the earliest/latest entries:

image

Nothing happens at 22:00, unfortunately the roller shutters moved down at normal sunset time:

2018-04-16 06:32:00.002 [vent.ChannelTriggeredEvent] - astro:sun:local:rise#event triggered END
2018-04-16 20:20:00.001 [vent.ChannelTriggeredEvent] - astro:sun:local:set#event triggered START

I’m quite unsure, but shouldn’t astro:sun:local:set#event respect the earliest/latest settings in astro:sun:local:set#start?

[EDIT 1] Forgot to mention: Running openHAB 2.2.0 in a Docker Container (Debian).

I changed my config to this one:

astro:sun:home   [ geolocation="44.422621, 8.870313", interval=300 ] {
	Channels:
		Type start : night#start [
			earliest="21:30"
		]
		Type start : night#start [
			latest="22:30"
		]
		Type end : night#end [
			earliest="06:00"
		]
		Type end : night#end [
			latest="06:30"
		]
		Type rangeEvent : night#event [
			earliest="06:01"
		]
		Type rangeEvent : night#event [
			latest="21:31"
		]
		Type end : morningNight#end [
			earliest="06:00"
		]
		Type end : morningNight#end [
			latest="06:30"
		]
		Type rangeEvent : morningNight#event [
			earliest="00:03"
		]
		Type rangeEvent : morningNight#event [
			latest="06:33"
		]
		Type start : daylight#start [
			earliest="06:00"
		]
		Type start : daylight#start [
			latest="07:30"
		]
		Type end : daylight#end [
			earliest="16:00"
		]
		Type end : daylight#end [
			latest="21:30"
		]
		Type rangeEvent : daylight#event [
			earliest="06:02"
		]
		Type rangeEvent : daylight#event [
			latest="21:32"
		]
}

and this seemed to have the effect. right now, the time ranges are within the boundaries at my location, so I’m not 100% sure, but I have the feeling, it worked.

I trigger some proxy items with this - the items are for “nightstate” = it’s night (heating, locks, …) and “darkoutside” = it’s dark (outside lighting, …):

rule "Update NightState ON"
when
    Channel 'astro:sun:home:night#event' triggered START
then
	postUpdate(Binder_Nightstate, ON)
end

rule "Update NightState ON"
when
    Channel 'astro:sun:home:morningNight#event' triggered END
then
	postUpdate(Binder_Nightstate, OFF)
end

rule "Update dunkel draußen ON"
when
	Channel 'astro:sun:home:daylight#event' triggered START
then
	postUpdate(Binder_Darkoutside, OFF)
end

rule "Update dunkel draußen OFF"
when
	Channel 'astro:sun:home:daylight#event' triggered END
then
	postUpdate(Binder_Darkoutside, ON)
end

perhaps this won’t be sufficient in some cases, as I at least see in PaperUI only one trigger:


only earliest is active at least in PaperUI - I have to test a bit more

but long story short at present I guess:

  • either use two astro-Things
  • or use enough astro-Events

(OH2.2 - stable)

Does this mean that the rangeEvent für daylight#event has to cover the whole time Slot, beginning from daylight#start/earliest and ending with daylight#end/latest?

for a bit more confusion… :wink:

Type rangeEvent : civilDawn#event  [
            offset=10,
            earliest="06:00",
            latest="08:00"
        ]
        Type rangeEvent : civilDusk#event  [
            offset=25,
            earliest="16:00",
            latest="22:00"
        ]


First event channel is used to open the roller shutters, second event channel is used to close them.

In my mind it should read something like:

  • use normal “daylight”-time unless
  • it’s not yet 6:00
  • it’s already 7:30

=> so, if daylight is reached already at 4:45, the trigger won’t start until 6:00 - and it’s daylight at 8:15 the trigger will already start at 7:30. I just checked - having two definitions of an channel Attribute - only the first one will be used by OH2…

Yes, you have to define all values in one channel (see my posting)

1 Like

But astro:sun:local:daylight#event does not trigger start or end in the time slots I’ve set the in the earliest and latest parameter in astro:sun:local:daylight#start and astro:sun:local:daylight#end. It always triggers to the normal times which have been calculated by the Astro Binding. Shouldn’t astro:sun:local:daylight#event only trigger start and end between the time slots that have been defined by the earliest and latest parameter in astro:sun:local:daylight#start and astro:sun:local:daylight#end?

Defining earliest and latest in astro:sun:local:daylight#event does not make sense imho, because I want to set time slots for both start and end events but I think thats not possible. What’s a range defined by earliest and latest good for when talking about astro:sun:local:daylight#event, which event will be moved between earliest and latest, start or end?

Maybe there’s some sort of confusion in my head right now (to be honest: I’m pretty sure it is :wink: ) and I have to apologize for asking stupid questions. But right now I’m stuck with the astro:sun:local:daylight#event

Thanks for helping me out…

I think you didn’t get it. You have to set boundaries for the event channel, not for datetime channels. Take a look at my post Astro-binding; trigger latest & earliest daylight/night
As you can see, I define a time slot for civilDawn#event. This is, if (civilDawn +offset) will take place within this time slot, the trigger will be sent at time. If it takes place before the time slot, it will trigger at strt of time slot. If it will take place after the end of time slot, it will trigger at end of time slot.

The same is for civilDusk. In the end, I get two triggers, one for “House, open up your eyes!” and one for “House, close your eyes!” :wink:

In fact, there is a trigger START (that is the event occurrence). I’m not aware of a trigger END for an event at all, but I did not test this.

Maybe that’s my error, that I want to be aware of both triggers, START and END. From my point of view these are two different events in the event channel. Apparently this is not the fact and my view is wrong then. :wink: Seems to be illogical to me. :smiley:

So if I set boundaries on any …#event they only apply to START and there’s no way to manipulate the END trigger?

What would be the END of sunrise? When the sun leaves the horizon? What would this be good for?

Sunrise event START is ‘exactly’ when the sun rises above the horizon (I think the ‘upper’ end of the sun… :slight_smile: ) or 0°
civil dawn is -6°, nautical dawn is -12°, astronomical dawn is -18°
sunset on the other hand is when the sun drops under the horizon (0°),
again, civil dusk is -6°, nautical dusk is -12°, astronomical dusk is -18°.
I know there is a start and an end time and a duration, I can only guess this is because the sun has a virtual size of ~ 0.5°. So, there might also be a trigger END but I think it will have no sense in question of home automation.

There IS some Events, which trigger START and END, for now I assumed it to be a bug, if there is no end!
to be honest:

  • sunrise START: the first Little part of the sun is seen
  • sunrise END: the whole sun is up

I would trigger END, if I’d like to have the whole sun above the horizon and I’d assume to get all possible light for example. Same goes with the other events…

Well, yes, that makes sense, but as long as the astro binding does not use hight to calculate the time but only theoretical amount of radiation (afaik this is the only value of giving the hight of a location by now)…
And why would this calculation not incorporate seconds? The calculation is not as precise as necessary for this :slight_smile:

1 Like

i didn’t have a look in the Code for it (as if I even understand it… :wink: ) - but yeah, I don’t use it for mathematical correctness, I’d just like to have triggers for “house Close your eyes” and “House, turn outside lights on/off”… :wink:

But I think, best way would be to use two different events as you did…