@@ -10,17 +10,18 @@ let hap;
10
10
11
11
module . exports = homebridge => {
12
12
hap = homebridge . hap ;
13
- homebridge . registerAccessory ( 'homebridge-nature-remo-aircon' , 'NatureRemoAircon ' , NatureRemoAircon ) ;
13
+ homebridge . registerAccessory ( 'homebridge-nature-remo-cloud- aircon' , 'NatureRemoCloudAircon ' , NatureRemoCloudAircon ) ;
14
14
} ;
15
15
16
- class NatureRemoAircon {
16
+ class NatureRemoCloudAircon {
17
17
18
18
constructor ( log , config ) {
19
- log ( 'NatureRemoAircon init' ) ;
19
+ log ( 'NatureRemoCloudAircon init' ) ;
20
20
21
21
this . log = log ;
22
- this . appliance_id = config . appliance_id || null ;
23
- this . access_token = config . access_token ;
22
+ this . useDryForCool = config . useDryForCool || false ;
23
+ this . applianceId = config . applianceId || null ;
24
+ this . accessToken = config . accessToken ;
24
25
this . schedule = config . schedule || '* * * * *' ;
25
26
26
27
this . service = null ;
@@ -50,7 +51,7 @@ class NatureRemoAircon {
50
51
51
52
const options = Object . assign ( { } , DEFAULT_REQUEST_OPTIONS , {
52
53
uri : `/appliances/${ this . record . id } /aircon_settings` ,
53
- headers : { 'authorization' : `Bearer ${ this . access_token } ` } ,
54
+ headers : { 'authorization' : `Bearer ${ this . accessToken } ` } ,
54
55
method : 'POST' ,
55
56
form : this . requestParams
56
57
} ) ;
@@ -94,7 +95,7 @@ class NatureRemoAircon {
94
95
this . log ( 'refreshing target appliance record' ) ;
95
96
const options = Object . assign ( { } , DEFAULT_REQUEST_OPTIONS , {
96
97
uri : '/appliances' ,
97
- headers : { 'authorization' : `Bearer ${ this . access_token } ` }
98
+ headers : { 'authorization' : `Bearer ${ this . accessToken } ` }
98
99
} ) ;
99
100
100
101
request ( options , ( error , response , body ) => {
@@ -113,9 +114,9 @@ class NatureRemoAircon {
113
114
return ;
114
115
}
115
116
let appliance ;
116
- if ( this . appliance_id ) {
117
+ if ( this . applianceId ) {
117
118
appliance = json . find ( ( app , i ) => {
118
- return app . id === this . appliance_id ;
119
+ return app . id === this . applianceId ;
119
120
} ) ;
120
121
} else {
121
122
appliance = json . filter ( app => {
@@ -128,12 +129,12 @@ class NatureRemoAircon {
128
129
if ( appliance ) {
129
130
this . log ( `Target aircon ID: ${ appliance . id } ` ) ;
130
131
this . record = appliance ;
131
- this . appliance_id = appliance . id ; // persist discovered ID
132
+ this . applianceId = appliance . id ; // persist discovered ID
132
133
this . _refreshTemperature ( ) ;
133
134
this . _notifyConfigurationIfNeeded ( ) ;
134
135
this . _notifyLatestValues ( ) ;
135
136
} else {
136
- this . log ( 'Target aircon could not be found. You can leave `appliance_id ` blank to automatically use the first aircon.' ) ;
137
+ this . log ( 'Target aircon could not be found. You can leave `applianceId ` blank to automatically use the first aircon.' ) ;
137
138
}
138
139
} ) ;
139
140
}
@@ -147,7 +148,7 @@ class NatureRemoAircon {
147
148
this . log ( 'refreshing temperature record' ) ;
148
149
const options = Object . assign ( { } , DEFAULT_REQUEST_OPTIONS , {
149
150
uri : '/devices' ,
150
- headers : { 'authorization' : `Bearer ${ this . access_token } ` }
151
+ headers : { 'authorization' : `Bearer ${ this . accessToken } ` }
151
152
} ) ;
152
153
153
154
request ( options , ( error , response , body ) => {
@@ -226,7 +227,8 @@ class NatureRemoAircon {
226
227
return 0 ;
227
228
} else if ( settings . mode === 'warm' ) {
228
229
return 1 ;
229
- } else if ( settings . mode === 'cool' ) {
230
+ } else if ( settings . mode === 'cool' ||
231
+ settings . mode === 'dry' ) {
230
232
return 2 ;
231
233
} else if ( settings . mode === 'auto' ) {
232
234
return 3 ;
@@ -256,7 +258,7 @@ class NatureRemoAircon {
256
258
} else if ( value == 2 ) {
257
259
// cool
258
260
params . button = '' ;
259
- params . operation_mode = 'cool' ;
261
+ params . operation_mode = this . useDryForCool ? 'dry' : 'cool' ;
260
262
} else if ( value == 3 ) {
261
263
// auto
262
264
if ( 'auto' in this . record . aircon . range . modes ) {
@@ -377,7 +379,7 @@ class NatureRemoAircon {
377
379
const modes = this . record . aircon . range . modes ;
378
380
379
381
for ( const mode in modes ) {
380
- if ( ! ( mode === 'cool' || mode === 'warm' ) ) {
382
+ if ( ! ( mode === 'cool' || mode === 'warm' || mode === 'dry ') ) {
381
383
continue ;
382
384
}
383
385
const temperatures = modes [ mode ] . temp . filter ( t => t . match ( / ^ \d + ( \. \d + ) ? $ / ) ) . map ( t => parseInt ( t ) ) ;
@@ -387,4 +389,4 @@ class NatureRemoAircon {
387
389
return allTemperatures ;
388
390
}
389
391
390
- } // class NatureRemoAircon
392
+ } // class NatureRemoCloudAircon
0 commit comments