Um hier zu landen hast du dir vielleicht eine der folgenden Fragen gestellt
- Wie kann ich Philips Hue-Lampen ohne die originale Bridge in OpenHAB integrieren?
- Was ist zigbee2mqtt und wie funktioniert es mit Philips Hue?
- Welche Hardware benötige ich, um zigbee2mqtt zu nutzen?
- Wie richte ich die MQTT-Bridge für die Kommunikation zwischen zigbee2mqtt und OpenHAB ein?
- Kann ich mit dieser Lösung Farben, Helligkeit und Gruppen steuern?
- Ist die Integration stabil und zuverlässig im Alltag?
- Wie aufwendig ist die Einrichtung für Einsteiger?
- Gibt es Sicherheitsaspekte bei der Nutzung von zigbee2mqtt?
- Welche Vorteile bietet die Nutzung von zigbee2mqtt gegenüber der offiziellen Philips Hue Bridge?
- Funktionieren alle Philips Hue Geräte mit zigbee2mqtt?
Die smarte Beleuchtung mit Philips Hue bietet vielfältige Möglichkeiten, dein Zuhause komfortabel und individuell zu steuern. Doch die volle Kontrolle und Integration in ein umfassendes Smarthome-System wie OpenHAB erfordert oft zusätzliche Komponenten. Mit zigbee2mqtt kannst du deine Philips Hue-Lampen ganz ohne Hersteller-Bridge direkt über MQTT in OpenHAB einbinden. Diese Methode ermöglicht flexible Automatisierungen, Gruppierungen und die Steuerung von Farben und Helligkeit – perfekt für smarte Lichtsteuerung auf Profi-Niveau.
Du willst über freie Alternativen dein Philips Hue Equipment in OpenHAB einbringen? Kein Problem. Ich hab da mal was vorbereitet.
Zigbee2mqtt
1. zigbee2mqtt installieren
siehe auf den Seiten von zigbee2mqtt
2. Dein Hue-Equipment in zigbee2mqtt einbinden
OpenHAB
3. Die zigbee-Bridge bei OpenHAB bekannt machen (Bsp: via .things-File)
Bridge mqtt:broker:myMosquitto "Mosquitto" [ host="IP-DES-MQTT-BROKERS", port=1883, clientID="OpenHAB_pi", username="xxxx", password="xxxx" ]
4. notwendige Things bei OpenHAB bekannt machen (Bsp: via .things-File)
Bei den MQTT Pfaden verwende ich meine Strategie, wie im MQTT-Beitrag beschrieben
//Beispiel für Bridge-Parameter
Thing topic zigbeebridge "Zigbee Pi" {
Channels:
Type switch : permitJoin [ commandTopic="zigbee2mqtt/bridge/config/permit_join", on="true", off="false" ]
Type string : state [ stateTopic="zigbee2mqtt/bridge/state" ]
Type string : logType [ stateTopic="zigbee2mqtt/bridge/log", transformationPattern="JSONPATH:$.type" ]
Type string : logMessage [ stateTopic="zigbee2mqtt/bridge/log", transformationPattern="JSONPATH:$.message" ]
Type string : groups [ stateTopic="zigbee2mqtt/bridge/groups" ]
Type string : devices [ stateTopic="zigbee2mqtt/bridge/devices" ]
}
//Beispiel für eine Hue-Gruppe
Thing mqtt:topic:myMosquitto:HueBulbLivingRoom "Wohnzimmer Licht" (mqtt:broker:myMosquitto) @ "Wohnzimmer" {
Channels:
Type switch : switch [
stateTopic="+/+/livingRoom/+/lightBulb/group",
commandTopic="zigbee2mqtt/eg/livingRoom/undef/lightBulb/group/set",
transformationPattern="REGEX:(.*state.*(ON|OFF).*)∩JSONPATH:$.state",
transformationPatternOut="JS:switch2zigbee2mqtt.js"
]
Type dimmer : brightness [
stateTopic="+/+/livingRoom/+/lightBulb/group",
commandTopic="zigbee2mqtt/eg/livingRoom/undef/lightBulb/group/set",
min=0, max=100, step=1,
transformationPatternOut="JS:openhabDimmer2zigbeebridge.js",
transformationPattern="JS:hueWhiteDimmer2openhab.js"
]
Type dimmer : color_temperature [
stateTopic="+/+/livingRoom/+/lightBulb/group",
commandTopic="zigbee2mqtt/eg/livingRoom/undef/lightBulb/group/set",
min=0, max=100, step=1,
transformationPatternOut="JS:openhabColorTemperature2zigbeebridge.js",
transformationPattern="JS:hueWhiteAndColorTemperature2openhab.js"
]
Type color : color [
stateTopic="+/+/livingRoom/+/lightBulb/group",
commandTopic="zigbee2mqtt/eg/livingRoom/undef/lightBulb/group/set",
transformationPatternOut="JS:openhabColor2zigbeebridge.js",
transformationPattern="JS:hueWhiteAndColorColor2openhab.js"
]
}
Anmerkung zu OpenHAB 4.x:
OpenHAB 4 verwendet Java 17 statt Java 11 und die nachfolgenden Javascript-Transformations sind so nicht mehr verfügbar. Statt dessen kann Javascript aber als Plugin installiert werden und die Thing-Syntax ändert sich wie folgt (nur in der Version 4.0.0, nicht mehr in Version 4.0.3):
Thing mqtt:topic:myMosquitto:HueBulbLivingRoom "Wohnzimmer Licht" (mqtt:broker:myMosquitto) @ "Wohnzimmer" {
Channels:
Type switch : switch [ stateTopic="+/+/livingRoom/+/lightBulb/group", commandTopic="tensorpi2/eg/livingRoom/undef/lightBulb/group/set", transformationPattern="REGEX:(.*state.*(ON|OFF).*)∩JSONPATH:$.state", transformationPatternOut="SCRIPT:js:switch2zigbee2mqtt.script"]
Type dimmer : brightness [ stateTopic="+/+/livingRoom/+/lightBulb/group", commandTopic="tensorpi2/eg/livingRoom/undef/lightBulb/group/set", min=0, max=100, step=1, transformationPatternOut="SCRIPT:js:openhabDimmer2zigbeebridge.script", transformationPattern="SCRIPT:js:hueWhiteDimmer2openhab.script" ]
Type dimmer : color_temperature [ stateTopic="+/+/livingRoom/+/lightBulb/group", commandTopic="tensorpi2/eg/livingRoom/undef/lightBulb/group/set", min=0, max=100, step=1, transformationPatternOut="SCRIPT:js:openhabColorTemperature2zigbeebridge.script", transformationPattern="SCRIPT:js:hueWhiteAndColorTemperature2openhab.script" ]
Type color : color [ stateTopic="+/+/livingRoom/+/lightBulb/group", commandTopic="tensorpi2/eg/livingRoom/undef/lightBulb/group/set", transformationPatternOut="SCRIPT:js:openhabColor2zigbeebridge.script", transformationPattern="SCRIPT:js:hueWhiteAndColorColor2openhab.script" ]
Type string : interface [ commandTopic="zigbee2mqtt/ug/officeAlex/undef/lightBulb/group/set", transformationPatternOut="SCRIPT:js:openhabJSON2zigbeebridgeHueInterface.script" ]
}
Auch die nachfolgenden Files müssen zwingend mit *.script benannt werden, statt *.js.
5. Transformation Patterns
Die einzige Komplikation besteht nun darin, die MQTT-Daten sauber in Anweisungen für die Thing-Channels und zurück zu verwandeln. Das klappt mit folgenden von mir vorbereiteten Files im Pfad /etc/openhab/transform/, die dort noch angelegt werden wollen.
(function(input) {
input_r = input.split(",");
var h = input_r[0];
var s = input_r[1];
var b = input_r[2];
if(b == 0){
return JSON.stringify({state:'OFF'});
}
if(h != undefined && s != undefined && b != undefined){
return JSON.stringify({state:'ON',color_mode:'hs',color:{hue:h,saturation:s},brightness_percent:b,transition:0.4});
}
return JSON.stringify({state:'ON',color_mode:'hs',color:{hue:46,saturation:56},brightness_percent:100,transition:0.4});
})(input)
(function(input) {
if(input == 0) return JSON.stringify({state:'OFF'});
return JSON.stringify({state:'ON',color_temp:Math.round(input*3.47+153),transition:0.4});
})(input)
(function(input) {
if(input == "0") return JSON.stringify({state:'OFF'});
return JSON.stringify({state:'ON',brightness_percent:input,transition:0.4});
})(input)
(function(x) {
if (x == '1' || x == 'ON' || x === true) {
return "{ \"state\": \"ON\" }";
}
return "{ \"state\": \"OFF\" }";
})(input)
(function(x) {
var result;
var json = JSON.parse(x);
if (json.color == undefined || json.state == 'OFF') {
return '46,56,100';
}
if (json.color.hue == undefined || json.color.hue > 360 || json.color.hue < 0) {
json.color.hue = 46;
}
if (json.color.saturation == undefined || json.color.saturation > 100 || json.color.saturation < 0) {
json.color.saturation = 56;
}
if (json.brightness == undefined || json.brightness > 100 || json.color.saturation < 0) {
json.brightness = 100;
}
return '' + json.color.hue + ',' + json.color.saturation + ',' + json.brightness;
})(input)
(function(x) {
var result;
var json = JSON.parse(x);
if (json.state == 'OFF' || json.color_temp < 153) {
return 0;
}
if (json.color_temp == undefined || json.color_temp > 500) {
return 100
}
result = Math.round(((json.color_temp - 153) / 3.47));
return result;
})(input)
(function(x) {
var result;
var json = JSON.parse(x);
if (json.state == 'OFF') {
return 0;
}
if (json.brightness == undefined || json.brightness >= 254) {
return 100;
}
// If brightnes is 0 or 1 it is off from my experiments
if (json.brightness <= 1) {
return 0;
}
result = Math.round(((json.brightness / 255) * 100));
return result;
})(input)
Pingback: künstlicher Sonnenaufgang mit OpenHAB, Kalender und Hue - Smarthome DIY - Heimautomatisierung selbst gemacht
Pingback: Dynamische Szenen mit Zigbee2MQTT, OpenHAB, Hue und anderen Leuchtmitteln - Smarthome DIY - Heimautomatisierung selbst gemacht