node-miio 0.0.0-dev-20250810-f1674d0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/.editorconfig +21 -0
  2. package/.eslintrc +32 -0
  3. package/.github/workflows/build.yml +50 -0
  4. package/.github/workflows/codecov.yml +35 -0
  5. package/.github/workflows/codeql.yml +24 -0
  6. package/.github/workflows/publish-dev-from-main.yml +92 -0
  7. package/.github/workflows/publish-release-to-npm.yml +48 -0
  8. package/CONTRIBUTING.md +104 -0
  9. package/LICENSE.md +20 -0
  10. package/README.md +216 -0
  11. package/cli/commands/configure.js +69 -0
  12. package/cli/commands/control.js +54 -0
  13. package/cli/commands/discover.js +36 -0
  14. package/cli/commands/inspect.js +197 -0
  15. package/cli/commands/protocol/call.js +66 -0
  16. package/cli/commands/protocol/json-dump.js +52 -0
  17. package/cli/commands/protocol/packet.js +29 -0
  18. package/cli/commands/protocol.js +8 -0
  19. package/cli/commands/tokens/update.js +58 -0
  20. package/cli/commands/tokens.js +8 -0
  21. package/cli/device-finder.js +66 -0
  22. package/cli/index.js +9 -0
  23. package/cli/log.js +89 -0
  24. package/docs/advanced-api.md +103 -0
  25. package/docs/devices/README.md +111 -0
  26. package/docs/devices/air-purifier.md +142 -0
  27. package/docs/devices/controller.md +89 -0
  28. package/docs/devices/gateway.md +41 -0
  29. package/docs/devices/humidifier.md +136 -0
  30. package/docs/devices/light.md +141 -0
  31. package/docs/devices/power-outlet.md +56 -0
  32. package/docs/devices/power-plug.md +69 -0
  33. package/docs/devices/power-strip.md +73 -0
  34. package/docs/devices/sensor.md +74 -0
  35. package/docs/devices/vacuum.md +80 -0
  36. package/docs/devices/wall-switch.md +62 -0
  37. package/docs/management.md +109 -0
  38. package/docs/missing-devices.md +48 -0
  39. package/docs/protocol.md +77 -0
  40. package/docs/reporting-issues.md +47 -0
  41. package/example.js +11 -0
  42. package/lib/checkResult.js +13 -0
  43. package/lib/connectToDevice.js +62 -0
  44. package/lib/device.js +290 -0
  45. package/lib/device_info.js +329 -0
  46. package/lib/device_info.test.js +337 -0
  47. package/lib/devices/air-monitor.js +53 -0
  48. package/lib/devices/air-purifier.js +162 -0
  49. package/lib/devices/capabilities/battery-level.js +16 -0
  50. package/lib/devices/capabilities/buzzer.js +78 -0
  51. package/lib/devices/capabilities/changeable-led-brightness.js +48 -0
  52. package/lib/devices/capabilities/colorable.js +14 -0
  53. package/lib/devices/capabilities/dimmable.js +14 -0
  54. package/lib/devices/capabilities/mode.js +13 -0
  55. package/lib/devices/capabilities/power.js +14 -0
  56. package/lib/devices/capabilities/sensor.js +50 -0
  57. package/lib/devices/capabilities/switchable-led.js +49 -0
  58. package/lib/devices/chuangmi.plug.v1.js +61 -0
  59. package/lib/devices/eyecare-lamp2.js +179 -0
  60. package/lib/devices/gateway/86sw1.js +28 -0
  61. package/lib/devices/gateway/86sw2.js +44 -0
  62. package/lib/devices/gateway/ctrl_ln1.js +44 -0
  63. package/lib/devices/gateway/ctrl_ln2.js +53 -0
  64. package/lib/devices/gateway/ctrl_neutral1.js +44 -0
  65. package/lib/devices/gateway/ctrl_neutral2.js +53 -0
  66. package/lib/devices/gateway/cube.js +55 -0
  67. package/lib/devices/gateway/developer-api.js +120 -0
  68. package/lib/devices/gateway/light-channel.js +32 -0
  69. package/lib/devices/gateway/light-mixin.js +71 -0
  70. package/lib/devices/gateway/magnet.js +29 -0
  71. package/lib/devices/gateway/magnet2.js +13 -0
  72. package/lib/devices/gateway/motion.js +27 -0
  73. package/lib/devices/gateway/motion2.js +31 -0
  74. package/lib/devices/gateway/plug.js +45 -0
  75. package/lib/devices/gateway/sensor_ht.js +17 -0
  76. package/lib/devices/gateway/subdevice.js +227 -0
  77. package/lib/devices/gateway/subdevices.js +37 -0
  78. package/lib/devices/gateway/switch.js +29 -0
  79. package/lib/devices/gateway/switch2.js +27 -0
  80. package/lib/devices/gateway/voltage.js +28 -0
  81. package/lib/devices/gateway/weather.js +22 -0
  82. package/lib/devices/gateway.js +244 -0
  83. package/lib/devices/humidifier.js +162 -0
  84. package/lib/devices/mijiavacuum.js +22 -0
  85. package/lib/devices/philips-light-bulb.js +73 -0
  86. package/lib/devices/power-plug.js +26 -0
  87. package/lib/devices/power-strip.js +38 -0
  88. package/lib/devices/vacuum.js +412 -0
  89. package/lib/devices/viomivacuum.js +250 -0
  90. package/lib/devices/yeelight.color.js +6 -0
  91. package/lib/devices/yeelight.js +286 -0
  92. package/lib/devices/yeelight.mono.js +9 -0
  93. package/lib/discovery.js +192 -0
  94. package/lib/index.js +40 -0
  95. package/lib/infoFromHostname.js +24 -0
  96. package/lib/management.js +102 -0
  97. package/lib/models.js +77 -0
  98. package/lib/network.js +234 -0
  99. package/lib/packet.js +191 -0
  100. package/lib/placeholder.js +12 -0
  101. package/lib/safeishJSON.js +14 -0
  102. package/lib/tokens.js +129 -0
  103. package/npm-shrinkwrap.json +853 -0
  104. package/package.json +40 -0
@@ -0,0 +1,136 @@
1
+ # Humidifier
2
+
3
+ * **Devices**: Mi Humidifier
4
+ * **Model identifiers**: `zhimi.humidifier.v1`
5
+
6
+ Humidifiers are turned into devices of type [humidifer][humidifier]
7
+ and by default support [power switching][switchable-power] and
8
+ [setting their mode][switchable-mode]. The Mi Humidifier are also
9
+ [sensors][sensor] and can report the [temperature][temp] and
10
+ [relative humidity][humidity] of where they are placed.
11
+
12
+ ## Examples
13
+
14
+ ### Check if device is a humidifier
15
+
16
+ ```javascript
17
+ if(device.matches('type:humidifier')) {
18
+ /*
19
+ * This device is a humidifier.
20
+ */
21
+ }
22
+ ```
23
+
24
+ ### Check if powered on
25
+
26
+ ```javascript
27
+ // Get if the humidifier is on
28
+ device.power()
29
+ .then(isOn => console.log('Humidifier on:', isOn))
30
+ .catch(...);
31
+
32
+ // Using async/await
33
+ console.log('Humidifier on:', await device.power());
34
+ ```
35
+
36
+ ### Power on device
37
+
38
+ ```javascript
39
+ // Switch the humidifier on
40
+ device.setPower(true)
41
+ .then(...)
42
+ .catch(...)
43
+
44
+ // Switch on via async/await
45
+ await device.power(true);
46
+ ```
47
+
48
+ ### Read temperature
49
+
50
+ ```javascript
51
+ // Read the temperature
52
+ device.temperature()
53
+ .then(temp => console.log('Temperature:', temp.celsius))
54
+ .catch(...);
55
+
56
+ // Using async/await
57
+ const temp = await device.temperature();
58
+ console.log('Temperature:', temp.celsius);
59
+ ```
60
+
61
+ ### Read humidity
62
+
63
+ ```javascript
64
+ // Read the relative humidity
65
+ device.relativeHumidity()
66
+ .then(rh => console.log('Relative humidity:', rh))
67
+ .catch(...);
68
+
69
+ // Using async/await
70
+ const rh = await device.relativeHumidity();
71
+ console.log('Relative humidity:', rh);
72
+ ```
73
+
74
+ ## API
75
+
76
+ ### Power - [`cap:power`][power] and [`cap:switchable-power`][switchable-power]
77
+
78
+ * `device.power()` - get if the humidifier is currently active
79
+ * `device.power(boolean)` - switch the humidifer is on, returns a promise
80
+ * `device.setPower(boolean)` - change the power state of the device, returns a promise
81
+ * `device.on('powerChanged', isOn => ...)` - listen for power changes
82
+
83
+ ### Mode - [`cap:mode`][mode] and [`cap:switchable-mode`][switchable-mode]
84
+
85
+ The air purifiers have different modes that controls their speed.
86
+
87
+ * `device.mode()` - get the current mode
88
+ * `device.mode(string)` - set the current mode of the device, returns a promise
89
+ * `device.setMode(string)` - set the current mode of the device, returns a promise
90
+ * `device.modes()` - read-only array indicating the modes supports by the device
91
+ * `device.on('modeChanged', mode => ...)` - listen for changes to the current mode
92
+
93
+ The modes supported change between different models, but most devices support:
94
+
95
+ * `idle`, turn the device off
96
+ * `silent`, silent mode, lowest speed
97
+ * `medium`, medium speed
98
+ * `hight`, high speed
99
+
100
+ ### Sensor - [`type:sensor`][sensor]
101
+
102
+ * `device.temperature()` - get the current temperature, see [`cap:temperature`][temp] for details
103
+ * `device.on('temperature', temp => ...)` - listen to changes to the read temperature
104
+ * `device.relativeHumidity()` - get the current relative humidity, see [`cap:relative-humidity`][humidity] for details
105
+ * `device.on('relativeHumidityChanged', rh => ...)` - listen to changes to the relative humidity
106
+
107
+ ### Target humidity - [`cap:target-humidity`][target-humidity] and [`cap:adjustable-target-humidity`][adjustable-target-humidity]
108
+
109
+ * `device.targetHumidity()` - get the current target humidity
110
+ * `device.targetHumidity(target)` - set the target humidity
111
+ * `device.on('targetHumidityChanged', th => ...)` - listen to changes to the target humidity
112
+
113
+ ### Buzzer settings - `cap:miio:buzzer`
114
+
115
+ * `device.buzzer()` - boolean indicating if the buzzer (beep) is active
116
+ * `device.buzzer(boolean)` - switch the buzzer on or off
117
+ * `device.setBuzzer(boolean)` - switch the buzzer on or off
118
+
119
+ ### LED brightness - `cap:miio:led-brightness`
120
+
121
+ Change the brightness of the LED on the device.
122
+
123
+ * `device.ledBrightness()` - the LED brightness, `bright`, `dim` or `off`
124
+ * `device.ledBrightness(string)` - set the brightness of the LED
125
+
126
+ [air-purifier]: http://abstract-things.readthedocs.io/en/latest/climate/air-purifiers.html
127
+ [sensor]: http://abstract-things.readthedocs.io/en/latest/sensors/index.html
128
+ [power]: http://abstract-things.readthedocs.io/en/latest/common/power.html
129
+ [switchable-power]: http://abstract-things.readthedocs.io/en/latest/common/switchable-power.html
130
+ [mode]: http://abstract-things.readthedocs.io/en/latest/common/mode.html
131
+ [switchable-mode]: http://abstract-things.readthedocs.io/en/latest/common/switchable-mode.html
132
+ [pm2.5]: http://abstract-things.readthedocs.io/en/latest/sensors/pm2.5.html
133
+ [temp]: http://abstract-things.readthedocs.io/en/latest/sensors/temperature.html
134
+ [humidity]: http://abstract-things.readthedocs.io/en/latest/sensors/relative-humidity.html
135
+ [target-humidity]: http://abstract-things.readthedocs.io/en/latest/climate/target-humidity.html
136
+ [adjustable-target-humidity]: http://abstract-things.readthedocs.io/en/latest/climate/adjustable-target-humidity.html
@@ -0,0 +1,141 @@
1
+ # Lights
2
+
3
+ * **Devices**: Mi Yeelight Lamps, Philiphs Bulb, Philiphs Eye Care lamp
4
+ * **Model identifiers**: `yeelink.light.lamp1`, `yeelink.light.mono1`, `yeelink.light.color1`, `yeelink.light.strip1`, `philips.light.sread1`, `philips.light.bulb`
5
+
6
+ Lights are turned into devices of type [light][light] and by default support
7
+ [power switching][switchable-power] and [dimming][dimmable]. Depending on the
8
+ model the light might [support color][colorable] and [fading][fading].
9
+
10
+ ## Examples
11
+
12
+ ### Check if device is a light
13
+
14
+ ```javascript
15
+ if(device.matches('type:light')) {
16
+ /*
17
+ * This device is a light.
18
+ */
19
+ }
20
+ ```
21
+
22
+ ### Check if powered on
23
+
24
+ ```javascript
25
+ // Get if the light is on
26
+ device.power()
27
+ .then(isOn => console.log('Light on:', isOn))
28
+ .catch(...);
29
+
30
+ // Using async/await
31
+ console.log('Light on:', await device.power());
32
+ ```
33
+
34
+ ### Power on light
35
+
36
+ ```javascript
37
+ // Switch the light on
38
+ device.setPower(true)
39
+ .then(...)
40
+ .catch(...)
41
+
42
+ // Switch on via async/await
43
+ await device.power(true);
44
+ ```
45
+
46
+ ### Read current brightness
47
+
48
+ ```javascript
49
+ // Read the current brightness
50
+ device.brightness()
51
+ .then(b => console.log('Brightness:', b))
52
+ .catch(...);
53
+
54
+ // Using async/await
55
+ console.log('Brightness:', await device.brightness());
56
+ ```
57
+
58
+ ### Change the brightness
59
+
60
+ ```javascript
61
+ // Set the brightness
62
+ device.setBrightness(50)
63
+ .then(...)
64
+ .catch(...);
65
+
66
+ // Using async/await
67
+ await device.setBrightness(50);
68
+
69
+ // Increase the brightness by 20%
70
+ await device.increaseBrightness(20);
71
+
72
+ // Decrease the brightness by 20%
73
+ await device.decreaseBrightness(20);
74
+ ```
75
+
76
+ ### Check if color is supported
77
+
78
+ ```javascript
79
+ if(device.matches('cap:colorable')) {
80
+ // Light supports setting color
81
+ }
82
+
83
+ if(device.matches('cap:colorable', 'cap:color:full')) {
84
+ // Light supports setting full range of colors
85
+ }
86
+
87
+ if(device.matches('cap:colorable', 'cap:color:temperature')) {
88
+ // Light supports color temperatures
89
+ }
90
+ ```
91
+
92
+ ## API
93
+
94
+ ### Power - [`cap:power`][power] and [`cap:switchable-power`][switchable-power]
95
+
96
+ * `device.power()` - get if the light is turned on
97
+ * `device.power(boolean)` - switch the light on or off
98
+ * `device.setPower(boolean)` - switch the light on or off
99
+ * `device.on('powerChanged', isOn => ...)` - listen for power changes
100
+
101
+ ### Brightness - [`cap:brightness`][brightness] and [`cap:dimmable`][dimmable]
102
+
103
+ * `device.brightness()` - get the brightness of the light
104
+ * `device.brightness(percentage, duration)` - set the brightness of the light
105
+ * `device.setBrightness(percentage, duration)` - set the brightness of the light
106
+ * `device.increaseBrightness(percentage, duration)` - increase the brightness of the light
107
+ * `device.decreaseBrightness(percentage, duration)` - decrease the brightness of the light
108
+ * `device.on('brightnessChanged', bri => ...)` - listen for changes in brightness
109
+
110
+ ### Color - [`cap:colorable`][colorable]
111
+
112
+ * `device.color()` - get the current color of the light
113
+ * `device.color(color, duration)` - update the color of the light, color can be hex-values, Kelvin-values, see capability docs for details
114
+ * `device.on('colorChanged', color => ...)` - listen for changes to color
115
+
116
+ ### Fading - [`cap:fading`][fading]
117
+
118
+ Supported by Yeelights. Indicates that the `duration` parameter works.
119
+
120
+ ## Models
121
+
122
+ ### Philiphs Eye Care Lamp - `philips.light.sread1`
123
+
124
+ The Eye Care lamp provides a child device to control the ambient light. This
125
+ ambient light implements [power switching][switchable-power] and
126
+ [dimming][dimmable]:
127
+
128
+ ```javascript
129
+ const ambientLight = light.child('ambient');
130
+
131
+ const isOn = await ambientLight.power();
132
+ ```
133
+
134
+ [light]: http://abstract-things.readthedocs.io/en/latest/lights/index.html
135
+ [sensor]: http://abstract-things.readthedocs.io/en/latest/sensors/index.html
136
+ [power]: http://abstract-things.readthedocs.io/en/latest/common/power.html
137
+ [switchable-power]: http://abstract-things.readthedocs.io/en/latest/common/switchable-power.html
138
+ [brightness]: http://abstract-things.readthedocs.io/en/latest/lights/brightness.html
139
+ [dimmable]: http://abstract-things.readthedocs.io/en/latest/lights/dimmable.html
140
+ [colorable]: http://abstract-things.readthedocs.io/en/latest/lights/colorable.html
141
+ [fading]: http://abstract-things.readthedocs.io/en/latest/lights/fading.html
@@ -0,0 +1,56 @@
1
+ # Power Outlets
2
+
3
+ * **Devices**: No outlets currently supported
4
+ * **Model identifiers**: No outlets currently supported
5
+
6
+ The supported models of power outlets are mapped into a [`power-outlet`][power-outlet] with support for [power switching][switchable-power].
7
+
8
+ ## Examples
9
+
10
+ ### Check if device is a power strip
11
+
12
+ ```javascript
13
+ if(device.matches('type:power-strip')) {
14
+ /*
15
+ * This device is a power strip.
16
+ */
17
+ }
18
+ ```
19
+
20
+ ### Check if powered on
21
+
22
+ ```javascript
23
+ // Get if the outlets on the strip have power
24
+ device.power()
25
+ .then(isOn => console.log('Outlet power:', isOn))
26
+ .catch(...);
27
+
28
+ // Using async/await
29
+ console.log('Outlet power:', await device.power());
30
+ ```
31
+
32
+ ### Power on device
33
+
34
+ ```javascript
35
+ // Switch the outlets on
36
+ device.setPower(true)
37
+ .then(...)
38
+ .catch(...)
39
+
40
+ // Switch on via async/await
41
+ await device.power(true);
42
+ ```
43
+
44
+ ## API
45
+
46
+ ### Power - [`cap:power`][power] and [`cap:switchable-power`][switchable-power]
47
+
48
+ * `device.power()` - get if the outlets currently have power
49
+ * `device.power(boolean)` - switch if outlets have power
50
+ * `device.setPower(boolean)` - switch if outlets have power
51
+ * `device.on(power, isOn => ...)` - listen for power changes
52
+
53
+ [power-outlet]: http://abstract-things.readthedocs.io/en/latest/electrical/outlets.html
54
+ [sensor]: http://abstract-things.readthedocs.io/en/latest/sensors/index.html
55
+ [power]: http://abstract-things.readthedocs.io/en/latest/common/power.html
56
+ [switchable-power]: http://abstract-things.readthedocs.io/en/latest/common/switchable-power.html
@@ -0,0 +1,69 @@
1
+ # Power Plugs
2
+
3
+ * **Devices**: Mi Smart Socket Plug, Aqara Plug
4
+ * **Model identifiers**: `chuangmi.plug.v1`, `chuangmi.plug.v2`, `chuangmi.plug.m1`, `lumi.plug`
5
+
6
+ The supported models of power plugs are mapped into a [`power-plug`][power-plug] with support for [power switching][switchable-power].
7
+
8
+ ## Examples
9
+
10
+ ### Check if device is a power strip
11
+
12
+ ```javascript
13
+ if(device.matches('type:power-strip')) {
14
+ /*
15
+ * This device is a power strip.
16
+ */
17
+ }
18
+ ```
19
+
20
+ ### Check if powered on
21
+
22
+ ```javascript
23
+ // Get if the outlets on the strip have power
24
+ device.power()
25
+ .then(isOn => console.log('Outlet power:', isOn))
26
+ .catch(...);
27
+
28
+ // Using async/await
29
+ console.log('Outlet power:', await device.power());
30
+ ```
31
+
32
+ ### Power on device
33
+
34
+ ```javascript
35
+ // Switch the outlets on
36
+ device.setPower(true)
37
+ .then(...)
38
+ .catch(...)
39
+
40
+ // Switch on via async/await
41
+ await device.power(true);
42
+ ```
43
+
44
+ ## API
45
+
46
+ ### Power - [`cap:power`][power] and [`cap:switchable-power`][switchable-power]
47
+
48
+ * `device.power()` - get if the outlets currently have power
49
+ * `device.power(boolean)` - switch if outlets have power
50
+ * `device.setPower(boolean)` - switch if outlets have power
51
+ * `device.on(power, isOn => ...)` - listen for power changes
52
+
53
+ ## Models
54
+
55
+ ### Mi Smart Socket Plug (V1) - `chuangmi.plug.v1`
56
+
57
+ The V1 plug has a USB-outlet that can be controlled individually. It is made
58
+ available as a child that implements [power switching][switchable-power]:
59
+
60
+ ```javascript
61
+ const usbOutlet = light.child('usb');
62
+
63
+ const isOn = await usbOutlet.power();
64
+ ```
65
+
66
+ [power-plug]: http://abstract-things.readthedocs.io/en/latest/electrical/plugs.html
67
+ [sensor]: http://abstract-things.readthedocs.io/en/latest/sensors/index.html
68
+ [power]: http://abstract-things.readthedocs.io/en/latest/common/power.html
69
+ [switchable-power]: http://abstract-things.readthedocs.io/en/latest/common/switchable-power.html
@@ -0,0 +1,73 @@
1
+ # Power Strips
2
+
3
+ * **Devices**: Mi Smart Power Strip
4
+ * **Model identifiers**: `qmi.powerstrip.v1`, `zimi.powerstrip.v2`
5
+
6
+ The two supported models of power strips are mapped into a [`power-strip`][power-strip] with support for [power switching][switchable-power].
7
+
8
+ ## Examples
9
+
10
+ ### Check if device is a power strip
11
+
12
+ ```javascript
13
+ if(device.matches('type:power-strip')) {
14
+ /*
15
+ * This device is a power strip.
16
+ */
17
+ }
18
+ ```
19
+
20
+ ### Check if powered on
21
+
22
+ ```javascript
23
+ // Get if the outlets on the strip have power
24
+ device.power()
25
+ .then(isOn => console.log('Outlet power:', isOn))
26
+ .catch(...);
27
+
28
+ // Using async/await
29
+ console.log('Outlet power:', await device.power());
30
+ ```
31
+
32
+ ### Power on device
33
+
34
+ ```javascript
35
+ // Switch the outlets on
36
+ device.setPower(true)
37
+ .then(...)
38
+ .catch(...)
39
+
40
+ // Switch on via async/await
41
+ await device.power(true);
42
+ ```
43
+
44
+ ## API
45
+
46
+ ### Power - [`cap:power`][power] and [`cap:switchable-power`][switchable-power]
47
+
48
+ * `device.power()` - get if the outlets currently have power
49
+ * `device.power(boolean)` - switch if outlets have power
50
+ * `device.setPower(boolean)` - switch if outlets have power
51
+ * `device.on(power, isOn => ...)` - listen for power changes
52
+
53
+ ### Mode - [`cap:mode`][mode] and [`cap:switchable-mode`][switchable-mode]
54
+
55
+ Power strips may support setting a certain mode, such as a special green mode.
56
+
57
+ * `device.mode()` - get the current mode
58
+ * `device.mode(string)` - set the current mode of the device, returns a promise
59
+ * `device.setMode(string)` - set the current mode of the device, returns a promise
60
+ * `device.modes()` - read-only array indicating the modes supports by the device
61
+ * `device.on('modeChanged', mode => ...)` - listen for changes to the current mode
62
+
63
+ The modes supported change between different models, but most devices support:
64
+
65
+ * `green`, green mode
66
+ * `normal`, normal mode
67
+
68
+ [power-strip]: http://abstract-things.readthedocs.io/en/latest/electrical/strips.html
69
+ [sensor]: http://abstract-things.readthedocs.io/en/latest/sensors/index.html
70
+ [power]: http://abstract-things.readthedocs.io/en/latest/common/power.html
71
+ [switchable-power]: http://abstract-things.readthedocs.io/en/latest/common/switchable-power.html
72
+ [mode]: http://abstract-things.readthedocs.io/en/latest/common/mode.html
73
+ [switchable-mode]: http://abstract-things.readthedocs.io/en/latest/common/switchable-mode.html
@@ -0,0 +1,74 @@
1
+ # Sensor
2
+
3
+ * `device.type`: `switch`
4
+ * **Models**: Aqara Temperature and Humidity Sensor
5
+ * **Model identifiers**: `lumi.sensor_ht`
6
+
7
+ The sensor type is used for things that are primarily a sensor. The capabilities
8
+ described below can be used without the type being `sensor` in which case the
9
+ device will instead be marked with `sensor` as a capability.
10
+
11
+ ## Basic API
12
+
13
+ None.
14
+
15
+ ## Capability: `temperature`
16
+
17
+ For when the device supports measuring the temperature.
18
+
19
+ ### Properties
20
+
21
+ * `temperature` - temperature in degrees Celsius
22
+
23
+ ### `device.temperature: number`
24
+
25
+ Get the temperature in degrees Celsius.
26
+
27
+ ## Capability: `humidity`
28
+
29
+ For when the device supports measuring the relative humidity.
30
+
31
+ ### Properties
32
+
33
+ * `humidity` - relative humidity in percent between 0 and 100
34
+
35
+ ### `device.humidity: number`
36
+
37
+ Get the relative humidity in percent between 0 and 100
38
+
39
+ ## Capability: `aqi`
40
+
41
+ For when the device supports measuring the air quality. Most Mi Home
42
+ products uses tha name `aqi` internally but seems to measure PM2.5.
43
+
44
+ ### Properties
45
+
46
+ * `aqi` - Air Quality Index number
47
+
48
+ ### `device.aqi: number`
49
+
50
+ Get the current Air Quality Index
51
+
52
+ ## Capability: `illuminance`
53
+
54
+ For when the device supports measuring illuminance in Lux.
55
+
56
+ ### Properties
57
+
58
+ * `illuminance` - the current illuminance in Lux
59
+
60
+ ### `device.illuminance: number`
61
+
62
+ Get the current illuminance in Lux
63
+
64
+ ## Capability: `pressure`
65
+
66
+ For when the device supports measuring the atmospheric pressure.
67
+
68
+ ### Properties
69
+
70
+ * `pressure` - Atmospheric pressure
71
+
72
+ ### `device.pressure: number`
73
+
74
+ Get the current atmospheric pressure in kPa
@@ -0,0 +1,80 @@
1
+ # Robot Vacuums
2
+
3
+ * **Devices**: Mi Robot Vacuum
4
+ * **Model identifiers**: `rockrobo.vacuum.v1`
5
+
6
+ Robot vacuums are mapped into a device of type [`vacuum`][vacuum]. The device
7
+ will support many different capabilities, such as autonomous cleaning, getting
8
+ the cleaning state and more.
9
+
10
+ ## Examples
11
+
12
+ ### Check if device is a vacuum
13
+
14
+ ```javascript
15
+ if(device.matches('type:vacuum')) {
16
+ /*
17
+ * This device is a vacuum.
18
+ */
19
+ }
20
+ ```
21
+
22
+ ### Check if cleaning
23
+
24
+ ```javascript
25
+ // Get the current cleaning state
26
+ device.cleaning()
27
+ .then(isCleaning => ...)
28
+ .catch(...);
29
+
30
+ // With async/wait
31
+ const isCleaning = await device.cleaning();
32
+ ```
33
+
34
+ ### Request cleaning
35
+
36
+ ```javascript
37
+ // Request cleaning
38
+ device.clean()
39
+ .then(...)
40
+ .catch(...);
41
+
42
+ // With async/await
43
+ await device.clean();
44
+ ```
45
+
46
+ ### Stop current cleaning
47
+
48
+ ```javascript
49
+ // Stop cleaning
50
+ device.stop()
51
+ .then(...)
52
+ .catch(...);
53
+
54
+ // With async/await
55
+ await device.stop();
56
+ ```
57
+
58
+ ### Request spot cleaning
59
+
60
+ ```javascript
61
+ // Spot clean
62
+ device.spotClean()
63
+ .then(...)
64
+ .catch(...);
65
+
66
+ // With async/await
67
+ await device.spotClean();
68
+ ```
69
+
70
+ ### Get the battery level
71
+
72
+ ```javascript
73
+ // Get the battery level
74
+ device.batteryLevel()
75
+ .then(level => ...)
76
+ .catch(...);
77
+
78
+ // With async/wait
79
+ const level = await device.batteryLevel();
80
+ ```
@@ -0,0 +1,62 @@
1
+ # Wall Switches
2
+
3
+ * **Devices**: Aqara Light Control (Wall Switch)
4
+ * **Model identifiers**: `lumi.ctrl_neutral1`, `lumi.ctrl_neutral2`, `lumi.ctrl_ln1`, `lumi.ctrl_ln2`
5
+
6
+ The supported models of power strips are mapped into a [`wall-switch`][wall-switch] where individual channels are available as child devices. The
7
+ child devices are [lights][light] with support for
8
+ [power switching][switchable-power].
9
+
10
+ ## Examples
11
+
12
+ ### Check if device is a wall switch
13
+
14
+ ```javascript
15
+ if(device.matches('type:wall-switch')) {
16
+ /*
17
+ * This device is a wall switch.
18
+ */
19
+ }
20
+ ```
21
+
22
+ ## Get a light channel
23
+
24
+ ```javascript
25
+ const light0 = device.child('0');
26
+
27
+ // For some devices
28
+ const light1 = device.child('1');
29
+ ```
30
+
31
+ ## Toggle power a light channel
32
+
33
+ ```javascript
34
+ const light0 = device.child('0');
35
+
36
+ // Change power to on
37
+ light0.power(true)
38
+ .then(...)
39
+ .catch(...);
40
+
41
+ // With async/await
42
+ await light0.power(true);
43
+ ```
44
+
45
+ ## API
46
+
47
+ ### Access individual power channels
48
+
49
+ * `device.
50
+
51
+ ## Child API
52
+
53
+ ### Power - [`cap:power`][power] and [`cap:switchable-power`][switchable-power]
54
+
55
+ * `device.power()` - get if the air purifier is currently active
56
+ * `device.power(boolean)` - switch the air purifier on, returns a promise
57
+ * `device.setPower(boolean)` - change the power state of the device, returns a promise
58
+ * `device.on(power, isOn => ...)` - listen for power changes
59
+
60
+ [wall-switch]: http://abstract-things.readthedocs.io/en/latest/electrical/wall-switches.html
61
+ [power]: http://abstract-things.readthedocs.io/en/latest/common/power.html
62
+ [switchable-power]: http://abstract-things.readthedocs.io/en/latest/common/switchable-power.html