Door Sensor state change not triggering rule

I’ve got a Z-Wave Door Sensor (Aeotec ZW120 Door/ Window Sensor Gen5) that I am wanting to use to trigger a light when the door is opened or shut.

Background:
I am also currently testing OpenHAB4. So to test migrating from 3 (OH 3.4.4), I backed up my configuration from OH3 and imported it into my OH4 instance. Fresh install in same VM. Using snapshots to move between the two.

  • Everything that I already had seemed to be working fine.
  • The rule was being added to the new instance, not migrated from the old.
  • The Script to toggle the light works. I built it in Blockly and tested it before adding it to the rule.

So I know the script is definitely not the issue.

The rule is meant to look for a change in door sensor status and fire off the rule:

	configuration: {}
	triggers:
	- id: "1"
		configuration:
		itemName: DoorSensor01frontz005_DoorSensor
		type: core.ItemStateChangeTrigger
	conditions: []
	actions:
	- inputs: {}
		id: "2"
		configuration:
		considerConditions: false
		ruleUIDs:
			- UUID_number
		type: core.RunRuleAction
	- inputs: {}
		id: "3"
		configuration:
		message: Door status changed
		type: notification.SendLogNotification

Nothing. No change of lights. No message in the logs. No state change. No commands.

I then reverted back to OH3 and copied the rule across (recreating the Script and replacing the UUID in the rule) and it works perfectly.

Which now also tells me that the rule itself works. In OH3, at least.

	2024-04-01 11:01:58.970 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'HueBulbTableLamp_Brightness' received command ON
	2024-04-01 11:01:58.971 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'HueBulbTableLamp_Brightness' predicted to become ON
	2024-04-01 11:01:58.974 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'HueBulbTableLamp_Brightness' changed from OFF to ON
	2024-04-01 11:02:00.321 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorSensor01frontz005_DoorSensor' changed from OPEN to CLOSED

	==> /var/log/openhab/openhab.log <==
	2024-04-01 11:02:00.323 [DEBUG] [o.openhabcloud.internal.CloudService] - Sending log message 'Door status changed'

Nothing like this shows in the OH4 logs.

I’m also noticing that the OH3 logs show other status changes too. Like Wattage numbers. These don’t show up in the OH4 logs but do get registered in InfluxDB.
The same is true for the door status. Nothing shows up in the logs but it is being updated in InfluxDB.

It also seems a motion sensor light triggering rule isn’t working. I didn’t notice that at first due to its location and the fact that I did the test upgrade outside of that room’s schedule.
Went into the room to check whilst still on OH4, light didn’t go on. Went in after switching back to OH3, light went on.

Something about status changes either isn’t triggering rules or isn’t properly registering at all. But I’m at a loss as to why.

I can’t have both running at the same time, so what should I be looking out for when I next switch it over to troubleshoot?

This could just be a difference in the logging configuration for openhab.event.ItemStateChangedEvent

Add a script action and in the script, issue a log info command. I’m guessing that the rule did trigger just fine.

Maybe your openhab cloud isn’t configured properly? (notification.SendLogNotification is related to the openhab cloud, not a plain log4j log if I’m not mistaken. I’m not familiar with this particular action)

Do you have a rule with UUID_number as its UID and what does that rule do?

Possibly. As I said, it affects other triggered rules as well so something has changed in how those are logged or processed, and/or I haven’t accounted for it in some other place.

It’s not calling the script. I know the script works, even in OH4, as I can manually trigger it.

Nothing in the rule is being actioned. It should call the script and add a note in the lgos every time the door is opened or closed.
Nothing’s happening.

This is all local. I do have the cloud setup too, so things are likely being logged for that as well, but that is separate to this issue.

Or should be.

Yes.

This is the script that is being called. The number differs in each installation but it works in OH3. And, as mentioned, technically works in OH4 but isn’t being called.

OK. Strike all that…
Here we have a caultionary tale of upgrading form OH3 to OH4. Giving details in case anyone else runs into a similar issue with scripts when upgrading and stumbles upon this tread.

So, for some reason, when importing the backup form my OH3 setup into a fresh OH4 installation, it sort got confused as to what version is was on.

Help & About showed it as still on v3.4 and the settings menu still had the OH3 layout. But running openhab-cli info did show it as being v4.1.1.

I then used apt to reinstall openhab.

It still had all my setitngs but was now correctly showing as v4.1.1 and had the new menu layout.

When I then looked as the automation addons, it was showing as not having JavaScript Scripting (Nashorn) installed. But it had looked to be installed previously.

So I installed it. Now upon checking the script, it gave me the option to chose the scripting type and allowed me to re-save. And it’s finally working.