In an attempt to solve this problem in a way that I actually understand, I thought, I know … I’ll just be create multiple locations that I can reference all along the same latitude. If the longitude that I reference is 15 degrees apart from my own, then the sunset times of the other location will be an hour different (360 degrees / 24hrs per day = 15 degrees per hour).
Warning (Danger Danger) - The below is not tested as of this post! Use at your own risk.
So in my things file (sanitized in this example below for my protection) I now have:
astro:sun:home [ geolocation=“45.000000,-80.000000”, interval=60 ]
astro:moon:home [ geolocation=“42.000000,-80.000000”, interval=60 ]
Then if I want to turn on a light, say 60 mins before sunset I can simply:
// Stairwell Lights On at Sunset - 1 hour.
rule "Stairwell Lights On - Sunset - 1 hour"
when
Channel 'astro:sun:minus60:set#event' triggered START
then
sendCommand(swStairway, ON)
end
It looks like this should work out well until I can figure out how to do the offsets in a file. In the end I might not want them there but I don’t understand how to use them as they are - or even how to reference them if I define them.
So I’ve done the above and initially I got an exception in my logs. Touching the file fixed that and now I see a new Channel in PaperUI that wasn’t there before:
OK, I’ll probably have to wait a couple of days for that PR to filter down to the Docker image on DockerHub. Now that the Docker image build is working again it should not be long. Thanks!
I’m probably telling you something you already know, but if you take @itheiss example (slightly modified by me and therefor probably wrong) and then also duplicate it as below … you could do:
// 30 mins prior to sunsest
Thing astro:sun:homeMinus30 [ geolocation="xx.xx,yy.yyy", interval=60] {
Channels:
Type rangeEvent : set#event [
offset=-30
]
}
// 45 mins prior to sunsest
Thing astro:sun:homeMinus45 [ geolocation="xx.xx,yy.yyy", interval=60] {
Channels:
Type rangeEvent : set#event [
offset=-45
]
}
That should work for that … now for my soapbox …
All this “Thing” generation seems repetitive and resource intensive (it’s not like your going to need a trigger to occur on the nautical sunrise minus 30 mins on every additional astro thing you create). – Kind of going off the tracks here to possible system changes … and … Maybe should bring in @ThomDietrich here.) I think that we need some way to DEFINE a new range event (trigger channel?) at least in this example, based on an existing thing(s) above but possibly modified with parameters as in
NOT A WORKING EXAMPLE
// 30 & 45 mins prior to sunsest
Thing astro:sun:home [ geolocation="xx.xx,yy.yyy", interval=60] {
Channels:
Type rangeEvent : set#event : minus30 [
offset=-30
]
Type rangeEvent : set#event : minus45 [
offset=-45
]
}
END OF NOT A WORKING EXAMPLE
Where the “minus30” entry and the “minus45” in the above gets added to the list of available triggers (trigger channels?). Enter as many different ones as you would want. The good news is that more items that you don’t need aren’t added like they are when you define and entirely new astro ‘thing’. Then maybe one could reference it as in:
YET ANOTHER NON-WORKING EXAMPLE
rule "example trigger rule"
when
Channel 'astro:sun:home:set#event#minus30' triggered START
then
...
end
END OF YET ANOTHER NON-WORKING EXAMPLE
as the "#minus30 is simply added to the channel?
Thoughts? Maybe I should put this somewhere else? Am I missing something? Is this information anyone would want?
Frame label="Bunch of Display Items" {
Text label="All Items" icon="none" {
Frame label="Display" {
Text item=Sunrise_Time
Text item=Sunset_Time
Text item=Sunrise_Time_Ex
Text item=Sunset_Time_Ex
}
}
}
When saving the Things, in the log I get:
2017-01-25 21:39:35.361 [temChannelLinkRemovedEvent] - Link 'Sunset_Time => astro:sun:home:set#start' has been removed.
2017-01-25 21:39:35.368 [temChannelLinkRemovedEvent] - Link 'Sunrise_Time => astro:sun:home:rise#start' has been removed.
2017-01-25 21:39:35.711 [ItemStateChangedEvent ] - Sunrise_Time changed from NULL to 2017-01-25T06:55:00.000-0600
2017-01-25 21:39:35.716 [ItemAddedEvent ] - Item 'Sunrise_Time' has been added.
2017-01-25 21:39:35.725 [ItemChannelLinkAddedEvent ] - Link 'Sunrise_Time-astro:sun:home:rise#start' has been added.
2017-01-25 21:39:35.736 [ItemStateChangedEvent ] - Sunset_Time changed from NULL to 2017-01-25T17:06:00.000-0600
2017-01-25 21:39:35.737 [ItemAddedEvent ] - Item 'Sunset_Time' has been added.
2017-01-25 21:39:35.747 [ItemChannelLinkAddedEvent ] - Link 'Sunset_Time-astro:sun:home:set#start' has been added.
2017-01-25 21:39:35.786 [ItemStateChangedEvent ] - Sunrise_Time_Ex changed from NULL to 2017-01-25T06:55:00.000-0600
2017-01-25 21:39:35.804 [ItemAddedEvent ] - Item 'Sunrise_Time_Ex' has been added.
2017-01-25 21:39:35.815 [ItemStateChangedEvent ] - Sunrise_Time_Ex changed from NULL to 2017-01-25T06:55:00.000-0600
2017-01-25 21:39:35.821 [ItemChannelLinkAddedEvent ] - Link 'Sunrise_Time_Ex-astro:sun:homeMinus60:rise#start' has been added.
2017-01-25 21:39:35.830 [ItemStateChangedEvent ] - Sunset_Time_Ex changed from NULL to 2017-01-25T17:06:00.000-0600
2017-01-25 21:39:35.830 [ItemAddedEvent ] - Item 'Sunset_Time_Ex' has been added.
2017-01-25 21:39:35.838 [ItemChannelLinkAddedEvent ] - Link 'Sunset_Time_Ex-astro:sun:homeMinus60:set#start' has been added.
2017-01-25 21:39:35.841 [ItemRemovedEvent ] - Item 'Sunrise_Time' has been removed.
2017-01-25 21:39:35.851 [ItemStateChangedEvent ] - Sunrise_Time changed from NULL to 2017-01-25T06:55:00.000-0600
2017-01-25 21:39:35.854 [ItemRemovedEvent ] - Item 'Sunset_Time' has been removed.
2017-01-25 21:39:35.865 [ItemStateChangedEvent ] - Sunset_Time changed from NULL to 2017-01-25T17:06:00.000-0600
2017-01-25 21:39:35.865 [ItemRemovedEvent ] - Item 'Sunrise_Time_Ex' has been removed.
2017-01-25 21:39:35.874 [ItemRemovedEvent ] - Item 'Sunset_Time_Ex' has been removed.
But if you look at it … the offset is not used (or perhaps just not placed in the DateTime Item). I have not actually put them in a trigger because I wasn’t getting the right values – maybe that doesn’t matter? Here is the output:
I got it to work but I found that if you want to have, for example, an event at Sunset and 90 minutes before Sunset you end up needing two Things anyway so I’ve stuck with the +/-15 degrees per hour trick for now since that was already working for me. I’ll probably go back to using the offsets at some point, but if the offset doesn’t adjust the DateTime Items then that wouldn’t work for me as I need both the events and the DateTimes for both Sunset and Sunset - 90 minutes.