mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-10-23 06:12:23 +00:00
Revert "Experimental support for home assistant device registry. https://github.com/Koenkk/zigbee2mqtt/issues/646"
This reverts commit 7ea1fc66c2.
This commit is contained in:
1 parent
81d04d3dae
commit
65526e7f68
1 file changed
+10
-19
@@ -428,30 +428,30 @@ class HomeAssistant {
|
||||
|
||||
// MQTT discovery of all paired devices on startup.
|
||||
this.zigbee.getAllClients().forEach((device) => {
|
||||
const mappedModel = zigbeeShepherdConverters.findByZigbeeModel(device.modelId);
|
||||
if (mappedModel) {
|
||||
this.discover(device.ieeeAddr, mappedModel, true);
|
||||
const mappedDevice = zigbeeShepherdConverters.findByZigbeeModel(device.modelId);
|
||||
if (mappedDevice) {
|
||||
this.discover(device.ieeeAddr, mappedDevice.model, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
discover(ieeeAddr, mappedModel, force=false) {
|
||||
discover(ieeeAddr, model, force=false) {
|
||||
// Check if already discoverd and check if there are configs.
|
||||
const discover = force || !this.discovered[ieeeAddr];
|
||||
if (!discover || !mapping[mappedModel.model] || !settings.getDevice(ieeeAddr)) {
|
||||
if (!discover || !mapping[model] || !settings.getDevice(ieeeAddr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const friendlyName = settings.getDevice(ieeeAddr).friendly_name;
|
||||
|
||||
mapping[mappedModel.model].forEach((config) => {
|
||||
mapping[model].forEach((config) => {
|
||||
const topic = `${config.type}/${ieeeAddr}/${config.object_id}/config`;
|
||||
const payload = {...config.discovery_payload};
|
||||
payload.state_topic = `${settings.get().mqtt.base_topic}/${friendlyName}`;
|
||||
payload.availability_topic = `${settings.get().mqtt.base_topic}/bridge/state`;
|
||||
|
||||
// Set unique names in cases this device produces multiple entities in homeassistant.
|
||||
payload.name = mapping[mappedModel.model].length > 1 ? `${friendlyName}_${config.object_id}` : friendlyName;
|
||||
payload.name = mapping[model].length > 1 ? `${friendlyName}_${config.object_id}` : friendlyName;
|
||||
|
||||
// Only set unique_id when user did not set a friendly_name yet,
|
||||
// see https://github.com/Koenkk/zigbee2mqtt/issues/138
|
||||
@@ -469,15 +469,6 @@ class HomeAssistant {
|
||||
payload.command_topic += 'set';
|
||||
}
|
||||
|
||||
// Add Home Assistant device registry payload
|
||||
payload.device = {
|
||||
identifiers: ieeeAddr,
|
||||
name: mappedModel.description,
|
||||
sw_version: 'test',
|
||||
model: mappedModel.model,
|
||||
manufacturer: mappedModel.vendor,
|
||||
};
|
||||
|
||||
this.mqtt.publish(topic, JSON.stringify(payload), {retain: true, qos: 0}, null, 'homeassistant');
|
||||
});
|
||||
|
||||
@@ -505,9 +496,9 @@ class HomeAssistant {
|
||||
return true;
|
||||
}
|
||||
|
||||
onZigbeeMessage(message, device, mappedModel) {
|
||||
if (device && mappedModel) {
|
||||
this.discover(device.ieeeAddr, mappedModel);
|
||||
onZigbeeMessage(message, device, mappedDevice) {
|
||||
if (device && mappedDevice) {
|
||||
this.discover(device.ieeeAddr, mappedDevice.model);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user