[SOLVED] Help wanted to get Astro rules working

Please follow the link to the documentation. There is a full example at the end.

I just try that but it don’t work? I try all exaples, also from vzoglub (@vzorglub, could you provide me of working examples?)

Do I always need to create a extra thing with a event in it?
See my first post for my Things, they don’t trigger my rules, even when I use the

Channel 'astro:sun:home:rise#event' triggered START

line

In fact, you don’t need to configure any Channel, 'cause they are already pre configured.
I recommend a step-by-step solution.

  1. install Astro2 Binding and ensure that it’s installed.
  2. Create one thing:
Thing astro:sun:home "Sun"  [ geolocation="52.5200066,13.4049540,100", interval=180 ]
  • and take a look at Paper UI -> Things. The thing named “Sun” should appear as online.
  1. Now try linking some channels to items. Check if the thing “sun” is shown with the linked channels in Paper UI Control page.

When changing settings for channels, take a look at Paper UI -> Things -> Sun -> Channels (the one with changed settings) -> edit (the pencil symbol) to see if the parameters changed accordingly.

For first setup, it’s advisable to use a short interval to ensure that all changes take place in time. interval is in seconds, so 180 would be 3 Minutes.

When the first thing seems to be ok, create another thing and check wether the two things are online.

I thought my code would work but I could be wrong. I’ll have to test in the morning

Yesterday I created a bunch of testrules to trigger on the sunrise.
This one was the winner!

Channel "astro:sun:home:rise#event" triggered START

thank you guys for your advise.

I have also another question:

Is it possible to create a rule for the following logic?

when
     <CRON rule for for example 6 am>
then
     IF <check if it is after (or before) sunrise>{
     <do stuff>
     }
end

If this “IF” part possible?

Have a look at this very useful post:

I still have problems. The rules (or channels) with the offset won’t trigger.
See my first post for the configuration.

I use the datetime offset, could that be the problem?
I see there is also a event offset, what is the difference between the two?

Displaying datetimes on the GUI

For triggering in rules.

I recommend to use autodiscovered astro things, much more easier to setup for offsets :grinning:
If you need more than one offset, define additional things manually (via PaperUI) …

autodiscovered? do you mean with the PAPERUI (INBOX) ?

I use the text config files so I can backup them easy (like I did on OpenHab 1.x)

Yes.

PaperUI config is stored in JsonDB and backed up automatically :heart_eyes:

If you still want to do it with manual things files:
your things definitions are completely wrong, see examples in the docs for correct setup:

https://www.openhab.org/addons/bindings/astro/#full-example

Could you tell me why things are they completely wrong, so I can learn from it?
I used the examples as input for my configuration (almost the same!)

I used the thing config for the SUN thing, I made two things because I want to use the real sun set and I want to use one with a offset.
For the second one I used the “datetime offset” example.

so I created the following things:

Thing astro:sun:home  [ geolocation="52.5200066,13.4049540,100", interval=1800 ]

Thing astro:sun:home_plus20  [ geolocation="52.5200066,13.4049540,100", interval=1800 ]{
	Channels:
		Type start : set#start[offset=20]
	}

I know that I used “THING” before the thing config, this is so documented somewhere in the openhab documents, the things are online in the paperUI so I let it be there.

I find the explanation for this binding not very clear.

First there are all the available channels in the “channels” chapter, I want to use the thing “sun” with the group “set” and the channel “start”

Then there is the chapter “trigger channels”. I assume that this are the channels that can be used to trigger rules? The one I need (I want to use the thing “sun” with the group “set” and the channel (called event here) “start”) are included.

So I assume that a basic astro thing setup without any offset (see my first thing) can be used to display the time (datetime item) and trigger a rule like this:

when
   Channel "astro:sun:home:set#event" triggered START
then

This is also (almost) the same as in the axample.

I also thought that this same rule trigger can be used for a Thing with a “datetime offset”, should be logic but seems to be not.

Could you please rewrite my thing config and rules so like they should be? and please add some comment so I can understand what I’am doing wrong?

No, this is not possible like said before.

No, I can’t because I’m not using astro things in a text file. Please see the docs for a working config.

Instead I still recommend to do it the usual way via PaperUI:

1

You will be up and running a working config in 30 seconds :grinning:

You need to do this for the “Sunrise Start Time” (or whatever you want to use) to display your chosen time in your sitemap and you need to do this for the “Range event” channel to trigger on it in rules. Both channels need to have the same offset and/or earliest/latest settings.

Ok, thank you.

In the paper UI, do you also need to create more than 1 thing?
1 without offset and 1 with offset?

If you need more than one offset: yes.

I need one with no offset end one with an offset

Yes, create two astro things.

I finaly found why my rules do not trigger!

When I change the offset for my astro thing it seems that the time is not recalculated to the new time (there is no rescheduling of the thing). Thats why my rules do not trigger while I’m testing my astro rules.

when I reboot my Openhab device, all things get scheduled and the rules are working.
It’s a small bug or something?

thanks for helping me guys!

No. The time is recalculated on changes/during openHAB restart and every night at 00:00:

2018-06-08 15:28:36.221 [INFO ] [thome.binding.astro.internal.job.Job] - Scheduled Astro event-jobs for thing astro:sun:shutterkitchen

2018-06-09 00:00:30.208 [INFO ] [thome.binding.astro.internal.job.Job] - Scheduled Astro event-jobs for thing astro:sun:shutterkitchen

is this in the openhab.log or event.log?