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.
Check if you have the correct thing:
In PaperUI, you should see a channel astro:sun:local:set#start
If you see astro:sun:home:set#start, you need to change your rule to Channel 'astro:sun:home:set#event' triggered START
add a loginfo to your rule:
rule "ImpostaNotte"
when
Channel ‘astro:sun:local:set#event’ triggered START
then
logInfo(“FILE”,“Sunset event has been triggered”)
sendCommand(Notte, ON)
end
(Don’t forget to use the correct name local or home according to your defined thing)
Then take a look in to your openhab.log if it says “Sunset event has been triggered”.
If this is the case your switch definition may be wrong (you could try using Notte.sendCommand(ON)
that I want to change when the sun starts to go down (nightTime on/dayTime off) and when it has finished rising (nightTime off/ dayTime on).
I have created sun and moon things for the astro binding
rule "Set day time"
when
Channel 'astro:sun:home:rise#event' triggered START
then
sendCommand(nightTime, OFF)
sendCommand(dayTime, ON)
end
rule "Set night time"
when
Channel 'astro:sun:local:set#event' triggered START
then
sendCommand(nightTime, ON)
sendCommand(dayTime, OFF)
end
It doesn’t seem to work though. The switches never change their states. Where is the error? And are these the right channels for my needs?
I am using openhab version 4.0.8 and the version of astro that gets installed via the paperUI.