node-miio 0.3.0 → 0.5.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/settings.json +5 -0
- package/.claude/skills/release/SKILL.md +73 -0
- package/AGENTS.md +25 -2
- package/CONTRIBUTING.md +41 -87
- package/LICENSE.md +28 -0
- package/README.md +86 -44
- package/dist/cli/commands/cloud/devices.d.ts +10 -0
- package/dist/cli/commands/cloud/devices.js +71 -0
- package/dist/cli/commands/cloud/devices.js.map +1 -0
- package/dist/cli/commands/cloud/login.d.ts +8 -0
- package/dist/cli/commands/cloud/login.js +63 -0
- package/dist/cli/commands/cloud/login.js.map +1 -0
- package/dist/cli/commands/cloud/logout.d.ts +4 -0
- package/dist/cli/commands/cloud/logout.js +14 -0
- package/dist/cli/commands/cloud/logout.js.map +1 -0
- package/dist/cli/commands/cloud.d.ts +5 -0
- package/dist/cli/commands/cloud.js +49 -0
- package/dist/cli/commands/cloud.js.map +1 -0
- 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/index.js +2 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/log.d.ts +9 -0
- package/dist/cli/prompt.d.ts +11 -0
- package/dist/cli/prompt.js +42 -0
- package/dist/cli/prompt.js.map +1 -0
- package/dist/cli/terminal_qr.d.ts +7 -0
- package/dist/cli/terminal_qr.js +14 -0
- package/dist/cli/terminal_qr.js.map +1 -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 +282 -0
- package/dist/lib/cloud/client.js.map +1 -0
- package/dist/lib/cloud/crypto.d.ts +56 -0
- package/dist/lib/cloud/crypto.js +128 -0
- package/dist/lib/cloud/crypto.js.map +1 -0
- package/dist/lib/cloud/errors.d.ts +26 -0
- package/dist/lib/cloud/errors.js +50 -0
- package/dist/lib/cloud/errors.js.map +1 -0
- package/dist/lib/cloud/http.d.ts +55 -0
- package/dist/lib/cloud/http.js +159 -0
- package/dist/lib/cloud/http.js.map +1 -0
- package/dist/lib/cloud/index.d.ts +5 -0
- package/dist/lib/cloud/index.js +22 -0
- package/dist/lib/cloud/index.js.map +1 -0
- package/dist/lib/cloud/login.d.ts +57 -0
- package/dist/lib/cloud/login.js +352 -0
- package/dist/lib/cloud/login.js.map +1 -0
- package/dist/lib/cloud/session_store.d.ts +27 -0
- package/dist/lib/cloud/session_store.js +71 -0
- package/dist/lib/cloud/session_store.js.map +1 -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 +82 -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 +18 -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 +127 -0
- package/dist/lib/maps/map_watcher.js.map +1 -0
- package/dist/lib/maps/roborock_map.d.ts +83 -0
- package/dist/lib/maps/roborock_map.js +269 -0
- package/dist/lib/maps/roborock_map.js.map +1 -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 +74 -0
- package/docs/devices/vacuum.md +9 -1
- package/package.json +7 -3
- package/snapshots/vacuum-specs.json.gz +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: release
|
|
3
|
+
description: Prepare and publish a new version of node-miio (version bump on main, GitHub release with generated notes, which publishes to npm with a fresh MIoT spec snapshot). Use when asked to release, cut, or prepare a new version (patch, minor, major or a beta).
|
|
4
|
+
argument-hint: "[patch|minor|major|prerelease|preminor --preid beta]"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Release a new version
|
|
8
|
+
|
|
9
|
+
Argument: the `npm version` level: `patch`, `minor`, `major`, or a beta (`preminor --preid beta` for the first beta of
|
|
10
|
+
the next minor, `prerelease` for the next beta). If it's missing, propose one from the PRs merged since the last tag
|
|
11
|
+
(`git log v$PREV..main --oneline`: new features → `minor`, only fixes → `patch`; betas while a feature set is being
|
|
12
|
+
tested by users) and ask before going on.
|
|
13
|
+
|
|
14
|
+
There's no CHANGELOG: the release notes are generated from the PR labels (`.github/release.yml`). Before releasing,
|
|
15
|
+
check that every PR merged since the last tag has a label (`enhancement`, `bug`, `dependencies`, `documentation`…),
|
|
16
|
+
or it lands in "Other Changes".
|
|
17
|
+
|
|
18
|
+
## Before starting
|
|
19
|
+
|
|
20
|
+
- Start from an up-to-date, clean `main`: `git checkout main && git pull --ff-only`, `git status` clean.
|
|
21
|
+
- Work out:
|
|
22
|
+
- `PREV`: the current version in `package.json`.
|
|
23
|
+
- `NEXT`: the version after applying the level to `PREV`.
|
|
24
|
+
- `DATE`: today, as `YYYY-MM-DD`.
|
|
25
|
+
- `START`: the tag the release notes start from. For a beta: the previous tag (`v$PREV`). For a stable release: the
|
|
26
|
+
previous **stable** tag (e.g. `v0.3.0` for `0.4.0`), so the notes cover all the betas.
|
|
27
|
+
|
|
28
|
+
## 1. Version bump (directly on `main`)
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npm version <level>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
- `preversion` runs lint, build and tests. If they fail, fix that first (in a PR): don't skip them.
|
|
35
|
+
- It creates the `$NEXT` commit and the `v$NEXT` tag on `main`, and `postversion` pushes both.
|
|
36
|
+
|
|
37
|
+
## 2. GitHub release (publishes to npm)
|
|
38
|
+
|
|
39
|
+
Creating the release triggers `.github/workflows/publish-release-to-npm.yml` (on `release: created`, so **never create
|
|
40
|
+
a draft**: it would publish too). The workflow checks the tag matches `package.json`, lints, tests, builds, refreshes
|
|
41
|
+
the bundled MIoT spec snapshot (`npm run snapshot`) and publishes with npm Trusted Publishing. Betas go to the `beta`
|
|
42
|
+
dist-tag, stable releases to `latest`.
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
gh release create v$NEXT --title "v$NEXT - $DATE" --generate-notes --notes-start-tag $START --verify-tag
|
|
46
|
+
# betas: add --prerelease
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Check the notes: `gh release view v$NEXT` should list only the PRs merged since `$START`.
|
|
50
|
+
|
|
51
|
+
## 3. Check the publish
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
gh run list --repo afharo/node-miio --workflow publish-release-to-npm.yml --limit 1
|
|
55
|
+
gh run watch <id> --repo afharo/node-miio --exit-status
|
|
56
|
+
npm view node-miio dist-tags
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
If it fails, report it: don't publish by hand without asking. Once a version is on npm, the plugins'
|
|
60
|
+
Renovate (no cooldown for node-miio) opens their update PRs.
|
|
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
|
+
|
|
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
|
|
|
@@ -115,3 +130,11 @@ Implementation (`src/lib/miot/`):
|
|
|
115
130
|
reference only (which commands exist, what they do). **Never copy or translate its code, mappings or tables.**
|
|
116
131
|
Implement from the miot-spec data, protocol documentation (e.g. marcelrv/XiaomiRobotVacuumProtocol) and captured traffic.
|
|
117
132
|
Other projects (openHAB: EPL-2.0; hass-xiaomi-miot: Apache-2.0) need attribution if anything is reused. Prefer reimplementing.
|
|
133
|
+
Piotr Machowski's Xiaomi-cloud-tokens-extractor and Xiaomi-Cloud-Map-Extractor are **MIT**: they may be ported, keeping the
|
|
134
|
+
attribution header in the ported files (`src/lib/cloud/`) and the notice in `LICENSE.md`.
|
|
135
|
+
|
|
136
|
+
## Xiaomi Cloud (`src/lib/cloud/`)
|
|
137
|
+
|
|
138
|
+
Opt-in only: nothing in the local control paths may require the cloud. Tests use the fake server in
|
|
139
|
+
`cloud.test.mock.ts` (no network); the crypto is checked against vectors generated by the Python reference
|
|
140
|
+
(`__fixtures__/cloud/crypto-vectors.json`). Never log passwords, tokens, `ssecurity` or `serviceToken`.
|
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/LICENSE.md
CHANGED
|
@@ -18,3 +18,31 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
19
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
20
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
Parts of `src/lib/cloud/` are ported from Xiaomi-cloud-tokens-extractor
|
|
25
|
+
(https://github.com/PiotrMachowski/Xiaomi-cloud-tokens-extractor) and
|
|
26
|
+
Xiaomi-Cloud-Map-Extractor
|
|
27
|
+
(https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor),
|
|
28
|
+
licensed under the MIT License:
|
|
29
|
+
|
|
30
|
+
Copyright (c) 2020 Piotr Machowski
|
|
31
|
+
|
|
32
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
33
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
34
|
+
in the Software without restriction, including without limitation the rights
|
|
35
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
36
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
37
|
+
furnished to do so, subject to the following conditions:
|
|
38
|
+
|
|
39
|
+
The above copyright notice and this permission notice shall be included in all
|
|
40
|
+
copies or substantial portions of the Software.
|
|
41
|
+
|
|
42
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
43
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
44
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
45
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
46
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
47
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
48
|
+
SOFTWARE.
|
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
|
|
|
@@ -34,15 +32,15 @@ them.
|
|
|
34
32
|
|
|
35
33
|
Currently supported devices are:
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
- Air Purifiers (1, 2 and Pro)
|
|
36
|
+
- Mi Humidifier
|
|
37
|
+
- Mi Smart Socket Plug and Power Strips
|
|
38
|
+
- Robot vacuums:
|
|
39
|
+
- Roborock / Mi Robot Vacuum (legacy miIO protocol), Viomi and Dreame (mc1808)
|
|
40
|
+
- **Any MIoT vacuum** (Xiaomi, Dreame, Mijia, ijai, …), driven by its spec from [miot-spec.org](https://home.miot-spec.com) (see [MIoT devices](#miot-devices))
|
|
41
|
+
- Mi Smart Home Gateway (Aqara) and accessories - switches, sensors, etc
|
|
42
|
+
- Philips Light Bulb and Eyecare Lamp
|
|
43
|
+
- Yeelights (White Bulb, Color Bulb, Desk Lamp and Strip)
|
|
46
44
|
|
|
47
45
|
See [documentation for devices](docs/devices/README.md) for information about
|
|
48
46
|
the types, their API and supported device models. You can also check
|
|
@@ -93,30 +91,49 @@ npm install -g node-miio
|
|
|
93
91
|
## Usage
|
|
94
92
|
|
|
95
93
|
```javascript
|
|
96
|
-
const miio = require(
|
|
94
|
+
const miio = require("node-miio");
|
|
95
|
+
```
|
|
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
|
+
}
|
|
97
111
|
```
|
|
98
112
|
|
|
99
113
|
Resolve a handle to the device:
|
|
100
114
|
|
|
101
115
|
```javascript
|
|
102
116
|
// Resolve a device, resolving the token automatically or from storage
|
|
103
|
-
miio
|
|
104
|
-
.
|
|
105
|
-
.
|
|
117
|
+
miio
|
|
118
|
+
.device({ address: "192.168.100.8" })
|
|
119
|
+
.then((device) => console.log("Connected to", device))
|
|
120
|
+
.catch((err) => handleErrorHere);
|
|
106
121
|
|
|
107
122
|
// Resolve a device, specifying the token (see below for how to get the token)
|
|
108
|
-
miio
|
|
109
|
-
.
|
|
110
|
-
.
|
|
123
|
+
miio
|
|
124
|
+
.device({ address: "192.168.100.8", token: "token-as-hex" })
|
|
125
|
+
.then((device) => console.log("Connected to", device))
|
|
126
|
+
.catch((err) => handleErrorHere);
|
|
111
127
|
```
|
|
112
128
|
|
|
113
129
|
Call methods to interact with the device:
|
|
114
130
|
|
|
115
131
|
```javascript
|
|
116
132
|
// Switch the power of the device
|
|
117
|
-
device
|
|
118
|
-
.
|
|
119
|
-
.
|
|
133
|
+
device
|
|
134
|
+
.togglePower()
|
|
135
|
+
.then((on) => console.log("Power is now", on))
|
|
136
|
+
.catch((err) => handleErrorHere);
|
|
120
137
|
|
|
121
138
|
// Using async/await
|
|
122
139
|
await device.togglePower();
|
|
@@ -126,25 +143,24 @@ Listen to events such as property changes and actions:
|
|
|
126
143
|
|
|
127
144
|
```javascript
|
|
128
145
|
// Listen for power changes
|
|
129
|
-
device.on(
|
|
146
|
+
device.on("power", (power) => console.log("Power changed to", power));
|
|
130
147
|
|
|
131
148
|
// The device is available for event handlers
|
|
132
|
-
const handler = ({ action }, device) =>
|
|
133
|
-
|
|
134
|
-
|
|
149
|
+
const handler = ({ action }, device) =>
|
|
150
|
+
console.log("Action", action, "performed on", device);
|
|
151
|
+
device1.on("action", handler);
|
|
152
|
+
device2.on("action", handler);
|
|
135
153
|
```
|
|
136
154
|
|
|
137
155
|
Capabilities and types are used to hint about what a device can do:
|
|
138
156
|
|
|
139
157
|
```javascript
|
|
140
|
-
if(device.matches(
|
|
158
|
+
if (device.matches("cap:temperature")) {
|
|
141
159
|
console.log(await device.temperature());
|
|
142
160
|
}
|
|
143
161
|
|
|
144
|
-
if(device.matches(
|
|
145
|
-
device.setPower(false)
|
|
146
|
-
.then(console.log)
|
|
147
|
-
.catch(console.error);
|
|
162
|
+
if (device.matches("cap:switchable-power")) {
|
|
163
|
+
device.setPower(false).then(console.log).catch(console.error);
|
|
148
164
|
}
|
|
149
165
|
```
|
|
150
166
|
|
|
@@ -164,6 +180,10 @@ There is a command line tool named `miio` that helps with finding and storing
|
|
|
164
180
|
tokens. See [Device management](docs/management.md) for details
|
|
165
181
|
and common use cases.
|
|
166
182
|
|
|
183
|
+
The easiest way to get the tokens is from your Xiaomi account (opt-in):
|
|
184
|
+
`npx node-miio cloud login --qr` (scan the QR code with the Mi Home app), then
|
|
185
|
+
`npx node-miio cloud devices`. See [Xiaomi Cloud](docs/cloud.md).
|
|
186
|
+
|
|
167
187
|
## Discovering devices
|
|
168
188
|
|
|
169
189
|
Use `miio.devices()` to look for and connect to devices on the local network.
|
|
@@ -175,29 +195,29 @@ Example using `miio.devices()`:
|
|
|
175
195
|
|
|
176
196
|
```javascript
|
|
177
197
|
const devices = miio.devices({
|
|
178
|
-
cacheTime: 300 // 5 minutes. Default is 1800 seconds (30 minutes)
|
|
198
|
+
cacheTime: 300, // 5 minutes. Default is 1800 seconds (30 minutes)
|
|
179
199
|
});
|
|
180
200
|
|
|
181
|
-
devices.on(
|
|
182
|
-
if(device.matches(
|
|
201
|
+
devices.on("available", (device) => {
|
|
202
|
+
if (device.matches("placeholder")) {
|
|
183
203
|
// This device is either missing a token or could not be connected to
|
|
184
204
|
} else {
|
|
185
205
|
// Do something useful with device
|
|
186
206
|
}
|
|
187
207
|
});
|
|
188
208
|
|
|
189
|
-
devices.on(
|
|
209
|
+
devices.on("unavailable", (device) => {
|
|
190
210
|
// Device is no longer available and is destroyed
|
|
191
211
|
});
|
|
192
212
|
```
|
|
193
213
|
|
|
194
214
|
`miio.devices()` supports these options:
|
|
195
215
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
216
|
+
- `cacheTime`, the maximum amount of seconds a device can be unreachable before it becomes unavailable. Default: `1800`
|
|
217
|
+
- `filter`, function used to filter what devices are connected to. Default: `reg => true`
|
|
218
|
+
- `skipSubDevices`, if sub devices on Aqara gateways should be skipped. Default: `false`
|
|
219
|
+
- `useTokenStorage`, if tokens should be fetched from storage (see device management). Default: `true`
|
|
220
|
+
- `tokens`, object with manual mapping between ids and tokens (advanced, use [Device management](docs/management.md) if possible)
|
|
201
221
|
|
|
202
222
|
See [Advanced API](docs/advanced-api.md) for details about `miio.browse()`.
|
|
203
223
|
|
|
@@ -248,6 +268,28 @@ To activate both namespaces set `DEBUG` to both:
|
|
|
248
268
|
$ DEBUG=miio\*,thing\* miio discover
|
|
249
269
|
```
|
|
250
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
|
+
|
|
251
293
|
## Protocol documentation
|
|
252
294
|
|
|
253
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,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handler = exports.builder = exports.description = exports.command = void 0;
|
|
4
|
+
const index_1 = require("../../../lib/cloud/index");
|
|
5
|
+
const tokens_1 = require("../../../lib/tokens");
|
|
6
|
+
const log_1 = require("../../log");
|
|
7
|
+
exports.command = "devices";
|
|
8
|
+
exports.description = "List the devices of your Xiaomi account, with their tokens";
|
|
9
|
+
exports.builder = {
|
|
10
|
+
server: {
|
|
11
|
+
type: "string",
|
|
12
|
+
choices: [...index_1.CLOUD_SERVERS],
|
|
13
|
+
description: "Only check this server (all of them by default)",
|
|
14
|
+
},
|
|
15
|
+
json: { type: "boolean", description: "Print the devices as JSON" },
|
|
16
|
+
save: {
|
|
17
|
+
type: "boolean",
|
|
18
|
+
description: "Save the tokens, so other node-miio commands can use them",
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
const handler = async (argv) => {
|
|
22
|
+
const session = await (0, index_1.loadSession)();
|
|
23
|
+
if (!session) {
|
|
24
|
+
log_1.log.error("Not logged in. Run: node-miio cloud login");
|
|
25
|
+
process.exitCode = 1;
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const cloud = new index_1.XiaomiCloud(session);
|
|
30
|
+
const devices = await cloud.getDevices({
|
|
31
|
+
servers: argv.server ? [argv.server] : undefined,
|
|
32
|
+
});
|
|
33
|
+
if (argv.save) {
|
|
34
|
+
for (const device of devices) {
|
|
35
|
+
if (/^[0-9a-f]{32}$/i.test(device.token)) {
|
|
36
|
+
await tokens_1.tokens.update(device.did, Buffer.from(device.token, "hex"));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (argv.json) {
|
|
41
|
+
console.log(JSON.stringify(devices, null, 2));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (devices.length === 0) {
|
|
45
|
+
log_1.log.info("No devices found in this account.");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
for (const device of devices) {
|
|
49
|
+
log_1.log.plain(device.name);
|
|
50
|
+
log_1.log.plain(` Model: ${device.model}`);
|
|
51
|
+
log_1.log.plain(` IP: ${device.localip ?? "-"}`);
|
|
52
|
+
log_1.log.plain(` ID: ${device.did}`);
|
|
53
|
+
log_1.log.plain(` Token: ${device.token || "-"}`);
|
|
54
|
+
log_1.log.plain(` Server: ${device.server}`);
|
|
55
|
+
log_1.log.plain();
|
|
56
|
+
}
|
|
57
|
+
if (argv.save)
|
|
58
|
+
log_1.log.info("Tokens saved.");
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
if (err instanceof index_1.CloudSessionExpiredError) {
|
|
62
|
+
log_1.log.error("The session expired. Run: node-miio cloud login");
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
log_1.log.error(err instanceof index_1.CloudError ? err.message : String(err));
|
|
66
|
+
}
|
|
67
|
+
process.exitCode = 1;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
exports.handler = handler;
|
|
71
|
+
//# sourceMappingURL=devices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devices.js","sourceRoot":"","sources":["../../../../src/cli/commands/cloud/devices.ts"],"names":[],"mappings":"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"}
|
|
@@ -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>;
|