node-miio 0.4.0 → 0.6.0
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.
- package/.claude/skills/release/SKILL.md +11 -0
- package/AGENTS.md +17 -2
- package/CONTRIBUTING.md +41 -87
- package/README.md +43 -7
- package/dist/cli/commands/cloud/devices.d.ts +10 -0
- package/dist/cli/commands/cloud/login.d.ts +8 -0
- package/dist/cli/commands/cloud/logout.d.ts +4 -0
- package/dist/cli/commands/cloud/map.d.ts +10 -0
- package/dist/cli/commands/cloud/map.js +131 -0
- package/dist/cli/commands/cloud/map.js.map +1 -0
- package/dist/cli/commands/cloud.d.ts +5 -0
- package/dist/cli/commands/cloud.js +3 -1
- package/dist/cli/commands/cloud.js.map +1 -1
- package/dist/cli/commands/configure.d.ts +18 -0
- package/dist/cli/commands/control.d.ts +4 -0
- package/dist/cli/commands/discover.d.ts +9 -0
- package/dist/cli/commands/inspect.d.ts +4 -0
- package/dist/cli/commands/miot-spec.d.ts +10 -0
- package/dist/cli/commands/protocol/call.d.ts +9 -0
- package/dist/cli/commands/protocol/json-dump.d.ts +8 -0
- package/dist/cli/commands/protocol/packet.d.ts +8 -0
- package/dist/cli/commands/protocol.d.ts +5 -0
- package/dist/cli/commands/tokens/update.d.ts +9 -0
- package/dist/cli/commands/tokens.d.ts +5 -0
- package/dist/cli/device-finder.d.ts +3 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/log.d.ts +9 -0
- package/dist/cli/prompt.d.ts +11 -0
- package/dist/cli/terminal_qr.d.ts +7 -0
- package/dist/lib/check_result.d.ts +6 -0
- package/dist/lib/cloud/client.d.ts +142 -0
- package/dist/lib/cloud/client.js +2 -5
- package/dist/lib/cloud/client.js.map +1 -1
- package/dist/lib/cloud/crypto.d.ts +56 -0
- package/dist/lib/cloud/errors.d.ts +26 -0
- package/dist/lib/cloud/http.d.ts +55 -0
- package/dist/lib/cloud/index.d.ts +5 -0
- package/dist/lib/cloud/login.d.ts +57 -0
- package/dist/lib/cloud/login.js +2 -2
- package/dist/lib/cloud/login.js.map +1 -1
- package/dist/lib/cloud/session_store.d.ts +27 -0
- package/dist/lib/connect_to_device.d.ts +10 -0
- package/dist/lib/device.d.ts +151 -0
- package/dist/lib/device.js +53 -19
- package/dist/lib/device.js.map +1 -1
- package/dist/lib/device_info.d.ts +66 -0
- package/dist/lib/device_info.js +23 -10
- package/dist/lib/device_info.js.map +1 -1
- package/dist/lib/devices/air-monitor.d.ts +8 -0
- package/dist/lib/devices/air-purifier.d.ts +40 -0
- package/dist/lib/devices/capabilities/battery-level.d.ts +22 -0
- package/dist/lib/devices/capabilities/buzzer.d.ts +33 -0
- package/dist/lib/devices/capabilities/changeable-led-brightness.d.ts +35 -0
- package/dist/lib/devices/capabilities/colorable.d.ts +21 -0
- package/dist/lib/devices/capabilities/dimmable.d.ts +21 -0
- package/dist/lib/devices/capabilities/mode.d.ts +21 -0
- package/dist/lib/devices/capabilities/power.d.ts +21 -0
- package/dist/lib/devices/capabilities/sensor.d.ts +15 -0
- package/dist/lib/devices/capabilities/switchable-led.d.ts +35 -0
- package/dist/lib/devices/chuangmi.plug.v1.d.ts +31 -0
- package/dist/lib/devices/eyecare-lamp2.d.ts +91 -0
- package/dist/lib/devices/gateway/86sw1.d.ts +7 -0
- package/dist/lib/devices/gateway/86sw2.d.ts +7 -0
- package/dist/lib/devices/gateway/ctrl_ln1.d.ts +8 -0
- package/dist/lib/devices/gateway/ctrl_ln2.d.ts +8 -0
- package/dist/lib/devices/gateway/ctrl_neutral1.d.ts +8 -0
- package/dist/lib/devices/gateway/ctrl_neutral2.d.ts +8 -0
- package/dist/lib/devices/gateway/cube.d.ts +6 -0
- package/dist/lib/devices/gateway/developer-api.d.ts +15 -0
- package/dist/lib/devices/gateway/light-channel.d.ts +10 -0
- package/dist/lib/devices/gateway/light-mixin.d.ts +2 -0
- package/dist/lib/devices/gateway/magnet.d.ts +6 -0
- package/dist/lib/devices/gateway/magnet2.d.ts +5 -0
- package/dist/lib/devices/gateway/motion.d.ts +6 -0
- package/dist/lib/devices/gateway/motion2.d.ts +6 -0
- package/dist/lib/devices/gateway/plug.d.ts +6 -0
- package/dist/lib/devices/gateway/sensor_ht.d.ts +5 -0
- package/dist/lib/devices/gateway/subdevice.d.ts +70 -0
- package/dist/lib/devices/gateway/subdevices.d.ts +49 -0
- package/dist/lib/devices/gateway/switch.d.ts +6 -0
- package/dist/lib/devices/gateway/switch2.d.ts +6 -0
- package/dist/lib/devices/gateway/voltage.d.ts +23 -0
- package/dist/lib/devices/gateway/weather.d.ts +5 -0
- package/dist/lib/devices/gateway.d.ts +98 -0
- package/dist/lib/devices/humidifier.d.ts +20 -0
- package/dist/lib/devices/philips-light-bulb.d.ts +8 -0
- package/dist/lib/devices/power-plug.d.ts +30 -0
- package/dist/lib/devices/power-strip.d.ts +7 -0
- package/dist/lib/devices/vacuums/dreamevacuum.d.ts +81 -0
- package/dist/lib/devices/vacuums/dreamevacuum.js +10 -2
- package/dist/lib/devices/vacuums/dreamevacuum.js.map +1 -1
- package/dist/lib/devices/vacuums/mijiavacuum.d.ts +4 -0
- package/dist/lib/devices/vacuums/miot-vacuum.d.ts +130 -0
- package/dist/lib/devices/vacuums/miot-vacuum.js +2 -0
- package/dist/lib/devices/vacuums/miot-vacuum.js.map +1 -1
- package/dist/lib/devices/vacuums/vacuum.d.ts +276 -0
- package/dist/lib/devices/vacuums/vacuum.js +2 -0
- package/dist/lib/devices/vacuums/vacuum.js.map +1 -1
- package/dist/lib/devices/vacuums/vacuum_device.d.ts +17 -0
- package/dist/lib/devices/vacuums/vacuum_device.js +14 -0
- package/dist/lib/devices/vacuums/vacuum_device.js.map +1 -0
- package/dist/lib/devices/vacuums/vacuum_errors.d.ts +10 -0
- package/dist/lib/devices/vacuums/vacuum_errors.js +25 -0
- package/dist/lib/devices/vacuums/vacuum_errors.js.map +1 -0
- package/dist/lib/devices/vacuums/vacuum_modes.d.ts +51 -0
- package/dist/lib/devices/vacuums/viomivacuum.d.ts +76 -0
- package/dist/lib/devices/vacuums/viomivacuum.js +2 -0
- package/dist/lib/devices/vacuums/viomivacuum.js.map +1 -1
- package/dist/lib/devices/yeelight.color.d.ts +3 -0
- package/dist/lib/devices/yeelight.d.ts +159 -0
- package/dist/lib/devices/yeelight.mono.d.ts +3 -0
- package/dist/lib/discovery.d.ts +53 -0
- package/dist/lib/events.d.ts +18 -0
- package/dist/lib/events.js +3 -0
- package/dist/lib/events.js.map +1 -0
- package/dist/lib/index.d.ts +60 -0
- package/dist/lib/index.js +5 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/info_from_hostname.d.ts +13 -0
- package/dist/lib/logger.d.ts +43 -0
- package/dist/lib/logger.js +62 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/management.d.ts +53 -0
- package/dist/lib/maps/map_watcher.d.ts +71 -0
- package/dist/lib/maps/map_watcher.js +2 -5
- package/dist/lib/maps/map_watcher.js.map +1 -1
- package/dist/lib/maps/roborock_map.d.ts +83 -0
- package/dist/lib/miio_error.d.ts +12 -0
- package/dist/lib/miot/miot_api.d.ts +54 -0
- package/dist/lib/miot/miot_spec.d.ts +114 -0
- package/dist/lib/miot/spec_client.d.ts +125 -0
- package/dist/lib/miot/spec_client.js +2 -2
- package/dist/lib/miot/spec_client.js.map +1 -1
- package/dist/lib/models.d.ts +271 -0
- package/dist/lib/network.d.ts +58 -0
- package/dist/lib/network.js +5 -2
- package/dist/lib/network.js.map +1 -1
- package/dist/lib/packet.d.ts +21 -0
- package/dist/lib/placeholder.d.ts +7 -0
- package/dist/lib/protocol.d.ts +299 -0
- package/dist/lib/safeish_json.d.ts +7 -0
- package/dist/lib/tokens.d.ts +12 -0
- package/dist/types/abstract-things/climate/index.d.ts +431 -0
- package/dist/types/abstract-things/electricals/index.d.ts +5 -0
- package/dist/types/abstract-things/index.d.ts +206 -0
- package/dist/types/abstract-things/lights/index.d.ts +14 -0
- package/dist/types/abstract-things/values/index.d.ts +12 -0
- package/docs/cloud.md +5 -1
- package/package.json +6 -3
- package/snapshots/vacuum-specs.json.gz +0 -0
|
@@ -59,4 +59,15 @@ npm view node-miio dist-tags
|
|
|
59
59
|
If it fails, report it: don't publish by hand without asking. Once a version is on npm, the plugins'
|
|
60
60
|
Renovate (no cooldown for node-miio) opens their update PRs.
|
|
61
61
|
|
|
62
|
+
## Ask the testers / tell the reporters
|
|
63
|
+
|
|
64
|
+
Once the version is on npm:
|
|
65
|
+
|
|
66
|
+
- **Beta**: comment on the beta testers issue (#18) mentioning the testers whose model or dock matches the
|
|
67
|
+
changes. Give them a short test list (2–3 items: "turn on X, check that Y happens") and ask for ✅ / ❌ per item, with
|
|
68
|
+
debug logs for ❌. Also comment on the issues the beta addresses, asking the reporters to try it. node-miio betas usually come from a plugin issue: also mention the matching testers in the plugins' issues (homebridge #1232, matterbridge #387).
|
|
69
|
+
- **Release**: comment on every issue it addresses: the version, how to enable/use it, and "if it doesn't work, comment
|
|
70
|
+
here and we'll reopen it" (reporters can't reopen issues closed by a maintainer or a PR). Keep them closed: don't
|
|
71
|
+
leave issues open waiting for feedback that may never come.
|
|
72
|
+
|
|
62
73
|
Report the release and npm links to the user.
|
package/AGENTS.md
CHANGED
|
@@ -20,7 +20,8 @@ Guidance for AI coding agents (and humans) working on `node-miio`.
|
|
|
20
20
|
npm ci
|
|
21
21
|
npm run lint # eslint --max-warnings=0: warnings fail CI too
|
|
22
22
|
npm test # jest (babel-jest: tests are NOT type-checked, `npm run build` is)
|
|
23
|
-
npm run build # tsc -> dist/
|
|
23
|
+
npm run build # tsc -> dist/ (JS + .d.ts), then scripts/copy-types.mjs ships src/types/ (abstract-things)
|
|
24
|
+
npm run test:types # after build: type-checks test-types/consumer.ts against the published types, like a plugin
|
|
24
25
|
node dist/cli/index.js --help # smoke-test the CLI after building
|
|
25
26
|
```
|
|
26
27
|
|
|
@@ -49,11 +50,25 @@ the ESM-only yargs 18 is loaded with `require()`, which needs `require(esm)` sup
|
|
|
49
50
|
- Commands using `refresh`/`refreshDelay` wait on timers: use fake timers and `jest.advanceTimersByTimeAsync`.
|
|
50
51
|
- `src/lib/modules_load.test.ts` loads every module in isolation. It catches broken mixins and circular imports.
|
|
51
52
|
|
|
53
|
+
## Published types
|
|
54
|
+
|
|
55
|
+
- The package ships declarations (`"types": "dist/lib/index.d.ts"`), so the plugins don't need hand-written ones.
|
|
56
|
+
`test-types/consumer.ts` uses the API the way the plugins do: when you add or change public API, use it there too.
|
|
57
|
+
- The class-mixin pattern (`Thing.type(...)`, `.with(...)`) can't publish private/protected members (TS4094): mark them
|
|
58
|
+
`/** @internal */` (removed from the declarations with `stripInternal`). Computed methods (e.g. `[util.inspect.custom]`)
|
|
59
|
+
can't be named either: `Device` defines that one in its constructor.
|
|
60
|
+
- The mixin typings live in `src/types/abstract-things/` (the package has none) and are published with the library.
|
|
61
|
+
`Proto<T>` (the instance type of a class or mixin) keeps the composed classes typed: `T["prototype"]` was `any`.
|
|
62
|
+
- `VacuumDevice` is the union of the vacuum classes: only their shared API is available without narrowing
|
|
63
|
+
(`instanceof Vacuum`…). Keep that shared API consistent across the classes (e.g. `cleanRooms` rejects when unsupported).
|
|
64
|
+
|
|
52
65
|
## Linting
|
|
53
66
|
|
|
54
67
|
- JSDoc is optional. When present, it must be correct (`check-param-names`, `require-param`, `check-tag-names`).
|
|
55
68
|
In `.ts` files, types come from TypeScript, so JSDoc types are not allowed (`jsdoc/no-types`). In `.js` files, `@param {type}` is required.
|
|
56
|
-
- `console` is only allowed in `src/cli/**` and `scripts/**`.
|
|
69
|
+
- `console` is only allowed in `src/cli/**` and `scripts/**`. In the library, log with `createDebug(namespace)` from `src/lib/logger.ts`
|
|
70
|
+
(not the `debug` package directly): it also forwards to the logger injected by the plugins (`device({ logger })` /
|
|
71
|
+
`configureLogging`), and redacts tokens and passwords. Never log a token in full (use `maskToken`).
|
|
57
72
|
|
|
58
73
|
## Gotchas learned the hard way
|
|
59
74
|
|
package/CONTRIBUTING.md
CHANGED
|
@@ -1,104 +1,58 @@
|
|
|
1
1
|
# Contributing
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Thank you for helping! The maintainer **doesn't own most of the supported devices**: changes are developed against
|
|
4
|
+
automated tests that replay what real devices answered, and they're validated by users on beta releases. So the most
|
|
5
|
+
valuable contributions don't need any code:
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
- [Become a beta tester](#become-a-beta-tester)
|
|
8
|
+
- [Share what your device reports](#share-what-your-device-reports)
|
|
9
|
+
- [Contributing code](#contributing-code)
|
|
8
10
|
|
|
9
|
-
##
|
|
11
|
+
## Become a beta tester
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
for Markdown and a few JSON-files. Install an [Editorconfig](http://editorconfig.org/)
|
|
14
|
-
plugin in your editor to simplify white-space handling.
|
|
13
|
+
Most users run node-miio through a plugin. Sign up as a beta tester in the plugin you use, with your **model**,
|
|
14
|
+
**firmware version** and dock (if any). You'll be mentioned whenever a beta needs a device like yours:
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
while you work.
|
|
16
|
+
- Homebridge: [homebridge-xiaomi-roborock-vacuum#1232](https://github.com/homebridge-xiaomi-roborock-vacuum/homebridge-xiaomi-roborock-vacuum/issues/1232)
|
|
17
|
+
- Matterbridge: [matterbridge-xiaomi-roborock#387](https://github.com/afharo/matterbridge-xiaomi-roborock/issues/387)
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
If you use node-miio directly, comment on [#18](https://github.com/afharo/node-miio/issues/18) instead. Betas are
|
|
20
|
+
published with the `beta` tag: `npm install node-miio@beta`.
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
via other projects. When opening an issue try to include as much details about
|
|
24
|
-
how the library is used, such as if its being used via a third-party project
|
|
25
|
-
and the version being used.
|
|
22
|
+
## Share what your device reports
|
|
26
23
|
|
|
27
|
-
|
|
28
|
-
questions you can. If you have the same issue as someone else, try adding a few
|
|
29
|
-
more details if you can.
|
|
24
|
+
Supporting a model or a feature starts with knowing what the device answers. When opening an issue, include:
|
|
30
25
|
|
|
31
|
-
|
|
26
|
+
- [ ] The **model** and **firmware version**: `npx node-miio@latest protocol call <ip> miIO.info --token <token>` (the
|
|
27
|
+
`model` and `fw_ver` fields).
|
|
28
|
+
- [ ] What you'd like to do, and **how you do it in the Mi Home app**.
|
|
29
|
+
- [ ] Raw captures:
|
|
30
|
+
- Roborock (`roborock.vacuum.*`, `rockrobo.vacuum.*`):
|
|
31
|
+
`npx node-miio@latest protocol call <ip> get_status --token <token>`. Ideally twice: before and after doing the
|
|
32
|
+
action in the app, so we can see which field changes.
|
|
33
|
+
- Any other brand (MIoT devices): `npx node-miio@latest spec <model>`.
|
|
34
|
+
- [ ] Whether you can test a beta.
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
Replies are turned into test fixtures (`src/lib/__fixtures__/`), so the behaviour stays covered without the device.
|
|
34
37
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
|
38
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
39
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
|
40
|
-
orientation.
|
|
38
|
+
**Remove private data before posting**: the token (and any `ssecurity` / `serviceToken`), the serial number, the MAC and
|
|
39
|
+
IP addresses, your Wi-Fi name (`ssid`) and anything else that identifies your home.
|
|
41
40
|
|
|
42
|
-
|
|
41
|
+
## Contributing code
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
Pull requests are very welcome, too. Read [AGENTS.md](./AGENTS.md) first: it describes the layout, the commands, how to
|
|
44
|
+
test without hardware, and the gotchas (for humans as well).
|
|
46
45
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
- Open PRs from a feature branch against `main`, with a label (`enhancement`, `bug`, `dependencies`, `documentation`):
|
|
47
|
+
the release notes are generated from them.
|
|
48
|
+
- Every behavioural change needs **unit tests**. Use `createFakeHandle(model, responses)` to replay device responses,
|
|
49
|
+
ideally real captures from users.
|
|
50
|
+
- Before pushing: `npm run lint` (ESLint and Prettier, warnings fail too), `npm test` and `npm run build`.
|
|
51
|
+
- **Licensing**: node-miio is MIT. Don't copy or translate code, mappings or tables from GPL projects (e.g. python-miio).
|
|
52
|
+
Using them as a reference for how a device behaves is fine.
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
## Code of conduct
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
* Public or private harassment
|
|
59
|
-
* Publishing others' private information, such as a physical or electronic
|
|
60
|
-
address, without explicit permission
|
|
61
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
|
62
|
-
professional setting
|
|
63
|
-
|
|
64
|
-
### Our Responsibilities
|
|
65
|
-
|
|
66
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
|
67
|
-
behavior and are expected to take appropriate and fair corrective action in
|
|
68
|
-
response to any instances of unacceptable behavior.
|
|
69
|
-
|
|
70
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
|
71
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
72
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
73
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
|
74
|
-
threatening, offensive, or harmful.
|
|
75
|
-
|
|
76
|
-
### Scope
|
|
77
|
-
|
|
78
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
|
79
|
-
when an individual is representing the project or its community. Examples of
|
|
80
|
-
representing a project or community include using an official project e-mail
|
|
81
|
-
address, posting via an official social media account, or acting as an appointed
|
|
82
|
-
representative at an online or offline event. Representation of a project may be
|
|
83
|
-
further defined and clarified by project maintainers.
|
|
84
|
-
|
|
85
|
-
### Enforcement
|
|
86
|
-
|
|
87
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
88
|
-
reported by contacting the main developer at a@holstenson.se. All
|
|
89
|
-
complaints will be reviewed and investigated and will result in a response that
|
|
90
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
|
91
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
92
|
-
Further details of specific enforcement policies may be posted separately.
|
|
93
|
-
|
|
94
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
95
|
-
faith may face temporary or permanent repercussions as determined by other
|
|
96
|
-
members of the project's leadership.
|
|
97
|
-
|
|
98
|
-
### Attribution
|
|
99
|
-
|
|
100
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
101
|
-
available at [http://contributor-covenant.org/version/1/4][version]
|
|
102
|
-
|
|
103
|
-
[homepage]: http://contributor-covenant.org
|
|
104
|
-
[version]: http://contributor-covenant.org/version/1/4/
|
|
56
|
+
Be kind and respectful. This project follows the
|
|
57
|
+
[Contributor Covenant](https://www.contributor-covenant.org/version/2/1/code_of_conduct/). Unacceptable behaviour can be
|
|
58
|
+
reported to the maintainer ([@afharo](https://github.com/afharo)).
|
package/README.md
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
<!-- prettier-ignore -->
|
|
2
|
-
> [!
|
|
3
|
-
> **
|
|
2
|
+
> [!NOTE]
|
|
3
|
+
> **Beta testers wanted**
|
|
4
4
|
>
|
|
5
|
-
>
|
|
6
|
-
>
|
|
7
|
-
>
|
|
8
|
-
> In the meantime, I'll keep addressing the reported issues with AI-assisted development, relying on the automated tests and **your feedback**: please, try the beta releases and report back.
|
|
9
|
-
> Interested in taking over? Please, comment on [this issue](https://github.com/afharo/node-miio/issues/18).
|
|
5
|
+
> The maintainer no longer owns most of the supported devices, so changes are developed against automated tests and validated by users on beta releases.
|
|
6
|
+
> If you'd like to help, sign up as a beta tester in the plugin you use ([Homebridge](https://github.com/homebridge-xiaomi-roborock-vacuum/homebridge-xiaomi-roborock-vacuum/issues/1232), [Matterbridge](https://github.com/afharo/matterbridge-xiaomi-roborock/issues/387)) or in [#18](https://github.com/afharo/node-miio/issues/18).
|
|
7
|
+
> See [CONTRIBUTING.md](./CONTRIBUTING.md) for other ways to help. Co-maintainers are welcome too.
|
|
10
8
|
|
|
11
9
|
# miIO Device Library
|
|
12
10
|
|
|
@@ -96,6 +94,22 @@ npm install -g node-miio
|
|
|
96
94
|
const miio = require("node-miio");
|
|
97
95
|
```
|
|
98
96
|
|
|
97
|
+
The package includes TypeScript declarations. With TypeScript, use `isVacuum()` to narrow the device to a
|
|
98
|
+
`VacuumDevice`, and `instanceof` for the API of a specific implementation:
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
import * as miio from "node-miio";
|
|
102
|
+
import { isVacuum, Vacuum } from "node-miio";
|
|
103
|
+
|
|
104
|
+
const device = await miio.device({ address, token });
|
|
105
|
+
if (isVacuum(device)) {
|
|
106
|
+
await device.activateCleaning(); // shared by every vacuum
|
|
107
|
+
if (device instanceof Vacuum) {
|
|
108
|
+
await device.startMopWash(); // Roborock only
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
99
113
|
Resolve a handle to the device:
|
|
100
114
|
|
|
101
115
|
```javascript
|
|
@@ -254,6 +268,28 @@ To activate both namespaces set `DEBUG` to both:
|
|
|
254
268
|
$ DEBUG=miio\*,thing\* miio discover
|
|
255
269
|
```
|
|
256
270
|
|
|
271
|
+
### Sending the debug messages to your own logger
|
|
272
|
+
|
|
273
|
+
Apps (e.g. Homebridge or Matterbridge plugins) can send node-miio's debug messages to their own logger, so users don't
|
|
274
|
+
need to set `DEBUG`. Tokens and passwords are redacted from these messages.
|
|
275
|
+
|
|
276
|
+
```javascript
|
|
277
|
+
const miio = require("node-miio");
|
|
278
|
+
|
|
279
|
+
// The messages of this device (requests, responses, property changes…)
|
|
280
|
+
const device = await miio.device({
|
|
281
|
+
address,
|
|
282
|
+
token,
|
|
283
|
+
logger: { debug: (msg) => log.debug(msg) },
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
// Everything that isn't about a specific device (network, MIoT specs, Xiaomi Cloud…)
|
|
287
|
+
miio.configureLogging({ logger: { debug: (msg) => log.debug(msg) } });
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
The messages are prefixed with their namespace, e.g. `[thing:miio:1234] <- Message: ...`. The low-level packet details
|
|
291
|
+
(`miio:packet`) are only available through `DEBUG`.
|
|
292
|
+
|
|
257
293
|
## Protocol documentation
|
|
258
294
|
|
|
259
295
|
This library is based on the documentation provided by OpenMiHome. See https://github.com/OpenMiHome/mihome-binary-protocol for details. For details
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CommandBuilder } from "yargs";
|
|
2
|
+
import { type CloudServer } from "../../../lib/cloud/index";
|
|
3
|
+
export declare const command = "devices";
|
|
4
|
+
export declare const description = "List the devices of your Xiaomi account, with their tokens";
|
|
5
|
+
export declare const builder: CommandBuilder;
|
|
6
|
+
export declare const handler: (argv: {
|
|
7
|
+
server?: CloudServer;
|
|
8
|
+
json?: boolean;
|
|
9
|
+
save?: boolean;
|
|
10
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CommandBuilder } from "yargs";
|
|
2
|
+
export declare const command = "login";
|
|
3
|
+
export declare const description = "Log in to the Xiaomi Cloud (the session is saved, your password is not)";
|
|
4
|
+
export declare const builder: CommandBuilder;
|
|
5
|
+
export declare const handler: (argv: {
|
|
6
|
+
qr?: boolean;
|
|
7
|
+
username?: string;
|
|
8
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CommandBuilder } from "yargs";
|
|
2
|
+
export declare const command = "map <device>";
|
|
3
|
+
export declare const description = "Download the map of a Roborock vacuum: rooms, robot position and current room";
|
|
4
|
+
export declare const builder: CommandBuilder;
|
|
5
|
+
export declare const handler: (argv: {
|
|
6
|
+
device: string;
|
|
7
|
+
ip?: string;
|
|
8
|
+
out?: string;
|
|
9
|
+
json?: boolean;
|
|
10
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.handler = exports.builder = exports.description = exports.command = void 0;
|
|
7
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
8
|
+
const index_1 = require("../../../lib/cloud/index");
|
|
9
|
+
const connect_to_device_1 = require("../../../lib/connect_to_device");
|
|
10
|
+
const vacuum_1 = require("../../../lib/devices/vacuums/vacuum");
|
|
11
|
+
const roborock_map_1 = require("../../../lib/maps/roborock_map");
|
|
12
|
+
const log_1 = require("../../log");
|
|
13
|
+
exports.command = "map <device>";
|
|
14
|
+
exports.description = "Download the map of a Roborock vacuum: rooms, robot position and current room";
|
|
15
|
+
exports.builder = {
|
|
16
|
+
ip: {
|
|
17
|
+
type: "string",
|
|
18
|
+
description: "The IP of the vacuum (defaults to the one reported by the Xiaomi Cloud)",
|
|
19
|
+
},
|
|
20
|
+
out: {
|
|
21
|
+
type: "string",
|
|
22
|
+
description: "Save the raw map file (gzipped), e.g. to attach it to a bug report",
|
|
23
|
+
},
|
|
24
|
+
json: { type: "boolean", description: "Print the result as JSON" },
|
|
25
|
+
};
|
|
26
|
+
const IPV4 = /^\d{1,3}(\.\d{1,3}){3}$/;
|
|
27
|
+
const handler = async (argv) => {
|
|
28
|
+
const session = await (0, index_1.loadSession)();
|
|
29
|
+
if (!session) {
|
|
30
|
+
log_1.log.error("Not logged in. Run: node-miio cloud login");
|
|
31
|
+
process.exitCode = 1;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
let vacuum;
|
|
35
|
+
try {
|
|
36
|
+
const cloud = new index_1.XiaomiCloud(session);
|
|
37
|
+
const target = String(argv.device);
|
|
38
|
+
const device = await cloud.findDevice(IPV4.test(target) ? { ip: target } : { did: target });
|
|
39
|
+
if (!device) {
|
|
40
|
+
log_1.log.error(`${target} isn't in your Xiaomi account (use the device ID or IP from: node-miio cloud devices)`);
|
|
41
|
+
process.exitCode = 1;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (!/^(roborock|rockrobo)\./.test(device.model)) {
|
|
45
|
+
log_1.log.error(`Only Roborock maps are supported for now (${device.model}). Please open an issue to request your model.`);
|
|
46
|
+
process.exitCode = 1;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const address = argv.ip ?? (IPV4.test(target) ? target : device.localip);
|
|
50
|
+
if (!address) {
|
|
51
|
+
log_1.log.error("The IP of the vacuum is unknown: use --ip");
|
|
52
|
+
process.exitCode = 1;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
// The map name comes from the vacuum itself (local network), the file from the cloud
|
|
56
|
+
const connected = await (0, connect_to_device_1.connectToDevice)({
|
|
57
|
+
address,
|
|
58
|
+
token: device.token,
|
|
59
|
+
});
|
|
60
|
+
if (!(connected instanceof vacuum_1.Vacuum)) {
|
|
61
|
+
log_1.log.error(`Unexpected device type for ${device.model}`);
|
|
62
|
+
process.exitCode = 1;
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
vacuum = connected;
|
|
66
|
+
const name = await vacuum.getMapName();
|
|
67
|
+
const url = await cloud.getMapFileUrl(device.server, name);
|
|
68
|
+
const file = await cloud.download(url);
|
|
69
|
+
if (argv.out) {
|
|
70
|
+
await promises_1.default.writeFile(argv.out, file);
|
|
71
|
+
}
|
|
72
|
+
const map = (0, roborock_map_1.parseRoborockMap)(file);
|
|
73
|
+
const roomNames = new Map();
|
|
74
|
+
try {
|
|
75
|
+
for (const [id, roomName] of await vacuum.getRoomMap()) {
|
|
76
|
+
roomNames.set(Number(id), String(roomName));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// Older firmware: no room names
|
|
81
|
+
}
|
|
82
|
+
const summary = {
|
|
83
|
+
model: device.model,
|
|
84
|
+
mapVersion: `${map.majorVersion}.${map.minorVersion}`,
|
|
85
|
+
rooms: map.rooms.map((room) => ({
|
|
86
|
+
...room,
|
|
87
|
+
name: roomNames.get(room.id),
|
|
88
|
+
})),
|
|
89
|
+
robot: map.robot,
|
|
90
|
+
charger: map.charger,
|
|
91
|
+
currentRoom: map.currentRoom,
|
|
92
|
+
pathPoints: map.path.length,
|
|
93
|
+
};
|
|
94
|
+
if (argv.json) {
|
|
95
|
+
console.log(JSON.stringify(summary, null, 2));
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
log_1.log.info(`Map of ${device.name} (${device.model})`);
|
|
99
|
+
log_1.log.plain(` Rooms: ${map.rooms.length}`);
|
|
100
|
+
for (const room of summary.rooms) {
|
|
101
|
+
log_1.log.plain(` ${room.id}${room.name ? ` (${room.name})` : ""}`);
|
|
102
|
+
}
|
|
103
|
+
log_1.log.plain(` Robot: ${map.robot ? `${map.robot.x}, ${map.robot.y}` : "-"}`);
|
|
104
|
+
log_1.log.plain(` Charger: ${map.charger ? `${map.charger.x}, ${map.charger.y}` : "-"}`);
|
|
105
|
+
const current = map.currentRoom;
|
|
106
|
+
log_1.log.plain(` Current room: ${current === undefined
|
|
107
|
+
? "none (e.g. docked, or between rooms)"
|
|
108
|
+
: `${current}${roomNames.get(current) ? ` (${roomNames.get(current)})` : ""}`}`);
|
|
109
|
+
}
|
|
110
|
+
if (argv.out)
|
|
111
|
+
log_1.log.info(`Map file saved to ${argv.out}`);
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
if (err instanceof index_1.CloudSessionExpiredError) {
|
|
115
|
+
log_1.log.error("The session expired. Run: node-miio cloud login");
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
log_1.log.error(err instanceof index_1.CloudError || err instanceof Error
|
|
119
|
+
? err.message
|
|
120
|
+
: String(err));
|
|
121
|
+
}
|
|
122
|
+
process.exitCode = 1;
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
await vacuum?.destroy();
|
|
126
|
+
// The miIO network socket keeps the process alive
|
|
127
|
+
setTimeout(() => process.exit(), 100).unref(); // eslint-disable-line n/no-process-exit
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
exports.handler = handler;
|
|
131
|
+
//# sourceMappingURL=map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.js","sourceRoot":"","sources":["../../../../src/cli/commands/cloud/map.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAkC;AAIlC,oDAKkC;AAClC,sEAAiE;AACjE,gEAA6D;AAC7D,iEAAkE;AAClE,mCAAgC;AAEnB,QAAA,OAAO,GAAG,cAAc,CAAC;AACzB,QAAA,WAAW,GACtB,+EAA+E,CAAC;AACrE,QAAA,OAAO,GAAmB;IACrC,EAAE,EAAE;QACF,IAAI,EAAE,QAAQ;QACd,WAAW,EACT,yEAAyE;KAC5E;IACD,GAAG,EAAE;QACH,IAAI,EAAE,QAAQ;QACd,WAAW,EACT,oEAAoE;KACvE;IACD,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,0BAA0B,EAAE;CACnE,CAAC;AAEF,MAAM,IAAI,GAAG,yBAAyB,CAAC;AAEhC,MAAM,OAAO,GAAG,KAAK,EAAE,IAK7B,EAAE,EAAE;IACH,MAAM,OAAO,GAAG,MAAM,IAAA,mBAAW,GAAE,CAAC;IACpC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,SAAG,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;QACvD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IAED,IAAI,MAA0B,CAAC;IAC/B,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,IAAI,mBAAW,CAAC,OAAO,CAAC,CAAC;QACvC,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnC,MAAM,MAA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G,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAC/E,EAAE,CACH,CAAC;QACJ,CAAC;QACD,IAAI,IAAI,CAAC,GAAG;YAAE,SAAG,CAAC,IAAI,CAAC,qBAAqB,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAC1D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,gCAAwB,EAAE,CAAC;YAC5C,SAAG,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAC;QAC/D,CAAC;aAAM,CAAC;YACN,SAAG,CAAC,KAAK,CACP,GAAG,YAAY,kBAAU,IAAI,GAAG,YAAY,KAAK;gBAC/C,CAAC,CAAC,GAAG,CAAC,OAAO;gBACb,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAChB,CAAC;QACJ,CAAC;QACD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;YAAS,CAAC;QACT,MAAM,MAAM,EAAE,OAAO,EAAE,CAAC;QACxB,kDAAkD;QAClD,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,wCAAwC;IACzF,CAAC;AACH,CAAC,CAAC;AAzHW,QAAA,OAAO,WAyHlB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CommandBuilder } from "yargs";
|
|
2
|
+
export declare const command = "cloud <command>";
|
|
3
|
+
export declare const description = "Use the Xiaomi Cloud (opt-in): log in, list your devices with their tokens, download maps";
|
|
4
|
+
export declare const builder: CommandBuilder;
|
|
5
|
+
export declare const handler: () => void;
|
|
@@ -37,11 +37,13 @@ exports.handler = exports.builder = exports.description = exports.command = void
|
|
|
37
37
|
const devices = __importStar(require("./cloud/devices"));
|
|
38
38
|
const login = __importStar(require("./cloud/login"));
|
|
39
39
|
const logout = __importStar(require("./cloud/logout"));
|
|
40
|
+
const map = __importStar(require("./cloud/map"));
|
|
40
41
|
exports.command = "cloud <command>";
|
|
41
|
-
exports.description = "Use the Xiaomi Cloud (opt-in): log in
|
|
42
|
+
exports.description = "Use the Xiaomi Cloud (opt-in): log in, list your devices with their tokens, download maps";
|
|
42
43
|
const builder = (yargs) => yargs
|
|
43
44
|
.command(login)
|
|
44
45
|
.command(devices)
|
|
46
|
+
.command(map)
|
|
45
47
|
.command(logout);
|
|
46
48
|
exports.builder = builder;
|
|
47
49
|
const handler = () => { };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud.js","sourceRoot":"","sources":["../../../src/cli/commands/cloud.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,yDAA2C;AAC3C,qDAAuC;AACvC,uDAAyC;
|
|
1
|
+
{"version":3,"file":"cloud.js","sourceRoot":"","sources":["../../../src/cli/commands/cloud.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,yDAA2C;AAC3C,qDAAuC;AACvC,uDAAyC;AACzC,iDAAmC;AAEtB,QAAA,OAAO,GAAG,iBAAiB,CAAC;AAC5B,QAAA,WAAW,GACtB,2FAA2F,CAAC;AACvF,MAAM,OAAO,GAAmB,CAAC,KAAW,EAAE,EAAE,CACrD,KAAK;KACF,OAAO,CAAC,KAAiC,CAAC;KAC1C,OAAO,CAAC,OAAmC,CAAC;KAC5C,OAAO,CAAC,GAA+B,CAAC;KACxC,OAAO,CAAC,MAAkC,CAAC,CAAC;AALpC,QAAA,OAAO,WAK6B;AAC1C,MAAM,OAAO,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAAnB,QAAA,OAAO,WAAY"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const command: "configure <idOrIp>";
|
|
2
|
+
export const description: "Control a device by invoking the given method";
|
|
3
|
+
export namespace builder {
|
|
4
|
+
namespace ssid {
|
|
5
|
+
let required: boolean;
|
|
6
|
+
let description: string;
|
|
7
|
+
let type: string;
|
|
8
|
+
}
|
|
9
|
+
namespace passwd {
|
|
10
|
+
let required_1: boolean;
|
|
11
|
+
export { required_1 as required };
|
|
12
|
+
let description_1: string;
|
|
13
|
+
export { description_1 as description };
|
|
14
|
+
let type_1: string;
|
|
15
|
+
export { type_1 as type };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function handler(argv: any): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CommandBuilder } from "yargs";
|
|
2
|
+
export declare const command = "spec <model>";
|
|
3
|
+
export declare const description = "Show the MIoT spec of a model (from miot-spec.org, the cache or the bundled snapshot)";
|
|
4
|
+
export declare const builder: CommandBuilder;
|
|
5
|
+
export declare const handler: (argv: {
|
|
6
|
+
model: string;
|
|
7
|
+
offline?: boolean;
|
|
8
|
+
json?: boolean;
|
|
9
|
+
specDir?: string;
|
|
10
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const command: "call <idOrIp> <method> [params...]";
|
|
2
|
+
export const description: "Call a raw method on a device";
|
|
3
|
+
export namespace builder {
|
|
4
|
+
namespace token {
|
|
5
|
+
let type: string;
|
|
6
|
+
let description: string;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export function handler(argv: any): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CommandBuilder } from "yargs";
|
|
2
|
+
export declare const command = "json-dump <file>";
|
|
3
|
+
export declare const description = "Extract packets from a Wireshark JSON dump";
|
|
4
|
+
export declare const builder: CommandBuilder;
|
|
5
|
+
export declare const handler: (argv: {
|
|
6
|
+
file: string;
|
|
7
|
+
token: string;
|
|
8
|
+
}) => void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CommandBuilder } from "yargs";
|
|
2
|
+
export declare const command = "packet <hexData>";
|
|
3
|
+
export declare const description = "Decode a miIO UDP packet";
|
|
4
|
+
export declare const builder: CommandBuilder;
|
|
5
|
+
export declare const handler: (argv: {
|
|
6
|
+
token: string;
|
|
7
|
+
hexData: string;
|
|
8
|
+
}) => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const command: "update <idOrIp>";
|
|
2
|
+
export const description: "Update the token to use for the given device";
|
|
3
|
+
export namespace builder {
|
|
4
|
+
namespace token {
|
|
5
|
+
let required: boolean;
|
|
6
|
+
let description: string;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export function handler(argv: any): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asks a question in the terminal.
|
|
3
|
+
*
|
|
4
|
+
* @param question The question
|
|
5
|
+
* @param options The options
|
|
6
|
+
* @param options.hidden Don't echo the answer (passwords)
|
|
7
|
+
* @returns The answer
|
|
8
|
+
*/
|
|
9
|
+
export declare function prompt(question: string, options?: {
|
|
10
|
+
hidden?: boolean;
|
|
11
|
+
}): Promise<string>;
|