Foreword
This tutorial was written for openHAB2. If you are using openHAB3 you may wish to make use the UI using this tutorial.
We have an Ikea Tradfri e14 400lm dimmable bulb.
Here is how I integrated into openHAB, via zigbee2mqtt and Mosquitto .
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 swPorchLight
:
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:
'0x086bd7fffe210efc':
friendly_name: swPorchLight
experimental:
output: attribute
openHAB
bridge.things
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
//Porch light
Thing mqtt:topic:swPorchLight "Porch Light" (mqtt:broker:MosquittoMqttBroker) {
Channels:
Type switch:switch "Power Switch" [
stateTopic="zigbee2mqtt/swPorchLight/state",
commandTopic="zigbee2mqtt/swPorchLight/set",
on="ON",
off="OFF"
]
Type dimmer:dimmer "Dimmer" [
stateTopic="zigbee2mqtt/swPorchLight/brightness",
commandTopic="zigbee2mqtt/swPorchLight/set/brightness",
min=0,
max=255,
step=1
]
Type switch:reachable "Reachable" [
stateTopic="zigbee2mqtt/swPorchLight/availability",
on="online",
off="offline"
]
}
zigbee.items
Switch sPorchLight "Porch Light" { channel="mqtt:topic:swPorchLight:switch" }
Dimmer dPorchLight "Porch Light" {channel="mqtt:topic:swPorchLight:dimmer"}
Switch sPorchLightReachable "Porch Light" { channel="mqtt:topic:swPorchLight:reachable"}
sitemap
Text item=sPorchLightReachable label="Porch light [MAP(switch2online.map):%s]" icon="light" valuecolor=["ON"="green", "OFF"="red", "NULL"="red", "-"="red"]
Switch item=sPorchLight label="Porch" icon="light"
Slider item=dPorchLight label="Brightness [%d %%]" sendFrequency=500
The switch2online.map file contains the below, saved into the transform folder:
OFF=OFFLINE
ON=ONLINE
NULL=UNDEFINED
-=-