Merge pull request #152 from Koenkk/issue_138

Homeassistant: dont set unique_id when friendlyName set. #138
This commit is contained in:
Koen Kanters 2018-06-26 21:36:14 +02:00 committed by GitHub
commit 2ba2864f87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -305,7 +305,12 @@ function discover(deviceID, model, mqtt, force) {
// Set unique names in cases this device produces multiple entities in homeassistant.
payload.name = mapping[model].length > 1 ? `${friendlyName}_${config.object_id}` : friendlyName;
payload.unique_id = `${deviceID}_${config.object_id}_${settings.get().mqtt.base_topic}`;
// Only set unique_id when user did not set a friendly_name yet,
// see https://github.com/Koenkk/zigbee2mqtt/issues/138
if (deviceID === friendlyName) {
payload.unique_id = `${deviceID}_${config.object_id}_${settings.get().mqtt.base_topic}`;
}
if (payload.command_topic) {
payload.command_topic = `${settings.get().mqtt.base_topic}/${friendlyName}/`;