node-miio 0.3.0-beta.2 → 0.3.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/AGENTS.md +117 -0
- package/README.md +41 -2
- package/dist/cli/commands/configure.js +60 -0
- package/dist/cli/commands/configure.js.map +1 -0
- package/dist/cli/commands/control.js +47 -0
- package/dist/cli/commands/control.js.map +1 -0
- package/dist/cli/commands/discover.js +32 -0
- package/dist/cli/commands/discover.js.map +1 -0
- package/dist/cli/commands/inspect.js +183 -0
- package/dist/cli/commands/inspect.js.map +1 -0
- package/dist/cli/commands/miot-spec.js +60 -0
- package/dist/cli/commands/miot-spec.js.map +1 -0
- package/dist/cli/commands/protocol/call.js +59 -0
- package/dist/cli/commands/protocol/call.js.map +1 -0
- package/dist/cli/commands/protocol/json-dump.js +56 -0
- package/dist/cli/commands/protocol/json-dump.js.map +1 -0
- package/dist/cli/commands/protocol/packet.js +30 -0
- package/dist/cli/commands/protocol/packet.js.map +1 -0
- package/dist/cli/commands/protocol.js +49 -0
- package/dist/cli/commands/protocol.js.map +1 -0
- package/dist/cli/commands/tokens/update.js +53 -0
- package/dist/cli/commands/tokens/update.js.map +1 -0
- package/dist/cli/commands/tokens.js +44 -0
- package/dist/cli/commands/tokens.js.map +1 -0
- package/dist/cli/device-finder.js +72 -0
- package/dist/cli/device-finder.js.map +1 -0
- package/dist/cli/index.js +64 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/log.js +69 -0
- package/dist/cli/log.js.map +1 -0
- package/dist/lib/check_result.js +18 -0
- package/dist/lib/check_result.js.map +1 -0
- package/dist/lib/connect_to_device.js +123 -0
- package/dist/lib/connect_to_device.js.map +1 -0
- package/dist/lib/device.js +259 -0
- package/dist/lib/device.js.map +1 -0
- package/dist/lib/device_info.js +297 -0
- package/dist/lib/device_info.js.map +1 -0
- package/dist/lib/devices/air-monitor.js +42 -0
- package/dist/lib/devices/air-monitor.js.map +1 -0
- package/dist/lib/devices/air-purifier.js +144 -0
- package/dist/lib/devices/air-purifier.js.map +1 -0
- package/dist/lib/devices/capabilities/battery-level.js +13 -0
- package/dist/lib/devices/capabilities/battery-level.js.map +1 -0
- package/dist/lib/devices/capabilities/buzzer.js +69 -0
- package/dist/lib/devices/capabilities/buzzer.js.map +1 -0
- package/dist/lib/devices/capabilities/changeable-led-brightness.js +44 -0
- package/dist/lib/devices/capabilities/changeable-led-brightness.js.map +1 -0
- package/dist/lib/devices/capabilities/colorable.js +14 -0
- package/dist/lib/devices/capabilities/colorable.js.map +1 -0
- package/dist/lib/devices/capabilities/dimmable.js +14 -0
- package/dist/lib/devices/capabilities/dimmable.js.map +1 -0
- package/dist/lib/devices/capabilities/mode.js +13 -0
- package/dist/lib/devices/capabilities/mode.js.map +1 -0
- package/dist/lib/devices/capabilities/power.js +13 -0
- package/dist/lib/devices/capabilities/power.js.map +1 -0
- package/dist/lib/devices/capabilities/sensor.js +46 -0
- package/dist/lib/devices/capabilities/sensor.js.map +1 -0
- package/dist/lib/devices/capabilities/switchable-led.js +48 -0
- package/dist/lib/devices/capabilities/switchable-led.js.map +1 -0
- package/dist/lib/devices/chuangmi.plug.v1.js +47 -0
- package/dist/lib/devices/chuangmi.plug.v1.js.map +1 -0
- package/dist/lib/devices/eyecare-lamp2.js +151 -0
- package/dist/lib/devices/eyecare-lamp2.js.map +1 -0
- package/dist/lib/devices/gateway/86sw1.js +20 -0
- package/dist/lib/devices/gateway/86sw1.js.map +1 -0
- package/dist/lib/devices/gateway/86sw2.js +36 -0
- package/dist/lib/devices/gateway/86sw2.js.map +1 -0
- package/dist/lib/devices/gateway/ctrl_ln1.js +37 -0
- package/dist/lib/devices/gateway/ctrl_ln1.js.map +1 -0
- package/dist/lib/devices/gateway/ctrl_ln2.js +45 -0
- package/dist/lib/devices/gateway/ctrl_ln2.js.map +1 -0
- package/dist/lib/devices/gateway/ctrl_neutral1.js +37 -0
- package/dist/lib/devices/gateway/ctrl_neutral1.js.map +1 -0
- package/dist/lib/devices/gateway/ctrl_neutral2.js +45 -0
- package/dist/lib/devices/gateway/ctrl_neutral2.js.map +1 -0
- package/dist/lib/devices/gateway/cube.js +49 -0
- package/dist/lib/devices/gateway/cube.js.map +1 -0
- package/dist/lib/devices/gateway/developer-api.js +104 -0
- package/dist/lib/devices/gateway/developer-api.js.map +1 -0
- package/dist/lib/devices/gateway/light-channel.js +24 -0
- package/dist/lib/devices/gateway/light-channel.js.map +1 -0
- package/dist/lib/devices/gateway/light-mixin.js +59 -0
- package/dist/lib/devices/gateway/light-mixin.js.map +1 -0
- package/dist/lib/devices/gateway/magnet.js +23 -0
- package/dist/lib/devices/gateway/magnet.js.map +1 -0
- package/dist/lib/devices/gateway/magnet2.js +9 -0
- package/dist/lib/devices/gateway/magnet2.js.map +1 -0
- package/dist/lib/devices/gateway/motion.js +21 -0
- package/dist/lib/devices/gateway/motion.js.map +1 -0
- package/dist/lib/devices/gateway/motion2.js +25 -0
- package/dist/lib/devices/gateway/motion2.js.map +1 -0
- package/dist/lib/devices/gateway/plug.js +34 -0
- package/dist/lib/devices/gateway/plug.js.map +1 -0
- package/dist/lib/devices/gateway/sensor_ht.js +13 -0
- package/dist/lib/devices/gateway/sensor_ht.js.map +1 -0
- package/dist/lib/devices/gateway/subdevice.js +203 -0
- package/dist/lib/devices/gateway/subdevice.js.map +1 -0
- package/dist/lib/devices/gateway/subdevices.js +33 -0
- package/dist/lib/devices/gateway/subdevices.js.map +1 -0
- package/dist/lib/devices/gateway/switch.js +24 -0
- package/dist/lib/devices/gateway/switch.js.map +1 -0
- package/dist/lib/devices/gateway/switch2.js +19 -0
- package/dist/lib/devices/gateway/switch2.js.map +1 -0
- package/dist/lib/devices/gateway/voltage.js +21 -0
- package/dist/lib/devices/gateway/voltage.js.map +1 -0
- package/dist/lib/devices/gateway/weather.js +16 -0
- package/dist/lib/devices/gateway/weather.js.map +1 -0
- package/dist/lib/devices/gateway.js +212 -0
- package/dist/lib/devices/gateway.js.map +1 -0
- package/dist/lib/devices/humidifier.js +141 -0
- package/dist/lib/devices/humidifier.js.map +1 -0
- package/dist/lib/devices/philips-light-bulb.js +63 -0
- package/dist/lib/devices/philips-light-bulb.js.map +1 -0
- package/dist/lib/devices/power-plug.js +22 -0
- package/dist/lib/devices/power-plug.js.map +1 -0
- package/dist/lib/devices/power-strip.js +27 -0
- package/dist/lib/devices/power-strip.js.map +1 -0
- package/dist/lib/devices/vacuums/dreamevacuum.js +312 -0
- package/dist/lib/devices/vacuums/dreamevacuum.js.map +1 -0
- package/dist/lib/devices/vacuums/mijiavacuum.js +21 -0
- package/dist/lib/devices/vacuums/mijiavacuum.js.map +1 -0
- package/dist/lib/devices/vacuums/miot-vacuum.js +444 -0
- package/dist/lib/devices/vacuums/miot-vacuum.js.map +1 -0
- package/dist/lib/devices/vacuums/vacuum.js +669 -0
- package/dist/lib/devices/vacuums/vacuum.js.map +1 -0
- package/dist/lib/devices/vacuums/vacuum_modes.js +171 -0
- package/dist/lib/devices/vacuums/vacuum_modes.js.map +1 -0
- package/dist/lib/devices/vacuums/viomivacuum.js +222 -0
- package/dist/lib/devices/vacuums/viomivacuum.js.map +1 -0
- package/dist/lib/devices/yeelight.color.js +5 -0
- package/dist/lib/devices/yeelight.color.js.map +1 -0
- package/dist/lib/devices/yeelight.js +242 -0
- package/dist/lib/devices/yeelight.js.map +1 -0
- package/dist/lib/devices/yeelight.mono.js +5 -0
- package/dist/lib/devices/yeelight.mono.js.map +1 -0
- package/dist/lib/discovery.js +147 -0
- package/dist/lib/discovery.js.map +1 -0
- package/dist/lib/index.js +89 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/info_from_hostname.js +27 -0
- package/dist/lib/info_from_hostname.js.map +1 -0
- package/dist/lib/management.js +101 -0
- package/dist/lib/management.js.map +1 -0
- package/dist/lib/miio_error.js +23 -0
- package/dist/lib/miio_error.js.map +1 -0
- package/dist/lib/miot/miot_api.js +73 -0
- package/dist/lib/miot/miot_api.js.map +1 -0
- package/dist/lib/miot/miot_spec.js +105 -0
- package/dist/lib/miot/miot_spec.js.map +1 -0
- package/dist/lib/miot/spec_client.js +290 -0
- package/dist/lib/miot/spec_client.js.map +1 -0
- package/dist/lib/models.js +69 -0
- package/dist/lib/models.js.map +1 -0
- package/dist/lib/network.js +194 -0
- package/dist/lib/network.js.map +1 -0
- package/dist/lib/packet.js +177 -0
- package/dist/lib/packet.js.map +1 -0
- package/dist/lib/placeholder.js +16 -0
- package/dist/lib/placeholder.js.map +1 -0
- package/dist/lib/protocol.js +3 -0
- package/dist/lib/protocol.js.map +1 -0
- package/dist/lib/safeish_json.js +22 -0
- package/dist/lib/safeish_json.js.map +1 -0
- package/dist/lib/tokens.js +30 -0
- package/dist/lib/tokens.js.map +1 -0
- package/docs/devices/vacuum.md +63 -3
- package/example.js +1 -1
- package/package.json +49 -16
- package/snapshots/vacuum-specs.json.gz +0 -0
- package/.editorconfig +0 -26
- package/.eslintrc +0 -32
- package/.github/release.yml +0 -20
- package/.github/workflows/build.yml +0 -50
- package/.github/workflows/codecov.yml +0 -35
- package/.github/workflows/codeql.yml +0 -24
- package/.github/workflows/publish-dev-from-main.yml +0 -92
- package/.github/workflows/publish-release-to-npm.yml +0 -45
- package/cli/commands/configure.js +0 -69
- package/cli/commands/control.js +0 -54
- package/cli/commands/discover.js +0 -36
- package/cli/commands/inspect.js +0 -197
- package/cli/commands/protocol/call.js +0 -66
- package/cli/commands/protocol/json-dump.js +0 -52
- package/cli/commands/protocol/packet.js +0 -29
- package/cli/commands/protocol.js +0 -8
- package/cli/commands/tokens/update.js +0 -58
- package/cli/commands/tokens.js +0 -8
- package/cli/device-finder.js +0 -69
- package/cli/index.js +0 -9
- package/cli/log.js +0 -89
- package/lib/checkResult.js +0 -13
- package/lib/connectToDevice.js +0 -66
- package/lib/device.js +0 -290
- package/lib/device_info.js +0 -329
- package/lib/device_info.test.js +0 -337
- package/lib/devices/air-monitor.js +0 -53
- package/lib/devices/air-purifier.js +0 -162
- package/lib/devices/capabilities/battery-level.js +0 -16
- package/lib/devices/capabilities/buzzer.js +0 -78
- package/lib/devices/capabilities/changeable-led-brightness.js +0 -48
- package/lib/devices/capabilities/colorable.js +0 -14
- package/lib/devices/capabilities/dimmable.js +0 -14
- package/lib/devices/capabilities/mode.js +0 -13
- package/lib/devices/capabilities/power.js +0 -14
- package/lib/devices/capabilities/sensor.js +0 -50
- package/lib/devices/capabilities/switchable-led.js +0 -49
- package/lib/devices/chuangmi.plug.v1.js +0 -61
- package/lib/devices/eyecare-lamp2.js +0 -179
- package/lib/devices/gateway/86sw1.js +0 -28
- package/lib/devices/gateway/86sw2.js +0 -44
- package/lib/devices/gateway/ctrl_ln1.js +0 -44
- package/lib/devices/gateway/ctrl_ln2.js +0 -53
- package/lib/devices/gateway/ctrl_neutral1.js +0 -44
- package/lib/devices/gateway/ctrl_neutral2.js +0 -53
- package/lib/devices/gateway/cube.js +0 -55
- package/lib/devices/gateway/developer-api.js +0 -120
- package/lib/devices/gateway/light-channel.js +0 -32
- package/lib/devices/gateway/light-mixin.js +0 -71
- package/lib/devices/gateway/magnet.js +0 -29
- package/lib/devices/gateway/magnet2.js +0 -13
- package/lib/devices/gateway/motion.js +0 -27
- package/lib/devices/gateway/motion2.js +0 -31
- package/lib/devices/gateway/plug.js +0 -45
- package/lib/devices/gateway/sensor_ht.js +0 -17
- package/lib/devices/gateway/subdevice.js +0 -227
- package/lib/devices/gateway/subdevices.js +0 -37
- package/lib/devices/gateway/switch.js +0 -29
- package/lib/devices/gateway/switch2.js +0 -27
- package/lib/devices/gateway/voltage.js +0 -28
- package/lib/devices/gateway/weather.js +0 -22
- package/lib/devices/gateway.js +0 -244
- package/lib/devices/humidifier.js +0 -162
- package/lib/devices/philips-light-bulb.js +0 -73
- package/lib/devices/power-plug.js +0 -26
- package/lib/devices/power-strip.js +0 -38
- package/lib/devices/vacuums/dreamevacuum.js +0 -350
- package/lib/devices/vacuums/mijiavacuum.js +0 -22
- package/lib/devices/vacuums/vacuum.js +0 -518
- package/lib/devices/vacuums/viomivacuum.js +0 -250
- package/lib/devices/yeelight.color.js +0 -6
- package/lib/devices/yeelight.js +0 -286
- package/lib/devices/yeelight.mono.js +0 -9
- package/lib/discovery.js +0 -192
- package/lib/index.js +0 -40
- package/lib/infoFromHostname.js +0 -24
- package/lib/management.js +0 -102
- package/lib/models.js +0 -76
- package/lib/network.js +0 -234
- package/lib/packet.js +0 -191
- package/lib/placeholder.js +0 -12
- package/lib/safeishJSON.js +0 -14
- package/lib/tokens.js +0 -129
|
Binary file
|
package/.editorconfig
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
root = true
|
|
2
|
-
|
|
3
|
-
[*]
|
|
4
|
-
indent_style = tab
|
|
5
|
-
end_of_line = lf
|
|
6
|
-
charset = utf-8
|
|
7
|
-
trim_trailing_whitespace = true
|
|
8
|
-
insert_final_newline = true
|
|
9
|
-
|
|
10
|
-
[*.md]
|
|
11
|
-
trim_trailing_whitespace = false
|
|
12
|
-
indent_style = space
|
|
13
|
-
indent_size = 2
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
[*.js]
|
|
17
|
-
indent_style = space
|
|
18
|
-
indent_size = 2
|
|
19
|
-
|
|
20
|
-
[*.json]
|
|
21
|
-
indent_style = space
|
|
22
|
-
indent_size = 2
|
|
23
|
-
|
|
24
|
-
[package.json]
|
|
25
|
-
indent_style = space
|
|
26
|
-
indent_size = 2
|
package/.eslintrc
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"plugins": [ "node" ],
|
|
3
|
-
"extends": [ "eslint:recommended", "plugin:node/recommended" ],
|
|
4
|
-
"env": {},
|
|
5
|
-
"globals": {},
|
|
6
|
-
"rules": {
|
|
7
|
-
"strict": [ "error", "global" ],
|
|
8
|
-
"no-irregular-whitespace": 2,
|
|
9
|
-
"quotes": [
|
|
10
|
-
2,
|
|
11
|
-
"single"
|
|
12
|
-
],
|
|
13
|
-
"no-unused-vars": [
|
|
14
|
-
"error",
|
|
15
|
-
{ "vars": "all", "args": "none", "ignoreRestSiblings": false }
|
|
16
|
-
],
|
|
17
|
-
"eqeqeq": [ "error" ],
|
|
18
|
-
"no-throw-literal": [ "error" ],
|
|
19
|
-
"semi": [ "error", "always" ]
|
|
20
|
-
},
|
|
21
|
-
"overrides": [
|
|
22
|
-
{
|
|
23
|
-
"files": [
|
|
24
|
-
"**/*.test.js",
|
|
25
|
-
"**/*.test.ts"
|
|
26
|
-
],
|
|
27
|
-
"env": {
|
|
28
|
-
"jest": true
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
}
|
package/.github/release.yml
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
changelog:
|
|
2
|
-
exclude:
|
|
3
|
-
labels:
|
|
4
|
-
- release
|
|
5
|
-
categories:
|
|
6
|
-
- title: 🏕 New Features
|
|
7
|
-
labels:
|
|
8
|
-
- enhancement
|
|
9
|
-
- title: 🐛 Bug Fixes
|
|
10
|
-
labels:
|
|
11
|
-
- bug
|
|
12
|
-
- title: ⚙️ Other Changes
|
|
13
|
-
labels:
|
|
14
|
-
- '*'
|
|
15
|
-
exclude:
|
|
16
|
-
labels:
|
|
17
|
-
- dependencies
|
|
18
|
-
- title: 👒 Dependencies
|
|
19
|
-
labels:
|
|
20
|
-
- dependencies
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
name: Node.js CI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [main]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: [main]
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
build:
|
|
11
|
-
runs-on: ${{ matrix.os }}
|
|
12
|
-
|
|
13
|
-
strategy:
|
|
14
|
-
fail-fast: false
|
|
15
|
-
matrix:
|
|
16
|
-
node-version: [20.x, 22.x, 24.x]
|
|
17
|
-
os:
|
|
18
|
-
- ubuntu-latest
|
|
19
|
-
- macos-latest
|
|
20
|
-
# - windows-latest
|
|
21
|
-
|
|
22
|
-
steps:
|
|
23
|
-
- name: Checkout repository
|
|
24
|
-
uses: actions/checkout@v4
|
|
25
|
-
|
|
26
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
27
|
-
uses: actions/setup-node@v4
|
|
28
|
-
with:
|
|
29
|
-
node-version: ${{ matrix.node-version }}
|
|
30
|
-
|
|
31
|
-
- name: Clean cache
|
|
32
|
-
run: npm cache clean --force
|
|
33
|
-
|
|
34
|
-
- name: Verify Node.js version
|
|
35
|
-
run: node -v
|
|
36
|
-
|
|
37
|
-
- name: Verify Npm version
|
|
38
|
-
run: npm -v
|
|
39
|
-
|
|
40
|
-
- name: Install dependencies
|
|
41
|
-
run: npm ci
|
|
42
|
-
|
|
43
|
-
- name: Lint
|
|
44
|
-
run: npm run lint
|
|
45
|
-
|
|
46
|
-
- name: Test
|
|
47
|
-
run: npm t
|
|
48
|
-
|
|
49
|
-
# - name: Build
|
|
50
|
-
# run: npm run build
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
name: Codecov
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [main]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: [main]
|
|
8
|
-
workflow_dispatch:
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
test:
|
|
12
|
-
name: Run tests and collect coverage
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
|
-
steps:
|
|
15
|
-
- name: Checkout
|
|
16
|
-
uses: actions/checkout@v4
|
|
17
|
-
with:
|
|
18
|
-
fetch-depth: 2
|
|
19
|
-
|
|
20
|
-
- name: Set up Node
|
|
21
|
-
uses: actions/setup-node@v4
|
|
22
|
-
with:
|
|
23
|
-
node-version: '22.x'
|
|
24
|
-
registry-url: 'https://registry.npmjs.org'
|
|
25
|
-
|
|
26
|
-
- name: Install dependencies
|
|
27
|
-
run: npm ci
|
|
28
|
-
|
|
29
|
-
- name: Run tests
|
|
30
|
-
run: npm run test:coverage
|
|
31
|
-
|
|
32
|
-
- name: Upload results to Codecov
|
|
33
|
-
uses: codecov/codecov-action@v5
|
|
34
|
-
with:
|
|
35
|
-
token: ${{ secrets.CODECOV_TOKEN }}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
name: CodeQL
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [main]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: [main]
|
|
8
|
-
workflow_dispatch:
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
analyze:
|
|
12
|
-
name: Analyze
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
|
-
permissions:
|
|
15
|
-
actions: read
|
|
16
|
-
contents: read
|
|
17
|
-
security-events: write
|
|
18
|
-
|
|
19
|
-
steps:
|
|
20
|
-
- uses: actions/checkout@v4
|
|
21
|
-
- uses: github/codeql-action/init@v3
|
|
22
|
-
with:
|
|
23
|
-
languages: javascript
|
|
24
|
-
- uses: github/codeql-action/analyze@v3
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
# Inspired by .github\workflows\publish-matterbridge-plugin-dev-daily-from-main.yml
|
|
2
|
-
name: Publish to npm from main branch to dev tag
|
|
3
|
-
|
|
4
|
-
on:
|
|
5
|
-
# Allow manual dispatch
|
|
6
|
-
workflow_dispatch:
|
|
7
|
-
# push:
|
|
8
|
-
# branches: [ main ]
|
|
9
|
-
# # Daily at midnight UTC
|
|
10
|
-
# schedule:
|
|
11
|
-
# - cron: '0 0 * * *'
|
|
12
|
-
|
|
13
|
-
jobs:
|
|
14
|
-
publish-dev:
|
|
15
|
-
runs-on: ubuntu-latest
|
|
16
|
-
steps:
|
|
17
|
-
# Always check out the main branch, even for scheduled runs
|
|
18
|
-
- name: Checkout main
|
|
19
|
-
uses: actions/checkout@v4
|
|
20
|
-
with:
|
|
21
|
-
ref: main
|
|
22
|
-
fetch-depth: 0
|
|
23
|
-
|
|
24
|
-
- name: Set up Node.js & registry
|
|
25
|
-
uses: actions/setup-node@v4
|
|
26
|
-
with:
|
|
27
|
-
node-version: '22.x'
|
|
28
|
-
registry-url: 'https://registry.npmjs.org'
|
|
29
|
-
|
|
30
|
-
- name: Clean npm cache
|
|
31
|
-
run: npm cache clean --force
|
|
32
|
-
|
|
33
|
-
- name: Lint & test & build
|
|
34
|
-
run: |
|
|
35
|
-
npm ci
|
|
36
|
-
npm run lint
|
|
37
|
-
npm t
|
|
38
|
-
npm pkg delete devDependencies
|
|
39
|
-
npx shx rm -rf ./node_modules
|
|
40
|
-
npm install --omit=dev
|
|
41
|
-
npm shrinkwrap
|
|
42
|
-
|
|
43
|
-
- name: Extract base version and date
|
|
44
|
-
id: vars
|
|
45
|
-
run: |
|
|
46
|
-
BASE=$(jq -r '.version' package.json)
|
|
47
|
-
DATE=$(date -u +'%Y%m%d')
|
|
48
|
-
SHA=$(git rev-parse --short=7 HEAD)
|
|
49
|
-
DEV_TAG="${BASE}-dev-${DATE}-${SHA}"
|
|
50
|
-
echo "DEV_TAG=$DEV_TAG" >> $GITHUB_ENV
|
|
51
|
-
echo "ORIG_SHA=$SHA" >> $GITHUB_ENV
|
|
52
|
-
|
|
53
|
-
- name: Bump to date-stamped dev version (no git tag)
|
|
54
|
-
run: npm version "${{ env.DEV_TAG }}" --no-git-tag-version
|
|
55
|
-
|
|
56
|
-
- name: Check if a new dev-publish is needed
|
|
57
|
-
id: check_new
|
|
58
|
-
env:
|
|
59
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
60
|
-
run: |
|
|
61
|
-
# ensure npm can read the private or public registry
|
|
62
|
-
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
|
|
63
|
-
|
|
64
|
-
# 1) grab the package name
|
|
65
|
-
PKG=$(node -p "require('./package.json').name")
|
|
66
|
-
|
|
67
|
-
# 2) fetch the currently-published 'dev' dist-tag (e.g. "3.0.0-dev-20250430-1a2b3c4")
|
|
68
|
-
PUBLISHED=$(npm view "$PKG" dist-tags.dev 2>/dev/null || echo "")
|
|
69
|
-
|
|
70
|
-
# 3) extract the SHA suffix (after the last dash)
|
|
71
|
-
PUBLISHED_SHA=${PUBLISHED##*-}
|
|
72
|
-
|
|
73
|
-
# 4) get the current commit short-SHA
|
|
74
|
-
CURRENT_SHA=${ORIG_SHA}
|
|
75
|
-
|
|
76
|
-
echo "Published dev tag: $PUBLISHED"
|
|
77
|
-
echo "Published SHA: $PUBLISHED_SHA"
|
|
78
|
-
echo "Current SHA: $CURRENT_SHA"
|
|
79
|
-
|
|
80
|
-
if [ "$PUBLISHED_SHA" = "$CURRENT_SHA" ]; then
|
|
81
|
-
# nothing new → skip
|
|
82
|
-
echo "should_publish=false" >> $GITHUB_OUTPUT
|
|
83
|
-
else
|
|
84
|
-
# new commit → proceed
|
|
85
|
-
echo "should_publish=true" >> $GITHUB_OUTPUT
|
|
86
|
-
fi
|
|
87
|
-
|
|
88
|
-
- name: Publish to npm under ‘dev’ tag
|
|
89
|
-
if: steps.check_new.outputs.should_publish == 'true'
|
|
90
|
-
run: npm publish --tag dev
|
|
91
|
-
env:
|
|
92
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
name: Publish to npm on release
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
release:
|
|
5
|
-
types: [created]
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
publish:
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
|
|
11
|
-
steps:
|
|
12
|
-
- name: Checkout repository
|
|
13
|
-
uses: actions/checkout@v4
|
|
14
|
-
|
|
15
|
-
- name: Setup Node.js
|
|
16
|
-
uses: actions/setup-node@v4
|
|
17
|
-
with:
|
|
18
|
-
node-version: '22.x'
|
|
19
|
-
registry-url: 'https://registry.npmjs.org'
|
|
20
|
-
|
|
21
|
-
- name: Clean cache
|
|
22
|
-
run: npm cache clean --force
|
|
23
|
-
|
|
24
|
-
- name: Verify Node.js version
|
|
25
|
-
run: node -v
|
|
26
|
-
|
|
27
|
-
- name: Verify Npm version
|
|
28
|
-
run: npm -v
|
|
29
|
-
|
|
30
|
-
- name: Install dependencies
|
|
31
|
-
run: npm ci
|
|
32
|
-
|
|
33
|
-
- name: Lint
|
|
34
|
-
run: npm run lint
|
|
35
|
-
|
|
36
|
-
- name: Test
|
|
37
|
-
run: npm t
|
|
38
|
-
|
|
39
|
-
# - name: Build
|
|
40
|
-
# run: npm run build
|
|
41
|
-
|
|
42
|
-
- name: Publish to npm
|
|
43
|
-
run: npm publish
|
|
44
|
-
env:
|
|
45
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const log = require('../log');
|
|
4
|
-
const deviceFinder = require('../device-finder');
|
|
5
|
-
|
|
6
|
-
const tokens = require('../../lib/tokens');
|
|
7
|
-
|
|
8
|
-
exports.command = 'configure <idOrIp>';
|
|
9
|
-
exports.description = 'Control a device by invoking the given method';
|
|
10
|
-
exports.builder = {
|
|
11
|
-
ssid: {
|
|
12
|
-
required: true,
|
|
13
|
-
description: 'SSID of the WiFi network',
|
|
14
|
-
type: 'string'
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
passwd: {
|
|
18
|
-
required: true,
|
|
19
|
-
description: 'Password of WiFi-network',
|
|
20
|
-
type: 'string'
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
exports.handler = function(argv) {
|
|
25
|
-
let target = argv.idOrIp;
|
|
26
|
-
log.info('Attempting to configure', target);
|
|
27
|
-
|
|
28
|
-
let foundDevice = false;
|
|
29
|
-
let pending = 0;
|
|
30
|
-
const browser = deviceFinder({
|
|
31
|
-
filter: target
|
|
32
|
-
});
|
|
33
|
-
browser.on('available', device => {
|
|
34
|
-
pending++;
|
|
35
|
-
|
|
36
|
-
log.plain();
|
|
37
|
-
|
|
38
|
-
device.management.updateWireless({
|
|
39
|
-
ssid: argv.ssid,
|
|
40
|
-
passwd: argv.passwd
|
|
41
|
-
})
|
|
42
|
-
.then(result => {
|
|
43
|
-
log.plain('Updated wireless configuration');
|
|
44
|
-
|
|
45
|
-
return tokens.update(device.id, device.management.token);
|
|
46
|
-
})
|
|
47
|
-
.catch(err => {
|
|
48
|
-
log.error('Encountered an error while updating wireless');
|
|
49
|
-
log.plain();
|
|
50
|
-
log.plain('Error was:');
|
|
51
|
-
log.plain(err.message);
|
|
52
|
-
})
|
|
53
|
-
.then(() => {
|
|
54
|
-
pending--;
|
|
55
|
-
process.exit(0); // eslint-disable-line
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const doneHandler = () => {
|
|
60
|
-
if(pending === 0) {
|
|
61
|
-
if(! foundDevice) {
|
|
62
|
-
log.warn('Could not find device');
|
|
63
|
-
}
|
|
64
|
-
process.exit(0); // eslint-disable-line
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
setTimeout(doneHandler, 5000);
|
|
68
|
-
browser.on('done', doneHandler);
|
|
69
|
-
};
|
package/cli/commands/control.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const log = require('../log');
|
|
4
|
-
const deviceFinder = require('../device-finder');
|
|
5
|
-
|
|
6
|
-
exports.command = 'control <idOrIp> <method> [params..]';
|
|
7
|
-
exports.description = 'Control a device by invoking the given method';
|
|
8
|
-
exports.builder = {
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
exports.handler = function(argv) {
|
|
12
|
-
let target = argv.idOrIp;
|
|
13
|
-
log.info('Attempting to invoke', argv.method, 'on', target);
|
|
14
|
-
|
|
15
|
-
let foundDevice = false;
|
|
16
|
-
let pending = 0;
|
|
17
|
-
const browser = deviceFinder({
|
|
18
|
-
filter: target
|
|
19
|
-
});
|
|
20
|
-
browser.on('available', device => {
|
|
21
|
-
if(! device[argv.method]) {
|
|
22
|
-
log.error('The method ' + argv.method + ' is not available');
|
|
23
|
-
process.exit(0); // eslint-disable-line
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
pending++;
|
|
27
|
-
|
|
28
|
-
Promise.resolve(device[argv.method](...argv.params))
|
|
29
|
-
.then(result => {
|
|
30
|
-
log.plain(JSON.stringify(result, null, ' '));
|
|
31
|
-
})
|
|
32
|
-
.catch(err => {
|
|
33
|
-
log.error('Encountered an error while controlling device');
|
|
34
|
-
log.plain();
|
|
35
|
-
log.plain('Error was:');
|
|
36
|
-
log.plain(err.message);
|
|
37
|
-
})
|
|
38
|
-
.then(() => {
|
|
39
|
-
pending--;
|
|
40
|
-
process.exit(0); // eslint-disable-line
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const doneHandler = () => {
|
|
45
|
-
if(pending === 0) {
|
|
46
|
-
if(! foundDevice) {
|
|
47
|
-
log.warn('Could not find device');
|
|
48
|
-
}
|
|
49
|
-
process.exit(0); // eslint-disable-line
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
setTimeout(doneHandler, 5000);
|
|
53
|
-
browser.on('done', doneHandler);
|
|
54
|
-
};
|
package/cli/commands/discover.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const log = require('../log');
|
|
4
|
-
const deviceFinder = require('../device-finder');
|
|
5
|
-
const tokens = require('../../lib/tokens');
|
|
6
|
-
|
|
7
|
-
exports.command = 'discover';
|
|
8
|
-
exports.description = 'Discover devices on the local network';
|
|
9
|
-
exports.builder = {
|
|
10
|
-
'sync': {
|
|
11
|
-
type: 'boolean',
|
|
12
|
-
description: 'Synchronize tokens'
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
exports.handler = function(argv) {
|
|
17
|
-
log.info('Discovering devices. Press Ctrl+C to stop.');
|
|
18
|
-
log.plain();
|
|
19
|
-
|
|
20
|
-
const browser = deviceFinder();
|
|
21
|
-
browser.on('available', device => {
|
|
22
|
-
try {
|
|
23
|
-
log.device(device);
|
|
24
|
-
} catch(ex) {
|
|
25
|
-
log.error(ex);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const mgmt = device.management;
|
|
29
|
-
if(argv.sync && mgmt.token && mgmt.autoToken) {
|
|
30
|
-
tokens.update(device.id, mgmt.token)
|
|
31
|
-
.catch(err => {
|
|
32
|
-
log.error('Could not update token for', device.id, ':', err);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
};
|
package/cli/commands/inspect.js
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const chalk = require('chalk');
|
|
4
|
-
const log = require('../log');
|
|
5
|
-
const deviceFinder = require('../device-finder');
|
|
6
|
-
|
|
7
|
-
const GROUPS = [
|
|
8
|
-
{ name: 'Power', tags: [ 'cap:power', 'cap:switchable-power' ] },
|
|
9
|
-
{ name: 'Mode', tags: [ 'cap:mode', 'cap:switchable-mode' ] },
|
|
10
|
-
{ name: 'Sensor', tags: [
|
|
11
|
-
'type:sensor',
|
|
12
|
-
'cap:temperature',
|
|
13
|
-
'cap:relativeHumidity',
|
|
14
|
-
'cap:pressure',
|
|
15
|
-
'cap:pm2.5',
|
|
16
|
-
'cap:illuminance',
|
|
17
|
-
'cap:contact',
|
|
18
|
-
'cap:motion',
|
|
19
|
-
] },
|
|
20
|
-
{ name: 'Brightness', tags: [ 'cap:brightness', 'cap:dimmable' ] },
|
|
21
|
-
{ name: 'Color', tags: [ 'cap:colorable' ] },
|
|
22
|
-
{ name: 'LED', tags: [ 'cap:miio:switchable-led', 'cap:miio:led-brightness' ] },
|
|
23
|
-
{ name: 'Buzzer', tags: [ 'cap:miio:buzzer' ] },
|
|
24
|
-
{ name: 'Children', tags: [ 'cap:children' ] },
|
|
25
|
-
{ name: 'miIO', tags: [ 'type:miio' ]}
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
exports.command = 'inspect <idOrIp>';
|
|
29
|
-
exports.description = 'Inspect a device';
|
|
30
|
-
exports.builder = {
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
exports.handler = function(argv) {
|
|
34
|
-
let target = argv.idOrIp;
|
|
35
|
-
log.info('Attempting to inspect', target);
|
|
36
|
-
|
|
37
|
-
let foundDevice = false;
|
|
38
|
-
let pending = 0;
|
|
39
|
-
const browser = deviceFinder({
|
|
40
|
-
instances: true,
|
|
41
|
-
filter: target
|
|
42
|
-
});
|
|
43
|
-
browser.on('available', device => {
|
|
44
|
-
pending++;
|
|
45
|
-
|
|
46
|
-
// TODO: Error handling
|
|
47
|
-
const mgmt = device.management;
|
|
48
|
-
mgmt.info()
|
|
49
|
-
.then(info => {
|
|
50
|
-
log.plain();
|
|
51
|
-
log.device(device, true);
|
|
52
|
-
|
|
53
|
-
if(! mgmt.parent) {
|
|
54
|
-
log.plain(chalk.bold('Firmware version:'), info.fw_ver);
|
|
55
|
-
log.plain(chalk.bold('Hardware version:'), info.hw_ver);
|
|
56
|
-
if(info.mcu_fw_ver) {
|
|
57
|
-
log.plain(chalk.bold('MCU firmware version:'), info.mcu_fw_ver);
|
|
58
|
-
}
|
|
59
|
-
log.plain();
|
|
60
|
-
|
|
61
|
-
if(info.ap) {
|
|
62
|
-
log.plain(chalk.bold('WiFi:'), info.ap.ssid, chalk.dim('(' + info.ap.bssid + ')'), chalk.bold('RSSI:'), info.ap.rssi);
|
|
63
|
-
} else {
|
|
64
|
-
log.plain(chalk.bold('WiFi:'), 'Not Connected');
|
|
65
|
-
}
|
|
66
|
-
if(info.wifi_fw_ver) {
|
|
67
|
-
log.plain(chalk.bold('WiFi firmware version:'), info.wifi_fw_ver);
|
|
68
|
-
}
|
|
69
|
-
log.plain();
|
|
70
|
-
|
|
71
|
-
if(info.ot) {
|
|
72
|
-
let type;
|
|
73
|
-
switch(info.ot) {
|
|
74
|
-
case 'otu':
|
|
75
|
-
type = 'UDP';
|
|
76
|
-
break;
|
|
77
|
-
case 'ott':
|
|
78
|
-
type = 'TCP';
|
|
79
|
-
break;
|
|
80
|
-
default:
|
|
81
|
-
type = 'Unknown (' + info.ot + ')';
|
|
82
|
-
}
|
|
83
|
-
log.plain(chalk.bold('Remote access (Mi Home App):'), type);
|
|
84
|
-
} else {
|
|
85
|
-
log.plain(chalk.bold('Remote access (Mi Home App):'), 'Maybe');
|
|
86
|
-
}
|
|
87
|
-
log.plain();
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const props = device.properties;
|
|
91
|
-
const keys = Object.keys(props);
|
|
92
|
-
if(keys.length > 0) {
|
|
93
|
-
log.plain(chalk.bold('Properties:'));
|
|
94
|
-
for(const key of keys) {
|
|
95
|
-
log.plain(' -', key + ':', props[key]);
|
|
96
|
-
}
|
|
97
|
-
log.plain();
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if(mgmt.parent) {
|
|
101
|
-
log.plain(chalk.bold('Parent:'));
|
|
102
|
-
log.group(() => {
|
|
103
|
-
log.device(mgmt.parent);
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
log.plain(chalk.bold('Actions:'));
|
|
108
|
-
log.group(() => {
|
|
109
|
-
const actions = device.metadata.actions;
|
|
110
|
-
const handled = new Set();
|
|
111
|
-
for(const group of GROUPS) {
|
|
112
|
-
let seenTags = new Set();
|
|
113
|
-
let actionsToPrint = [];
|
|
114
|
-
|
|
115
|
-
/*
|
|
116
|
-
* Go through all actions and collect those that
|
|
117
|
-
* belong to this group.
|
|
118
|
-
*/
|
|
119
|
-
for(const name of Object.keys(actions)) {
|
|
120
|
-
if(handled.has(name)) continue;
|
|
121
|
-
const action = actions[name];
|
|
122
|
-
|
|
123
|
-
for(const t of group.tags) {
|
|
124
|
-
if(action.tags.indexOf(t) >= 0) {
|
|
125
|
-
seenTags.add(t);
|
|
126
|
-
actionsToPrint.push(action);
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if(actionsToPrint.length > 0) {
|
|
133
|
-
log.plain(chalk.bold(group.name), '-', Array.from(seenTags).join(', '));
|
|
134
|
-
|
|
135
|
-
for(const action of actionsToPrint) {
|
|
136
|
-
printAction(action);
|
|
137
|
-
handled.add(action.name);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
log.plain();
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
let isFirst = true;
|
|
145
|
-
for(const name of Object.keys(actions)) {
|
|
146
|
-
if(handled.has(name)) continue;
|
|
147
|
-
|
|
148
|
-
if(isFirst) {
|
|
149
|
-
log.plain(chalk.bold('Other actions'));
|
|
150
|
-
isFirst = false;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
printAction(actions[name]);
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
})
|
|
157
|
-
.catch(err => {
|
|
158
|
-
log.error('Could inspect device. Error was:', err.message);
|
|
159
|
-
})
|
|
160
|
-
.then(() => {
|
|
161
|
-
pending--;
|
|
162
|
-
process.exit(0); // eslint-disable-line
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
const doneHandler = () => {
|
|
167
|
-
if(pending === 0) {
|
|
168
|
-
if(! foundDevice) {
|
|
169
|
-
log.warn('Could not find device');
|
|
170
|
-
}
|
|
171
|
-
process.exit(0); // eslint-disable-line
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
setTimeout(doneHandler, 5000);
|
|
175
|
-
browser.on('done', doneHandler);
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
function printAction(action) {
|
|
179
|
-
log.group(() => {
|
|
180
|
-
let args = action.name;
|
|
181
|
-
for(const arg of action.arguments) {
|
|
182
|
-
args += ' ';
|
|
183
|
-
|
|
184
|
-
if(arg.optional) {
|
|
185
|
-
args += '[';
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
args += arg.type;
|
|
189
|
-
|
|
190
|
-
if(arg.optional) {
|
|
191
|
-
args += ']';
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
log.plain(args);
|
|
196
|
-
});
|
|
197
|
-
}
|