[SOLVED] Things definition, here Astro offset

I have an astro thing like this;

Thing astro:sun:home  [ geolocation="-25.3164855,153.3701568", interval=60 ]

… and have items like this:

DateTime Twilight_Time		"Twilight [%1$tH:%1$tM]"	<moon>	(Weather)	{ channel="astro:sun:home:minus90:set#start" }
Switch   Twilight_Event											(Weather)	{ channel="astro:sun:home:minus90:set#start" }

In order to use:

channel="astro:sun:minus90:set#start"

Do I need to add something to the thing definition? Maybe like this:

Thing astro:sun:home  [ geolocation="-25.3164855,153.3701568", interval=60 ]
    Channels:
        Type start : set#start [
            offset=-90
        ]
}

How would OH know whether to use the standard definition for set#start vs the extra defined set#start.

Or is the minus90 that needs to be defined; e.g. type minus90 : set#start [ offset=-90 ]?

Thanks for any insights.

Yes.

Based on the example in the ASTRO docs what you have looks reasonable.

It doesnt. It only uses the offset. If you want the time without the offset you need to define two Things, one with the offset and one without.

Hi,
as @rlkoshak explained, you have to define the several usage-forms. Here an example of my setup, with normal usings and with offset:

//    Astro - Binding Geo-Position  geolocation="xx.xxxxxx,y.yyyyy,zzz"

Thing astro:sun:local     "Sonnen Daten"    [geolocation="xx.xxxxxx,y.yyyyyyy,zzz", interval=300]
Thing astro:moon:local    "Mond Daten"      [geolocation="xx.xxxxxx,y.yyyyyyy,zzz", interval=300]
                                        
Thing astro:sun:stowing   "Offset -180"     [geolocation="xx.xxxxxx,y.yyyyyyy,zzz", interval=300]{
  Channels:
    Type rangeEvent : set#event [
      offset=-180,
      earliest="19:40"
    ]
  }

and a complete Rule-Set:

/*===============================================================================
|             Begin Astro Rules                 |
=================================================================================*/
//===============================================================================
//*
rule "Moonrise Start"
  when
    Channel 'astro:moon:local:rise#event' triggered START
  then
    logInfo("astro-rules" + '_01'," Der Mond geht auf. START ")
    //Sonoff_Basic_03.sendCommand(ON)
end
//===============================================================================
rule "Moonset Ende"
  when
    Channel 'astro:moon:local:set#event' triggered END
  then
    logInfo("astro-rules" + '_02'," Der Mond geht unter. END")
    //Sonoff_Basic_03.sendCommand(ON)
end
//===============================================================================
rule "Sunset_180 Start"
  when
      Channel 'astro:sun:stowing:set#event' triggered START
  then
    logInfo("astro-rules" + '_03', " Sunset_180 Start. START")
    //EG_EG_Kind2_Licht.sendCommand(ON)
end
//===============================================================================
rule "Sunset_180 Ende"
  when
      Channel 'astro:sun:stowing:set#event' triggered END
  then
    logInfo("astro-rules" + '_04', " Sunset_180 Ende. END")
    //EG_EG_Kind2_Licht.sendCommand(ON)
end

//===============================================================================
rule "Sunrise Start"
  when
      Channel 'astro:sun:local:rise#event' triggered START
  then
    logInfo("astro-rules" + '_05', " Sunrise START ")
    //EG_EG_Kind2_Licht.sendCommand(ON)
end

//===============================================================================
rule "Mittag Start"
  when
    Channel 'astro:sun:local:noon#event' triggered START
  then
    logInfo("astro-rules" + '_06', " Mittag - noon. START")
    //Sonoff_Basic_03.sendCommand(ON)
end
//===============================================================================
rule "Civil Dusk Start"
  when
    Channel 'astro:sun:local:civilDusk#event' triggered START
  then
    logInfo("astro-rules" + '_07', " Civil Dusk START")
    //EG_EG_Kind2_Licht.sendCommand(ON)
    
end
//===============================================================================
rule "Civil Dusk Ende"
  when
    Channel 'astro:sun:local:civilDusk#event' triggered END
  then
    logInfo("astro-rules" + '_08'," Civil Dusk END")
    //Sonoff_Basic_03.sendCommand(ON)
end
//===============================================================================
rule "Nautik Dusk Start"
  when
    Channel 'astro:sun:local:nauticDusk#event' triggered START
  then
    logInfo("astro-rules" + '_09'," Nautik Dusk Start. START")
    //Sonoff_Basic_03.sendCommand(ON)
end

//===============================================================================
rule "Nautik Dusk Ende"
  when
    Channel 'astro:sun:local:nauticDusk#event' triggered END
  then
    logInfo("astro-rules" + '_10'," Nautik Dusk Ende. END")
    //Sonoff_Basic_03.sendCommand(ON)
end
//===============================================================================
rule "Morning Night Start"
when
    Channel 'astro:sun:local:morningNight#event' triggered START
  then
    logInfo("astro-rules" + '_11'," Morning Night Start. START")
    //Sonoff_Basic_03.sendCommand(ON)
end
//===============================================================================
rule "Morning Night Ende"
  when
    Channel 'astro:sun:local:morningNight#event' triggered END
  then
    logInfo("astro-rules" + '_12'," MorningNight END")
    //EG_EG_Kind2_Licht.sendCommand(ON)
end
//===============================================================================
rule "Sunset Start"
  when
    Channel 'astro:sun:local:set#event' triggered START
  then
    logInfo("astro-rules" + '_13'," Sunset Start. START")
    //Sonoff_Basic_03.sendCommand(ON)
end

//===============================================================================
rule "Sunset Ende"
  when
    Channel 'astro:sun:local:set#event' triggered END
  then
    logInfo("astro-rules" + '_14'," Sunset Ende. END")
    //Sonoff_Basic_03.sendCommand(ON)
end

//===============================================================================
rule "Tagesphase"
  when
    Item Day_Phase changed
  then
    logInfo("astro-rules" + '_30'," Tagesphase " + Day_Phase)
    //logInfo("astro-rules" + '_30',"Tagesphase " + Day_Phase)
    //Sonoff_Basic_03.sendCommand(ON)
end
//*/
/*===============================================================================
|             End Astro Rules                 |
=================================================================================*/


Have fun with testing, and you don’t need to define extra items for, just use it with your normal items, as in my Rule-Examples

3 Likes

Thank you :slight_smile:

I didn’t dare to ask what the rule should look like, which is at times a good thing, as I had to figure it out myself. Which I did, by realising the third part of the thing definition is what needs to be varied.
In essence it is a duplicate but with a modified channel…

As I understand you want to use a Rule with an offset ? Isn’t it ?

so for example you can use a thing like this(stowing or whatever you want, but different from the first two):

                                        
Thing astro:sun:stowing   "Offset -180"     [geolocation="xx.xxxxxx,y.yyyyyyy,zzz", interval=300]{
  Channels:
    Type rangeEvent : set#event [
      offset=-180,
      earliest="19:40"
    ]
  }

which uses the “sun”-Thing (stowing) with the (sun)set-Channel as an event. And if you want to trigger it before(in my case) you give it an offset (-180 Minutes), and if this to early, you can say, but “earliest” at 19:40

Then use a Rule like those:

//===============================================================================
rule "Sunset_180 Start"
	when
			Channel 'astro:sun:stowing:set#event' triggered START
	then
		logInfo("astro-rules" + '_03', " Sunset_180 Start. START")
		//EG_EG_Kind2_Licht.sendCommand(ON)
end
//===============================================================================
rule "Sunset_180 Ende"
	when
			Channel 'astro:sun:stowing:set#event' triggered END
	then
		logInfo("astro-rules" + '_04', " Sunset_180 Ende. END")
		//EG_EG_Kind2_Licht.sendCommand(ON)
end

//===============================================================================

to switch on or off a light or whatever you want to control. Docs are here. Hope this can help you

1 Like

hi,
quite an older article but anyhow i would like to ask.
for me it seems not to work properly all the time with the offsets if I trust the logs.
what i have is the following:

astro:sun:home  [ geolocation="xxx.xxx, xxxx.xx,xxxx", interval=60 ] {
    
    Channels:
        Type start : civilDawn#start [
            offset=20,
            earliest="06:15"
        ]
        Type end : civilDusk#end [
            offset=-25,
            latest="20:00"
        ]
}

but in the log i see that it is triggered at:
2020-04-19 05:36:00.003 [vent.ChannelTriggeredEvent] - astro:sun:home:civilDawn#event triggered START

I do not see a logline triggering at 06:15

But beside this, i can see that the offset basically works as when its reconfiguring i see the following:
2020-04-20 00:00:00.125 [vent.ItemStateChangedEvent] - CivilDawn_Start changed from 2020-04-19T06:15:00.000+0200 to 2020-04-20T06:15:00.000+0200

Do you see the same in your logs? maybe this line is written all the time anyhow but has no effect and vice versa the right offset-time has no log entry? would not make sense but maybe its just to confuse me :wink:

thx
BR

Your offsets are applied to civilDawn#start and civilDusk#end

Your events log is for civilDawn#event, which is something else altogether, and has no offset applied to it as yet.
Look again at the Astro docs for example of applying offset to an event using rangeEvent

People often seem to struggle with this.
civilDawn has three different channels.
#start and #end are state channels, you can link those to a DateTime Item and see times.
#event is a trigger channel, something that just happens or isn’t happening. It can trigger rules with payloads of START or END etc, but you cannot link to an Item because it has no state.
Each of the channels has its own different offsets.

1 Like

thanks a lot - still little bit confusing but this should now make what i would like to.

astro:sun:home  [ geolocation="xxxx6, xxxx", interval=60 ] {
    
    Channels:
        Type rangeEvent : civilDawn#event [
            offset=20,
            earliest="06:15",
            latest="08:00"
        ]
        Type rangeEvent : civilDusk#event [
            offset=-25,
            earliest="17:30",
            latest="20:00"
        ]
}

thanks a lot

1 Like