Skip to content

Commit 4e4bb88

Browse files
change model name
1 parent 96ef5d7 commit 4e4bb88

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

lib/switchbot-advertising.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ class SwitchbotAdvertising {
8585

8686
if (model === 'H') { // WoHand
8787
sd = this._parseServiceDataForWoHand(buf);
88-
} else if (model === 'h') { // WoHumi
88+
} else if (model === 'e') { // WoHumi
8989
sd = this._parseServiceDataForWoHumi(buf);
9090
} else if (model === 'T') { // WoSensorTH
9191
sd = this._parseServiceDataForWoSensorTH(buf);
9292
} else if (model === 'c') { // WoCurtain
9393
sd = this._parseServiceDataForWoCurtain(buf);
94-
} else if (model === 'P') { // WoPresence
94+
} else if (model === 's') { // WoPresence
9595
sd = this._parseServiceDataForWoPresence(buf);
96-
} else if (model === 'C') { // WoContact
96+
} else if (model === 'd') { // WoContact
9797
sd = this._parseServiceDataForWoContact(buf);
9898
} else {
9999
return null;

lib/switchbot.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,13 @@ class Switchbot {
5757
* - duration | Integer | Optional | Duration for discovery process (msec).
5858
* | | | The value must be in the range of 1 to 60000.
5959
* | | | The default value is 5000 (msec).
60-
* - model | String | Optional | "H", "T", "M", "CS", or "c".
60+
* - model | String | Optional | "H", "T", "e", "s", "d", or "c".
6161
* | | | If "H" is specified, this method will discover only Bots.
6262
* | | | If "T" is specified, this method will discover only Meters.
63-
* | | | If "M" is specified, this method will discover only Motion Sensors.
64-
* | | | If "CS" is specified, this method will discover only Contact Sensors.
65-
* | | | If "C" is specified, this method will discover only Curtains.
63+
* | | | If "e" is specified, this method will discover only Humidifiers.
64+
* | | | If "s" is specified, this method will discover only Motion Sensors.
65+
* | | | If "d" is specified, this method will discover only Contact Sensors.
66+
* | | | If "c" is specified, this method will discover only Curtains.
6667
* - id | String | Optional | If this value is set, this method willl discover
6768
* | | | only a device whose ID is as same as this value.
6869
* | | | The ID is identical to the MAC address.
@@ -84,7 +85,7 @@ class Switchbot {
8485
// Check the parameters
8586
let valid = parameterChecker.check(params, {
8687
duration: { required: false, type: 'integer', min: 1, max: 60000 },
87-
model: { required: false, type: 'string', enum: ['H', 'h','T', 'P', 'C', 'c'] },
88+
model: { required: false, type: 'string', enum: ['H', 'T', 'e', 's', 'd', 'c'] },
8889
id: { required: false, type: 'string', min: 12, max: 17 },
8990
quick: { required: false, type: 'boolean' }
9091
}, false);
@@ -191,16 +192,16 @@ class Switchbot {
191192
case 'H':
192193
device = new SwitchbotDeviceWoHand(peripheral, this.noble);
193194
break;
194-
case 'Hu':
195+
case 'e':
195196
device = new SwitchbotDeviceWoHumi(peripheral, this.noble);
196197
break;
197198
case 'T':
198199
device = new SwitchbotDeviceWoSensorTH(peripheral, this.noble);
199200
break;
200-
case 'M':
201+
case 's':
201202
device = new SwitchbotDeviceWoPresence(peripheral, this.noble);
202203
break;
203-
case 'CS':
204+
case 'd':
204205
device = new SwitchbotDeviceWoContact(peripheral, this.noble);
205206
break;
206207
case 'c':
@@ -240,20 +241,23 @@ class Switchbot {
240241
*
241242
* [Arguments]
242243
* - params | Object | Optional |
243-
* - model | String | Optional | "H", "T", "M", "CS", or "C".
244+
* - model | String | Optional | "H", "T", "e", "s", "d", or "c".
244245
* | | | If "H" is specified, the `onadvertisement`
245246
* | | | event hander will be called only when advertising
246247
* | | | packets comes from Bots.
247248
* | | | If "T" is specified, the `onadvertisement`
248249
* | | | event hander will be called only when advertising
249250
* | | | packets comes from Meters.
250-
* | | | If "M" is specified, the `onadvertisement`
251+
* | | | If "e" is specified, the `onadvertisement`
252+
* | | | event hander will be called only when advertising
253+
* | | | packets comes from Humidifiers.
254+
* | | | If "s" is specified, the `onadvertisement`
251255
* | | | event hander will be called only when advertising
252256
* | | | packets comes from Motion Sensor.
253-
* | | | If "CS" is specified, the `onadvertisement`
257+
* | | | If "d" is specified, the `onadvertisement`
254258
* | | | event hander will be called only when advertising
255259
* | | | packets comes from Contact Sensor.
256-
* | | | If "C" is specified, the `onadvertisement`
260+
* | | | If "c" is specified, the `onadvertisement`
257261
* | | | event hander will be called only when advertising
258262
* | | | packets comes from Curtains.
259263
* - id | String | Optional | If this value is set, the `onadvertisement`
@@ -272,7 +276,7 @@ class Switchbot {
272276
let promise = new Promise((resolve, reject) => {
273277
// Check the parameters
274278
let valid = parameterChecker.check(params, {
275-
model: { required: false, type: 'string', enum: ['H', 'h', 'T', 'P', 'C', 'c'] },
279+
model: { required: false, type: 'string', enum: ['H', 'T', 'e', 's', 'd', 'c'] },
276280
id: { required: false, type: 'string', min: 12, max: 17 },
277281
}, false);
278282

0 commit comments

Comments
 (0)