Astro binding issue?

Do you at least see the entries in the log? Like these examples:

08:05:00.001 [INFO ] [marthome.event.ChannelTriggeredEvent] - astro:sun:local:rise#event triggered START
08:09:00.001 [INFO ] [marthome.event.ChannelTriggeredEvent] - astro:sun:local:rise#event triggered END

Can you confirm you have the latest version of the Astro binding?

You can do that in Karaf:

> bundle:list | grep Astro
189 | Active   |  80 | 2.0.0.201612272212    | Astro Binding

There you can see I’m using the version built on the 27th of December.

Hello!

I’ve checked Karaf and I’m using Astro binding built on 27th too. I’ve checked logs too, and the events are definitely triggered. I think I might have found the root of the problem with a rule - after opening rules file in the Notepad++ I’ve found a strange hidden character between keyword Channel and the first quotation mark, instead of blank. I guess that was making a problem with triggering the rule. I’ll see if it will work tonight. Thank you for your help.

Best regards,
Davor

Hello!

Removing this hidden character from the rule solved a problem. Thank you all for your help.

Best regards,
Davor

Hi,

has anybody an example for me on how to specify the offset by config files instead of paper ui?

Best regards,
Ingo

1 Like

Hi @itheiss,

did you ever find this out? I’m also looking for such example… :slight_smile:

no. i have no clue how to specify this inside the configuration files :disappointed:

There’s an example in another thread showing the offset parameter and links to the updated docs:

To use config files only, I personally have:

astro.things:

astro:sun:local		[ geolocation="55.0,-1.0", interval=900 ]

The linked example then gives astro.items including the syntax to define an offset (e.g. to display the times on a sitemap). I’ve not seen (yet!) a worked example of rules with an offset trigger but as the feature has only just been added to the Astro binding, there are several people hard at work researching just this point…

Good luck!

Oh no … don’t blame me … I’m just guessing. But I’m working on it … See messages on down in that other thread as we continue to try (or if someone takes pitty on us). If I get it working I’ll post something there for sure.

Found a solution. Have a look here: https://community.openhab.org/t/astro-binding-to-move-switches-at-sunset-sunrise/18750/21

Hi @davorf,

I recently wrestled with triggering astro events and it works with the following setup:

rule "Lights on at sunset"
when
	Channel 'astro:sun:local:set#event' triggered START
then
	logInfo("Sunset", "Sunset rule trigerred!")
	postUpdate(Sunset_Event, ON)
end

Is that similar to what you have tried? (On OH2)

Hello!

My rule trigger looks exactly like that. The problem was hidden character between Channel and first quotation mark (I really don’t know how it got there), and it was shown only when I’ve opened rules file in Notepad++.

Best regards,
Davor

Hello @itheiss, @Ctrl-G, @UglyKidJoe and all the others out there. It would be a big help for everyone, if you could enhance the astro README.md with your findings.

You could enhance the descriptions or give more examples. Both would be great. You can either directly create a Pull Request for this file or create a simple Ticket proposing your changes. If you’ve got a nice set of configured items, rules and a sitemap arrangement around the astro binding, you could also post an article in the Tutorials & Examples category.

Thanks for giving back to the community! :tada:

1 Like
when
	Channel 'astro:sun:local:set#event' triggered START
then

I wonder about the choosen syntax for events…

To me the above feels a bit “on a different” level than other triggers used in rules. What I mean is that “normally” one creates items to hide these kind of details (the mapping to a particular channel of a particular thing).

It would have been more natural (to me at least) to define the following either in an .items file (or maybe in a new kind of .events file?):

Event SunriseEvent { channel = "astro:sun:local:set#event" }

and then use something along the lines of this in a rule:

when
	Event SunriseEvent changed to START
then

or maybe

when
	Event SunriseEvent triggered
then

Does anybody know why the choosen syntax was; eh… choosen?

Hi Thom,

I will gladly contribute to the documentation for this or any other bindings. Being relatively new to OH2 I can help identify where the documentation is thin as I mainly rely on step-by-step instructions, and if it’s not clearly written I would stumble.

Craig

I agree and I believe the answer is 1) nobody did define that item type yet and 2) the nature of this item is unclear as an event does not have a value at a given point of time. In OH1 the astro events were simulated by switches being switched on and back off immediately, which is a workaround.

The topic is discussed in this issue:

Feel free to take part in the discussion there :wink:

Sounds good. The first step (after stumbling) should be to create a ticket. Noting down your idea for improvement is the most important step, working out the details can still be done later by you or also others. Is there any area you would like to get active? I can help with the details.

I think I’ve made a pull request on the Astro ‘readme’ file:

I’ll contribute to the documentation through each step of my journey. I wen’t straight to OH2 as a beginner, so my focus would be entirely on OH2 implementations. Hopefully this approach can help eliminate some confusion between the two architectures. I found this to be a bit tricky as a novice. I’ll be mindful about where I can help along the way.

In the OH1 binding, I never understood why the switch state wasn’t defined to mean “the sun is UP” – so it is in the ON state all the time that the sun is up, and OFF all the time that the sun is down. So it’s conceptually no different than any other binary state condition. And of course, altering it by time offsets, say, 30 minutes after sunrise, would just mean the switch is ON from thirty minutes after sunrise, all the time until the ending offset. Any rule triggering on Item IsSunUp changed to ON would catch the moment of sunrise. Every time the job doing the calculation is run, it simply updates the bound switches to whatever the correct state is. Simples!

1 Like

Regarding the different events you might want to check here: Explanation of eveningNight and morningNight
As you can see the idea was I believe to have the event of the sun passing the horizon as one distinguishable state rather than “The sun is up”. Why? I don’t know. I also had a rule to generate this state.

Regarding the events: not everything can be represented as a switch between states. It’s possible of course but not always meaningful. I believe more motivation is available in the respective PRs.
Maybe @kaikreuzer wants to say a few more things regarding events/triggers. Many, me included, are still not quite familiar with this silently arising new concept.

I am referring to this section of the code:

/**
 * Publishes the item state ON/OFF for scheduled events.
 *
 * @author Gerhard Riegler
 * @since 1.6.0
 */
public class ItemJob extends AbstractBaseJob {

    @Override
    protected void executeJob(JobDataMap jobDataMap) {
        String itemName = jobDataMap.getString("itemName");
        context.getEventPublisher().postUpdate(itemName, OnOffType.ON);
        context.getEventPublisher().postUpdate(itemName, OnOffType.OFF);
    }
}

So the Astro 1.x binding toggles a switch item, instead of putting it into the state that means “the sun is up” (for example). The point is that a rule can easily trigger on changed to ON, but subsequently other consumers would want to know the binary state of the sun. One can of course add a rule and another item to represent this, but I never understood the reason to treat the condition only as a trigger instead of a change in state, directly from the binding without needing a rule to achieve it. The same thinking in the 2.0 binding of using a Trigger channel seems to apply, but I’m not sure of that.

By the way, thanks for the link. My thinking is each of the entries in the table could be:

MorningNight ON         00:00
MorningNight OFF        04:00
Night OFF               05:02
AstroDawn ON            05:00
AstroDawn OFF           05:45
NauticDawn ON           05:45
NauticDawn OFF          06:27
...
Night ON                21:33
EveningNight ON         21:33
EveningNight OFF        00:00