Skip to content

Commit

Permalink
fix(hass): better notifications names (#98)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: entities names could change
  • Loading branch information
varet80 authored Dec 21, 2020
1 parent e7ad93b commit a0365a9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/Gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,6 @@ function deviceInfo (node, nodeName) {
function getDiscoveryTopic (hassDevice, nodeName) {
return `${hassDevice.type}/${nodeName}/${hassDevice.object_id}/config`
}

/**
* Calculate the correct template string to use for modes templates
* based on gateway settings and mapped mode values
Expand Down Expand Up @@ -1471,7 +1470,12 @@ Gateway.prototype.discoverValue = function (node, vId) {
// https://github.com/zwave-js/node-zwave-js/blob/master/packages/zwave-js/src/lib/commandclass/NotificationCC.ts
// https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/notifications.json
cfg = copy(hassCfg.sensor_generic)
cfg.object_id = 'notification_' + valueId.property
if (valueId.propertyKey) {
cfg.object_id =
'notification_' + valueId.property + '_' + valueId.propertyKey
} else {
cfg.object_id = 'notification_' + valueId.property
}
cfg.discovery_payload.icon = 'mdi:alarm-light'
break
case CommandClasses['Multilevel Sensor']:
Expand Down Expand Up @@ -1601,7 +1605,7 @@ Gateway.prototype.discoverValue = function (node, vId) {

// Check if another value already exists and add the index to object_id to make it unique
if (node.hassDevices[cfg.type + '_' + cfg.object_id]) {
cfg.object_id += '_' + valueId.property
cfg.object_id += '_' + valueId.endpoint
}

// Set a friendly name for this component
Expand Down

0 comments on commit a0365a9

Please sign in to comment.