OH3/Zigbee2Mqtt: IKEA TRADFRI Remote and Bulb including custom Color Scenes (arrow buttons left/right)

This instruction is to get all functions of the Ikea remote in combination with a light without using the Ikea gateway. Instead it uses openhab and zigbee2mqtt with the advantage not only to switch predefined color profiles but allows to create own color scenes and switch between them.

[NOTE] You will notice that the arrow buttons (left/right) are not working out of the box. I struggled a long time fixing this. Unfortunately with newer firmware for the devices the GROUP information does not work (it’s always NULL).
Here is a discussion on this Topic: IKEA TRADFRI remote control, color temperature not working · Issue #1232 · Koenkk/zigbee2mqtt · GitHub

Assuming you have openhab set up and running as well as zigbee2mqtt. I did the zigbee2mqtt setup using the official instruction from zigbee2mqtt.

https://www.zigbee2mqtt.io/guide/installation/

Make sure openhab has the needed transformation add-ons installed:

Javascript Transformation and JSONPath Transformation

My environment - Software/Firmware Versions:
Openhab: 3.2.0 (running in a linux virtual machine on a Synology NAS)
Zigbee2mqtt: 1.24.0, Conbee II USB Stick
Ikea Remote: Model: E1524/E1810, FW: 2.3.080
Bild16

Ikea Light Model: LED1924G9, FW: 1.0.021
LED1924G9

Zigbee2mqtt

[1] Pair IKEA remote and Light over the Frontend.
In my case I have the remote as “ZB_Ikea_Remote_6” and the light bulb as “ZB_Ikea_Licht_6” connected.
Bild1

[2] To make the On/Off and Brightness to work (even when openhab and zigbee2mqtt is not running) you need to set some bindings for the device.

Devices > ZB_Ikea_Licht_6 > Bind
(make sure to wake up the Remote by pressing a button right before adding the binding)
Bild2_

[3] Creating a group for Light and Remote:
Add a new group in zigbee2mqtt “Ikea Licht 6” and added the remote and light to that group.
Bild3

[4] Create scenes for the light
This is to store your preferred scenes for recalling them in openhab.

Devices > “ZB_Ikea_Light_6” > Scene
Doing so set the light to the wanted color and brightness for the scene. Then give it a scene ID (starting at 0) and a friendly name. Store all the different scenes for the group.
Bild4

[5] Enable reporting for the remote arrow buttons through zigbe2mqtt. The setup should look like this and include “Scenes” in the binding…

Device “ZB_Ikea_Remote_6” > Bind
Bild5_
Including “Scenes” in the binding enables the report for “arrow_left_click” and “arrow_right_click” over mqtt.

Openhab 3:

[1] Add thing to openhab linked to your mqtt broker: “ZB_Ikea_Licht_6”

Administration > Settings > Things > Add > MQTT Binding > Generic MQTT thing

ZB_Ikea_Licht_6:

[2] Add the channels for the light.

  • On/Off switch
  • Dimmer
  • Color
  • Scenes

Here are the configurations I use:

ZB_Ikea_Light_6
Bild8

ZB_Ikea_Licht_6_OnOff:

zigbee2mqtt/ZB_Ikea_Licht_6/state
zigbee2mqtt/ZB_Ikea_Licht_6/set
ON
OFF

ZB_Ikea_Licht_6_Dimmer:

zigbee2mqtt/ZB_Ikea_Licht_6/brightness
zigbee2mqtt/ZB_Ikea_Licht_6/set/brightness
0
255

ZB_Ikea_Licht_6_Color:

select “CIE xyY”
zigbee2mqtt/ZB_Ikea_Licht_6
zigbee2mqtt/ZB_Ikea_Licht_6/set
JSONPATH:$.color
{“color”:{“x”:%s, “y”:%s},“brightness”:%s}

ZB_Ikea_Licht_6_Scenes:

zigbee2mqtt/ZB_Ikea_Licht_6
zigbee2mqtt/ZB_Ikea_Licht_6/set
{“scene_recall”:%s}

[3] Add thing to openhab linked to your mqtt broker: “ZB_Ikea_Remote_6”

Administration > Settings > Things > Add > MQTT Binding > Generic MQTT thing

ZB_Ikea_Remote_6:

[4] Add the channel for the remote.

  • Buttons left / right

Here are the configurations I use:

ZB_Ikea_Remote_6_LeftRight:

zigbee2mqtt/ZB_Ikea_Remote_6
JSONPATH:$.action

[5] Add a Rule to handle the left / right buttons to switch scenes. Make sure the variable “maxscene” matches the maximum scene ID you configured for the group in zigbee2mqtt.
In this example I have scenes 0, 1 and 2.

rule "Ikea Remote/Light 6 Color switch"
    when
        Item ZBIkeaRemote6_ZBIkeaRemote6LeftRight received update
    then
        logInfo("Rule", "message: " + ZBIkeaRemote6_ZBIkeaRemote6LeftRight.state.toString)
        var Number maxscene = 2 // 
        var Number currentscene = ZBIkeaLicht6_ZBIkeaLicht6Scenes.state
        if (currentscene < 0){
            currentscene = 0
        }       
        if (currentscene >= 0){
            switch (ZBIkeaRemote6_ZBIkeaRemote6LeftRight.state.toString){
                case "arrow_right_click" : {
                    if (currentscene < maxscene){
                        currentscene += 1
                        ZBIkeaLicht6_ZBIkeaLicht6Scenes.sendCommand(currentscene)
                    }
                }
                case "arrow_left_click" : {
                    if (currentscene > 0){                  
                        currentscene -= 1
                        ZBIkeaLicht6_ZBIkeaLicht6Scenes.sendCommand(currentscene)
                    }
                }
            }
        }
    end

That’s it - DONE !! You should now be able to turn the light on and off, set brightness and switch between your own color scenes.

5 Likes

Thank you very much, for this comprehensive guide. It mad my day, and now I can control colour lamps, with openhab/z2m.

My openhab installation expects to receive “x,y,brightness” as incoming value, when using “CIE xyY”. By changing the incoming filter to:
JSONPATH:$.color.x,JSONPATH:$.color.y,JSONPATH:$.brightness
it all worked.

Did not set up scenes, as I don’t use it. But there is another approach, by creating scenes and a special group within zigbee2mqtt, haven’t tried that either though :wink:

Following the instructions I could change power and brightness. Somehow color and scenes don’t work. My configuration is:

UID Bridge

UID: mqtt:broker:Zigbee2Mqtt
label: MQTT Broker (Bridge)
thingTypeUID: mqtt:broker
configuration:
  lwtQos: 0
  publickeypin: true
  keepAlive: 60
  clientid: XXX
  hostnameValidated: true
  secure: false
  birthRetain: true
  shutdownRetain: false
  certificatepin: true
  protocol: TCP
  qos: 0
  reconnectTime: 60000
  mqttVersion: V5
  host: 192.168.X.X
  lwtRetain: true
  enableDiscovery: true

UID IkeaBulb1

UID: mqtt:topic:Zigbee2Mqtt:IkeaBulb1
label: IkeaBulb1_Thing
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:Zigbee2Mqtt
channels:
  - id: IkeaBulb1_OnOff
    channelTypeUID: mqtt:switch
    label: IkeaBulb1_OnOff_Switch
    description: null
    configuration:
      commandTopic: zigbee2mqtt/IkeaBulb1/set
      stateTopic: zigbee2mqtt/IkeaBulb1/state
      off: OFF
      on: ON
  - id: IkeaBulb1_Dimmer
    channelTypeUID: mqtt:dimmer
    label: IkeaBulb1_Dimmer
    description: null
    configuration:
      commandTopic: zigbee2mqtt/IkeaBulb1/set/brightness
      min: 0
      stateTopic: zigbee2mqtt/IkeaBulb1/brightness
      max: 255
  - id: IkeaBulb1_color
    channelTypeUID: mqtt:color
    label: IkeaBulb1_color
    description: ""
    configuration:
      commandTopic: zigbee2mqtt/IkeaBulb1/set
      colorMode: XYY
      formatBeforePublish: "{“color”:{“x”:%s, “y”:%s},“brightness”:%s}"
      stateTopic: zigbee2mqtt/IkeaBulb1
      transformationPattern: JSONPATH:$.color.x,JSONPATH:$.color.y,JSONPATH:$.brightness
  - id: IkeaBulb1_scenes
    channelTypeUID: mqtt:number
    label: IkeaBulb1_scenes
    description: ""
    configuration:
      formatBeforePublish: "{“scene_recall”:%s}"
      commandTopic: zigbee2mqtt/IkeaBulb1/set
      stateTopic: zigbee2mqtt/IkeaBulb1

Trying to change the color the following happened:

Log fronttail

2023-02-12 01:01:21.325 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'IkeaBulb1_Thing_IkeaBulb1_color' received command 39,66,100

2023-02-12 01:01:21.325 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'IkeaBulb1_Thing_IkeaBulb1_color' predicted to become 39,66,100

2023-02-12 01:01:21.326 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'IkeaBulb1_Thing_IkeaBulb1_color' changed from 331,66,100 to 39,66,100

Log Zigbee2MQTT

debug 2023-02-12 01:01:21Received MQTT message on 'zigbee2mqtt/IkeaBulb1/set' with data '{“color”:{“x”:0.44259116, “y”:0.4338149},“brightness”:100.0}'
error 2023-02-12 01:01:21Invalid message 'null', skipping...

I also tried it with JSONPATH:$.color.x,JSONPATH:$.color.y,JSONPATH:$.brightness, still no success.

Trying to change the scenes:

Frontail log

2023-02-12 01:12:40.938 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'IkeaBulb1_scenes' received command 1

2023-02-12 01:12:40.939 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'IkeaBulb1_scenes' predicted to become 1

2023-02-12 01:12:40.940 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'IkeaBulb1_scenes' changed from 2 to 1

Log Zigbee2MQTT

debug 2023-02-12 01:12:40Received MQTT message on 'zigbee2mqtt/IkeaBulb1/set' with data '{“scene_recall”:1}'
error 2023-02-12 01:12:41Invalid message 'null', skipping...

What am I doing wrong? I’m searching the fourth day in vain…

See Zigbee2mqtt revisited: No more ugly transformations - #201 by AndreHimSelf.

1 Like