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,76 @@
|
|
|
1
|
+
import { ChargingState, AutonomousCharging } from "abstract-things";
|
|
2
|
+
import { Vacuum, AdjustableFanSpeed, AutonomousCleaning, SpotCleaning } from "abstract-things/climate";
|
|
3
|
+
import { MiioApi } from "../../device";
|
|
4
|
+
import { type VacuumMode } from "./vacuum_modes";
|
|
5
|
+
declare const ViomiVacuum_base: new (...args: unknown[]) => Vacuum & MiioApi & {
|
|
6
|
+
propertyUpdated(key: any, value: any): void;
|
|
7
|
+
id: string | null;
|
|
8
|
+
metadata: Record<string, unknown> & {
|
|
9
|
+
types: string[];
|
|
10
|
+
capabilities: string[];
|
|
11
|
+
addCapabilities(...capabilities: string[]): void;
|
|
12
|
+
};
|
|
13
|
+
init(): Promise</*elided*/ any | undefined>;
|
|
14
|
+
initCallback(): Promise<void>;
|
|
15
|
+
destroy(): Promise<void>;
|
|
16
|
+
destroyCallback(): Promise<void>;
|
|
17
|
+
debug(...parts: unknown[]): void;
|
|
18
|
+
matches(...tags: string[]): boolean;
|
|
19
|
+
emitEvent(event: string, data?: unknown, options?: unknown): void;
|
|
20
|
+
on(event: string, listener: (...args: never[]) => void): unknown;
|
|
21
|
+
off(event: string, listener: (...args: never[]) => void): unknown;
|
|
22
|
+
extendWith<T>(...mixins: T[]): T & import("abstract-things").Thing;
|
|
23
|
+
batteryLevel(): Promise<number>;
|
|
24
|
+
updateBatteryLevel(level: number): void;
|
|
25
|
+
} & import("abstract-things").Thing & AutonomousCharging & AutonomousCleaning & SpotCleaning & AdjustableFanSpeed & ChargingState;
|
|
26
|
+
export declare class ViomiVacuum extends ViomiVacuum_base {
|
|
27
|
+
static get type(): string;
|
|
28
|
+
constructor(options: any);
|
|
29
|
+
propertyUpdated<T>(key: string, value: T, oldValue?: T): void;
|
|
30
|
+
/**
|
|
31
|
+
* The fan speeds supported by this model, to be used with {@link changeFanSpeed}.
|
|
32
|
+
*
|
|
33
|
+
* @returns The list of modes
|
|
34
|
+
*/
|
|
35
|
+
fanSpeeds(): Promise<VacuumMode[]>;
|
|
36
|
+
/**
|
|
37
|
+
* The water levels supported by this model. Empty if not supported.
|
|
38
|
+
*
|
|
39
|
+
* @returns The list of modes
|
|
40
|
+
*/
|
|
41
|
+
waterBoxModes(): Promise<VacuumMode[]>;
|
|
42
|
+
getDeviceInfo(): Promise<import("../../protocol").MiioDeviceInfo>;
|
|
43
|
+
getSerialNumber(): Promise<string>;
|
|
44
|
+
getRoomMap(): Promise<[string, string][]>;
|
|
45
|
+
cleanRooms(listOfRooms: any): Promise<void>;
|
|
46
|
+
resumeCleanRooms(listOfRooms: any): Promise<void>;
|
|
47
|
+
getTimer(): Promise<import("../../protocol").GetTimerResponseTimer[]>;
|
|
48
|
+
/**
|
|
49
|
+
* Start a cleaning session.
|
|
50
|
+
*/
|
|
51
|
+
activateCleaning(): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Pause the current cleaning session.
|
|
54
|
+
*/
|
|
55
|
+
pause(): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Stop the current cleaning session.
|
|
58
|
+
*/
|
|
59
|
+
deactivateCleaning(): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Stop the current cleaning session and return to charge.
|
|
62
|
+
*/
|
|
63
|
+
activateCharging(): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Set the power of the fan.
|
|
66
|
+
* Values reported by users (#216 in homebridge-xiaomi-roborock-vacuum): 0 (Silent), 1 (Standard), 2 (Medium), 3 (Turbo).
|
|
67
|
+
*
|
|
68
|
+
* @param speed
|
|
69
|
+
*/
|
|
70
|
+
changeFanSpeed(speed: any): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Activate the find function, will make the device give off a sound.
|
|
73
|
+
*/
|
|
74
|
+
find(): Promise<null>;
|
|
75
|
+
}
|
|
76
|
+
export {};
|
|
@@ -7,6 +7,7 @@ const device_1 = require("../../device");
|
|
|
7
7
|
const battery_level_1 = require("../capabilities/battery-level");
|
|
8
8
|
const check_result_1 = require("../../check_result");
|
|
9
9
|
const vacuum_modes_1 = require("./vacuum_modes");
|
|
10
|
+
const vacuum_errors_1 = require("./vacuum_errors");
|
|
10
11
|
class ViomiVacuum extends climate_1.Vacuum.with(device_1.MiioApi, battery_level_1.BatteryLevel, abstract_things_1.AutonomousCharging, climate_1.AutonomousCleaning, climate_1.SpotCleaning, climate_1.AdjustableFanSpeed, abstract_things_1.ChargingState) {
|
|
11
12
|
static get type() {
|
|
12
13
|
return "miio:vacuum";
|
|
@@ -82,6 +83,7 @@ class ViomiVacuum extends climate_1.Vacuum.with(device_1.MiioApi, battery_level_
|
|
|
82
83
|
}
|
|
83
84
|
propertyUpdated(key, value, oldValue) {
|
|
84
85
|
if (key === "state") {
|
|
86
|
+
(0, vacuum_errors_1.clearErrorOnRecovery)(this, value);
|
|
85
87
|
// Update charging state
|
|
86
88
|
this.updateCharging(value === "charging");
|
|
87
89
|
switch (value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viomivacuum.js","sourceRoot":"","sources":["../../../../src/lib/devices/vacuums/viomivacuum.ts"],"names":[],"mappings":";;;AAAA,qDAAoE;AACpE,qDAKiC;AAEjC,yCAAuC;AACvC,iEAA6D;AAC7D,qDAAiD;AAEjD,iDAAqE;
|
|
1
|
+
{"version":3,"file":"viomivacuum.js","sourceRoot":"","sources":["../../../../src/lib/devices/vacuums/viomivacuum.ts"],"names":[],"mappings":";;;AAAA,qDAAoE;AACpE,qDAKiC;AAEjC,yCAAuC;AACvC,iEAA6D;AAC7D,qDAAiD;AAEjD,iDAAqE;AACrE,mDAAuD;AAEvD,MAAa,WAAY,SAAQ,gBAAM,CAAC,IAAI,CAC1C,gBAAO,EACP,4BAAY,EACZ,oCAAkB,EAClB,4BAAkB,EAClB,sBAAY,EACZ,4BAAkB,EAClB,+BAAa,CACd;IACC,MAAM,KAAK,IAAI;QACb,OAAO,aAAa,CAAC;IACvB,CAAC;IACD,YAAY,OAAO;QACjB,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE;YAC/B,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE;gBACZ,QAAQ,CAAC,EAAE,CAAC;oBACV,KAAK,CAAC;wBACJ,OAAO,IAAI,CAAC;oBACd;wBACE,OAAO;4BACL,IAAI,EAAE,CAAC;4BACP,OAAO,EAAE,gBAAgB,GAAG,CAAC;yBAC9B,CAAC;gBACN,CAAC;YACH,CAAC;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE;YAC/B,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE;gBACZ,QAAQ,CAAC,EAAE,CAAC;oBACV,KAAK,CAAC;wB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EAAE,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;CACF;AAvPD,kCAuPC"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
export const ColorTemperature: new (...args: any[]) => {
|
|
2
|
+
propertyUpdated(key: any, value: any): void;
|
|
3
|
+
changeColor(color: any, options: any): Promise<null>;
|
|
4
|
+
id: string | null;
|
|
5
|
+
metadata: Record<string, unknown> & {
|
|
6
|
+
types: string[];
|
|
7
|
+
capabilities: string[];
|
|
8
|
+
addCapabilities(...capabilities: string[]): void;
|
|
9
|
+
};
|
|
10
|
+
init(): Promise</*elided*/ any | undefined>;
|
|
11
|
+
initCallback(): Promise<void>;
|
|
12
|
+
destroy(): Promise<void>;
|
|
13
|
+
destroyCallback: (() => Promise<void>) & (() => Promise<void>);
|
|
14
|
+
debug: ((...parts: unknown[]) => void) & ((...msgs: unknown[]) => void);
|
|
15
|
+
matches(...tags: string[]): boolean;
|
|
16
|
+
emitEvent(event: string, data?: unknown, options?: unknown): void;
|
|
17
|
+
on(event: string, listener: (...args: never[]) => void): unknown;
|
|
18
|
+
off(event: string, listener: (...args: never[]) => void): unknown;
|
|
19
|
+
extendWith<T>(...mixins: T[]): T & Thing;
|
|
20
|
+
readonly miioModel?: string;
|
|
21
|
+
readonly _properties: Record<string, unknown>;
|
|
22
|
+
readonly _propertiesToMonitor: string[];
|
|
23
|
+
readonly _propertyDefinitions: Record<string, import("../device").PersistedPropertyDefinition<never, never>>;
|
|
24
|
+
readonly _reversePropertyDefinitions: Record<string, string>;
|
|
25
|
+
readonly management: import("../management").DeviceManagement;
|
|
26
|
+
debugFn?: import("../logger").DebugFn;
|
|
27
|
+
readonly handle: import("../management").DeviceHandle;
|
|
28
|
+
miioCall<Method extends keyof import("../protocol").Protocol, Params extends import("../protocol").Protocol[Method]["params"], Response extends import("../protocol").Protocol[Method]["response"]>(method: Method, args: Params): Promise<Response>;
|
|
29
|
+
call<Method extends keyof import("../protocol").Protocol, Params extends import("../protocol").Protocol[Method]["params"], Response extends import("../protocol").Protocol[Method]["response"]>(method: Method, args: Params, options?: {
|
|
30
|
+
refresh?: string[];
|
|
31
|
+
refreshDelay?: number;
|
|
32
|
+
sid?: number;
|
|
33
|
+
retries?: number;
|
|
34
|
+
}): Promise<Response>;
|
|
35
|
+
defineProperty<T, V>(name: string, def?: import("../device").Mapper<T, V> | import("../device").PropertyDefinition<T, V> | undefined): void;
|
|
36
|
+
_pushProperty(result: Record<string, unknown>, name: string, value: unknown): void;
|
|
37
|
+
poll(_isInitial?: boolean): Promise<void>;
|
|
38
|
+
_loadProperties(properties?: string[]): Promise<void>;
|
|
39
|
+
setProperty(key: string, value: unknown): void;
|
|
40
|
+
setRawProperty(name: string, value: unknown): void;
|
|
41
|
+
property<T>(key: string): T;
|
|
42
|
+
get connected(): boolean;
|
|
43
|
+
get properties(): Record<string, unknown>;
|
|
44
|
+
miioProperties(): Record<string, unknown>;
|
|
45
|
+
getProperties(props: string[]): {};
|
|
46
|
+
loadProperties(props: string[]): Promise<{}>;
|
|
47
|
+
updatePollDuration(duration: number): void;
|
|
48
|
+
updateMaxPollFailures(failures: number): void;
|
|
49
|
+
updateColor(value: import("abstract-things/values").Color): void;
|
|
50
|
+
} & Thing;
|
|
51
|
+
export const ColorFull: new (...args: any[]) => {
|
|
52
|
+
propertyUpdated(key: any, value: any): void;
|
|
53
|
+
changeColor(color: any, options: any): Promise<null>;
|
|
54
|
+
id: string | null;
|
|
55
|
+
metadata: Record<string, unknown> & {
|
|
56
|
+
types: string[];
|
|
57
|
+
capabilities: string[];
|
|
58
|
+
addCapabilities(...capabilities: string[]): void;
|
|
59
|
+
};
|
|
60
|
+
init(): Promise</*elided*/ any | undefined>;
|
|
61
|
+
initCallback(): Promise<void>;
|
|
62
|
+
destroy(): Promise<void>;
|
|
63
|
+
destroyCallback: (() => Promise<void>) & (() => Promise<void>);
|
|
64
|
+
debug: ((...parts: unknown[]) => void) & ((...msgs: unknown[]) => void);
|
|
65
|
+
matches(...tags: string[]): boolean;
|
|
66
|
+
emitEvent(event: string, data?: unknown, options?: unknown): void;
|
|
67
|
+
on(event: string, listener: (...args: never[]) => void): unknown;
|
|
68
|
+
off(event: string, listener: (...args: never[]) => void): unknown;
|
|
69
|
+
extendWith<T>(...mixins: T[]): T & Thing;
|
|
70
|
+
readonly miioModel?: string;
|
|
71
|
+
readonly _properties: Record<string, unknown>;
|
|
72
|
+
readonly _propertiesToMonitor: string[];
|
|
73
|
+
readonly _propertyDefinitions: Record<string, import("../device").PersistedPropertyDefinition<never, never>>;
|
|
74
|
+
readonly _reversePropertyDefinitions: Record<string, string>;
|
|
75
|
+
readonly management: import("../management").DeviceManagement;
|
|
76
|
+
debugFn?: import("../logger").DebugFn;
|
|
77
|
+
readonly handle: import("../management").DeviceHandle;
|
|
78
|
+
miioCall<Method extends keyof import("../protocol").Protocol, Params extends import("../protocol").Protocol[Method]["params"], Response extends import("../protocol").Protocol[Method]["response"]>(method: Method, args: Params): Promise<Response>;
|
|
79
|
+
call<Method extends keyof import("../protocol").Protocol, Params extends import("../protocol").Protocol[Method]["params"], Response extends import("../protocol").Protocol[Method]["response"]>(method: Method, args: Params, options?: {
|
|
80
|
+
refresh?: string[];
|
|
81
|
+
refreshDelay?: number;
|
|
82
|
+
sid?: number;
|
|
83
|
+
retries?: number;
|
|
84
|
+
}): Promise<Response>;
|
|
85
|
+
defineProperty<T, V>(name: string, def?: import("../device").Mapper<T, V> | import("../device").PropertyDefinition<T, V> | undefined): void;
|
|
86
|
+
_pushProperty(result: Record<string, unknown>, name: string, value: unknown): void;
|
|
87
|
+
poll(_isInitial?: boolean): Promise<void>;
|
|
88
|
+
_loadProperties(properties?: string[]): Promise<void>;
|
|
89
|
+
setProperty(key: string, value: unknown): void;
|
|
90
|
+
setRawProperty(name: string, value: unknown): void;
|
|
91
|
+
property<T>(key: string): T;
|
|
92
|
+
get connected(): boolean;
|
|
93
|
+
get properties(): Record<string, unknown>;
|
|
94
|
+
miioProperties(): Record<string, unknown>;
|
|
95
|
+
getProperties(props: string[]): {};
|
|
96
|
+
loadProperties(props: string[]): Promise<{}>;
|
|
97
|
+
updatePollDuration(duration: number): void;
|
|
98
|
+
updateMaxPollFailures(failures: number): void;
|
|
99
|
+
updateColor(value: import("abstract-things/values").Color): void;
|
|
100
|
+
} & Thing;
|
|
101
|
+
export const Yeelight: new (options?: any) => {
|
|
102
|
+
propertyUpdated(key: any, value: any): void;
|
|
103
|
+
changePower(power: any): Promise<null>;
|
|
104
|
+
/**
|
|
105
|
+
* Make the current state the default state, meaning the light will restore
|
|
106
|
+
* to this state after power has been cut.
|
|
107
|
+
*/
|
|
108
|
+
setDefault(): Promise<null>;
|
|
109
|
+
changeBrightness(brightness: any, options: any): Promise<null>;
|
|
110
|
+
changeName(name: any): Promise<any>;
|
|
111
|
+
id: string | null;
|
|
112
|
+
metadata: Record<string, unknown> & {
|
|
113
|
+
types: string[];
|
|
114
|
+
capabilities: string[];
|
|
115
|
+
addCapabilities(...capabilities: string[]): void;
|
|
116
|
+
};
|
|
117
|
+
init(): Promise</*elided*/ any | undefined>;
|
|
118
|
+
initCallback(): Promise<void>;
|
|
119
|
+
destroy(): Promise<void>;
|
|
120
|
+
destroyCallback: (() => Promise<void>) & (() => Promise<void>);
|
|
121
|
+
debug: ((...parts: unknown[]) => void) & ((...msgs: unknown[]) => void);
|
|
122
|
+
matches(...tags: string[]): boolean;
|
|
123
|
+
emitEvent(event: string, data?: unknown, options?: unknown): void;
|
|
124
|
+
on(event: string, listener: (...args: never[]) => void): unknown;
|
|
125
|
+
off(event: string, listener: (...args: never[]) => void): unknown;
|
|
126
|
+
extendWith<T>(...mixins: T[]): T & Thing;
|
|
127
|
+
readonly miioModel?: string;
|
|
128
|
+
readonly _properties: Record<string, unknown>;
|
|
129
|
+
readonly _propertiesToMonitor: string[];
|
|
130
|
+
readonly _propertyDefinitions: Record<string, import("../device").PersistedPropertyDefinition<never, never>>;
|
|
131
|
+
readonly _reversePropertyDefinitions: Record<string, string>;
|
|
132
|
+
readonly management: import("../management").DeviceManagement;
|
|
133
|
+
debugFn?: import("../logger").DebugFn;
|
|
134
|
+
readonly handle: import("../management").DeviceHandle;
|
|
135
|
+
miioCall<Method extends keyof import("../protocol").Protocol, Params extends import("../protocol").Protocol[Method]["params"], Response extends import("../protocol").Protocol[Method]["response"]>(method: Method, args: Params): Promise<Response>;
|
|
136
|
+
call<Method extends keyof import("../protocol").Protocol, Params extends import("../protocol").Protocol[Method]["params"], Response extends import("../protocol").Protocol[Method]["response"]>(method: Method, args: Params, options?: {
|
|
137
|
+
refresh?: string[];
|
|
138
|
+
refreshDelay?: number;
|
|
139
|
+
sid?: number;
|
|
140
|
+
retries?: number;
|
|
141
|
+
}): Promise<Response>;
|
|
142
|
+
defineProperty<T, V>(name: string, def?: import("../device").Mapper<T, V> | import("../device").PropertyDefinition<T, V> | undefined): void;
|
|
143
|
+
_pushProperty(result: Record<string, unknown>, name: string, value: unknown): void;
|
|
144
|
+
poll(_isInitial?: boolean): Promise<void>;
|
|
145
|
+
_loadProperties(properties?: string[]): Promise<void>;
|
|
146
|
+
setProperty(key: string, value: unknown): void;
|
|
147
|
+
setRawProperty(name: string, value: unknown): void;
|
|
148
|
+
property<T>(key: string): T;
|
|
149
|
+
get connected(): boolean;
|
|
150
|
+
get properties(): Record<string, unknown>;
|
|
151
|
+
miioProperties(): Record<string, unknown>;
|
|
152
|
+
getProperties(props: string[]): {};
|
|
153
|
+
loadProperties(props: string[]): Promise<{}>;
|
|
154
|
+
updatePollDuration(duration: number): void;
|
|
155
|
+
updateMaxPollFailures(failures: number): void;
|
|
156
|
+
updatePower<T>(value: T): void;
|
|
157
|
+
updateBrightness(value: number): void;
|
|
158
|
+
} & Thing;
|
|
159
|
+
import { Thing } from "abstract-things";
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import util from "node:util";
|
|
2
|
+
import { TimedServiceDiscovery, BasicServiceDiscovery, type Service } from "tinkerhub-discovery";
|
|
3
|
+
import { type ConnectToDeviceOptions } from "./connect_to_device";
|
|
4
|
+
import type { DeviceInfo } from "./device_info";
|
|
5
|
+
import type { IDevice } from "./device";
|
|
6
|
+
declare const tryAdd: unique symbol;
|
|
7
|
+
export interface BrowserOptions {
|
|
8
|
+
cacheTime?: number;
|
|
9
|
+
tokens?: Record<string, string>;
|
|
10
|
+
}
|
|
11
|
+
interface BrowserService extends Service {
|
|
12
|
+
address: string;
|
|
13
|
+
port: number;
|
|
14
|
+
token: string | Buffer | null;
|
|
15
|
+
autoToken?: boolean;
|
|
16
|
+
model?: string;
|
|
17
|
+
hostname?: string;
|
|
18
|
+
connect: (options?: Partial<ConnectToDeviceOptions>) => Promise<IDevice | undefined>;
|
|
19
|
+
}
|
|
20
|
+
export declare class Browser extends TimedServiceDiscovery<BrowserService> {
|
|
21
|
+
static get type(): string;
|
|
22
|
+
private handle?;
|
|
23
|
+
private readonly manualTokens;
|
|
24
|
+
constructor(options: BrowserOptions);
|
|
25
|
+
_manualToken(id: any): string | null;
|
|
26
|
+
start(): void;
|
|
27
|
+
destroy(): Promise<void>;
|
|
28
|
+
search(): void;
|
|
29
|
+
[tryAdd](device: DeviceInfo): void;
|
|
30
|
+
[util.inspect.custom](): string;
|
|
31
|
+
}
|
|
32
|
+
export interface DevicesOptions extends BrowserOptions {
|
|
33
|
+
token?: string | Buffer;
|
|
34
|
+
filter?: (reg: {
|
|
35
|
+
id: string;
|
|
36
|
+
model: string;
|
|
37
|
+
type: string;
|
|
38
|
+
}) => boolean;
|
|
39
|
+
skipSubDevices?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export declare class Devices extends BasicServiceDiscovery<IDevice & {
|
|
42
|
+
id: string;
|
|
43
|
+
}> {
|
|
44
|
+
static get type(): string;
|
|
45
|
+
private readonly _filter?;
|
|
46
|
+
private readonly _skipSubDevices?;
|
|
47
|
+
private readonly _browser;
|
|
48
|
+
constructor(options: DevicesOptions);
|
|
49
|
+
destroy(): Promise<void>;
|
|
50
|
+
[util.inspect.custom](): string;
|
|
51
|
+
_bindSubDevices(device: any): void;
|
|
52
|
+
}
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payload of the `stateChanged` event (`device.on("stateChanged", ...)`), emitted for every change of `state()`.
|
|
3
|
+
*/
|
|
4
|
+
export interface StateChangedEvent {
|
|
5
|
+
key: string;
|
|
6
|
+
value: unknown;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Payload of the `errorChanged` event (`device.on("errorChanged", ...)`): the error, or `null` when it's cleared.
|
|
10
|
+
*
|
|
11
|
+
* abstract-things converts the errors set by the devices (`{ code, message }`) into this shape.
|
|
12
|
+
*/
|
|
13
|
+
export type ErrorChangedEvent = {
|
|
14
|
+
/** The error code, e.g. `10` (Roborock) or `"charging-error"` */
|
|
15
|
+
id: number | string;
|
|
16
|
+
/** A human-readable description, if known */
|
|
17
|
+
description?: string;
|
|
18
|
+
} | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/lib/events.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/// <reference path="../types/abstract-things/climate/index.d.ts" />
|
|
2
|
+
/// <reference path="../types/abstract-things/electricals/index.d.ts" />
|
|
3
|
+
/// <reference path="../types/abstract-things/index.d.ts" />
|
|
4
|
+
/// <reference path="../types/abstract-things/lights/index.d.ts" />
|
|
5
|
+
/// <reference path="../types/abstract-things/values/index.d.ts" />
|
|
6
|
+
import * as discovery from "./discovery";
|
|
7
|
+
import { models } from "./models";
|
|
8
|
+
import { connectToDevice } from "./connect_to_device";
|
|
9
|
+
import { infoFromHostname } from "./info_from_hostname";
|
|
10
|
+
import type { BrowserOptions, DevicesOptions } from "./discovery";
|
|
11
|
+
export { Device as MiioDevice } from "./device";
|
|
12
|
+
export { MiioError } from "./miio_error";
|
|
13
|
+
export { configureLogging, type MiioLogger } from "./logger";
|
|
14
|
+
export type { StateChangedEvent, ErrorChangedEvent } from "./events";
|
|
15
|
+
export { Vacuum, MOP_ROUTES, type RoborockConsumable, } from "./devices/vacuums/vacuum";
|
|
16
|
+
export { resolveVacuumModes, type VacuumMode, type VacuumModes, } from "./devices/vacuums/vacuum_modes";
|
|
17
|
+
export { MijiaVacuum } from "./devices/vacuums/mijiavacuum";
|
|
18
|
+
export { isVacuum, type VacuumDevice } from "./devices/vacuums/vacuum_device";
|
|
19
|
+
export { ViomiVacuum } from "./devices/vacuums/viomivacuum";
|
|
20
|
+
export { DreameVacuum } from "./devices/vacuums/dreamevacuum";
|
|
21
|
+
export { MiotVacuum, type MiotMode } from "./devices/vacuums/miot-vacuum";
|
|
22
|
+
export { MiotSpecClient, configureMiotSpecs, type MiotSpecOptions, type ResolvedMiotSpec, } from "./miot/spec_client";
|
|
23
|
+
export { MiotSpecIndex, parseUrn, type MiotSpec } from "./miot/miot_spec";
|
|
24
|
+
export { MiotError } from "./miot/miot_api";
|
|
25
|
+
export * from "./cloud/index";
|
|
26
|
+
export { parseRoborockMap, roomAt, roomOfPixel, MapParseError, MM_PER_PIXEL, PIXEL, type RoborockMap, type MapRoom, type MapPoint, type MapRectangle, type MapArea, type MapImage, } from "./maps/roborock_map";
|
|
27
|
+
export { MapWatcher, type MapWatcherDevice, type MapWatcherOptions, type MapWatcherEvents, } from "./maps/map_watcher";
|
|
28
|
+
export {
|
|
29
|
+
/**
|
|
30
|
+
* Get information about the models supported. Can be used to extend the models
|
|
31
|
+
* supported.
|
|
32
|
+
*/
|
|
33
|
+
models,
|
|
34
|
+
/**
|
|
35
|
+
* Resolve a device from the given options.
|
|
36
|
+
*
|
|
37
|
+
* Options:
|
|
38
|
+
* `address`, **required** the address to the device as an IP or hostname
|
|
39
|
+
* `port`, optional port number, if not specified the default 54321 will be used
|
|
40
|
+
* `token`, optional token of the device
|
|
41
|
+
*/
|
|
42
|
+
connectToDevice as device,
|
|
43
|
+
/**
|
|
44
|
+
* Extract information about a device from its hostname on the local network.
|
|
45
|
+
*/
|
|
46
|
+
infoFromHostname, };
|
|
47
|
+
/**
|
|
48
|
+
* Browse for devices available on the network. Will not automatically
|
|
49
|
+
* connect to them.
|
|
50
|
+
*
|
|
51
|
+
* @param options
|
|
52
|
+
*/
|
|
53
|
+
export declare function browse(options?: BrowserOptions): discovery.Browser;
|
|
54
|
+
/**
|
|
55
|
+
* Get access to all devices on the current network. Will find and connect to
|
|
56
|
+
* devices automatically.
|
|
57
|
+
*
|
|
58
|
+
* @param options
|
|
59
|
+
*/
|
|
60
|
+
export declare function devices(options?: DevicesOptions): discovery.Devices;
|
package/dist/lib/index.js
CHANGED
|
@@ -32,8 +32,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.infoFromHostname = exports.device = exports.models = exports.MiotError = exports.parseUrn = exports.MiotSpecIndex = exports.configureMiotSpecs = exports.MiotSpecClient = exports.MiotVacuum = exports.DreameVacuum = exports.ViomiVacuum = exports.MijiaVacuum = exports.resolveVacuumModes = exports.MOP_ROUTES = exports.Vacuum = exports.MiioError = exports.MiioDevice = void 0;
|
|
39
|
+
exports.infoFromHostname = exports.device = exports.models = exports.MapWatcher = exports.PIXEL = exports.MM_PER_PIXEL = exports.MapParseError = exports.roomOfPixel = exports.roomAt = exports.parseRoborockMap = exports.MiotError = exports.parseUrn = exports.MiotSpecIndex = exports.configureMiotSpecs = exports.MiotSpecClient = exports.MiotVacuum = exports.DreameVacuum = exports.ViomiVacuum = exports.isVacuum = exports.MijiaVacuum = exports.resolveVacuumModes = exports.MOP_ROUTES = exports.Vacuum = exports.configureLogging = exports.MiioError = exports.MiioDevice = void 0;
|
|
37
40
|
exports.browse = browse;
|
|
38
41
|
exports.devices = devices;
|
|
39
42
|
const discovery = __importStar(require("./discovery"));
|
|
@@ -47,6 +50,8 @@ var device_1 = require("./device");
|
|
|
47
50
|
Object.defineProperty(exports, "MiioDevice", { enumerable: true, get: function () { return device_1.Device; } });
|
|
48
51
|
var miio_error_1 = require("./miio_error");
|
|
49
52
|
Object.defineProperty(exports, "MiioError", { enumerable: true, get: function () { return miio_error_1.MiioError; } });
|
|
53
|
+
var logger_1 = require("./logger");
|
|
54
|
+
Object.defineProperty(exports, "configureLogging", { enumerable: true, get: function () { return logger_1.configureLogging; } });
|
|
50
55
|
var vacuum_1 = require("./devices/vacuums/vacuum");
|
|
51
56
|
Object.defineProperty(exports, "Vacuum", { enumerable: true, get: function () { return vacuum_1.Vacuum; } });
|
|
52
57
|
Object.defineProperty(exports, "MOP_ROUTES", { enumerable: true, get: function () { return vacuum_1.MOP_ROUTES; } });
|
|
@@ -54,6 +59,8 @@ var vacuum_modes_1 = require("./devices/vacuums/vacuum_modes");
|
|
|
54
59
|
Object.defineProperty(exports, "resolveVacuumModes", { enumerable: true, get: function () { return vacuum_modes_1.resolveVacuumModes; } });
|
|
55
60
|
var mijiavacuum_1 = require("./devices/vacuums/mijiavacuum");
|
|
56
61
|
Object.defineProperty(exports, "MijiaVacuum", { enumerable: true, get: function () { return mijiavacuum_1.MijiaVacuum; } });
|
|
62
|
+
var vacuum_device_1 = require("./devices/vacuums/vacuum_device");
|
|
63
|
+
Object.defineProperty(exports, "isVacuum", { enumerable: true, get: function () { return vacuum_device_1.isVacuum; } });
|
|
57
64
|
var viomivacuum_1 = require("./devices/vacuums/viomivacuum");
|
|
58
65
|
Object.defineProperty(exports, "ViomiVacuum", { enumerable: true, get: function () { return viomivacuum_1.ViomiVacuum; } });
|
|
59
66
|
var dreamevacuum_1 = require("./devices/vacuums/dreamevacuum");
|
|
@@ -68,6 +75,16 @@ Object.defineProperty(exports, "MiotSpecIndex", { enumerable: true, get: functio
|
|
|
68
75
|
Object.defineProperty(exports, "parseUrn", { enumerable: true, get: function () { return miot_spec_1.parseUrn; } });
|
|
69
76
|
var miot_api_1 = require("./miot/miot_api");
|
|
70
77
|
Object.defineProperty(exports, "MiotError", { enumerable: true, get: function () { return miot_api_1.MiotError; } });
|
|
78
|
+
__exportStar(require("./cloud/index"), exports);
|
|
79
|
+
var roborock_map_1 = require("./maps/roborock_map");
|
|
80
|
+
Object.defineProperty(exports, "parseRoborockMap", { enumerable: true, get: function () { return roborock_map_1.parseRoborockMap; } });
|
|
81
|
+
Object.defineProperty(exports, "roomAt", { enumerable: true, get: function () { return roborock_map_1.roomAt; } });
|
|
82
|
+
Object.defineProperty(exports, "roomOfPixel", { enumerable: true, get: function () { return roborock_map_1.roomOfPixel; } });
|
|
83
|
+
Object.defineProperty(exports, "MapParseError", { enumerable: true, get: function () { return roborock_map_1.MapParseError; } });
|
|
84
|
+
Object.defineProperty(exports, "MM_PER_PIXEL", { enumerable: true, get: function () { return roborock_map_1.MM_PER_PIXEL; } });
|
|
85
|
+
Object.defineProperty(exports, "PIXEL", { enumerable: true, get: function () { return roborock_map_1.PIXEL; } });
|
|
86
|
+
var map_watcher_1 = require("./maps/map_watcher");
|
|
87
|
+
Object.defineProperty(exports, "MapWatcher", { enumerable: true, get: function () { return map_watcher_1.MapWatcher; } });
|
|
71
88
|
/**
|
|
72
89
|
* Browse for devices available on the network. Will not automatically
|
|
73
90
|
* connect to them.
|
package/dist/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFA,wBAEC;AAQD,0BAEC;AA9FD,uDAAyC;AACzC,qCAAkC;AA2DhC,uFA3DO,eAAM,OA2DP;A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43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A logger that node-miio can send its debug messages to, e.g. the one provided by Homebridge or Matterbridge.
|
|
3
|
+
* Only `debug` is used: node-miio doesn't log anything above that level.
|
|
4
|
+
*/
|
|
5
|
+
export interface MiioLogger {
|
|
6
|
+
debug(message: string, ...args: unknown[]): void;
|
|
7
|
+
}
|
|
8
|
+
export type DebugFn = (...msgs: unknown[]) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Sends node-miio's debug messages to a logger, in addition to the `debug` package (`DEBUG=miio*`, used by the CLI).
|
|
11
|
+
*
|
|
12
|
+
* This is the global logger, used for messages that aren't about a specific device (network, MIoT specs, cloud…).
|
|
13
|
+
* Use the `logger` option of `device()` for the messages of a specific device.
|
|
14
|
+
*
|
|
15
|
+
* @param options The options
|
|
16
|
+
* @param options.logger The logger, or `undefined` to stop sending messages to it
|
|
17
|
+
*/
|
|
18
|
+
export declare function configureLogging(options: {
|
|
19
|
+
logger?: MiioLogger;
|
|
20
|
+
}): void;
|
|
21
|
+
/**
|
|
22
|
+
* Removes secrets (tokens, passwords) from a log message, so users can share their logs safely.
|
|
23
|
+
*
|
|
24
|
+
* @param message The message
|
|
25
|
+
* @returns The message, with the secrets replaced by `***`
|
|
26
|
+
*/
|
|
27
|
+
export declare function redact(message: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Masks a token: only its first 4 characters are kept, enough to tell tokens apart.
|
|
30
|
+
*
|
|
31
|
+
* @param token The token as hex
|
|
32
|
+
* @returns The masked token
|
|
33
|
+
*/
|
|
34
|
+
export declare function maskToken(token?: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a debug function that logs to the `debug` package under `namespace`, and to a {@link MiioLogger}:
|
|
37
|
+
* the one returned by `getLogger` (e.g. the device's), or the global one (see {@link configureLogging}).
|
|
38
|
+
*
|
|
39
|
+
* @param namespace The `debug` namespace (e.g. `miio:network`)
|
|
40
|
+
* @param getLogger Returns the logger to use instead of the global one, if any
|
|
41
|
+
* @returns The debug function
|
|
42
|
+
*/
|
|
43
|
+
export declare function createDebug(namespace: string, getLogger?: () => MiioLogger | undefined): DebugFn;
|
|
@@ -0,0 +1,62 @@
|
|
|
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.configureLogging = configureLogging;
|
|
7
|
+
exports.redact = redact;
|
|
8
|
+
exports.maskToken = maskToken;
|
|
9
|
+
exports.createDebug = createDebug;
|
|
10
|
+
const node_util_1 = __importDefault(require("node:util"));
|
|
11
|
+
const debug_1 = __importDefault(require("debug"));
|
|
12
|
+
let globalLogger;
|
|
13
|
+
/**
|
|
14
|
+
* Sends node-miio's debug messages to a logger, in addition to the `debug` package (`DEBUG=miio*`, used by the CLI).
|
|
15
|
+
*
|
|
16
|
+
* This is the global logger, used for messages that aren't about a specific device (network, MIoT specs, cloud…).
|
|
17
|
+
* Use the `logger` option of `device()` for the messages of a specific device.
|
|
18
|
+
*
|
|
19
|
+
* @param options The options
|
|
20
|
+
* @param options.logger The logger, or `undefined` to stop sending messages to it
|
|
21
|
+
*/
|
|
22
|
+
function configureLogging(options) {
|
|
23
|
+
globalLogger = options.logger;
|
|
24
|
+
}
|
|
25
|
+
/** Keys whose values are never logged */
|
|
26
|
+
const SECRET_KEYS = /"(token|passwd|password|ssecurity|serviceToken)"\s*:\s*"[^"]*"/g;
|
|
27
|
+
/**
|
|
28
|
+
* Removes secrets (tokens, passwords) from a log message, so users can share their logs safely.
|
|
29
|
+
*
|
|
30
|
+
* @param message The message
|
|
31
|
+
* @returns The message, with the secrets replaced by `***`
|
|
32
|
+
*/
|
|
33
|
+
function redact(message) {
|
|
34
|
+
return message.replace(SECRET_KEYS, '"$1":"***"');
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Masks a token: only its first 4 characters are kept, enough to tell tokens apart.
|
|
38
|
+
*
|
|
39
|
+
* @param token The token as hex
|
|
40
|
+
* @returns The masked token
|
|
41
|
+
*/
|
|
42
|
+
function maskToken(token) {
|
|
43
|
+
return token ? `${token.slice(0, 4)}***` : String(token);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Creates a debug function that logs to the `debug` package under `namespace`, and to a {@link MiioLogger}:
|
|
47
|
+
* the one returned by `getLogger` (e.g. the device's), or the global one (see {@link configureLogging}).
|
|
48
|
+
*
|
|
49
|
+
* @param namespace The `debug` namespace (e.g. `miio:network`)
|
|
50
|
+
* @param getLogger Returns the logger to use instead of the global one, if any
|
|
51
|
+
* @returns The debug function
|
|
52
|
+
*/
|
|
53
|
+
function createDebug(namespace, getLogger) {
|
|
54
|
+
const debug = (0, debug_1.default)(namespace);
|
|
55
|
+
return (...msgs) => {
|
|
56
|
+
const message = redact(node_util_1.default.format(...msgs));
|
|
57
|
+
debug("%s", message);
|
|
58
|
+
const logger = getLogger?.() ?? globalLogger;
|
|
59
|
+
logger?.debug(`[${namespace}] ${message}`);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/lib/logger.ts"],"names":[],"mappings":";;;;;AAyBA,4CAEC;AAYD,wBAEC;AAQD,8BAEC;AAUD,kCAWC;AAxED,0DAA6B;AAE7B,kDAAiC;AAYjC,IAAI,YAAoC,CAAC;AAEzC;;;;;;;;GAQG;AACH,SAAgB,gBAAgB,CAAC,OAAgC;IAC/D,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;AAChC,CAAC;AAED,yCAAyC;AACzC,MAAM,WAAW,GACf,iEAAiE,CAAC;AAEpE;;;;;GAKG;AACH,SAAgB,MAAM,CAAC,OAAe;IACpC,OAAO,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;AAC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