IKEA Tradfri wireless dimmer switch via zigbee2mqtt

I have recently received a zigbee-compatible IKEA Tradfri wireless dimmer switch (004.684.32), which can report:

  • ON click
  • OFF click
  • Brightness up hold (ON long press)
  • Brightness down hold (OFF long press)
  • Brightness stop (ON or OFF long press release)

Prerequisites

  • Ensure the openHAB MQTT binding is installed (V2, not V1)
  • My Mosquitto MQTT broker is setup as per default.
  • Pair the device with zigbee2mqtt as described here.
    • Ensure that you are able to pair devices by setting permit_join to true in configuration.yaml (usually in /opt/zigbee2mqtt/data)
  • Once paired, adjust the zigbee2mqtt configuration.yaml (usually in /opt/zigbee2mqtt/data) to:

Here is my configuration.yaml - your device ID is likely to be different. I have given my device the friendly name swDimmer:

homeassistant: false
permit_join: true
mqtt:
  base_topic: zigbee2mqtt
  server: 'mqtt://localhost'
serial:
  port: /dev/ttyACM0
  disable_led: false
advanced:
  log_level: error
  availability_timeout: 5
devices:
  '0x588e81fffe5161ed':
    friendly_name: swDimmer
experimental:
  output: attribute

openHAB

MQTT bridge

I have a separate file which just contains the bridge Thing to my Mosquitto MQTT broker:

Bridge mqtt:broker:MosquittoMqttBroker "Mosquitto MQTT Broker" [
	host="192.168.1.92",
	secure=false,
	port=1883,
	clientID="OpenHAB2"
]

zigbee.things

//IKEA dimmer switch
Thing mqtt:topic:swDimmer "Dimmer switch" (mqtt:broker:MosquittoMqttBroker) {
    Channels:
        Type switch : availability "Reachable" [
            stateTopic = "zigbee2mqtt/swDimmer/availability",
            off="offline",
            on="online"
        ]
        Type switch : update_available "Update available" [
            stateTopic = "zigbee2mqtt/swDimmer/update_available",
            off="false",
            on="true"
        ]
        Type number : battery "Battery level" [
            stateTopic = "zigbee2mqtt/swDimmer/battery"
        ]
        Type number : linkquality "Link quality" [
            stateTopic = "zigbee2mqtt/swDimmer/linkquality"
        ]
        Type string : click "Click" [
            stateTopic = "zigbee2mqtt/swDimmer/click"
        ] 
}

zigbee.items

Switch sDimmerSwitchReachable "Zigbee dimmer reachable" (gReachable) {channel="mqtt:topic:swDimmer:availability", fixed="meta"[name="Dimmer switch", timeout="5"]}
Switch sDimmerSwitchUpdateAvailable "Zigbee dimmer update available" {channel="mqtt:topic:swDimmer:update_available"}
Number nDimmerSwitchBattery { channel="mqtt:topic:swDimmer:battery" }
Number nDimmerSwitchLinkQuality { channel="mqtt:topic:swDimmer:linkquality" }
String strDimmerClick { channel="mqtt:topic:swDimmer:click" }

Sitemap

image

Text item=sDimmerSwitchReachable label="Dimmer switch [MAP(switch2online.map):%s]" icon="wallswitch" valuecolor=["ON"="green", "OFF"="red", "NULL"="red", "-"="red"]
Text item=sDimmerSwitchUpdateAvailable label="Update available [%s]"
Text item=nDimmerSwitchBattery label="Battery [%.0f %%]" icon="battery"
Text item=nDimmerSwitchLinkQuality label="Link quality [%s]" icon="qualityofservice"
Text item=strDimmerSwitchClick label="Last click action [%s]"

The switch2online.map file contains the below, saved into the transform folder:

OFF=OFFLINE
ON=ONLINE
NULL=UNDEFINED
-=-

Rules

To do…

4 Likes

hi, why did you prefer to use the zigbee2mqtt binding instead zigbee binding?

A few reasons, two of which:

  • I already have an MQTT network setup to communicate with some other devices (Tasmota and MySensors based, amongst others). So the ‘infrastructure’ was there already.
  • I aim to keep things as flexible as possible. Connecting through zigbee2mqtt means that I do not have to use openHAB to communicate with the devices.

nice example, how did you deal with the long vs short presses?

Oooh, you’ve called me out there! I’m not properly using the switch yet, so haven’t got to developing the rules! However, I have another type of switch setup in a similar manner, which has sort-of similar settings:

Hi!

Did you have any progress with the Switches regarding the long presses?

I have the same setup (openhab with zigbee2mqtt) and own two of those IKEA on/off switches. Maybe I could be of some help.