I have a rule that listens for Tradfri Scene button presses:
rule "Shortcut Button"
when
Thing "tradfri:0820:[gw-id]:65586" received update
then
logInfo("tradfri", "pressed")
// Do other stuff, e.g. set scene based on current scene
end
However this rule isn’t just triggered on button presses, but also when the gateway refreshes its config and therefore the button is not ONLINE, but UNKNOWN for a short moment. How do I get the status that is sent on button presses?
I don’t see any “Thing ‘tradfri:0820:[gw-id]:65575’ changed from […]” when the button is pressed in the log.
In the first place I’d trigger upon an Item rather than the Thing. That would remove a need to distinguish inside the rule. I don’t know Tadfri but possibly there’s also a channel trigger ?
Or you might be able to retrieve the thing status.
You can use ScriptServiceUtil.getItemRegistry.getItem(<name>) to access the item by name and I think a similar possibility exists for Things. Don’t know code off the top of my head but I think have seen it on the forum.