Skip to content

Commit

Permalink
fix: 'Just value' payload for bool values #214
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Jan 30, 2020
1 parent 3f535a4 commit e1f61f8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/Gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,9 +641,11 @@ Gateway.prototype.publishDiscovery = function (hassDevice, nodeId, deleteDevice,

if (this.config.payloadType === 2) { // Payload is set to "Just Value"
var p = hassDevice.discovery_payload
var template = 'value' + (p.hasOwnProperty('payload_on') && p.hasOwnProperty('payload_off') ? ' | bool' : '')

for (const k in p) {
if (typeof p[k] === 'string') {
p[k] = p[k].replace(/value_json\.value/g, 'value')
p[k] = p[k].replace(/value_json\.value/g, template)
}
}
}
Expand Down

0 comments on commit e1f61f8

Please sign in to comment.