Hi community,
I’m in need of some assistance on what i thought was going to be a simple rule. I’m no coder, so I’ve scavenged the forums for some working examples. Trying to catch a Tradfri remote’s (the round one with 5 buttons) button presses and do something with it.
Items file:
// LED1545G12 - IKEA TRADFRI LED bulb E26/E27 980 lumen, dimmable, white spectrum, opal white (Router)
Switch Kitchen_Light_Switch "Kitchen Light [%s]" (Ikea) {channel="mqtt:topic:mosquitto:0x000b57fffe8d8719:kitchenLightState"}
Dimmer Kitchen_Light_Brightness "Kitchen light brightness [%d %%]" (Ikea) {channel="mqtt:topic:mosquitto:0x000b57fffe8d8719:kitchenLightBrightness"}
// E1524/E1810 - IKEA TRADFRI remote control (EndDevice)
Number Office_Remote_Linkquality "Office remote link [%d]" <qualityofservice> (Ikea) {channel="mqtt:topic:mosquitto:0x000b57fffe8d3e46:officeRemoteLinkquality"}
Number Office_Remote_Battery "Office remote [%.1f %%]" <battery> (Ikea) {channel="mqtt:topic:mosquitto:0x000b57fffe8d3e46:officeRemoteBattery"}
String Office_Remote_Action "Office remote [%s]" (Ikea) {channel="mqtt:topic:mosquitto:0x000b57fffe8d3e46:officeRemoteAction"}
Rule file:
rule "OfficeRemote"
when
Channel "mqtt:topic:mosquitto:0x000b57fffe8d3e46:officeRemoteAction" triggered
then
//var actionName = receivedEvent.getEvent()
switch(receivedEvent.getEvent()) {
case "toggle": {
Kitchen_Light_Switch.sendCommand(OFF)
}
}
end
I know the items are working (can see them with values in the basic ui and turn the light on/of). Pressing the buttons on the remote changes the action value in basic ui, i just can’t seem to grab it in a rule.
How about using your Item for the trigger? There is actually a bug the the rules DSL with Channel triggers too. A benefit of using the Item for the trigger is that you can add it to a sitemap and perform the same functions through the UI.
rule "OfficeRemote"
when
Item Office_Remote_Action received update
then
switch(triggeringItem.state.toString) {
case "toggle": {
Kitchen_Light_Switch.sendCommand(OFF)
}
}
end