Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6fd1a2a

Browse files
author
Stefan Kuper
committed
JSHint + configurable timings + changed default timings
1 parent0a6d9f6 commit6fd1a2a

File tree

31 files changed

+147
-198
lines changed

31 files changed

+147
-198
lines changed

‎.jshintrc‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"esversion":6,
3+
"node":true
4+
}

‎README.md‎

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Configuration sample:
3434
{
3535
"platform": "netatmo",
3636
"name": "netatmo platform",
37-
"ttl":5,
37+
"ttl":10,
3838
"auth": {
3939
"client_id": "XXXXX Create at https://dev.netatmo.com/",
4040
"client_secret": "XXXXX Create at https://dev.netatmo.com/",
@@ -58,6 +58,39 @@ To retrieve client id and secret please follow following guide:
5858

5959
There are some optional configuration options in the netatmo section of the config which provide finer control about what device and services to use to create accessories.
6060

61+
###API Refresh and timings
62+
63+
Communication towards netatmo API is time by three parameters:
64+
65+
<dl>
66+
<dt>ttl</dt>
67+
<dd>Time in seconds, how long data will be kept in the internal cache. Mainly useful to avoide duplicated requests for different values from the same device. Defaults to 10 seconds if left out in config.</dd>
68+
<dt>refresh_check</dt>
69+
<dd>Time in milliseconds, how often the api will be automatically polled to check for changes. Defaults to 900000 which is 15 Minutes. Do not take values much lower, or you risk, that you put to much traffic to the netatmo API. In worst case netatmo might temporarilly exclude your app from the api.</dd>
70+
<dt> refresh_run </dt>
71+
<dd>Time in milliseconds, how often the the module checks if there was a request to refresh the data, either from the automatic polling or due to changes in the homekit app. This allows to have regular checks as well as refreshes after changes were done in the app. Defaults to 20000 which is 20 Seconds.</dd>
72+
73+
<pre>
74+
75+
"platforms": [
76+
{
77+
"platform": "netatmo",
78+
79+
...
80+
81+
<b>"ttl": 10,
82+
"refresh_check": 900000
83+
"refresh_run": 20000</b>
84+
...
85+
86+
}
87+
],
88+
89+
</pre>
90+
91+
92+
93+
6194
###Control Accessories by device type
6295

6396
<pre>
@@ -121,6 +154,11 @@ If the whitelist contains at least one entry, all oter ids will be excluded.
121154

122155
TBD (Needs description here)
123156

157+
<!--
158+
"options_weather": {
159+
"device_id": "XX:XX:XX:XX:XX:XX"
160+
},
161+
-->
124162

125163
#<aname="notes"></a> Notes on devices
126164
##Weather station

‎accessory/camera-accessory.js‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = function(pHomebridge) {
2525
"firmware":deviceData.firmware||0.0,
2626
"name":deviceData.name||"Netatmo "+netatmoDevice.deviceType+" "+deviceData._id,
2727
"defaultServices":DEFAULT_SERVICES
28-
}
28+
};
2929

3030
super(homebridge,accessoryConfig,netatmoDevice);
3131

@@ -70,7 +70,7 @@ module.exports = function(pHomebridge) {
7070
newLastEventTimeStamp=event.time;
7171
}
7272
if(event.time>this.lastEventTimeStamp){
73-
result.motionDetected=result.motionDetected||this.eventIsMotion(event)
73+
result.motionDetected=result.motionDetected||this.eventIsMotion(event);
7474
}
7575
}.bind(this));
7676
this.lastEventTimeStamp=newLastEventTimeStamp;
@@ -93,7 +93,7 @@ module.exports = function(pHomebridge) {
9393
}
9494

9595
applyHomeData(homeData){
96-
vardataChanged=false
96+
vardataChanged=false;
9797

9898
if(this.motionDetected!=homeData.motionDetected){
9999
this.motionDetected=homeData.motionDetected;
@@ -103,14 +103,12 @@ module.exports = function(pHomebridge) {
103103
if(dataChanged){
104104
this.getServices().forEach(
105105
function(svc){
106-
svc.updateCharacteristics&&svc.updateCharacteristics();
106+
varcall=svc.updateCharacteristics&&svc.updateCharacteristics();
107107
}
108108
);
109109
}
110-
111110
}
112-
113111
}
114112

115113
returnCameraAccessory;
116-
}
114+
};

‎accessory/thermostat-accessory.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module.exports = function(pHomebridge) {
3030
"name":deviceData.station_name||"Netatmo "+netatmoDevice.deviceType+" "+deviceData._id,
3131
"defaultServices":DEFAULT_SERVICES
3232
// "dataTypes"
33-
}
33+
};
3434

3535
super(homebridge,accessoryConfig,netatmoDevice);
3636

@@ -81,15 +81,15 @@ module.exports = function(pHomebridge) {
8181

8282
varsetpoint=module.setpoint;
8383
if(setpoint){
84-
if(setpoint.setpoint_temp!=undefined){
84+
if(setpoint.setpoint_temp!==undefined){
8585
result.targetTemperature=setpoint.setpoint_temp;
8686
result.mode=setpoint.setpoint_mode;
8787
}
8888
}
8989

9090
if(result.targetTemperature<10)result.targetTemperature=10;
9191

92-
result.heating=(module.therm_relay_cmd!=0);
92+
result.heating=(module.therm_relay_cmd!==0);
9393
result.batteryPercent=module.battery_percent;
9494

9595
result.lowBattery=false;
@@ -111,7 +111,7 @@ module.exports = function(pHomebridge) {
111111
}
112112

113113
applyThermostatData(thermostatData){
114-
vardataChanged=false
114+
vardataChanged=false;
115115

116116
if(thermostatData.currentTemperature&&this.currentTemperature!=thermostatData.currentTemperature){
117117
this.currentTemperature=thermostatData.currentTemperature;
@@ -164,7 +164,7 @@ module.exports = function(pHomebridge) {
164164
if(dataChanged){
165165
this.getServices().forEach(
166166
function(svc){
167-
svc.updateCharacteristics&&svc.updateCharacteristics();
167+
varcall=svc.updateCharacteristics&&svc.updateCharacteristics();
168168
}
169169
);
170170
}
@@ -185,4 +185,4 @@ module.exports = function(pHomebridge) {
185185
}
186186

187187
returnThermostatAccessory;
188-
}
188+
};

‎accessory/weatherstation-accessory.js‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports = function(pHomebridge) {
4040
"name":deviceData._name||"Netatmo "+netatmoDevice.deviceType+" "+deviceData._id,
4141
"defaultServices":DEFAULT_SERVICES,
4242
"dataTypes":dataTypes
43-
}
43+
};
4444

4545
super(homebridge,accessoryConfig,netatmoDevice);
4646

@@ -88,7 +88,7 @@ module.exports = function(pHomebridge) {
8888
NAModule2:4360,
8989
NAModule3:4000,
9090
NAModule4:4560
91-
}
91+
};
9292

9393
if(levels[this.netatmoType]){
9494
returnlevels[this.netatmoType];
@@ -103,7 +103,7 @@ module.exports = function(pHomebridge) {
103103
NAModule2:5590,
104104
NAModule3:5500,
105105
NAModule4:5640
106-
}
106+
};
107107

108108
if(levels[this.netatmoType]){
109109
returnlevels[this.netatmoType];
@@ -176,7 +176,7 @@ module.exports = function(pHomebridge) {
176176
}
177177

178178
applyWeatherData(weatherData){
179-
vardataChanged=false
179+
vardataChanged=false;
180180

181181
if(weatherData.currentTemperature&&this.currentTemperature!=weatherData.currentTemperature){
182182
this.currentTemperature=weatherData.currentTemperature;
@@ -232,7 +232,7 @@ module.exports = function(pHomebridge) {
232232
if(dataChanged){
233233
this.getServices().forEach(
234234
function(svc){
235-
svc.updateCharacteristics&&svc.updateCharacteristics();
235+
varcall=svc.updateCharacteristics&&svc.updateCharacteristics();
236236
}
237237
);
238238
}
@@ -252,21 +252,21 @@ module.exports = function(pHomebridge) {
252252
case"co2" :
253253
returnthis.dataTypes.indexOf("CO2")>-1;
254254
case"battery" :
255-
returnthis.dataTypes.indexOf("Battery")>-1;;
255+
returnthis.dataTypes.indexOf("Battery")>-1;
256256
case"humidity" :
257-
returnthis.dataTypes.indexOf("Humidity")>-1;;
257+
returnthis.dataTypes.indexOf("Humidity")>-1;
258258
case"airpressure" :
259-
returnthis.dataTypes.indexOf("Pressure")>-1;;
259+
returnthis.dataTypes.indexOf("Pressure")>-1;
260260
case"noiselevel" :
261-
returnthis.dataTypes.indexOf("Noise")>-1;;
261+
returnthis.dataTypes.indexOf("Noise")>-1;
262262
case"rain" :
263-
returnthis.dataTypes.indexOf("Rain")>-1;;
263+
returnthis.dataTypes.indexOf("Rain")>-1;
264264
case"wind" :
265-
returnthis.dataTypes.indexOf("Wind")>-1;;
265+
returnthis.dataTypes.indexOf("Wind")>-1;
266266
}
267267
returnfalse;
268268
}
269269

270270
}
271271
returnWeatherStationAccessory;
272-
}
272+
};

‎device/camera-device.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ module.exports = function(pHomebridge) {
3939

4040
returnCameraDeviceType;
4141

42-
}
42+
};

‎device/thermostat-device.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = function(pHomebridge) {
2222
if(!err){
2323
vardeviceMap={};
2424
devices.forEach(function(device){
25-
deviceMap[device["_id"]]=device;
25+
deviceMap[device._id]=device;
2626
}.bind(this));
2727
this.cache.set(this.deviceType,deviceMap);
2828
this.deviceData=deviceMap;
@@ -39,4 +39,4 @@ module.exports = function(pHomebridge) {
3939

4040
returnThermostatDeviceType;
4141

42-
}
42+
};

‎device/weatherstation-device.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ module.exports = function(pHomebridge) {
2323
if(!err){
2424
vardeviceMap={};
2525
devices.forEach(function(device){
26-
deviceMap[device["_id"]]=device;
27-
device._name=device.station_name+" "+device.module_name
26+
deviceMap[device._id]=device;
27+
device._name=device.station_name+" "+device.module_name;
2828
if(device.modules){
2929
device.modules.forEach(function(module){
30-
module._name=device.station_name+" "+module.module_name
30+
module._name=device.station_name+" "+module.module_name;
3131
deviceMap[module._id]=module;
3232
}.bind(this));
3333
}
@@ -46,5 +46,5 @@ module.exports = function(pHomebridge) {
4646

4747
returnWeatherstationDeviceType;
4848

49-
}
49+
};
5050

‎index.js‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
'use strict';
2-
varhomebridge
2+
varhomebridge;
33
varNetatmoWeatherStationAccessory,NetatmoThermostatAccessory;
44
varasync=require('async');
55

66
// TODO: user info auswerten (metrisch /imperial ...)
77

88
module.exports=function(pHomebridge){
9-
109
homebridge=pHomebridge;
11-
1210
homebridge.registerPlatform("homebridge-netatmo","netatmo",NetatmoPlatform);
13-
}
11+
};
1412

1513
varnetatmo=require("netatmo");
1614
varinherits=require('util').inherits;
@@ -28,7 +26,7 @@ class NetatmoPlatform {
2826
this.log.warn('CAUTION! USING FAKE NETATMO API: '+config.mockapi);
2927
this.api=require("./lib/netatmo-api-mock")(config.mockapi);
3028
}else{
31-
this.api=newnetatmo(config["auth"]);
29+
this.api=newnetatmo(config.auth);
3230
}
3331
this.api.on("error",function(error){
3432
this.log.error('ERROR - Netatmo: '+error);

‎lib/netatmo-accessory.js‎

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ var inherits = require('util').inherits;
44
varAccessory,Service,Characteristic,uuid;
55
varhomebridge;
66

7-
varglob=require('glob')
8-
,path=require('path');
7+
varglob=require('glob'),path=require('path');
98

109
module.exports=function(pHomebridge){
1110
if(pHomebridge&&!homebridge){
@@ -48,8 +47,8 @@ module.exports = function(pHomebridge) {
4847

4948
varaccessoryInformationService=this.getService(Service.AccessoryInformation);
5049

51-
accessoryInformationService.getCharacteristic(Characteristic.FirmwareRevision)
52-
||accessoryInformationService.addCharacteristic(Characteristic.FirmwareRevision);
50+
varfwChar=accessoryInformationService.getCharacteristic(Characteristic.FirmwareRevision)||
51+
accessoryInformationService.addCharacteristic(Characteristic.FirmwareRevision);
5352

5453
accessoryInformationService
5554
.setCharacteristic(Characteristic.Model,"Netatmo "+this.deviceType+" ("+this.netatmoType+")")
@@ -71,7 +70,7 @@ module.exports = function(pHomebridge) {
7170
}
7271

7372
_buildServices(defaultServices){
74-
this.loadConfiguredServices(defaultServices)
73+
this.loadConfiguredServices(defaultServices);
7574
varserviceDir=path.dirname(__dirname)+'/service';
7675
varglobprefix=this.deviceType;
7776

@@ -101,54 +100,5 @@ module.exports = function(pHomebridge) {
101100
}
102101

103102
returnNetatmoAccessory;
104-
105-
106-
/*
107-
var serviceDir = path.dirname(__dirname) + '/services';
108-
var globprefix = netAtmoDevice.deviceType;
109-
glob.sync( globprefix + '-*.js', { 'cwd': serviceDir } ).forEach( function( file ) {
110-
try {
111-
var service = require( serviceDir + '/' + file )(this, stationData);
112-
if(this.isConfiguredService(file.slice(globprefix.length + 1, -3))) {
113-
var serviceProvider = new service.ServiceProvider();
114-
var services = serviceProvider.buildServices(this, stationData);
115-
if (services) {
116-
services.forEach(function(svc) {
117-
this.addService(svc);
118-
}.bind(this));
119-
}
120-
}
121-
} catch (err) {
122-
this.log("Could not process file " + file);
123-
this.log(err);
124-
this.log(err.stack);
125-
}
126-
}.bind(this));
127-
*/
128-
129-
}
130-
131-
/*
132-
NetatmoAccessory.prototype.configuredServices = [];
133-
NetatmoAccessory.prototype.defaultServices = [];
134-
135-
NetatmoAccessory.prototype.isConfiguredService = function (serviceType) {
136-
return ( this.configuredServices.indexOf(serviceType) > -1 );
137-
};
138-
139-
NetatmoAccessory.prototype.getDashboardValue = function (name, callback) {
140-
return this.device.getDashboardValue(this.deviceId, name, callback);
141-
}
142-
143-
NetatmoAccessory.prototype.getData = function (callback) {
144-
return this.device.getData(this.deviceId, callback);
145-
}
146-
147-
NetatmoAccessory.prototype.getServices = function () {
148-
return this.services;
149-
};
150103

151-
NetatmoAccessory.prototype.supportsService = function (serviceType) {
152-
return false;
153104
};
154-
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp