[SOLVED] Rule to detect change in light


(Avner) #1

I have a rule to detect when the Ikea Tradfri light is turned on

rule "FF bathroom hall light"
when
 Item Light_FF_Bathroom_Hall received command ON
then
 sendBroadcastNotification("Light_FF_Bathroom_Hall is ON")
end

The rule runs ok, and I get notification when I turn the light via the OpenHab Habpanel GUI.

I can also turn the light off/on via a Ikea Tradfri remote control, in which case, openhab reacts well and knows that the light has turned on:

  • the state in habpanel changes to turned-on
  • a log message appears in openhab.log
  2017-08-27 09:05:56.905 [ItemStateChangedEvent     ] - Light_FF_Bathroom_Hall changed from OFF to ON

How do I change the rule, to detect when the light changes, when the change is triggered outside from OpenHab?

Thanks


(Avner) #2

By changing the rule from

 Item Light_FF_Bathroom_Hall received command ON

to

 Item Light_FF_Bathroom_Hall received update

causes a notification when the light is turned-on outside openhab (e.g. via the Ikea remote control device), but the notification is coming also when the light is turned off.

Changing to

 Item Light_FF_Entrance changed from OFF to ON

solved the problem.