You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the example above, the system.get_sysinfo command returns a long structure that indicates the model of the device (system.get_sysinfo.model) and its device ID (system.get_sysinfo.deviceID.
92
99
93
100
This device is a single dimmer, and the state is directly part of the system.get_sysinfo structure (e.g. system.get_sysinfo.relay_state). It has four preferred levels (in array system.get_sysinfo.preferred_state: 100%, 75%, 50% and 25%). These preferred levels are shown on the phone app as shortcuts in the dimmer control screen.
94
101
95
102
The device can be turned on and of, without changing the dimmer level:
That command actually achieves two results: it both sets the dimmer level ("smartlife.iot.dimmer.set_brightness.brightness") and turns the light on ("smartlife.iot.dimmer.set_switch_state.state"). I guess the brightness level has little immediate effect when the light is turned off anyway.
113
124
114
125
(HouseKasa does not support controlling the dimmer level at this time.)
115
126
116
127
#### KP400
117
128
118
129
The example below shows the discovery of a KP400 (US model), using UDP:
The JSON returned is similar, but not all the same items are present (probably due to the different firmware version).
133
146
134
147
This device actually control two outlets independently, which is described in array "system.get_sysinfo.children". Note that each outlet has a two-character ID (00 and 01).
135
148
136
149
Note the "system.get_sysinfo.deviceID" value: this will be important later, when controlling each outlet.
137
150
138
151
Each outlet can be controlled independently by providing an identifier for that outlet. The outlet ID is the concatenation of the deviceID and outlet ID:
The array context.child_ids indicates which outlet(s) should be controlled. Apparently the protocol allows controlling multiple outlets in one command. The "system.set_relay_state.state" value indicates if the outlet should be turned off (0) or on (1).
146
161
147
162
The source item is optional. The context struct is mandatory (at least if one wants to control a subset of the outlets).
148
163
149
164
#### Alias
150
165
151
166
Each device or outlet can be assigned an alias, which is a way for the user to give a name to each:
@@ -167,7 +183,9 @@ Discovery of which devices are present on the network is made on a periodic basi
167
183
```
168
184
{"system":{"get_sysinfo":{}}}
169
185
```
186
+
170
187
HouseKasa searches for the following items in the response:
188
+
171
189
```
172
190
system.get_sysinfo.model
173
191
system.get_sysinfo.alias (if not set in HouseKasa)
@@ -183,6 +201,7 @@ If the array "system.get_sysinfo.children" is present, its state and alias eleme
183
201
The state of every known device is maintained by doing an unicast system.get_sysinfo request every 10 seconds, except after issuing a command, in which case the request is made at higher frequency for a minute, or else until the requested state was reached.
184
202
185
203
The Kasa devices (KP400 and HS220) all accept the "system.set_relay_state" command. However since the KP400 has two outlets, the exact outlet targetted must be specified using "context.child_ids". It happens that the HS220 also accept the presence of an outlet ID: it just ignores it. So the command sent for on and off is:
@@ -194,30 +213,41 @@ HouseKasa will query the state of each known device periodically (unicast UDP pa
194
213
## Command line tool
195
214
196
215
This software provides a tool named `kasa` to test controls of device:
216
+
197
217
```
198
218
kasa
199
219
```
220
+
200
221
Query the status of all devices present. This is a way to do some manual discovery.
222
+
201
223
```
202
224
kasa *host*
203
225
```
226
+
204
227
Query the status of the specified device.
228
+
205
229
```
206
230
kasa *host* alias *name*
207
231
```
208
232
209
233
Set the alias name for this device. This alias name is stored in the device.
234
+
210
235
```
211
236
kasa *host* on|off [hs220]
212
237
```
238
+
213
239
Set the device on or off. The hs220 option makes the tool use the alternative syntax accepted by the HS220 devices.
240
+
214
241
```
215
242
kasa *host* on|off kp400 *n*
216
243
```
244
+
217
245
Set an outlet on or off on a KP400 device. The KP400 has multiple outlets that can be controled independently, which is why the outlet number must be specified.
246
+
218
247
```
219
248
kasa -h|--help|help
220
249
```
250
+
221
251
Show the tool's help.
222
252
223
253
## Debian Packaging
@@ -232,6 +262,7 @@ The provided Makefile supports building private Debian packages. These are _not_
232
262
no source package.
233
263
234
264
To build a Debian package, use the `debian-package` target:
0 commit comments