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
totrue
in configuration.yaml (usually in /opt/zigbee2mqtt/data)
- Ensure that you are able to pair devices by setting
- Once paired, adjust the zigbee2mqtt configuration.yaml (usually in /opt/zigbee2mqtt/data) to:
- Give the paired device a friendly name
- Turn on the experimental attribute output, which means zigbee2mqtt will send plain strings, rather than JSON strings.
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
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…