diff --git a/lib/controller.js b/lib/controller.js index b0af3b4a1..e3215e0a5 100644 --- a/lib/controller.js +++ b/lib/controller.js @@ -53,8 +53,8 @@ class Controller { settings.write(); } - // We can't handle devices without modelId or cid. - if (!device.modelId || !message.data.cid) { + // We can't handle devices without modelId. + if (!device.modelId) { return; } @@ -77,10 +77,20 @@ class Controller { payload.state_topic = `${settings.get().mqtt.base_topic}/${friendlyName}`; payload.availability_topic = `${settings.get().mqtt.base_topic}/bridge/state`; payload.name = friendlyName; + + if (payload.command_topic) { + payload.command_topic = `${settings.get().mqtt.base_topic}/${friendlyName}/set`; + } + this.mqtt.publish(topic, JSON.stringify(payload), true, null, 'homeassistant'); this.hassDiscoveryCache[device.ieeeAddr] = true; } + // After this point we cant handle message withoud cid anymore. + if (!message.data.cid) { + return; + } + // Find a conveter for this message. const cid = message.data.cid; const converters = zigbee2mqtt.filter((c) => c.devices.includes(mappedModel.model) && c.cid === cid && c.type === message.type);