fixed unique id

This commit is contained in:
FireBall1725 2022-05-20 08:51:51 -04:00
parent 9ddc22ba79
commit e17a45cdea

View File

@ -154,6 +154,9 @@ class MQTT {
mapBaseConfigPayload(diag, diagEl, device_class, name, attr) {
name = name || MQTT.convertFriendlyName(diagEl.name);
name = this.addNamePrefix(name);
// Generate the unique id from the vin and name
let unique_id = `${this.vehicle.vin}-${diagEl.name}`
unique_id = unique_id.replace(/\s+/g, '-').toLowerCase();
return {
device_class,
name,
@ -170,7 +173,7 @@ class MQTT {
value_template: `{{ value_json.${MQTT.convertName(diagEl.name)} }}`,
json_attributes_topic: _.isUndefined(attr) ? undefined : this.getStateTopic(diag),
json_attributes_template: attr,
unique_id: `${this.vehicle.vin}-${device_class}-${name}`
unique_id: unique_id
};
}