From 1a9892abdba31d6ea9cf474cf0006ccdc8e2cbf7 Mon Sep 17 00:00:00 2001 From: Sebastian Kroll Date: Fri, 26 Apr 2019 19:38:26 +0200 Subject: [PATCH] added config option to add module-name suffix --- HISTORY.md | 3 +++ README.md | 1 + device/weatherstation-device.js | 15 +++++++++++++-- index.js | 2 ++ package.json | 2 +- 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index a876bcc..77bfdd0 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,8 @@ ## version history +### 0.4.4 +- added a config option which prevents the netatmo's devicename to be prepended and instead appends a configurable name to the modules + ### 0.4.3 - added configuration-option to override the alert-state threshold for the extra co2-sensors (https://github.com/skrollme/homebridge-eveatmo/issues/24) diff --git a/README.md b/README.md index 009f5bc..2b0f73a 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ Because this plugin's base was taken from [homebridge-netatmo](https://github.co - **co2_alert_threshold (optional):** Sets the co2-level [ppm] at which the sensors switch to alert-state - **ttl: (optional)** Seconds between two Netatmo API polls. Lower is not neccessarily better! The weatherstation itself collects one value per 5minutes, so going below 300s makes no sense. Default value is *540* (=9min) - **auth:** Credentials for the Netatmo API +- **module_suffix: (optional)** If this is set, the Netatmo's devicename will not be prepended to the modulename. Instead this config-value will be appended - with a space - to the module name ### Retrieve client id and secret diff --git a/device/weatherstation-device.js b/device/weatherstation-device.js index c2b99fc..0be5781 100644 --- a/device/weatherstation-device.js +++ b/device/weatherstation-device.js @@ -30,10 +30,21 @@ module.exports = function(pHomebridge) { var deviceMap = {}; devices.forEach(function(device) { deviceMap[device._id] = device; - device._name = device.station_name + " " + device.module_name; + + if(this.config.module_suffix != "") { + device._name = device.module_name + " " + this.config.module_suffix; + } else { + device._name = device.station_name + " " + device.module_name; + } + if (device.modules) { device.modules.forEach(function(module) { - module._name = device.station_name + " " + module.module_name; + if(this.config.module_suffix != "") { + module._name = module.module_name + " " + this.config.module_suffix; + } else { + module._name = device.station_name + " " + module.module_name; + } + deviceMap[module._id] = module; }.bind(this)); } diff --git a/index.js b/index.js index b32004d..941fb63 100644 --- a/index.js +++ b/index.js @@ -19,6 +19,8 @@ class EveatmoPlatform { this.config.extra_co2_sensor = typeof config.extra_co2_sensor !== 'undefined' ? Boolean(config.extra_co2_sensor) : false; this.config.co2_alert_threshold = typeof config.co2_alert_threshold !== 'undefined' ? parseInt(config.co2_alert_threshold) : 1000; + this.config.module_suffix = typeof config.module_suffix !== 'undefined' ? config.module_suffix : ''; + // If this log message is not seen, most likely the config.js is not found. this.log.debug('Creating EveatmoPlatform'); diff --git a/package.json b/package.json index 6fef959..1d1ae2f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-eveatmo", - "version": "0.4.3", + "version": "0.4.4", "description": "Homebridge plugin which adds a Netatmo weatherstation as HomeKit device and tries to act like Elgato Eve Room/Weather", "license": "ISC", "keywords": [