YSRSAI ZB-CT01
What happened
send { "brightness" : 0 } to the set topic of the device.
What did you expect to happen
device turns off.
How to reproduce it (minimal and precise)
send { brightness" : 0 } to the set topic of the device.
Debug info
Zigbee2MQTT version: 1.15.0 Adapter hardware: CC2531 Adapter firmware version: ?
How to fix it
If I send { "brightness" : 0, "state": "off" } it works.
If I initialize the variable state with off when brightness is zero - it works. (https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/converters/toZigbee.js#L496).
If I write an own converter which changes the meta.message.state it also works.
What I need to know: Is this a general bug/feature that should be added in the light_onoff_brightness or is it specific to my device?
If I have the information I can create a pull request.
devices.js
{
zigbeeModel: ['ZB-CT01'],
model: 'ZB-CT01',
vendor: 'YSRSAI',
description: 'Zigbee LED controller (WW/CW)',
fromZigbee: [fz.on_off, fz.brightness, fz.ignore_basic_report],
toZigbee: [
tz.ysrsai_zb_ct01,
],
},
toZigbee.js
// YSRSAI
ysrsai_zb_ct01: {
key: ['state', 'brightness', 'brightness_percent'],
convertSet: async (entity, key, value, meta) => {
let {message} = meta;
let state = message.hasOwnProperty('state') ? message.state.toLowerCase() : undefined;
let brightness = undefined;
if (message.hasOwnProperty('brightness')) brightness = Number(message.brightness);
else if (message.hasOwnProperty('brightness_percent')) brightness = Math.round(Number(message.brightness_percent) * 2.55);
if (state == undefined && brightness !== undefined && brightness === 0) {
meta.message.state = 'off';
}
return await converters.light_onoff_brightness.convertSet(entity, key, value, meta);
},
convertGet: async (entity, key, meta) => {
return await converters.light_onoff_brightness.convertGet(entity, key, meta);
},
},
OR add to general light_onoff_brightness converter:
if (state == undefined && brightness !== undefined && brightness === 0) {
meta.message.state = 'off';
}
@Koenkk What is the "correct" way to do it? General approach or individual converter?
- What does happen when you set brightness: 0?
- Can you provide the herdsman debug log of this?
To enable herdsman debug logging, see https://www.zigbee2mqtt.io/information/debug.html#zigbee-herdsman-debug-logging
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days