[solved] Rules do not work

Hi, I built my first rules, but they do not fire, even not the time-ones. Any ideas?

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*

/********** Aktionen **********/

/** Sonnenuntergang ** /

rule "Aktionen_bei_Sonnenuntergang"
when
    Channel 'astro:sun:28bc7fcd:civilDusk#event' triggered START
then
    sendCommand(flur_kugel, ON)
    sendCommand(gGartenLichtStandard, ON)
end


/** Sonnenaufgang **/

rule "Aktionen_bei_Sonnenaufgang"
when
    Channel 'astro:sun:28bc7fcd:civilDawn#event' triggered START
then
        sendCommand(flur_kugel, OFF)
end


/** Zeitpunktgesteuert **/

rule "um 23:00 Uhr"
when
    Time cron "0 0 23 * * ?"
then
    sendCommand(gGartenLichtStandard, OFF)
end

// testrule
rule "um 21:25 Uhr"
when
    Time cron "0 25 21 * * ?
then
    sendCommand(wz_vitrine, ON)
end

damned - it was a typo, forgot ", seen in the syntax-highlighting here …:grin:

I assume according to your rule that you are using OH2!
First of all, you do not need to import any openhab or esh packages!
As a preliminary question: are you using the Eclipse Smarthome Designer?
If yes, do you see any error with the trigger referring to Channel xxx?

BR,
George

Hi, thank you for your reply.
I removed the imports.

But now, my problem is, that the action on civilDusk and civilDawn does not work. Any ideas?

KR - Markus

What does your events.log say at the time of civilDusk and civilDawn?
there should be something like:

2017-04-01 06:30:00.025 [ChannelTriggeredEvent     ] - astro:sun:local:civilDawn#event triggered START

which brings me to the next point: your chanell name “astro:sun:28bc7fcd:” seems odd. did you choose that on purpose and does it match the chanell name shown in the log/paperUI?

Have you installed the Astro binding correctly?

In your *.things file you must have something like:

astro:sun:home [ geolocation=“52.9093963,4.3480191”, altitude=100, interval=60 ]
astro:moon:home [ geolocation=“50.9093963,4.3480191”, interval=60 ]

With your own geolocation

Next

Look in your events.log en see if you habe ivents like “astro:sun:home:daylight#event triggered END”

Hi, I think, it works fine:

2017-04-02 20:06:00.008 [ChannelTriggeredEvent     ] - astro:sun:local:civilDusk#event triggered START
2017-04-02 20:06:00.011 [ChannelTriggeredEvent     ] - astro:sun:local:set#event triggered END
...
2017-04-02 20:08:00.003 [ChannelTriggeredEvent     ] - astro:sun:28bc7fcd:set#event triggered END
2017-04-02 20:08:00.004 [ChannelTriggeredEvent     ] - astro:sun:28bc7fcd:civilDusk#event triggered START
2017-04-02 20:08:00.006 [ChannelTriggeredEvent     ] - astro:sun:home:set#event triggered END
2017-04-02 20:08:00.008 [ChannelTriggeredEvent     ] - astro:sun:home:civilDusk#event triggered START

But why do my rules not fire? …

Uh…you should have only one thing,not three:
astro:sun:local:
astro:sun:28bc7fcd:
astro:sun:home:
That is not OK. I have no idea how you even managed to do that.
Check your setup, all chanells should be tied to only one thing (e.g. astro:sun:28bc7fcd: )
Once you have sorted that out start thinking about why the rule does not work(and i see a solid chance it will work once this is fixed)

Hi, ok, I’ll try. I added a thing for astro manually, that’s why it has the ID.

Cleaned up my astro-settings, but that did not solve my problem. The solution was to fix a typo. I did not close the mass-comment. :rage:

I’m struggling with the same. I’m a ‘fresh’ beginner, 3 days in, so posting under beginners.
I run on a windows server - latest release version openhab2.

I have the events in the log:
2017-05-27 05:39:00.008 [ChannelTriggeredEvent ] - astro:sun:local:daylight#event triggered START
2017-05-27 05:39:00.011 [ChannelTriggeredEvent ] - astro:sun:local:rise#event triggered START

My rule won’t fire.

// Imports
import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*

// Global Variables

rule "example trigger rule"
when
        Channel 'astro:sun:local:rise#event' triggered START    		 

then
	MqttUpdate.postUpdate("astro:sun:local Channel trigger fired")
	pushsafer("DXL81o4a2HUALnFmW5Hp","Sunset event triggered!")
        sendCommand(WandContactSchakelaar3Command,ON)
end

So I googled, and searched. And finally found what might be the reason. In the latest release, the rules were not responding to ChannelTriggered Events? In any case I downloaded nightly build and trying again. pullrequest

I have 3 questions:

  1. Was the rule trigger mechanism broken in latest release, so I can see different results now? If not, how to debug?
  2. Is there an easy way to debug a ChannelTriggered Event that only takes place a few times a day? Any other binding that fires ChannelTriggered Events regularly?
  3. (offtopic) I would like to request a feature, but cannot find MQTT binding in github under Add-ons. State’s and Commands are posted to MQTT, but not ChannelTriggeredEvents. Can that be added?

Thanks!

I’m running OH2 on windows 10.

I found that if I had any CRON rules, however I wrote or copied them from working examples, not only did they fail to trigger reliably, but that they would interfere with the triggering of ASTRO events.

I eliminated CRON triggers and the ASTRO events starting triggering as expected. I then used these with timers instead of the few CRON triggers I wanted.

I wasn’t sure how to identify what the actual issue with my CRON statements was, so I haven’t raised an issue so far.

Well - I have a CronRule as well, in the same file. I will eliminate it, see if that will allow it to fire.

Will report back. Shame it only fires 2 times per day to debug/test

Remove it and reset OH2

I had CRON statements across 4 rules files. They all had to be removed.

I found that I could use the ASTRO events (with or without timers) to trigger the things I was using CRON for. If I needed something very regularly firing, then the updating of my NEST thermostat provides a good regular trigger.

Ok, Both the Cron-job and the rules live happily side by side;
Hence issue solved; Can’t give you a how or why, have to write it off to noobishness.