thanks, that worked!
i tried all kinds of combinations /set/state /state/set /set etc…but was getting some strange error in zigbee2mqtt logs until I rebooted rpi.
so, reboot + your solution worked
Hello mby someone have example for (items and things) to share for MOES BHT-002 thermostat, or mby some similar temperature sensor.
here is the things part as a file:
Thing mqtt:topic:ThermoSchlafzimmerO "ThermoSchlafzimmerO" (mqtt:broker:MosquittoMqttBroker) {Channels:
Type number : Temperature "Temperature" [stateTopic="zigbee2mqtt/ThermoSchlafzimmer/local_temperature", unit="°C"]
Type number : SollTemp "SollTemp" [stateTopic="zigbee2mqtt/ThermoSchlafzimmer/current_heating_setpoint", commandTopic="zigbee2mqtt/ThermoSchlafzimmer/set/current_heating_setpoint", unit="°C"]
Type datetime : last_seen "last_seen" [stateTopic="zigbee2mqtt/ThermoSchlafzimmer/last_seen"]
Type number : battery "battery" [stateTopic="zigbee2mqtt/ThermoSchlafzimmer/battery"]
}
I create the items in the UI with add equipment to model.
1 Like
This thread has been very helpful and helped me troubleshoot an issue I had so I thought I would dump my working solution, it may help someone else too.
Context
Zigbee2Mqtt and a Schwaiger HAL550 (GU10 RGB LED).
Thing
Bridge .... {
Thing topic hal550_zb037 "ZigBee - ZB037 - GU10 RGBW" {
Channels:
Type switch : state "State" [
stateTopic="zigbee2mqtt/ZB037/state",
commandTopic="zigbee2mqtt/ZB037/set/state"]
Type dimmer : brightness "Brightness" [
stateTopic="zigbee2mqtt/ZB037/brightness",
commandTopic="zigbee2mqtt/ZB037/set/brightness",
min=0,
max=254 ]
Type color : color "Color" [
stateTopic="zigbee2mqtt/ZB037/color",
commandTopic="zigbee2mqtt/ZB037/set",
colorMode="XYY",
transformationPattern="JS:z2m_hal550_color_in.js",
transformationPatternOut="JS:z2m_hal550_color_out.js"]
Type dimmer : temp "Temp" [
stateTopic="zigbee2mqtt/ZB037/color_temp",
commandTopic="zigbee2mqtt/ZB037/set/color_temp",
min=153,
max=500]
Type number : linkquality "Link Quality" [
stateTopic="zigbee2mqtt/ZB037/linkquality"]
}
}
Transforms
z2m_hal550_color_in.js
:
// x = { "color": { "x": 0.123, "y": 0.456 }, "brightness": 50 }
// output = "0.123,0.456,50"
(function (x) {
var o = JSON.parse(x);
// The brightness value is received as integer 1-254 but needed as percentage 0.100
var brightness = Math.round(o.brightness / 254 * 100);
return o.color.x + ',' + o.color.y + ',' + brightness
})(input)
z2m_hal550_color_out.js
:
// x = "0.123,0.456,50"
// output = { "color": { "x": 0.123, "y": 0.456 }, "brightness": 50 }
(
function (x) {
var [x, y, brightness] = x.split(',');
x = parseFloat(x);
y = parseFloat(y);
// The brightness value is received as percentage but needed as integer 1-254
brightness = brightness * 2.54;
var payload = {
color: {
x,
y
},
brightness
};
return JSON.stringify(payload);
}
)(input)
2 Likes