diff --git a/lib/Gateway.js b/lib/Gateway.js index 1a97774d494..63dfc242352 100755 --- a/lib/Gateway.js +++ b/lib/Gateway.js @@ -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]) { @@ -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) {