Trigger text output if number changed to 1

Dear all,

I have a Fibaro Motion Sensor that is showing a 1 or 0 respective of detected motion. I tried to set up a map that converts the 1 to “motion” or “Bewegung” in German. This did not work. However, I understood that some bindings do not support maps. Hence, I simply thought to set up a rule, i.e. if number item of MotionSensor changed to 1 then write to text item “motion detected” or “Bewegung” in German. I tried to play around with different woring in rules and I was looking in the forum but without success. The same issue exists with my KNX motion sensor.

My surely wrong rule looks like:

rule "Show Motion"
var motion = Item FibEye_Motion as Integer 
when Item FibEye_Motion received update
then
if (motion = 1)
postUpdate(FibEye_Bewegung, "Bewegung")
if (motion = 0)
postUpdate(FibEye_Bewegung, "Keine Bewegung")
end

FibEye_Motion is my number item with the Z-Wave Binding that shows a 1 or 0. The FibEye_Bewegung is a String item that should show in text if there is motion.

Any ideas about how to deal with this?

Best regards,
Sebastian

[quote=“Sebastian_OpenHAB, post:1, topic:17077”]
I habe a Fibaro Motion Sensor that is showing a 1 or 0 respective of detected motion.[/quote]

How did you manage to get that?
Normally the motion channel is defined as contact or switch item and you will get a Open/Closed or Off/On, then you can trigger your rule based on that.

I simply defined the respective channel as a number item. Anything else did not work. I get a 1 if motion is detected.

You cannot declare a var in the when clause of a rule. If you mean it to be a global move that line above all of your rules in that file.

Just if anybody else has the same issue:

rule “Show Motion”

when Item FibEye_Motion changed

then

if (FibEye_Motion.state == 1)

sendCommand(FibEye_Bewegung, “Bewegung”)

else

sendCommand(FibEye_Bewegung, “Keine Bewegung”)

end