Simple Astro-rule, not working

I’m trying out a simple astro-rule, according to information I think it should be working according to the attached code… I can see in my openhab-log that the event occurs…but the rule is not triggered… greatful for advice!

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import org.joda.time.*
import java.util.Date

rule "my astro-rule"
when
        Channel 'astro:sun:local:set#event' triggered START
then
        light1.sendCommand(ON)
        light2.sendCommand(ON)
        light3.sendCommand(ON)
end

Hello!

Could you paste a part of the OH log with an event being triggered?

Best regards,
Davor

Which version, 1 or 2?
According to your imports you are using openHAB1: astro 2 will not work with openHAB1
If you are using openHAB2:
check if your things is defined as “local”, because there is a mixup (not error) in the docs: manually created things example is “home”, but if you define astro thing through PaperUI it is “local”.

Thanks for the reply, I do use openhab2 and probably also astro2(?)… so this way of monitoring the channel does not work then ?

The imports are there because I dont know what Im doing :wink:
To be honest (as mentioned in another thred) I havent found any information of how to decide what to import and when …:confused:

Most rules don’t need imports anymore with OH2. There really isn’t any documentation, but as of right now none of my rules have required an import.

I believe you need to have

sendCommand(light1,ON)
sendCommand(light2,ON)
sendCommand(light3,ON)

A good place for sample rules is here, note though it was written for OH1 so it still has the imports:

https://github.com/openhab/openhab/wiki/Samples-Rules

Hello!

Actually, [Item name].sendCommand is preferred syntax, so, it’s definitely not a syntax problem.

From the other thread:

Best regards,
Davor

To clarify:
openHAB1 works with 1.x bindings while openHAB2 works with 2.x AND 1.x bindings.

So let’s start from an earlier point, assuming you are using PaperUI and not text based files.

Check PaperUI -> Add-Ons -> Bindings if you have installed the “Astro Binding” and not the "Astro Binding (1.x)"
Go to PaperUI -> Things and check if you have the thing Astro Sun data available and it’s online.
If not click on the “+” sign and let the Astro binding autodiscover the Astro Sun data thing.
Then click on the thing Astro sun data and add an item to the channel Sun Event Start Time
Now you have an item linked to the sun event channel and you should be good to go.

If you have done all that before I guess you only have to change
Channel 'astro:sun:local:set#event' triggered START to
Channel 'astro:sun:home:set#event' triggered START

If you are using text base things and items files it’s a little different story though …

Edit: and you should see in your openhab.log (after restart) something like:

2017-01-10 09:31:58.804 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled astro job-daily-sun at midnight for thing astro:sun:home
2017-01-10 09:31:58.809 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled astro job-positional with interval of 300 seconds for thing astro:sun:home
2017-01-10 09:31:59.548 [INFO ] [.astro.internal.job.AbstractDailyJob] - Scheduled astro event-jobs for thing astro:sun:home
1 Like

Unfortunately still no luck…
I changed my code to:

rule "my astro-rule"
when
         Channel 'astro:sun:home:set#event' triggered START
then
        light1.sendCommand(ON)
        light2.sendCommand(ON)
        light3.sendCommand(ON)
end

Nothing happens…but I can see in the log that the event took place:

2017-01-10 15:27:00.008 [ChannelTriggeredEvent ] - astro:sun:local:set#event triggered START

I tried around some more and ended up with my first line " Channel ‘astro:sun:local:set#event’ triggered START" which now worked today!!

Is the system very sensitive about if you’re doing spaces or tabs or so in your rules-files? if you have hit enter at the end of the lines or not ??