Merge pull request #95 from ciotlosm/master

Added unique id for easier renaming of sensors in HA
This commit is contained in:
Koen Kanters 2018-06-05 00:32:54 +02:00 committed by GitHub
commit fb1feca3ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -264,6 +264,7 @@ function discover(deviceID, model, mqtt) {
// 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}`;
if (payload.command_topic) {
payload.command_topic = `${settings.get().mqtt.base_topic}/${friendlyName}/`;