mirror of
https://github.com/mtan93/homebridge.git
synced 2026-04-01 06:13:10 +01:00
Merge pull request #325 from patricks/master
Fixed netatmo problem with duplicate module names
This commit is contained in:
@@ -49,7 +49,7 @@ function NetAtmoRepository(log, api) {
|
|||||||
|
|
||||||
NetAtmoRepository.prototype = {
|
NetAtmoRepository.prototype = {
|
||||||
refresh: function(callback) {
|
refresh: function(callback) {
|
||||||
var datasource={
|
var datasource = {
|
||||||
devices: {},
|
devices: {},
|
||||||
modules: {}
|
modules: {}
|
||||||
};
|
};
|
||||||
@@ -69,7 +69,7 @@ NetAtmoRepository.prototype = {
|
|||||||
},
|
},
|
||||||
load: function(callback) {
|
load: function(callback) {
|
||||||
var that = this;
|
var that = this;
|
||||||
this.cache.get( "datasource", function( err, datasource ){
|
this.cache.get( "datasource", function( err, datasource ) {
|
||||||
if( !err ){
|
if( !err ){
|
||||||
if ( datasource == undefined ){
|
if ( datasource == undefined ){
|
||||||
that.refresh(callback);
|
that.refresh(callback);
|
||||||
@@ -126,7 +126,14 @@ function NetatmoAccessory(log, repository, deviceId, moduleId, device) {
|
|||||||
if (moduleId) {
|
if (moduleId) {
|
||||||
this.serial = moduleId;
|
this.serial = moduleId;
|
||||||
}
|
}
|
||||||
this.name = device.module_name;
|
|
||||||
|
// add station name to devices to avoid duplicate names
|
||||||
|
if (device.station_name) {
|
||||||
|
this.name = device.station_name + " " + device.module_name;
|
||||||
|
} else {
|
||||||
|
this.name = device.module_name;
|
||||||
|
}
|
||||||
|
|
||||||
this.model = device.type;
|
this.model = device.type;
|
||||||
this.serviceTypes = device.data_type;
|
this.serviceTypes = device.data_type;
|
||||||
if (device.battery_vp) {
|
if (device.battery_vp) {
|
||||||
@@ -161,7 +168,7 @@ NetatmoAccessory.prototype = {
|
|||||||
|
|
||||||
getAirQuality: function(callback) {
|
getAirQuality: function(callback) {
|
||||||
this.getData(function(deviceData) {
|
this.getData(function(deviceData) {
|
||||||
var level = deviceData.dashboard_data.CO2;
|
var level = deviceData.dashboard_data.CO2;
|
||||||
var quality = 0;
|
var quality = 0;
|
||||||
if (level > 2000) quality = 5;
|
if (level > 2000) quality = 5;
|
||||||
else if (level > 1500) quality = 4;
|
else if (level > 1500) quality = 4;
|
||||||
@@ -391,4 +398,4 @@ NetatmoAccessory.prototype = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.exports.accessory = NetatmoAccessory;
|
module.exports.accessory = NetatmoAccessory;
|
||||||
module.exports.platform = NetatmoPlatform;
|
module.exports.platform = NetatmoPlatform;
|
||||||
|
|||||||
Reference in New Issue
Block a user