@apocaliss92/nodedreame 1.11.4 → 1.11.6
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/dist/index.cjs +119 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -8
- package/dist/index.d.ts +48 -8
- package/dist/index.js +117 -79
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1243,16 +1243,12 @@ interface VacuumMap {
|
|
|
1243
1243
|
* Pure: only `pngjs` + arithmetic. No casts.
|
|
1244
1244
|
*/
|
|
1245
1245
|
|
|
1246
|
-
/**
|
|
1247
|
-
|
|
1248
|
-
* choices; `flat` / `dark-neon` / `materico` are node-dreame additions for
|
|
1249
|
-
* distinct visual styles.
|
|
1250
|
-
*/
|
|
1251
|
-
type MapColorScheme = 'dreame-light' | 'dreame-dark' | 'mijia-light' | 'tasshack' | 'flat' | 'dark-neon' | 'materico';
|
|
1246
|
+
/** A named map palette — node-dreame's own distinct visual styles. */
|
|
1247
|
+
type MapColorScheme = 'flat' | 'dark-neon' | 'materico';
|
|
1252
1248
|
interface RenderVacuumPngOptions {
|
|
1253
1249
|
/** Integer upscale factor (nearest-neighbour). Default 1. */
|
|
1254
1250
|
scale?: number;
|
|
1255
|
-
/** Palette. Default `'
|
|
1251
|
+
/** Palette. Default `'flat'`. */
|
|
1256
1252
|
colorScheme?: MapColorScheme;
|
|
1257
1253
|
/** Draw the cleaning/mopping path polylines. Default true. */
|
|
1258
1254
|
showPath?: boolean;
|
|
@@ -1819,6 +1815,14 @@ declare enum MowerFault {
|
|
|
1819
1815
|
PauseTimeoutReturning = 72,// INFO
|
|
1820
1816
|
TopCoverOpen = 73
|
|
1821
1817
|
}
|
|
1818
|
+
/** Severity class of a mower DEVICE_CODE (2:2 / {@link MowerFault}). */
|
|
1819
|
+
type MowerFaultSeverity = 'info' | 'warning' | 'error';
|
|
1820
|
+
/**
|
|
1821
|
+
* Classify a mower device-code by severity, matching the INFO/WARNING/ERROR
|
|
1822
|
+
* annotations on {@link MowerFault}. Most codes are status/INFO (e.g. 50
|
|
1823
|
+
* TaskStart); only a subset are actionable. Unknown codes default to `info`.
|
|
1824
|
+
*/
|
|
1825
|
+
declare function mowerFaultSeverity(code: number | null): MowerFaultSeverity;
|
|
1822
1826
|
|
|
1823
1827
|
/**
|
|
1824
1828
|
* Cast-free mower decoders. Re-exports the shared numeric primitives, and adds
|
|
@@ -1895,6 +1899,28 @@ interface MowerHeartbeat {
|
|
|
1895
1899
|
* main state there is no active mowing task (returns `taskSubState: null`).
|
|
1896
1900
|
*/
|
|
1897
1901
|
declare function parseMowerHeartbeat(value: unknown): MowerHeartbeat | null;
|
|
1902
|
+
/** Decoded mowing-progress signal from the POSE_COVERAGE (1:4) `task` block. */
|
|
1903
|
+
interface MowerMowingProgress {
|
|
1904
|
+
/** 0..100 — overall mowing completion. */
|
|
1905
|
+
readonly progressPercent: number;
|
|
1906
|
+
/** Already-finished area in m². */
|
|
1907
|
+
readonly currentAreaSqm: number;
|
|
1908
|
+
/** Total target area in m². */
|
|
1909
|
+
readonly totalAreaSqm: number;
|
|
1910
|
+
}
|
|
1911
|
+
/**
|
|
1912
|
+
* Locate the 10-byte `task` block inside a POSE_COVERAGE (1:4) frame and decode
|
|
1913
|
+
* the mowing progress. Frame shapes (ported from antondaubert/dreame-mower
|
|
1914
|
+
* `pose_coverage.py`):
|
|
1915
|
+
* - sentinel-framed `[CE] pose(6) trace(15) task(10) [CE]` (33B) / `…task(10) trace2(11) [CE]` (44B)
|
|
1916
|
+
* → task at offset 22;
|
|
1917
|
+
* - alt `task(10) [CE] [+trace]` (no leading sentinel, ≥11B) → task at offset 0.
|
|
1918
|
+
* The 22B `[CE] pose trace` and 13B `[CE] pose extra` shapes carry NO task → null.
|
|
1919
|
+
*
|
|
1920
|
+
* `task` layout: `[2:4] percent u16LE (value×100) [4:7] total u24LE (centi-m²)
|
|
1921
|
+
* [7:10] finished u24LE (centi-m²)`.
|
|
1922
|
+
*/
|
|
1923
|
+
declare function parseMowingProgress(value: unknown): MowerMowingProgress | null;
|
|
1898
1924
|
|
|
1899
1925
|
/**
|
|
1900
1926
|
* Per-model mower capability records + a resolver adapting the rich record into
|
|
@@ -2114,6 +2140,17 @@ declare class MowerDevice extends BaseDevice {
|
|
|
2114
2140
|
* This is the P4 progress surface; the byte-accurate pose-track % is P5.
|
|
2115
2141
|
*/
|
|
2116
2142
|
get coverageTargetPct(): number | null;
|
|
2143
|
+
/**
|
|
2144
|
+
* Live mowing PROGRESS decoded from the POSE_COVERAGE (1:4) task block —
|
|
2145
|
+
* `{progressPercent, currentAreaSqm, totalAreaSqm}` — or null when 1:4 carries
|
|
2146
|
+
* no task block (idle / pose-only frame). This is the byte-accurate progress
|
|
2147
|
+
* the Dreamehome app shows (vs {@link coverageTargetPct}, the task TARGET).
|
|
2148
|
+
*/
|
|
2149
|
+
get mowingProgress(): MowerMowingProgress | null;
|
|
2150
|
+
/** Mowing completion percent (0..100) from {@link mowingProgress}, or null. */
|
|
2151
|
+
get mowingProgressPct(): number | null;
|
|
2152
|
+
/** Severity of the current DEVICE_CODE (2:2) — info / warning / error. */
|
|
2153
|
+
get faultSeverity(): MowerFaultSeverity;
|
|
2117
2154
|
/** Parsed per-zone control status (2:56), or null. */
|
|
2118
2155
|
get controlStatus(): MowerControlState | null;
|
|
2119
2156
|
get controlAction(): MowerControlAction | null;
|
|
@@ -2191,6 +2228,9 @@ declare class MowerDevice extends BaseDevice {
|
|
|
2191
2228
|
static readonly DEFAULT_PROPS: readonly [{
|
|
2192
2229
|
readonly siid: 1;
|
|
2193
2230
|
readonly piid: 1;
|
|
2231
|
+
}, {
|
|
2232
|
+
readonly siid: 1;
|
|
2233
|
+
readonly piid: 4;
|
|
2194
2234
|
}, {
|
|
2195
2235
|
readonly siid: 2;
|
|
2196
2236
|
readonly piid: 1;
|
|
@@ -2550,4 +2590,4 @@ declare function createDumper(target: DumperDevice, options?: DumperOptions): Du
|
|
|
2550
2590
|
*/
|
|
2551
2591
|
declare function createClientDumper(client: Nodreame, options?: DumperOptions): Dumper[];
|
|
2552
2592
|
|
|
2553
|
-
export { AI_FEATURE_BIT, AI_FEATURE_JSON_KEY, AUTO_SWITCH_JSON_KEY, type AiDetectionRaw, type AutoSwitchKey, type AutoSwitchRaw, BaseDevice, type BaseDeviceEvents, type BatchDeviceDataFetcher, type CapabilityResolver, ChargingStatus, type CleanOpts, CleaningMode, type ConsumableReading, type ConsumableSpec, type CreateDeviceArgs, DefaultCapabilityResolver, type DeviceCapabilities, type DeviceDump, type DeviceEvent, type DreameAiFeature, DreameApiError, DreameAuthError, type DreameCloudState, type DreameConsumableKey, type DreameDevice, DreameDeviceOfflineError, DreameError, type DreameRegion, type DreameSession, DreameTransportError, type DumperOptions, LIBRARY_NAME, MODEL_CAPABILITIES as MOWER_MODEL_CAPABILITIES, MOWER_TASK_SUBSTATES, type MapBoundingBox, type MapCleanedAreaOverlay, type MapColorScheme, type MapDimensions, type MapFrameType, type MapLayer, type MapLayerType, type MapLowLyingArea, type MapObstacle, type MapPath, type MapPathType, type MapPoint, type MapPose, type MapRestrictedArea, type MapRoom, type MapRoomWall, type MapRun, type MapSegment, type MapStorey, type MapVirtualWall, type MapWallsInfo, type MiotAction, MiotError, type MiotProp, MiotState, type MowerAvailableMap, type MowerCapabilities, MowerCapabilityResolver, MowerChargingStatus, type MowerConsumableKey, type MowerConsumableReading, type MowerContour, MowerControlAction, type MowerControlState, MowerDevice, type MowerDeviceInput, MowerFault, type MowerHeartbeat, type MowerMap, type MowerMapBoundary, type MowerMowPath, type MowerPathEntry, type MowerPoint, type MowerSpotArea, MowerStatus, type MowerTaskDescriptor, MowerTaskStatus, type MowerTaskSubState, type MowerZone, Nodreame, type NodreameDeps, type NodreameEvents, type NodreameOptions, type OssFetchInput, type OssFetcherLike, type PropertyChangedEvent, type PropertyResult, type PropertyState, type PropertyWrite, type RenderMowerSvgOptions, type RenderVacuumPngOptions, type StateChangedEvent, SuctionLevel, TaskStatus, VACUUM_CONSUMABLES, MODEL_CAPABILITIES$1 as VACUUM_MODEL_CAPABILITIES, type VacuumCapabilities, VacuumCapabilityResolver, VacuumDevice, type VacuumGetMapInput, type VacuumMap, WaterVolume, consumableSpec, createClientDumper, createDumper, decodeAiFeature, decodeAutoSwitch, decodeAutoSwitchAll, encodeAiFeatureWrite, encodeAutoSwitchWrite, extractMowerConsumableValues, getMowerCapabilities, getVacuumCapabilities, isDreameConsumableKey, mowerConsumableIndex, parseMowerConsumables, parseMowerHeartbeat, renderMowerSvg, renderVacuumPng, resolveCapabilities, supportedAutoSwitchKeys };
|
|
2593
|
+
export { AI_FEATURE_BIT, AI_FEATURE_JSON_KEY, AUTO_SWITCH_JSON_KEY, type AiDetectionRaw, type AutoSwitchKey, type AutoSwitchRaw, BaseDevice, type BaseDeviceEvents, type BatchDeviceDataFetcher, type CapabilityResolver, ChargingStatus, type CleanOpts, CleaningMode, type ConsumableReading, type ConsumableSpec, type CreateDeviceArgs, DefaultCapabilityResolver, type DeviceCapabilities, type DeviceDump, type DeviceEvent, type DreameAiFeature, DreameApiError, DreameAuthError, type DreameCloudState, type DreameConsumableKey, type DreameDevice, DreameDeviceOfflineError, DreameError, type DreameRegion, type DreameSession, DreameTransportError, type DumperOptions, LIBRARY_NAME, MODEL_CAPABILITIES as MOWER_MODEL_CAPABILITIES, MOWER_TASK_SUBSTATES, type MapBoundingBox, type MapCleanedAreaOverlay, type MapColorScheme, type MapDimensions, type MapFrameType, type MapLayer, type MapLayerType, type MapLowLyingArea, type MapObstacle, type MapPath, type MapPathType, type MapPoint, type MapPose, type MapRestrictedArea, type MapRoom, type MapRoomWall, type MapRun, type MapSegment, type MapStorey, type MapVirtualWall, type MapWallsInfo, type MiotAction, MiotError, type MiotProp, MiotState, type MowerAvailableMap, type MowerCapabilities, MowerCapabilityResolver, MowerChargingStatus, type MowerConsumableKey, type MowerConsumableReading, type MowerContour, MowerControlAction, type MowerControlState, MowerDevice, type MowerDeviceInput, MowerFault, type MowerFaultSeverity, type MowerHeartbeat, type MowerMap, type MowerMapBoundary, type MowerMowPath, type MowerMowingProgress, type MowerPathEntry, type MowerPoint, type MowerSpotArea, MowerStatus, type MowerTaskDescriptor, MowerTaskStatus, type MowerTaskSubState, type MowerZone, Nodreame, type NodreameDeps, type NodreameEvents, type NodreameOptions, type OssFetchInput, type OssFetcherLike, type PropertyChangedEvent, type PropertyResult, type PropertyState, type PropertyWrite, type RenderMowerSvgOptions, type RenderVacuumPngOptions, type StateChangedEvent, SuctionLevel, TaskStatus, VACUUM_CONSUMABLES, MODEL_CAPABILITIES$1 as VACUUM_MODEL_CAPABILITIES, type VacuumCapabilities, VacuumCapabilityResolver, VacuumDevice, type VacuumGetMapInput, type VacuumMap, WaterVolume, consumableSpec, createClientDumper, createDumper, decodeAiFeature, decodeAutoSwitch, decodeAutoSwitchAll, encodeAiFeatureWrite, encodeAutoSwitchWrite, extractMowerConsumableValues, getMowerCapabilities, getVacuumCapabilities, isDreameConsumableKey, mowerConsumableIndex, mowerFaultSeverity, parseMowerConsumables, parseMowerHeartbeat, parseMowingProgress, renderMowerSvg, renderVacuumPng, resolveCapabilities, supportedAutoSwitchKeys };
|
package/dist/index.d.ts
CHANGED
|
@@ -1243,16 +1243,12 @@ interface VacuumMap {
|
|
|
1243
1243
|
* Pure: only `pngjs` + arithmetic. No casts.
|
|
1244
1244
|
*/
|
|
1245
1245
|
|
|
1246
|
-
/**
|
|
1247
|
-
|
|
1248
|
-
* choices; `flat` / `dark-neon` / `materico` are node-dreame additions for
|
|
1249
|
-
* distinct visual styles.
|
|
1250
|
-
*/
|
|
1251
|
-
type MapColorScheme = 'dreame-light' | 'dreame-dark' | 'mijia-light' | 'tasshack' | 'flat' | 'dark-neon' | 'materico';
|
|
1246
|
+
/** A named map palette — node-dreame's own distinct visual styles. */
|
|
1247
|
+
type MapColorScheme = 'flat' | 'dark-neon' | 'materico';
|
|
1252
1248
|
interface RenderVacuumPngOptions {
|
|
1253
1249
|
/** Integer upscale factor (nearest-neighbour). Default 1. */
|
|
1254
1250
|
scale?: number;
|
|
1255
|
-
/** Palette. Default `'
|
|
1251
|
+
/** Palette. Default `'flat'`. */
|
|
1256
1252
|
colorScheme?: MapColorScheme;
|
|
1257
1253
|
/** Draw the cleaning/mopping path polylines. Default true. */
|
|
1258
1254
|
showPath?: boolean;
|
|
@@ -1819,6 +1815,14 @@ declare enum MowerFault {
|
|
|
1819
1815
|
PauseTimeoutReturning = 72,// INFO
|
|
1820
1816
|
TopCoverOpen = 73
|
|
1821
1817
|
}
|
|
1818
|
+
/** Severity class of a mower DEVICE_CODE (2:2 / {@link MowerFault}). */
|
|
1819
|
+
type MowerFaultSeverity = 'info' | 'warning' | 'error';
|
|
1820
|
+
/**
|
|
1821
|
+
* Classify a mower device-code by severity, matching the INFO/WARNING/ERROR
|
|
1822
|
+
* annotations on {@link MowerFault}. Most codes are status/INFO (e.g. 50
|
|
1823
|
+
* TaskStart); only a subset are actionable. Unknown codes default to `info`.
|
|
1824
|
+
*/
|
|
1825
|
+
declare function mowerFaultSeverity(code: number | null): MowerFaultSeverity;
|
|
1822
1826
|
|
|
1823
1827
|
/**
|
|
1824
1828
|
* Cast-free mower decoders. Re-exports the shared numeric primitives, and adds
|
|
@@ -1895,6 +1899,28 @@ interface MowerHeartbeat {
|
|
|
1895
1899
|
* main state there is no active mowing task (returns `taskSubState: null`).
|
|
1896
1900
|
*/
|
|
1897
1901
|
declare function parseMowerHeartbeat(value: unknown): MowerHeartbeat | null;
|
|
1902
|
+
/** Decoded mowing-progress signal from the POSE_COVERAGE (1:4) `task` block. */
|
|
1903
|
+
interface MowerMowingProgress {
|
|
1904
|
+
/** 0..100 — overall mowing completion. */
|
|
1905
|
+
readonly progressPercent: number;
|
|
1906
|
+
/** Already-finished area in m². */
|
|
1907
|
+
readonly currentAreaSqm: number;
|
|
1908
|
+
/** Total target area in m². */
|
|
1909
|
+
readonly totalAreaSqm: number;
|
|
1910
|
+
}
|
|
1911
|
+
/**
|
|
1912
|
+
* Locate the 10-byte `task` block inside a POSE_COVERAGE (1:4) frame and decode
|
|
1913
|
+
* the mowing progress. Frame shapes (ported from antondaubert/dreame-mower
|
|
1914
|
+
* `pose_coverage.py`):
|
|
1915
|
+
* - sentinel-framed `[CE] pose(6) trace(15) task(10) [CE]` (33B) / `…task(10) trace2(11) [CE]` (44B)
|
|
1916
|
+
* → task at offset 22;
|
|
1917
|
+
* - alt `task(10) [CE] [+trace]` (no leading sentinel, ≥11B) → task at offset 0.
|
|
1918
|
+
* The 22B `[CE] pose trace` and 13B `[CE] pose extra` shapes carry NO task → null.
|
|
1919
|
+
*
|
|
1920
|
+
* `task` layout: `[2:4] percent u16LE (value×100) [4:7] total u24LE (centi-m²)
|
|
1921
|
+
* [7:10] finished u24LE (centi-m²)`.
|
|
1922
|
+
*/
|
|
1923
|
+
declare function parseMowingProgress(value: unknown): MowerMowingProgress | null;
|
|
1898
1924
|
|
|
1899
1925
|
/**
|
|
1900
1926
|
* Per-model mower capability records + a resolver adapting the rich record into
|
|
@@ -2114,6 +2140,17 @@ declare class MowerDevice extends BaseDevice {
|
|
|
2114
2140
|
* This is the P4 progress surface; the byte-accurate pose-track % is P5.
|
|
2115
2141
|
*/
|
|
2116
2142
|
get coverageTargetPct(): number | null;
|
|
2143
|
+
/**
|
|
2144
|
+
* Live mowing PROGRESS decoded from the POSE_COVERAGE (1:4) task block —
|
|
2145
|
+
* `{progressPercent, currentAreaSqm, totalAreaSqm}` — or null when 1:4 carries
|
|
2146
|
+
* no task block (idle / pose-only frame). This is the byte-accurate progress
|
|
2147
|
+
* the Dreamehome app shows (vs {@link coverageTargetPct}, the task TARGET).
|
|
2148
|
+
*/
|
|
2149
|
+
get mowingProgress(): MowerMowingProgress | null;
|
|
2150
|
+
/** Mowing completion percent (0..100) from {@link mowingProgress}, or null. */
|
|
2151
|
+
get mowingProgressPct(): number | null;
|
|
2152
|
+
/** Severity of the current DEVICE_CODE (2:2) — info / warning / error. */
|
|
2153
|
+
get faultSeverity(): MowerFaultSeverity;
|
|
2117
2154
|
/** Parsed per-zone control status (2:56), or null. */
|
|
2118
2155
|
get controlStatus(): MowerControlState | null;
|
|
2119
2156
|
get controlAction(): MowerControlAction | null;
|
|
@@ -2191,6 +2228,9 @@ declare class MowerDevice extends BaseDevice {
|
|
|
2191
2228
|
static readonly DEFAULT_PROPS: readonly [{
|
|
2192
2229
|
readonly siid: 1;
|
|
2193
2230
|
readonly piid: 1;
|
|
2231
|
+
}, {
|
|
2232
|
+
readonly siid: 1;
|
|
2233
|
+
readonly piid: 4;
|
|
2194
2234
|
}, {
|
|
2195
2235
|
readonly siid: 2;
|
|
2196
2236
|
readonly piid: 1;
|
|
@@ -2550,4 +2590,4 @@ declare function createDumper(target: DumperDevice, options?: DumperOptions): Du
|
|
|
2550
2590
|
*/
|
|
2551
2591
|
declare function createClientDumper(client: Nodreame, options?: DumperOptions): Dumper[];
|
|
2552
2592
|
|
|
2553
|
-
export { AI_FEATURE_BIT, AI_FEATURE_JSON_KEY, AUTO_SWITCH_JSON_KEY, type AiDetectionRaw, type AutoSwitchKey, type AutoSwitchRaw, BaseDevice, type BaseDeviceEvents, type BatchDeviceDataFetcher, type CapabilityResolver, ChargingStatus, type CleanOpts, CleaningMode, type ConsumableReading, type ConsumableSpec, type CreateDeviceArgs, DefaultCapabilityResolver, type DeviceCapabilities, type DeviceDump, type DeviceEvent, type DreameAiFeature, DreameApiError, DreameAuthError, type DreameCloudState, type DreameConsumableKey, type DreameDevice, DreameDeviceOfflineError, DreameError, type DreameRegion, type DreameSession, DreameTransportError, type DumperOptions, LIBRARY_NAME, MODEL_CAPABILITIES as MOWER_MODEL_CAPABILITIES, MOWER_TASK_SUBSTATES, type MapBoundingBox, type MapCleanedAreaOverlay, type MapColorScheme, type MapDimensions, type MapFrameType, type MapLayer, type MapLayerType, type MapLowLyingArea, type MapObstacle, type MapPath, type MapPathType, type MapPoint, type MapPose, type MapRestrictedArea, type MapRoom, type MapRoomWall, type MapRun, type MapSegment, type MapStorey, type MapVirtualWall, type MapWallsInfo, type MiotAction, MiotError, type MiotProp, MiotState, type MowerAvailableMap, type MowerCapabilities, MowerCapabilityResolver, MowerChargingStatus, type MowerConsumableKey, type MowerConsumableReading, type MowerContour, MowerControlAction, type MowerControlState, MowerDevice, type MowerDeviceInput, MowerFault, type MowerHeartbeat, type MowerMap, type MowerMapBoundary, type MowerMowPath, type MowerPathEntry, type MowerPoint, type MowerSpotArea, MowerStatus, type MowerTaskDescriptor, MowerTaskStatus, type MowerTaskSubState, type MowerZone, Nodreame, type NodreameDeps, type NodreameEvents, type NodreameOptions, type OssFetchInput, type OssFetcherLike, type PropertyChangedEvent, type PropertyResult, type PropertyState, type PropertyWrite, type RenderMowerSvgOptions, type RenderVacuumPngOptions, type StateChangedEvent, SuctionLevel, TaskStatus, VACUUM_CONSUMABLES, MODEL_CAPABILITIES$1 as VACUUM_MODEL_CAPABILITIES, type VacuumCapabilities, VacuumCapabilityResolver, VacuumDevice, type VacuumGetMapInput, type VacuumMap, WaterVolume, consumableSpec, createClientDumper, createDumper, decodeAiFeature, decodeAutoSwitch, decodeAutoSwitchAll, encodeAiFeatureWrite, encodeAutoSwitchWrite, extractMowerConsumableValues, getMowerCapabilities, getVacuumCapabilities, isDreameConsumableKey, mowerConsumableIndex, parseMowerConsumables, parseMowerHeartbeat, renderMowerSvg, renderVacuumPng, resolveCapabilities, supportedAutoSwitchKeys };
|
|
2593
|
+
export { AI_FEATURE_BIT, AI_FEATURE_JSON_KEY, AUTO_SWITCH_JSON_KEY, type AiDetectionRaw, type AutoSwitchKey, type AutoSwitchRaw, BaseDevice, type BaseDeviceEvents, type BatchDeviceDataFetcher, type CapabilityResolver, ChargingStatus, type CleanOpts, CleaningMode, type ConsumableReading, type ConsumableSpec, type CreateDeviceArgs, DefaultCapabilityResolver, type DeviceCapabilities, type DeviceDump, type DeviceEvent, type DreameAiFeature, DreameApiError, DreameAuthError, type DreameCloudState, type DreameConsumableKey, type DreameDevice, DreameDeviceOfflineError, DreameError, type DreameRegion, type DreameSession, DreameTransportError, type DumperOptions, LIBRARY_NAME, MODEL_CAPABILITIES as MOWER_MODEL_CAPABILITIES, MOWER_TASK_SUBSTATES, type MapBoundingBox, type MapCleanedAreaOverlay, type MapColorScheme, type MapDimensions, type MapFrameType, type MapLayer, type MapLayerType, type MapLowLyingArea, type MapObstacle, type MapPath, type MapPathType, type MapPoint, type MapPose, type MapRestrictedArea, type MapRoom, type MapRoomWall, type MapRun, type MapSegment, type MapStorey, type MapVirtualWall, type MapWallsInfo, type MiotAction, MiotError, type MiotProp, MiotState, type MowerAvailableMap, type MowerCapabilities, MowerCapabilityResolver, MowerChargingStatus, type MowerConsumableKey, type MowerConsumableReading, type MowerContour, MowerControlAction, type MowerControlState, MowerDevice, type MowerDeviceInput, MowerFault, type MowerFaultSeverity, type MowerHeartbeat, type MowerMap, type MowerMapBoundary, type MowerMowPath, type MowerMowingProgress, type MowerPathEntry, type MowerPoint, type MowerSpotArea, MowerStatus, type MowerTaskDescriptor, MowerTaskStatus, type MowerTaskSubState, type MowerZone, Nodreame, type NodreameDeps, type NodreameEvents, type NodreameOptions, type OssFetchInput, type OssFetcherLike, type PropertyChangedEvent, type PropertyResult, type PropertyState, type PropertyWrite, type RenderMowerSvgOptions, type RenderVacuumPngOptions, type StateChangedEvent, SuctionLevel, TaskStatus, VACUUM_CONSUMABLES, MODEL_CAPABILITIES$1 as VACUUM_MODEL_CAPABILITIES, type VacuumCapabilities, VacuumCapabilityResolver, VacuumDevice, type VacuumGetMapInput, type VacuumMap, WaterVolume, consumableSpec, createClientDumper, createDumper, decodeAiFeature, decodeAutoSwitch, decodeAutoSwitchAll, encodeAiFeatureWrite, encodeAutoSwitchWrite, extractMowerConsumableValues, getMowerCapabilities, getVacuumCapabilities, isDreameConsumableKey, mowerConsumableIndex, mowerFaultSeverity, parseMowerConsumables, parseMowerHeartbeat, parseMowingProgress, renderMowerSvg, renderVacuumPng, resolveCapabilities, supportedAutoSwitchKeys };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/support/version.ts
|
|
2
2
|
var LIBRARY_NAME = "nodedreame";
|
|
3
|
-
var LIBRARY_VERSION = "1.11.
|
|
3
|
+
var LIBRARY_VERSION = "1.11.6";
|
|
4
4
|
|
|
5
5
|
// src/transport/errors.ts
|
|
6
6
|
var DreameError = class extends Error {
|
|
@@ -2771,18 +2771,27 @@ function decodeVacuumMap(input, opts = {}) {
|
|
|
2771
2771
|
const pixelGrid = inflated.subarray(pixelStart, pixelEnd);
|
|
2772
2772
|
const canDecodePixels = header.frameType === "I" && pixelGrid.length === header.width * header.height;
|
|
2773
2773
|
const layers = canDecodePixels ? decodePixelGridFsm1(pixelGrid, header.width, header.height) : [];
|
|
2774
|
-
const segments = canDecodePixels ? collectSegments(layers, dimensions, tail) : [];
|
|
2775
2774
|
const paths = parsePathTr(tail.tr ?? "");
|
|
2776
2775
|
const obstacles = parseObstacles(tail.ai_obstacle ?? []);
|
|
2777
2776
|
let geometry = parseTailGeometry(tail);
|
|
2778
|
-
|
|
2777
|
+
let segTail = tail;
|
|
2778
|
+
const outerHasNames = Object.values(tail.seg_inf ?? {}).some(
|
|
2779
|
+
(m) => typeof m?.name === "string" && m.name.length > 0
|
|
2780
|
+
);
|
|
2781
|
+
if ((!isGeometryComplete(geometry) || !outerHasNames) && typeof tail.rism === "string" && tail.rism.length > 0) {
|
|
2779
2782
|
try {
|
|
2780
2783
|
const innerInflated = unwrapEnvelope(tail.rism);
|
|
2781
2784
|
const { tail: innerTail } = parseFrame(innerInflated);
|
|
2782
|
-
|
|
2785
|
+
if (!isGeometryComplete(geometry)) {
|
|
2786
|
+
geometry = coalesceGeometry(geometry, parseTailGeometry(innerTail));
|
|
2787
|
+
}
|
|
2788
|
+
if (!outerHasNames && innerTail.seg_inf) {
|
|
2789
|
+
segTail = mergeSegInfNames(tail, innerTail.seg_inf);
|
|
2790
|
+
}
|
|
2783
2791
|
} catch {
|
|
2784
2792
|
}
|
|
2785
2793
|
}
|
|
2794
|
+
const segments = canDecodePixels ? collectSegments(layers, dimensions, segTail) : [];
|
|
2786
2795
|
const cleanedArea = typeof tail.decmap === "string" ? parseCleanedAreaOverlay(tail.decmap) : null;
|
|
2787
2796
|
return {
|
|
2788
2797
|
mapId: header.mapId,
|
|
@@ -2806,6 +2815,18 @@ function applyVacuumPFrame(prev, pframe, opts = {}) {
|
|
|
2806
2815
|
const merged = typeof prev === "string" || typeof pframe === "string" ? mergePFrameEnvelope(prev, pframe, opts.prev, opts.pframe) : mergePFrame(prev, pframe);
|
|
2807
2816
|
return { buffer: merged, data: decodeVacuumMap(merged) };
|
|
2808
2817
|
}
|
|
2818
|
+
function mergeSegInfNames(tail, innerSegInf) {
|
|
2819
|
+
const outer = tail.seg_inf ?? {};
|
|
2820
|
+
const ids = /* @__PURE__ */ new Set([...Object.keys(outer), ...Object.keys(innerSegInf)]);
|
|
2821
|
+
const merged = {};
|
|
2822
|
+
for (const id of ids) {
|
|
2823
|
+
const o = outer[id] ?? {};
|
|
2824
|
+
const inner = innerSegInf[id] ?? {};
|
|
2825
|
+
const name = typeof o.name === "string" && o.name.length > 0 ? o.name : inner.name;
|
|
2826
|
+
merged[id] = { ...inner, ...o, ...name !== void 0 ? { name } : {} };
|
|
2827
|
+
}
|
|
2828
|
+
return { ...tail, seg_inf: merged };
|
|
2829
|
+
}
|
|
2809
2830
|
function mergeDimensions(header, tail) {
|
|
2810
2831
|
const left = tail.origin?.[0] ?? header.left;
|
|
2811
2832
|
const top = tail.origin?.[1] ?? header.top;
|
|
@@ -2827,78 +2848,6 @@ function pose(x, y, angle, absent) {
|
|
|
2827
2848
|
// src/models/vacuum/map/render.ts
|
|
2828
2849
|
import { PNG } from "pngjs";
|
|
2829
2850
|
var SCHEMES = {
|
|
2830
|
-
"dreame-light": {
|
|
2831
|
-
floor: [210, 222, 235, 255],
|
|
2832
|
-
wall: [60, 60, 60, 255],
|
|
2833
|
-
carpet: [180, 150, 120, 200],
|
|
2834
|
-
segSat: 0.45,
|
|
2835
|
-
segVal: 0.95,
|
|
2836
|
-
path: [60, 110, 180, 235],
|
|
2837
|
-
robotBody: [40, 70, 110, 255],
|
|
2838
|
-
robotHeading: [255, 255, 255, 255],
|
|
2839
|
-
charger: [40, 160, 80, 255],
|
|
2840
|
-
noGoFill: [220, 60, 60, 70],
|
|
2841
|
-
noGoBorder: [200, 40, 40, 220],
|
|
2842
|
-
noMopFill: [60, 120, 220, 60],
|
|
2843
|
-
noMopBorder: [40, 90, 200, 200],
|
|
2844
|
-
virtualWall: [200, 40, 40, 230],
|
|
2845
|
-
obstacle: [230, 150, 30, 255],
|
|
2846
|
-
label: [40, 40, 40, 255]
|
|
2847
|
-
},
|
|
2848
|
-
"dreame-dark": {
|
|
2849
|
-
floor: [40, 46, 56, 255],
|
|
2850
|
-
wall: [15, 15, 18, 255],
|
|
2851
|
-
carpet: [80, 66, 52, 200],
|
|
2852
|
-
segSat: 0.5,
|
|
2853
|
-
segVal: 0.62,
|
|
2854
|
-
path: [120, 170, 230, 235],
|
|
2855
|
-
robotBody: [120, 170, 230, 255],
|
|
2856
|
-
robotHeading: [20, 24, 30, 255],
|
|
2857
|
-
charger: [60, 200, 110, 255],
|
|
2858
|
-
noGoFill: [220, 70, 70, 80],
|
|
2859
|
-
noGoBorder: [230, 70, 70, 220],
|
|
2860
|
-
noMopFill: [70, 130, 230, 70],
|
|
2861
|
-
noMopBorder: [80, 140, 235, 210],
|
|
2862
|
-
virtualWall: [230, 70, 70, 235],
|
|
2863
|
-
obstacle: [240, 180, 60, 255],
|
|
2864
|
-
label: [225, 230, 240, 255]
|
|
2865
|
-
},
|
|
2866
|
-
"mijia-light": {
|
|
2867
|
-
floor: [225, 232, 240, 255],
|
|
2868
|
-
wall: [70, 78, 92, 255],
|
|
2869
|
-
carpet: [188, 162, 132, 200],
|
|
2870
|
-
segSat: 0.35,
|
|
2871
|
-
segVal: 0.98,
|
|
2872
|
-
path: [80, 130, 200, 230],
|
|
2873
|
-
robotBody: [30, 100, 200, 255],
|
|
2874
|
-
robotHeading: [255, 255, 255, 255],
|
|
2875
|
-
charger: [40, 170, 90, 255],
|
|
2876
|
-
noGoFill: [225, 70, 70, 70],
|
|
2877
|
-
noGoBorder: [205, 45, 45, 220],
|
|
2878
|
-
noMopFill: [70, 130, 225, 60],
|
|
2879
|
-
noMopBorder: [50, 100, 205, 200],
|
|
2880
|
-
virtualWall: [205, 45, 45, 230],
|
|
2881
|
-
obstacle: [235, 160, 35, 255],
|
|
2882
|
-
label: [45, 52, 64, 255]
|
|
2883
|
-
},
|
|
2884
|
-
tasshack: {
|
|
2885
|
-
floor: [200, 210, 225, 255],
|
|
2886
|
-
wall: [80, 80, 95, 255],
|
|
2887
|
-
carpet: [176, 148, 118, 205],
|
|
2888
|
-
segSat: 0.5,
|
|
2889
|
-
segVal: 0.9,
|
|
2890
|
-
path: [50, 100, 170, 235],
|
|
2891
|
-
robotBody: [35, 60, 100, 255],
|
|
2892
|
-
robotHeading: [255, 255, 255, 255],
|
|
2893
|
-
charger: [35, 150, 75, 255],
|
|
2894
|
-
noGoFill: [215, 55, 55, 75],
|
|
2895
|
-
noGoBorder: [195, 35, 35, 220],
|
|
2896
|
-
noMopFill: [55, 115, 215, 65],
|
|
2897
|
-
noMopBorder: [35, 85, 195, 205],
|
|
2898
|
-
virtualWall: [195, 35, 35, 230],
|
|
2899
|
-
obstacle: [225, 145, 25, 255],
|
|
2900
|
-
label: [35, 42, 54, 255]
|
|
2901
|
-
},
|
|
2902
2851
|
// Flat-design: soft neutral floor, bright low-saturation segment fills, thin
|
|
2903
2852
|
// mid-grey walls, a single vivid accent for the path.
|
|
2904
2853
|
flat: {
|
|
@@ -2995,7 +2944,7 @@ function segmentColor(id, pal) {
|
|
|
2995
2944
|
}
|
|
2996
2945
|
function renderVacuumPng(map, opts = {}) {
|
|
2997
2946
|
const scale = Math.max(1, Math.trunc(opts.scale ?? 1));
|
|
2998
|
-
const pal = SCHEMES[opts.colorScheme ?? "
|
|
2947
|
+
const pal = SCHEMES[opts.colorScheme ?? "flat"] ?? SCHEMES.flat;
|
|
2999
2948
|
const w = Math.max(1, map.dimensions.width * scale);
|
|
3000
2949
|
const h = Math.max(1, map.dimensions.height * scale);
|
|
3001
2950
|
const png = new PNG({ width: w, height: h });
|
|
@@ -3038,8 +2987,12 @@ function renderVacuumPng(map, opts = {}) {
|
|
|
3038
2987
|
const byType = opts.colorObstaclesByType !== false;
|
|
3039
2988
|
for (const ob of map.obstacles) {
|
|
3040
2989
|
const p = worldToPx(ob.x, ob.y, dim, scale);
|
|
3041
|
-
const
|
|
3042
|
-
|
|
2990
|
+
const r = Math.max(2, scale * 2);
|
|
2991
|
+
if (byType) {
|
|
2992
|
+
drawObstacleShape(png, p.x, p.y, r, ob.type, obstacleColor(ob.type));
|
|
2993
|
+
} else {
|
|
2994
|
+
drawDiamond(png, p.x, p.y, r, pal.obstacle);
|
|
2995
|
+
}
|
|
3043
2996
|
}
|
|
3044
2997
|
}
|
|
3045
2998
|
if (opts.showCharger !== false && map.dock !== null) {
|
|
@@ -3200,6 +3153,32 @@ function obstacleColor(type) {
|
|
|
3200
3153
|
const hue = Math.abs(Math.trunc(type)) * 47 % 360;
|
|
3201
3154
|
return hsvToRgba(hue, 0.85, 0.95);
|
|
3202
3155
|
}
|
|
3156
|
+
function drawSquare(png, cx, cy, r, color) {
|
|
3157
|
+
fillRect(png, cx - r, cy - r, cx + r, cy + r, color);
|
|
3158
|
+
}
|
|
3159
|
+
function drawTriangle(png, cx, cy, r, color) {
|
|
3160
|
+
for (let dy = -r; dy <= r; dy += 1) {
|
|
3161
|
+
const w = Math.round((dy + r) / (2 * r) * r);
|
|
3162
|
+
for (let dx = -w; dx <= w; dx += 1) {
|
|
3163
|
+
setPixel(png, cx + dx, cy + dy, color);
|
|
3164
|
+
}
|
|
3165
|
+
}
|
|
3166
|
+
}
|
|
3167
|
+
function drawObstacleShape(png, cx, cy, r, type, color) {
|
|
3168
|
+
switch (Math.abs(Math.trunc(type)) % 4) {
|
|
3169
|
+
case 0:
|
|
3170
|
+
drawDiamond(png, cx, cy, r, color);
|
|
3171
|
+
return;
|
|
3172
|
+
case 1:
|
|
3173
|
+
drawSquare(png, cx, cy, r, color);
|
|
3174
|
+
return;
|
|
3175
|
+
case 2:
|
|
3176
|
+
drawTriangle(png, cx, cy, r, color);
|
|
3177
|
+
return;
|
|
3178
|
+
default:
|
|
3179
|
+
drawDisk(png, cx, cy, r, color);
|
|
3180
|
+
}
|
|
3181
|
+
}
|
|
3203
3182
|
var FURNITURE_LINE = [150, 110, 200, 235];
|
|
3204
3183
|
function paintFurnitureZone(png, points, dim, scale) {
|
|
3205
3184
|
if (points.length < 2) return;
|
|
@@ -4184,6 +4163,12 @@ var MowerFault = /* @__PURE__ */ ((MowerFault2) => {
|
|
|
4184
4163
|
MowerFault2[MowerFault2["TopCoverOpen"] = 73] = "TopCoverOpen";
|
|
4185
4164
|
return MowerFault2;
|
|
4186
4165
|
})(MowerFault || {});
|
|
4166
|
+
function mowerFaultSeverity(code) {
|
|
4167
|
+
if (code === null) return "info";
|
|
4168
|
+
if (code >= 1 && code <= 30 || code === 37 || code === 73) return "error";
|
|
4169
|
+
if (code >= 31 && code <= 36 || code >= 38 && code <= 45) return "warning";
|
|
4170
|
+
return "info";
|
|
4171
|
+
}
|
|
4187
4172
|
|
|
4188
4173
|
// src/models/mower/decode.ts
|
|
4189
4174
|
function isRecord2(v) {
|
|
@@ -4394,6 +4379,37 @@ function parseMowerHeartbeat(value) {
|
|
|
4394
4379
|
const taskSubState = mainState === HEARTBEAT_MAIN_STATE_MOWING ? MOWER_TASK_SUBSTATES[subStateRaw - HEARTBEAT_SUBSTATE_BASE] ?? null : null;
|
|
4395
4380
|
return { rawBattery, mainState, subStateRaw, taskSubState };
|
|
4396
4381
|
}
|
|
4382
|
+
var POSE_SENTINEL = 206;
|
|
4383
|
+
function poseBytes(value) {
|
|
4384
|
+
if (!Array.isArray(value)) return null;
|
|
4385
|
+
const bytes = [];
|
|
4386
|
+
for (const b of value) {
|
|
4387
|
+
if (typeof b !== "number") return null;
|
|
4388
|
+
bytes.push(b);
|
|
4389
|
+
}
|
|
4390
|
+
return bytes;
|
|
4391
|
+
}
|
|
4392
|
+
function parseMowingProgress(value) {
|
|
4393
|
+
const bytes = poseBytes(value);
|
|
4394
|
+
if (bytes === null || bytes.length < 11) return null;
|
|
4395
|
+
const last = bytes[bytes.length - 1];
|
|
4396
|
+
const head = bytes[0];
|
|
4397
|
+
let offset = null;
|
|
4398
|
+
if (head !== POSE_SENTINEL && last === POSE_SENTINEL) {
|
|
4399
|
+
offset = 0;
|
|
4400
|
+
} else if (head === POSE_SENTINEL && last === POSE_SENTINEL && bytes.length >= 33) {
|
|
4401
|
+
offset = 22;
|
|
4402
|
+
}
|
|
4403
|
+
if (offset === null || offset + 10 > bytes.length) return null;
|
|
4404
|
+
const rawPercent = (bytes[offset + 2] ?? 0) | (bytes[offset + 3] ?? 0) << 8;
|
|
4405
|
+
const total = (bytes[offset + 4] ?? 0) | (bytes[offset + 5] ?? 0) << 8 | (bytes[offset + 6] ?? 0) << 16;
|
|
4406
|
+
const finish = (bytes[offset + 7] ?? 0) | (bytes[offset + 8] ?? 0) << 8 | (bytes[offset + 9] ?? 0) << 16;
|
|
4407
|
+
return {
|
|
4408
|
+
progressPercent: rawPercent ? Math.min(100, rawPercent / 100) : 0,
|
|
4409
|
+
currentAreaSqm: finish / 100,
|
|
4410
|
+
totalAreaSqm: total / 100
|
|
4411
|
+
};
|
|
4412
|
+
}
|
|
4397
4413
|
|
|
4398
4414
|
// src/models/mower/capabilities.ts
|
|
4399
4415
|
var FALLBACK2 = {
|
|
@@ -5093,6 +5109,25 @@ var MowerDevice = class _MowerDevice extends BaseDevice {
|
|
|
5093
5109
|
get coverageTargetPct() {
|
|
5094
5110
|
return this.task?.coverageTarget ?? null;
|
|
5095
5111
|
}
|
|
5112
|
+
/**
|
|
5113
|
+
* Live mowing PROGRESS decoded from the POSE_COVERAGE (1:4) task block —
|
|
5114
|
+
* `{progressPercent, currentAreaSqm, totalAreaSqm}` — or null when 1:4 carries
|
|
5115
|
+
* no task block (idle / pose-only frame). This is the byte-accurate progress
|
|
5116
|
+
* the Dreamehome app shows (vs {@link coverageTargetPct}, the task TARGET).
|
|
5117
|
+
*/
|
|
5118
|
+
get mowingProgress() {
|
|
5119
|
+
return parseMowingProgress(
|
|
5120
|
+
this.getProperty(MOWER_PROP.POSE_COVERAGE.siid, MOWER_PROP.POSE_COVERAGE.piid)?.value
|
|
5121
|
+
);
|
|
5122
|
+
}
|
|
5123
|
+
/** Mowing completion percent (0..100) from {@link mowingProgress}, or null. */
|
|
5124
|
+
get mowingProgressPct() {
|
|
5125
|
+
return this.mowingProgress?.progressPercent ?? null;
|
|
5126
|
+
}
|
|
5127
|
+
/** Severity of the current DEVICE_CODE (2:2) — info / warning / error. */
|
|
5128
|
+
get faultSeverity() {
|
|
5129
|
+
return mowerFaultSeverity(this.faultRaw);
|
|
5130
|
+
}
|
|
5096
5131
|
/** Parsed per-zone control status (2:56), or null. */
|
|
5097
5132
|
get controlStatus() {
|
|
5098
5133
|
return parseControlStatus(
|
|
@@ -5272,6 +5307,7 @@ var MowerDevice = class _MowerDevice extends BaseDevice {
|
|
|
5272
5307
|
/** Props worth seeding on start() / polling — exported for the facade. */
|
|
5273
5308
|
static DEFAULT_PROPS = [
|
|
5274
5309
|
MOWER_PROP.HEARTBEAT,
|
|
5310
|
+
MOWER_PROP.POSE_COVERAGE,
|
|
5275
5311
|
MOWER_PROP.STATUS,
|
|
5276
5312
|
MOWER_PROP.DEVICE_CODE,
|
|
5277
5313
|
MOWER_PROP.BATTERY,
|
|
@@ -5930,8 +5966,10 @@ export {
|
|
|
5930
5966
|
getVacuumCapabilities,
|
|
5931
5967
|
isDreameConsumableKey,
|
|
5932
5968
|
mowerConsumableIndex,
|
|
5969
|
+
mowerFaultSeverity,
|
|
5933
5970
|
parseMowerConsumables,
|
|
5934
5971
|
parseMowerHeartbeat,
|
|
5972
|
+
parseMowingProgress,
|
|
5935
5973
|
renderMowerSvg,
|
|
5936
5974
|
renderVacuumPng,
|
|
5937
5975
|
resolveCapabilities,
|