Skip to content

Commit

Permalink
fix: Alarms hass discovery and undefined units bug #232 #231
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Feb 3, 2020
1 parent 9e0102e commit fa2b022
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions lib/Gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -858,15 +858,12 @@ Gateway.prototype.discoverValue = function (node, valueId) {
break
case 'alarm':

switch (valueId.index) {
case 0: cfg = 'sensor_alarm_type'
break
case 1: cfg = 'sensor_alarm_level'
break
case 10: cfg = 'sensor_alarm_burglar'
break
default:
return
if (valueId.index < 256) {
cfg = 'sensor_alarm_burglar'
} else if (valueId.index === 512) {
cfg = 'sensor_alarm_type'
} else if (valueId.index === 513) {
cfg = 'sensor_alarm_level'
}

if (cfg && hassCfg[cfg]) {
Expand All @@ -885,12 +882,12 @@ Gateway.prototype.discoverValue = function (node, valueId) {
cfg = Constants.meterType(valueId.index)
}

cfg = cfg ? copy(hassCfg[cfg]) : copy(hassCfg.sensor_generic)

if (valueId.units) {
cfg.discovery_payload.unit_of_measurement = valueId.units
}

cfg = cfg ? copy(hassCfg[cfg]) : copy(hassCfg.sensor_generic)

// check if there is a custom value configuration for this valueID
if (valueConf) {
if (valueConf.device_class) {
Expand Down

0 comments on commit fa2b022

Please sign in to comment.