Multiple offsets for Astro plugin?

I would like to open my rollershutter 30 min before sunrise. I can see that I can offset the event, but I ALSO want the possibility of triggering something to exact sunrise, so I would like to have event channels with different offsets.

What is the way to go there? I don’t see a custom field for the channel name in the docs. Should/Can I define another thing astro:sun:home_30_45 for channel offsets like 30 min before sunrise and 45 minutes after sunset?

Yes, that is the solution most users are realizing.
Just create the new thing with the “Add manually” button in PaperUI or use text files …

Thanks. I just decided, though, that I want all that stuff configurable, so I’ll write a more complicated ruleset in the spirit of https://groups.google.com/forum/#!msg/openhab/F2hqVwjbRC0/b1s44_MWGygJ

That is what the astro binding is doing … :grinning:

Well, I mean via sitemaps. Can I set an “earliest” time for a channel via sitemap?

Never tried that, don’t think so. But you can set that via PaperUI.

There are additional alarm clock examples here. They are OH 1 rules but should work with only minor modifications.

I set this up now:

import org.joda.time.DateTime

var Timer LE_Groundfloor_Livingroom_Gardendoor_Shutter_Rise_Timer = null
var Timer LE_Groundfloor_Livingroom_Gardendoor_Shutter_Set_Timer  = null

rule "LE_Groundfloor_Livingroom_Gardendoor_Shutter_Rise_Rule"
when
    Item LE_Groundfloor_Livingroom_Gardendoor_Shutter_Rise_MinHour received update or
    Item LE_Groundfloor_Livingroom_Gardendoor_Shutter_Rise_MinMinute received update or
    Item LE_Groundfloor_Livingroom_Gardendoor_Shutter_Rise_Offset received update or
    Item LE_CivilDawn_Time received update
then
	var DateTime civilDawnTime = (new DateTime((LE_CivilDawn_Time.state as DateTimeType).calendar.timeInMillis)).plusMinutes((LE_Groundfloor_Livingroom_Gardendoor_Shutter_Rise_Offset.state as DecimalType).intValue)
    var DateTime minRiseTime   = now.withTimeAtStartOfDay().plusHours((LE_Groundfloor_Livingroom_Gardendoor_Shutter_Rise_MinHour.state as DecimalType).intValue).plusMinutes((LE_Groundfloor_Livingroom_Gardendoor_Shutter_Rise_MinMinute.state as DecimalType).intValue)
    var DateTime riseTime = null;
    if (minRiseTime.isAfter(civilDawnTime)) {
    	riseTime = minRiseTime;
	} else {
    	riseTime = civilDawnTime;
    }

    if (LE_Groundfloor_Livingroom_Gardendoor_Shutter_Rise_Timer != null)
    	LE_Groundfloor_Livingroom_Gardendoor_Shutter_Rise_Timer.cancel();
    	
	logInfo("Rollershutter","Timer for UP: "+riseTime)	
	postUpdate(LE_Groundfloor_Livingroom_Gardendoor_Shutter_RiseTime,new DateTimeType(riseTime.toCalendar(null)))
    if (now.isBefore(riseTime))
    {
		LE_Groundfloor_Livingroom_Gardendoor_Shutter_Rise_Timer = createTimer(riseTime) [| 
	            LE_Groundfloor_Livingroom_Gardendoor_Shutter.sendCommand(UP)
	        ]
	}        
end

rule "LE_Groundfloor_Livingroom_Gardendoor_Shutter_Set_Rule"
when
    Item LE_Groundfloor_Livingroom_Gardendoor_Shutter_Set_MinHour received update or
    Item LE_Groundfloor_Livingroom_Gardendoor_Shutter_Set_MinMinute received update or
    Item LE_Groundfloor_Livingroom_Gardendoor_Shutter_Set_Offset received update or
    Item LE_CivilDusk_Time received update
then
	var DateTime civilDuskTime  = new DateTime((LE_CivilDusk_Time.state as DateTimeType).calendar.timeInMillis).plusMinutes((LE_Groundfloor_Livingroom_Gardendoor_Shutter_Set_Offset.state as DecimalType).intValue)
    var DateTime minSetTime   = now.withTimeAtStartOfDay().plusHours((LE_Groundfloor_Livingroom_Gardendoor_Shutter_Set_MinHour.state as DecimalType).intValue).plusMinutes((LE_Groundfloor_Livingroom_Gardendoor_Shutter_Set_MinMinute.state as DecimalType).intValue)
    var DateTime setTime = null;
    if (minSetTime.isAfter(civilDuskTime)) {
    	setTime = minSetTime;
	} else {
    	setTime = civilDuskTime;
    }
    	
	if (LE_Groundfloor_Livingroom_Gardendoor_Shutter_Set_Timer != null)
    	LE_Groundfloor_Livingroom_Gardendoor_Shutter_Set_Timer.cancel();
    	
    logInfo("Rollershutter","Timer for DOWN: "+setTime)	
    postUpdate(LE_Groundfloor_Livingroom_Gardendoor_Shutter_SetTime,new DateTimeType(setTime.toCalendar(null)))
    if (now.isBefore(setTime))
    {
		LE_Groundfloor_Livingroom_Gardendoor_Shutter_Set_Timer = createTimer(setTime) [|
				if (LE_Groundfloor_Livingroom_Gardendoor_Lock.state == CLOSED) { 
	            	LE_Groundfloor_Livingroom_Gardendoor_Shutter.sendCommand(DOWN)
	            }
	        ]
    }
	        
end

rule "LE_Groundfloor_Livingroom_Gardendoor_Lock_Close_Rule"
when
     Item LE_Groundfloor_Livingroom_Gardendoor_Lock received update CLOSED
then
    var DateTime civilDawnTime  = new DateTime((LE_CivilDawn_Time.state as DateTimeType).calendar.timeInMillis)
    var DateTime minRiseTime   = now.withTimeAtStartOfDay().plusHours((LE_Groundfloor_Livingroom_Gardendoor_Shutter_Rise_MinHour.state as DecimalType).intValue).plusMinutes((LE_Groundfloor_Livingroom_Gardendoor_Shutter_Rise_MinMinute.state as DecimalType).intValue)
    var DateTime civilDuskTime  = new DateTime((LE_CivilDusk_Time.state as DateTimeType).calendar.timeInMillis)
    var DateTime minSetTime   = now.withTimeAtStartOfDay().plusHours((LE_Groundfloor_Livingroom_Gardendoor_Shutter_Set_MinHour.state as DecimalType).intValue).plusMinutes((LE_Groundfloor_Livingroom_Gardendoor_Shutter_Set_MinMinute.state as DecimalType).intValue)
    
    if( ( now.isAfter(civilDuskTime) && now.isAfter(minSetTime) ) || ( now.isBefore(civilDawnTime) && now.isBefore(minRiseTime) ) )
        sendCommand(LE_Groundfloor_Livingroom_Gardendoor_Shutter,DOWN)
end

Opens and closes my rollershutters at dusk and dawn, with earliest times from the sitemap, and closes them if the door is locked during the closed period. (Opening is done in the controller, for escape route security purposes.) According to the log, it should work.