Skip to content

Commit

Permalink
fix: Hass discovery for SENSOR_ALARM cmd class
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Feb 14, 2020
1 parent bf3d61e commit 7313543
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions lib/Gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -799,14 +799,16 @@ Gateway.prototype.discoverValue = function (node, valueId) {
case 'switch_binary':
case 'switch_all':
case 'switch_toggle_binary':
let rgb = node.values['51-1-0']
if (rgb) {
cfg = copy(hassCfg.light_rgb_switch)
cfg.discovery_payload.rgb_state_topic = this.mqtt.getTopic(this.valueTopic(node, rgb))
cfg.discovery_payload.rgb_command_topic = cfg.discovery_payload.rgb_state_topic + '/set'
} else {
cfg = copy(hassCfg.switch)
}
if (valueId.index === 0) {
let rgb = node.values['51-1-0']
if (rgb) {
cfg = copy(hassCfg.light_rgb_switch)
cfg.discovery_payload.rgb_state_topic = this.mqtt.getTopic(this.valueTopic(node, rgb))
cfg.discovery_payload.rgb_command_topic = cfg.discovery_payload.rgb_state_topic + '/set'
} else {
cfg = copy(hassCfg.switch)
}
} else return
break
case 'switch_multilevel':
case 'switch_toggle_multilevel':
Expand All @@ -826,9 +828,7 @@ Gateway.prototype.discoverValue = function (node, valueId) {
} else {
cfg = copy(hassCfg.light_dimmer)
}
} else {
return
}
} else return
break
case 'door_lock':
if (valueId.index === 0) { // lock state
Expand Down Expand Up @@ -870,7 +870,16 @@ Gateway.prototype.discoverValue = function (node, valueId) {

break
case 'sensor_alarm':
let alarmMap = {
0: 'general',
1: 'smoke',
2: 'carbon_monoxide',
3: 'carbon_dioxide',
4: 'heat',
5: 'flood'
}
cfg = copy(hassCfg.binary_sensor_alarm)
cfg.object_id += alarmMap[valueId.index] ? '_' + alarmMap[valueId.index] : ''
break

case 'alarm':
Expand Down

0 comments on commit 7313543

Please sign in to comment.