Execute Commandline will only be executed when state is "OFF"

This Rule worked great under OH 1.x but now it doesn’t.

rule "SmartMirror Power"
when
	Item SmartMirrorPow changed
then
	if (SmartMirrorPow.state==ON && ZWMot2.state==CLOSED){
		if (SmartmirrorDSP!=null){
			SmartmirrorDSP.cancel
			SmartmirrorDSP=null
		}
		executeCommandLine("ssh@@pi@smartmirror@@./tv.sh "+SmartMirrorPow.state)
		SmartmirrorDSP = createTimer(now.plusMinutes(5)) [|
		sendCommand(SmartMirrorPow, OFF)]
	}
	
	if (SmartMirrorPow.state==ON && ZWMot2.state==OPEN) {
		if (SmartmirrorDSP!=null) {
			SmartmirrorDSP.cancel
			SmartmirrorDSP=null
		}
		executeCommandLine("ssh@@pi@smartmirror@@./tv.sh@@"+SmartMirrorPow.state)
	}

	if (SmartMirrorPow.state==OFF) {
		if	(SmartmirrorDSP!=null) {
			SmartmirrorDSP.cancel
			SmartmirrorDSP=null
		}
		executeCommandLine("ssh@@pi@smartmirror@@./tv.sh@@"+SmartMirrorPow.state)
	}		
end

When i look at the logs, i will only see the “OFF” command:
2016-10-18 15:49:33.226 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine '[ssh, pi@smartmirror, ./tv.sh, OFF]'

what does the tv.sh? it is located at the remote host /home/pi/tv.sh and “translates” the openhab ON/OFF state to a state that can be interpreted by the tvservice script. (It switches the display on or off)

#!/bin/bash
if   [ "$1" = "OFF" ]; then
        /opt/vc/bin/tvservice -o
elif [ "$1" = "ON" ]; then
        /opt/vc/bin/tvservice -p
fi

Why does it only execute the “OFF” part of my rule?

Thanks

You should logInfo your ZWMot2.state to see what the values are… I wonder if it’s value is coming in as different than OPEN and CLOSED?

@jflarente you are right,
Since i upgraded to OpenHAB 2 the value of a motion sensor will be defined as a switch (ON, OFF).
I changed it in the necessary file for the lights(which also toggles SmartmirrorPow), therefore i wondered why the smartmirror command is not executed.

A common phrase describes my situation really good:
to not see the forest for the trees
(more popular in German: Den Wald vor lauter Bäumen nicht sehen)

Thanks for your hint :slight_smile: