We have three Ikea Tradfri gu10 400lm dimmable bulbs, located in the upstairs hallway.
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 the initial installation defaults.
- 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 bulbs 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 names according to what they are closest to:
bUpstairsHallwayBathroomLight
bUpstairsHallwayMiddleLight
bUpstairsHallwayCupboardLight
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:
'0x680ae2fffe7f1dfb':
friendly_name: bUpstairsHallwayBathroomLight
'0x680ae2fffe93efaf':
friendly_name: bUpstairsHallwayMiddleLight
'0x588e81fffe15418b':
friendly_name: bUpstairsHallwayCupboardLight
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
//HALLWAY LIGHTS
//Bathroom
Thing mqtt:topic:bUpstairsHallwayBathroomLight "Upstairs Hallway Bathroom" (mqtt:broker:MosquittoMqttBroker) {
Channels:
Type switch:switch "Power Switch" [
stateTopic="zigbee2mqtt/bUpstairsHallwayBathroomLight/state",
commandTopic="zigbee2mqtt/bUpstairsHallwayBathroomLight/set",
on="ON",
off="OFF"
]
Type dimmer:dimmer "Dimmer" [
stateTopic="zigbee2mqtt/bUpstairsHallwayBathroomLight/brightness",
commandTopic="zigbee2mqtt/bUpstairsHallwayBathroomLight/set/brightness",
min=0,
max=255,
step=1
]
Type switch:reachable "Reachable" [
stateTopic="zigbee2mqtt/bUpstairsHallwayBathroomLight/availability",
on="online",
off="offline"
]
}
//Middle
Thing mqtt:topic:bUpstairsHallwayMiddleLight "Upstairs Hallway Middle" (mqtt:broker:MosquittoMqttBroker) {
Channels:
Type switch:switch "Power Switch" [
stateTopic="zigbee2mqtt/bUpstairsHallwayMiddleLight/state",
commandTopic="zigbee2mqtt/bUpstairsHallwayMiddleLight/set",
on="ON",
off="OFF"
]
Type dimmer:dimmer "Dimmer" [
stateTopic="zigbee2mqtt/bUpstairsHallwayMiddleLight/brightness",
commandTopic="zigbee2mqtt/bUpstairsHallwayMiddleLight/set/brightness",
min=0,
max=255,
step=1
]
Type switch:reachable "Reachable" [
stateTopic="zigbee2mqtt/bUpstairsHallwayMiddleLight/availability",
on="online",
off="offline"
]
}
//Cupboard
Thing mqtt:topic:bUpstairsHallwayCupboardLight "Upstairs Hallway Middle" (mqtt:broker:MosquittoMqttBroker) {
Channels:
Type switch:switch "Power Switch" [
stateTopic="zigbee2mqtt/bUpstairsHallwayCupboardLight/state",
commandTopic="zigbee2mqtt/bUpstairsHallwayCupboardLight/set",
on="ON",
off="OFF"
]
Type dimmer:dimmer "Dimmer" [
stateTopic="zigbee2mqtt/bUpstairsHallwayCupboardLight/brightness",
commandTopic="zigbee2mqtt/bUpstairsHallwayCupboardLight/set/brightness",
min=0,
max=255,
step=1
]
Type switch:reachable "Reachable" [
stateTopic="zigbee2mqtt/bUpstairsHallwayCupboardLight/availability",
on="online",
off="offline"
]
}
zigbee.items
- All the power switch Items are part the
gHallwayLights
switch Group, which is setup so that if any of the bulbs are ON, the Group itself is ON. - All the dimmer Items are part of the
gdHallwayLights
dimmer Group, which is setup so that the Group takes the maximum dimmer setting of any bulb. - See here for more ways to setup your groups.
Group:Switch:OR(ON,OFF) gHallwayLights
Group:Dimmer:MAX gdHallwayLights
//HALLWAY LIGHTS
//Hallway bathroom
Switch sUpstairsHallwayBathroomLight "Porch Light" (gHallwayLights) { channel="mqtt:topic:bUpstairsHallwayBathroomLight:switch" }
Dimmer dUpstairsHallwayBathroomLight "Porch Light" (gdHallwayLights) {channel="mqtt:topic:bUpstairsHallwayBathroomLight:dimmer"}
Switch sUpstairsHallwayBathroomLightReachable "Porch Light" { channel="mqtt:topic:bUpstairsHallwayBathroomLight:reachable" }
//Hallway middle
Switch sUpstairsHallwayMiddleLight "Porch Light" (gHallwayLights) { channel="mqtt:topic:bUpstairsHallwayMiddleLight:switch" }
Dimmer dUpstairsHallwayMiddleLight "Porch Light" (gdHallwayLights) {channel="mqtt:topic:bUpstairsHallwayMiddleLight:dimmer"}
Switch sUpstairsHallwayMiddleLightReachable "Porch Light" { channel="mqtt:topic:bUpstairsHallwayMiddleLight:reachable" }
//Hallway cupboard
Switch sUpstairsHallwayCupboardLight "Porch Light" (gHallwayLights) { channel="mqtt:topic:bUpstairsHallwayCupboardLight:switch" }
Dimmer dUpstairsHallwayCupboardLight "Porch Light" (gdHallwayLights) {channel="mqtt:topic:bUpstairsHallwayCupboardLight:dimmer"}
Switch sUpstairsHallwayCupboardLightReachable "Porch Light" { channel="mqtt:topic:bUpstairsHallwayCupboardLight:reachable" }
sitemap
In the screenshot below:
- You can see that the
Bathroom
andMiddle
bulbs are on, so the Group switch (underAll
) is on too. - The
Middle
bulbs’ brightness is the largest at 50%, so the Group dimmer (underAll
) is 50%. - If you now click the Group switch (under
All
), all bulbs would switch OFF. If you clicked it again, all bulbs would switch ON to their last individual brightness setting. - If one of the bulbs becomes unavailable (lost power, for example), its controls would disappear, to be replaced by an error icon.
Frame label="All"{
Switch item=gHallwayLights label="Switch" icon="light"
Slider item=gdHallwayLights label="Dimmer [%d %%]" sendFrequency=500
}
Frame label="Bathroom"{
Switch item=sUpstairsHallwayBathroomLight label="Switch" icon="light" visibility=[sUpstairsHallwayBathroomLightReachable==ON]
Slider item=dUpstairsHallwayBathroomLight label="Dimmer [%d %%]" sendFrequency=500 visibility=[sUpstairsHallwayBathroomLightReachable==ON]
Text item=sUpstairsHallwayBathroomLightReachable label="Bathroom light [MAP(switch2online.map):%s]" icon="error" visibility=[sUpstairsHallwayBathroomLightReachable==OFF]
}
Frame label="Middle"{
Switch item=sUpstairsHallwayMiddleLight label="Switch" icon="light" visibility=[sUpstairsHallwayMiddleLightReachable==ON]
Slider item=dUpstairsHallwayMiddleLight label="Dimmer [%d %%]" sendFrequency=500 visibility=[sUpstairsHallwayMiddleLightReachable==ON]
Text item=sUpstairsHallwayMiddleLightReachable label="Middle light [MAP(switch2online.map):%s]" icon="error" visibility=[sUpstairsHallwayMiddleLightReachable==OFF]
}
Frame label="Cupboard"{
Switch item=sUpstairsHallwayCupboardLight label="Switch" icon="light" visibility=[sUpstairsHallwayCupboardLightReachable==ON]
Slider item=dUpstairsHallwayCupboardLight label="Dimmer [%d %%]" sendFrequency=500 visibility=[sUpstairsHallwayCupboardLightReachable==ON]
Text item=sUpstairsHallwayCupboardLightReachable label="Cupboard light [MAP(switch2online.map):%s]" icon="error" visibility=[sUpstairsHallwayCupboardLightReachable==OFF]
}
The switch2online.map file contains the below, saved into the transform folder:
OFF=OFFLINE
ON=ONLINE
NULL=UNDEFINED
-=-