Switch with mapping to trigger rule not working

Sitemap

	Frame label="Scenes" {
		Switch item=SceneSwitch icon="colorlight" mappings=[ALL_OFF="Afsluiten", MOVIE="Movie", COZY="Cozy"]
	}

Items

Switch Switch_A { channel="rfxcom:lighting4:usb0:switch_17493:command" }
Switch Switch_B { channel="rfxcom:lighting4:usb0:switch_17685:command" }
Switch Switch_C { channel="rfxcom:lighting4:usb0:switch_17733:command" }
Switch Switch_D { channel="rfxcom:lighting4:usb0:switch_17745:command" }

Dimmer DIMMER_TAFEL "Tafel [%d %%]" {  channel="zwave:device:52a72468:node2:switch_dimmer" }
Dimmer DIMMER_PLAFOND "Plafond [%d %%]" {  channel="zwave:device:52a72468:node3:switch_dimmer" }

String HUB_ACTIVITY { channel="harmonyhub:hub:HarmonyHubFonteinstraat:currentActivity" }

String SceneSwitch "Scènes"

Rules

rule "Process Scene Changes"
when
	Item SceneSwitch received update
then
	logInfo("Scene: ", SceneSwitch.state.toString())
	if ( SceneSwitch.state == "COZY" ) {
		sendCommand(Switch_A, ON_1)
		sendCommand(Switch_B, ON_1)
		sendCommand(Switch_C, ON_1)
	}
	if ( SceneSwitch.state == "MOVIE" ) {
		sendCommand(Switch_A, ON_1)
		sendCommand(Switch_B, ON_1)
		sendCommand(Switch_C, OFF_0)
	}
	if ( SceneSwitch.state == "ALL_OFF" ) {
		sendCommand(Switch_A, OFF_0)
		sendCommand(Switch_B, OFF_0)
		sendCommand(Switch_C, OFF_0)
		sendCommand(DIMMER_TAFEL, OFF)
		sendCommand(DIMMER_PLAFOND, OFF)
		harmonyStartActivity("PowerOff")
	}
end

Lights are not switching (not via rfxcom, not via zwave) and appliances are not switched off.
Any tips are welcome.

Probably worth looking at

I changed the item to String but it doesn’t change a thing.

Well now that you have a “switch” capable of three states …
Are you expecting it to receive updates? The UI sends Commands to Items

I’m not sure what you mean. I’m expecting to trigger the rule by pressing one of the buttons and execute the commands depending on the state of the switch.

Assuming that your log entries show a correct state gets received(e.g.: Scene: COZY) i would suggest:
In the if statements, change to: SceneSwitch.state.toString
The ZWave Dimmers should react, but i doubt the sendCommand(Switch_A, ON_1) will work. As mentioned, Switches take only two commands: ON or OFF.

1 Like

Okeydoke; your current trigger looks for an update. Pressing a UI button generates a command. These two kinds of events are quite distinct in OpenHAB.

when
	Item SceneSwitch received command
1 Like