Jython error when adding rule

Raspberry Pi 4 Model B Rev 1.1 / 4GB
openHAB 3.1.0.M4

I’m in the weeds trying to understand writing a Jython Rule … I’m sure I have many issues but I’m currently trying to understand something very basic with the following code:

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

@rule("Hall Bath Motion test", description="Turn on the Hall bath light when motion detected")
#@when("Item Kitchen_Motion received update") 
@when("Item Hall Bath Motion received update") 
def Hall_Bath_Motion(event):
    Hall_Bath_Motion.log.info("Hall Bath Motion Detected")

Generates the following error:

2021-05-07 10:55:39.640 [DEBUG] [jsr223.jython.core.rules            ] - Added rule 'Hall Bath Motion test'
2021-05-07 10:55:39.643 [ERROR] [ore.common.registry.AbstractRegistry] - Cannot inform the listener "org.openhab.core.automation.internal.RuleEngineImpl$2@421885" about the "ADDED" event: Value not a number in cron expression 'Item Hall Bath Motion received update' in field 'DayOfWeek': For input string: "UPDATE"

But if I use
@when("Item Kitchen_Motion received update")
instead of
@when("Item Hall Bath Motion received update")

Everything works as expected … so, the question is … what could possibly be different between the two Items (Hall Bath Motion and Kitchen_Motion)? There are both Zigbee devices and work fine in other scripts.

Any guesses?

That is not and can not be an Item name. It may be an Item label but spaces are not allowed in an Item’s name. You must use the Item’s name in a rule as the Item’s name is the only thing guaranteed to be unique about an Item.

1 Like

Thanks Rich - Yes that was it … (wasted a few hours going down rabbit holes since the error message was so opaque :slight_smile: … I am going back through my naming scheme to be more consistent … thanks for the quick response :slight_smile: