Invalid Trigger Definition for Astro Channel Item

Tags: #<Tag:0x00007f617bce9be8> #<Tag:0x00007f617bce9940>
  • Platform Information
  • Hardware: Raspberry Pi 3B+
  • OS: Raspberry Pi OS (32 Bit - Buster)
  • Java Runtime Environment:
  • openjdk version “1.8.0_152”
  • OpenJDK Runtime Environment (Zulu Embedded 8.25.0.76-linux-aarch32hf) (build 1.8.0_152-b76)
  • OpenJDK Client VM (Zulu Embedded 8.25.0.76-linux-aarch32hf) (build 25.152-b76, mixed mode, Evaluation)
  • Jython 2.7.0
  • openHAB 2.5.5 (Release Build)

Hello Community,

I’m migrating my rules to the NGRE, and I ran across across a warning that the rule was not created due to an invalid trigger definition. Can anyone tell me why the trigger definition is invalid? For reference, I’ve listed the original (and now archived) Rules DSL rule as well.

Warning

2020-06-08 20:39:57.044 [WARN ] [jsr223.jython.core.triggers         ] - when: "Channel astro:sun:local:civilDusk#start triggered START" could not be parsed because Channel "astro:sun:local:civilDusk#start" is not a trigger
2020-06-08 20:39:57.050 [WARN ] [jsr223.jython.core.rules            ] - rule: not creating rule [Front Porch Lights On at Civil Dusk] due to an invalid trigger definition

Items

DateTime    Civil_Dusk_Start_Time    "Civil Dawn Start Time [%1$tH:%1$tM]"    { channel="astro:sun:local:civilDusk#start" }
Switch    Front_Porch_Lights    "Front Porch Lights"    <switch>    (gInsteon)    { channel="insteon:device:23F01B:switch" }

NGRE Rule (Python)

from core.rules import rule
from core.triggers import when
from core.actions import ScriptExecution

@rule("Front Porch Lights On at Civil Dusk")
@when("Channel astro:sun:local:civilDusk#start triggered START")
def front_porch_lights_on_at_civil_dusk(event):
    events.sendCommand("Front_Porch_Lights", "ON")
    front_porch_lights_on_at_civil_dusk.log.info("Rule: 'Front Porch Lights On at Civil Dusk' fired.")

Rules DSL Rule // Original Rule (Archived)

rule "Front Porch Off at Dawn"
  when
    Channel 'astro:sun:local:civilDawn#event' triggered START
  then
    Front_Porch_Lights.sendCommand(OFF)
  end

Regards,
Burzin

This is a Trigger Channel.

This is not a Trigger Channel, so the validation fails and the rule is not loaded. The astro binding provides these Trigger Channels…

I attempted to explain the difference in the docs…

https://openhab-scripters.github.io/openhab-helper-libraries/Guides/Triggers.html#channel-event

I’m still missing something. What am I missing?

https://openhab-scripters.github.io/openhab-helper-libraries/Guides/Triggers.html#channel-event says:

Channel triggers allow you to catch events from bindings using Channels. You can find Channel names and events in the documentation for the binding.

Note Only trigger Channels can be used with this trigger, same as in the rules DSL. If not using a trigger Channel, you will receive a validation error when saving the script. The binding documentation will identify which Channels, if any, are trigger Channels.

Python
@when(“Channel CHANNEL:NAME triggered [EVENT]”)

The above seems clear enough, I must not be using a trigger channel defined in the binding. However, the Astro binding list CivilDusk as a trigger channel

https://www.openhab.org/addons/bindings/astro/#trigger-channels says:

Trigger Channels

  • thing sun
    • group rise, set, noon, night, morningNight, astroDawn, nauticDawn, civilDawn, astroDusk, nauticDusk, civilDusk, eveningNight, daylight
      • event START, END

These are the rule Triggers that can be used for the civilDusk Channels…

@when("Channel astro:sun:local:civilDusk#event triggered START")
@when("Channel astro:sun:local:civilDusk#event triggered END")

All of the astro Trigger Channels end with #event.

1 Like

Better to look at it that CivilDusk has a trigger channel, as well as some state channels.

A complete channel definition
astro:sun:local:civilDusk#start
That one is not a trigger channel
astro:sun:local:civilDusk#event
This one is a trigger channel

Thank you @5iver and @rossko57. It makes sense now.