[SOLVED] Astro, offseting doesn't work?

Hi,
I have a hard time getting Astro offsets to work.
Here is what I want to acheive:

  • Variable offset of sunrise (± 60min) - I’m trying to offset Astro sunrise -60min and then just set a timer with my variable offset when the start event is triggered that will execute on the point in time
  • Variable offset of sunset (± 60min) - same as above but triggering on the sunset end event and I’m offseting whole thing -120 minutes because I want to turn lights on with offset (±60min) related to “my” sunset

example scenario:

  • Astro sunrise with -60min offset: 05:45 (without offset 6:45)
  • My sunrise offset: -15 minutes
  • 05:45 sunrise#start gets triggered and sets a timer for (60-15)minutes from now
  • 06:30 timer code executes
  • Astro sunset with -120min offset: 16:45 (without offset 18:45)
  • My sunset offset: +15 minutes
  • My light offset: -20 minutes
  • 16:45 sunrise#end gets triggered and sets timers:
    • (120+15)minutes from now (“stuff” timer)
    • (120+15-20)minutes from now (light timer)
  • 18:40 the light timer code executes
  • 19:00 the “stuff” timer code executes

Here is my .thing definition:

Thing astro:sun:coopLocation [ geolocation="aaa,bbb,100" ] {
	Channels:
		Type rangeEvent : rise#event [
			offset=-60
		]
		Type rangeEvent : set#event [
			offset=-120
		]
}

this doesn’t seem to affect the date in my items and logs show that sunrise#start gets triggered without the -60 minutes offset (same goes for the sunset)

sunset .items:

DateTime Sunrise "Sunrise raw [%1$tH:%1$tM]" <sun> { channel="astro:sun:coopLocation:rise#start" }

that item in the .sitemap:

Default item=Sunrise

I have tried to change thing definition to:

Type rangeEvent : rise#start [

or

Type start : rise#start [

but no success there too :slightly_frowning_face: at one opint I got to work displaying the offset time (it was showing 5:45 instead 6:45) but the event triggered without this offset :slightly_frowning_face:

Here is the rule that I use for sunrise (sunset is basically the same)

rule "Sunrise - prepare"
when
      Channel "astro:sun:coopLocation:rise#event" triggered START
then
      logInfo( "coop.rules", "sunrise !")
      createTimer( now.plusMinutes( 60 + Integer::parseInt( SunsetOffset.state.toString ) ), [
            //SunsetOffset is my variable offset
            logInfo( "coop.rules", "Doing stuff on the offset sunrise!")
            SunriseReady.sendCommand( ON )
      ])
end

The timers are executing without any problems (so far) - the problem is that the Astro events are triggered without offsets.

I think I might be missing something obvious but apparently I’m blind and just I cant see it :confused:

Edit:
I didn’t really change anything and code started working :thinking: I promably had a typo somewhere?:confused:

I believe that rangeEvents are not meant to affect data channels, only events. So I would not expect to see an Item linked to channel being affected by offsets. Not sure there.

when
      Channel "astro:sun:coopLocation:rise#event" triggered START

Try single quotes around trigger channel, as per documentation.

hmm… :thinking: the rule gets triggered but at the wrong time but I will change it :slightly_smiling_face:
meanwhile… I might get it to work… I don’t know what I changed but sunset just got triggered with the right offset :smiley: I will check the logs tomorrow

Items file:

DateTime Sunset           "Sunset [%1$tH:%1$tM]"                            <sunset>          (gAstro) {channel="astro:sun:local:set#start"}
DateTime Sunset_30           "Sunset - 30mins [%1$tH:%1$tM]"                            <sunset>          (gAstro) {channel="astro:sun:minus30:set#start"}

things file:

astro:sun:local  [ geolocation="9.66780,-90.12314", interval=300 ]

astro:sun:minus30  [ geolocation="9.66780,-90.12314", interval=300 ] 
{

Type start : set#start [
            offset=-30
        ]

Type rangeEvent : set#event [
            offset=-30
        ]


}

Rules:

yrule "Turn porch light off at Sunrise"
when
    Channel 'astro:sun:local:rise#event' triggered START
then    
    logInfo("rules", "It's sunrise, I'm turning off the porch light")
    gOutDoorDimmer.sendCommand(OFF)
end


rule "Turn porch light on at Sunset Duplicate"
when
    Channel 'astro:sun:minus30:set#event' triggered START
then
    logInfo("rules", "E It's sunset, I'm turning the porch light on")
    gOutDoorDimmer.sendCommand(100)
   // Garage_Door_Light1.sendCommand(100)
end

As promised! These files work, so if you change to match your setup it should work. Already I see one problem. You need to define a thing for -60 and another for -120.

1 Like