@apocaliss92/nodedreame 1.7.2 → 1.8.1

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.d.cts CHANGED
@@ -755,6 +755,58 @@ declare function decodeAiFeature(raw: AiDetectionRaw, feature: DreameAiFeature):
755
755
  */
756
756
  declare function encodeAiFeatureWrite(raw: AiDetectionRaw, feature: DreameAiFeature, value: boolean): number | string;
757
757
 
758
+ /**
759
+ * Auto-switch settings codec. The robot packs a large bundle of secondary
760
+ * cleaning toggles + multi-value settings into a SINGLE MIoT property —
761
+ * `AUTO_SWITCH_SETTINGS` (siid 4 piid 50) — whose value is a JSON string.
762
+ * Ported from the Tasshack `dreame-vacuum` HA integration (v2.0.0b25,
763
+ * `DreameVacuumAutoSwitchProperty` + `set_auto_switch_property`):
764
+ *
765
+ * - READ : a JSON LIST `[{"k":"LessColl","v":1}, …]` (or a single
766
+ * `{"k":…,"v":…}` object) — every supported key/value pair.
767
+ * - WRITE : a SINGLE `{"k":"LessColl","v":0}` object carrying ONLY the
768
+ * changed key; the device merges it server-side.
769
+ *
770
+ * Unlike `AI_DETECTION` this family is JSON-ONLY (no int-bitmask variant) and the
771
+ * values are arbitrary ints (booleans 0/1, small enums, and `-1`/`-n` "not
772
+ * applicable" sentinels) — the codec returns the raw int and leaves the
773
+ * boolean-vs-enum interpretation to the caller. Presence is data-driven: a key is
774
+ * "supported" iff it appears in the decoded payload (exactly how Tasshack derives
775
+ * `auto_switch_data`).
776
+ */
777
+ /** Canonical auto-switch keys. A given model reports a subset. */
778
+ type AutoSwitchKey = 'collisionAvoidance' | 'fillLight' | 'autoDrying' | 'stainAvoidance' | 'moppingType' | 'cleanGenius' | 'widerCornerCoverage' | 'floorDirectionCleaning' | 'petFocusedCleaning' | 'autoRecleaning' | 'autoRewashing' | 'mopPadSwing' | 'autoCharging' | 'humanFollow' | 'maxSuctionPower' | 'smartDrying' | 'drainageConfirmResult' | 'drainageTestResult' | 'hotWashing' | 'uvSterilization' | 'cleaningRoute' | 'customMoppingMode' | 'moppingMode' | 'selfCleanFrequency' | 'intensiveCarpetCleaning' | 'gapCleaningExtension' | 'moppingUnderFurnitures' | 'ultraCleanMode' | 'streamingVoicePrompt' | 'mopExtend' | 'mopExtendFrequency' | 'sideReach' | 'intelligentStainCleaning';
779
+ /**
780
+ * Short on-wire key for each setting inside the `AUTO_SWITCH_SETTINGS` JSON
781
+ * (Tasshack `DreameVacuumAutoSwitchProperty`). These opaque strings are the
782
+ * device's own identifiers and must match byte-for-byte.
783
+ */
784
+ declare const AUTO_SWITCH_JSON_KEY: Readonly<Record<AutoSwitchKey, string>>;
785
+ /** The raw on-wire `AUTO_SWITCH_SETTINGS` value: a JSON string, or absent. */
786
+ type AutoSwitchRaw = string | null;
787
+ /**
788
+ * Decode ONE auto-switch setting's int value from the packed
789
+ * `AUTO_SWITCH_SETTINGS` payload. Returns `null` when the value is absent or the
790
+ * key is not present in the payload (i.e. unsupported by this model/firmware).
791
+ */
792
+ declare function decodeAutoSwitch(raw: AutoSwitchRaw, key: AutoSwitchKey): number | null;
793
+ /**
794
+ * The auto-switch keys the payload actually reports (presence-driven — mirrors
795
+ * Tasshack `auto_switch_data`). On-wire keys with no canonical mapping (newer
796
+ * firmware extras like `MopFullyScalable`) are skipped. Order follows
797
+ * {@link AUTO_SWITCH_JSON_KEY} for determinism.
798
+ */
799
+ declare function supportedAutoSwitchKeys(raw: AutoSwitchRaw): readonly AutoSwitchKey[];
800
+ /** All `{ canonical key → int }` pairs the payload reports (canonical keys only). */
801
+ declare function decodeAutoSwitchAll(raw: AutoSwitchRaw): Readonly<Partial<Record<AutoSwitchKey, number>>>;
802
+ /**
803
+ * Compute the value to WRITE to `AUTO_SWITCH_SETTINGS` for ONE setting. Mirrors
804
+ * Tasshack `set_auto_switch_property`: a SINGLE `{"k":<key>,"v":<int>}` object
805
+ * (NOT the full list) — the device merges it server-side, so the other settings
806
+ * are preserved without a read-modify-write.
807
+ */
808
+ declare function encodeAutoSwitchWrite(key: AutoSwitchKey, value: number): string;
809
+
758
810
  /**
759
811
  * Vacuum consumable/maintenance map (ported from Tasshack `dreame-vacuum`
760
812
  * v2.0.0b25 — property + action mappings). Each consumable lives on its own MIoT
@@ -1370,6 +1422,43 @@ declare class VacuumDevice extends BaseDevice<VacuumDeviceEvents> {
1370
1422
  * is unknown (a blind write would clobber the other toggles).
1371
1423
  */
1372
1424
  setAiFeature(feature: DreameAiFeature, value: boolean): Promise<unknown>;
1425
+ /**
1426
+ * The raw `AUTO_SWITCH_SETTINGS` value (siid 4 piid 50) — a JSON string packing
1427
+ * every secondary toggle/setting — or `null` when not yet observed. Prefer the
1428
+ * decoded {@link autoSwitchProperty} / {@link supportedAutoSwitchKeys} surface.
1429
+ */
1430
+ get autoSwitchRaw(): AutoSwitchRaw;
1431
+ /** Whether this model reports the packed auto-switch bundle at all. */
1432
+ get hasAutoSwitchSettings(): boolean;
1433
+ /**
1434
+ * The auto-switch settings this model reports, decoded from the packed value.
1435
+ * Presence-driven (a key appears iff the payload carries it) — mirrors
1436
+ * Tasshack `auto_switch_data`.
1437
+ */
1438
+ get supportedAutoSwitchKeys(): readonly AutoSwitchKey[];
1439
+ /**
1440
+ * Read ONE auto-switch setting's int value, decoded from the packed
1441
+ * `AUTO_SWITCH_SETTINGS` payload. `null` when the value is unobserved or the
1442
+ * key is not present. The value is an opaque int (boolean 0/1, a small enum, or
1443
+ * a `-1`/`-n` "not applicable" sentinel) — the caller interprets it.
1444
+ */
1445
+ autoSwitchProperty(key: AutoSwitchKey): number | null;
1446
+ /**
1447
+ * Seed {@link autoSwitchRaw} from the CLOUD SHADOW (the last value the robot
1448
+ * pushed for `AUTO_SWITCH_SETTINGS`, siid 4 piid 50) WITHOUT waking it. Like the
1449
+ * AI bundle these are STATIC settings the robot rarely re-pushes over MQTT, so a
1450
+ * fresh connect to an idle robot has no value cached — call this on activate to
1451
+ * surface the current settings. Returns the resolved raw value (`null` when the
1452
+ * shadow carries none yet).
1453
+ */
1454
+ refreshAutoSwitch(): Promise<AutoSwitchRaw>;
1455
+ /**
1456
+ * Set ONE auto-switch setting. Mirrors Tasshack `set_auto_switch_property`: a
1457
+ * single-key `{"k":<key>,"v":<int>}` write the device merges server-side (the
1458
+ * other settings are preserved without a read-modify-write). Rejects when the
1459
+ * model does not report the bundle.
1460
+ */
1461
+ setAutoSwitchProperty(key: AutoSwitchKey, value: number): Promise<unknown>;
1373
1462
  /**
1374
1463
  * Start cleaning (MIoT action siid 2 aiid 1). Named `startCleaning` — NOT
1375
1464
  * `start` — because `BaseDevice.start()` is the lifecycle method that opens
@@ -2318,4 +2407,4 @@ declare function createDumper(target: DumperDevice, options?: DumperOptions): Du
2318
2407
  */
2319
2408
  declare function createClientDumper(client: Nodreame, options?: DumperOptions): Dumper[];
2320
2409
 
2321
- export { AI_FEATURE_BIT, AI_FEATURE_JSON_KEY, type AiDetectionRaw, 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, type MapBoundingBox, type MapCleanedAreaOverlay, 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 MowerContour, MowerControlAction, type MowerControlState, MowerDevice, type MowerDeviceInput, MowerFault, type MowerMap, type MowerMapBoundary, type MowerMowPath, type MowerPathEntry, type MowerPoint, type MowerSpotArea, MowerStatus, type MowerTaskDescriptor, MowerTaskStatus, 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, encodeAiFeatureWrite, getMowerCapabilities, getVacuumCapabilities, isDreameConsumableKey, renderMowerSvg, renderVacuumPng, resolveCapabilities };
2410
+ 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, type MapBoundingBox, type MapCleanedAreaOverlay, 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 MowerContour, MowerControlAction, type MowerControlState, MowerDevice, type MowerDeviceInput, MowerFault, type MowerMap, type MowerMapBoundary, type MowerMowPath, type MowerPathEntry, type MowerPoint, type MowerSpotArea, MowerStatus, type MowerTaskDescriptor, MowerTaskStatus, 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, getMowerCapabilities, getVacuumCapabilities, isDreameConsumableKey, renderMowerSvg, renderVacuumPng, resolveCapabilities, supportedAutoSwitchKeys };
package/dist/index.d.ts CHANGED
@@ -755,6 +755,58 @@ declare function decodeAiFeature(raw: AiDetectionRaw, feature: DreameAiFeature):
755
755
  */
756
756
  declare function encodeAiFeatureWrite(raw: AiDetectionRaw, feature: DreameAiFeature, value: boolean): number | string;
757
757
 
758
+ /**
759
+ * Auto-switch settings codec. The robot packs a large bundle of secondary
760
+ * cleaning toggles + multi-value settings into a SINGLE MIoT property —
761
+ * `AUTO_SWITCH_SETTINGS` (siid 4 piid 50) — whose value is a JSON string.
762
+ * Ported from the Tasshack `dreame-vacuum` HA integration (v2.0.0b25,
763
+ * `DreameVacuumAutoSwitchProperty` + `set_auto_switch_property`):
764
+ *
765
+ * - READ : a JSON LIST `[{"k":"LessColl","v":1}, …]` (or a single
766
+ * `{"k":…,"v":…}` object) — every supported key/value pair.
767
+ * - WRITE : a SINGLE `{"k":"LessColl","v":0}` object carrying ONLY the
768
+ * changed key; the device merges it server-side.
769
+ *
770
+ * Unlike `AI_DETECTION` this family is JSON-ONLY (no int-bitmask variant) and the
771
+ * values are arbitrary ints (booleans 0/1, small enums, and `-1`/`-n` "not
772
+ * applicable" sentinels) — the codec returns the raw int and leaves the
773
+ * boolean-vs-enum interpretation to the caller. Presence is data-driven: a key is
774
+ * "supported" iff it appears in the decoded payload (exactly how Tasshack derives
775
+ * `auto_switch_data`).
776
+ */
777
+ /** Canonical auto-switch keys. A given model reports a subset. */
778
+ type AutoSwitchKey = 'collisionAvoidance' | 'fillLight' | 'autoDrying' | 'stainAvoidance' | 'moppingType' | 'cleanGenius' | 'widerCornerCoverage' | 'floorDirectionCleaning' | 'petFocusedCleaning' | 'autoRecleaning' | 'autoRewashing' | 'mopPadSwing' | 'autoCharging' | 'humanFollow' | 'maxSuctionPower' | 'smartDrying' | 'drainageConfirmResult' | 'drainageTestResult' | 'hotWashing' | 'uvSterilization' | 'cleaningRoute' | 'customMoppingMode' | 'moppingMode' | 'selfCleanFrequency' | 'intensiveCarpetCleaning' | 'gapCleaningExtension' | 'moppingUnderFurnitures' | 'ultraCleanMode' | 'streamingVoicePrompt' | 'mopExtend' | 'mopExtendFrequency' | 'sideReach' | 'intelligentStainCleaning';
779
+ /**
780
+ * Short on-wire key for each setting inside the `AUTO_SWITCH_SETTINGS` JSON
781
+ * (Tasshack `DreameVacuumAutoSwitchProperty`). These opaque strings are the
782
+ * device's own identifiers and must match byte-for-byte.
783
+ */
784
+ declare const AUTO_SWITCH_JSON_KEY: Readonly<Record<AutoSwitchKey, string>>;
785
+ /** The raw on-wire `AUTO_SWITCH_SETTINGS` value: a JSON string, or absent. */
786
+ type AutoSwitchRaw = string | null;
787
+ /**
788
+ * Decode ONE auto-switch setting's int value from the packed
789
+ * `AUTO_SWITCH_SETTINGS` payload. Returns `null` when the value is absent or the
790
+ * key is not present in the payload (i.e. unsupported by this model/firmware).
791
+ */
792
+ declare function decodeAutoSwitch(raw: AutoSwitchRaw, key: AutoSwitchKey): number | null;
793
+ /**
794
+ * The auto-switch keys the payload actually reports (presence-driven — mirrors
795
+ * Tasshack `auto_switch_data`). On-wire keys with no canonical mapping (newer
796
+ * firmware extras like `MopFullyScalable`) are skipped. Order follows
797
+ * {@link AUTO_SWITCH_JSON_KEY} for determinism.
798
+ */
799
+ declare function supportedAutoSwitchKeys(raw: AutoSwitchRaw): readonly AutoSwitchKey[];
800
+ /** All `{ canonical key → int }` pairs the payload reports (canonical keys only). */
801
+ declare function decodeAutoSwitchAll(raw: AutoSwitchRaw): Readonly<Partial<Record<AutoSwitchKey, number>>>;
802
+ /**
803
+ * Compute the value to WRITE to `AUTO_SWITCH_SETTINGS` for ONE setting. Mirrors
804
+ * Tasshack `set_auto_switch_property`: a SINGLE `{"k":<key>,"v":<int>}` object
805
+ * (NOT the full list) — the device merges it server-side, so the other settings
806
+ * are preserved without a read-modify-write.
807
+ */
808
+ declare function encodeAutoSwitchWrite(key: AutoSwitchKey, value: number): string;
809
+
758
810
  /**
759
811
  * Vacuum consumable/maintenance map (ported from Tasshack `dreame-vacuum`
760
812
  * v2.0.0b25 — property + action mappings). Each consumable lives on its own MIoT
@@ -1370,6 +1422,43 @@ declare class VacuumDevice extends BaseDevice<VacuumDeviceEvents> {
1370
1422
  * is unknown (a blind write would clobber the other toggles).
1371
1423
  */
1372
1424
  setAiFeature(feature: DreameAiFeature, value: boolean): Promise<unknown>;
1425
+ /**
1426
+ * The raw `AUTO_SWITCH_SETTINGS` value (siid 4 piid 50) — a JSON string packing
1427
+ * every secondary toggle/setting — or `null` when not yet observed. Prefer the
1428
+ * decoded {@link autoSwitchProperty} / {@link supportedAutoSwitchKeys} surface.
1429
+ */
1430
+ get autoSwitchRaw(): AutoSwitchRaw;
1431
+ /** Whether this model reports the packed auto-switch bundle at all. */
1432
+ get hasAutoSwitchSettings(): boolean;
1433
+ /**
1434
+ * The auto-switch settings this model reports, decoded from the packed value.
1435
+ * Presence-driven (a key appears iff the payload carries it) — mirrors
1436
+ * Tasshack `auto_switch_data`.
1437
+ */
1438
+ get supportedAutoSwitchKeys(): readonly AutoSwitchKey[];
1439
+ /**
1440
+ * Read ONE auto-switch setting's int value, decoded from the packed
1441
+ * `AUTO_SWITCH_SETTINGS` payload. `null` when the value is unobserved or the
1442
+ * key is not present. The value is an opaque int (boolean 0/1, a small enum, or
1443
+ * a `-1`/`-n` "not applicable" sentinel) — the caller interprets it.
1444
+ */
1445
+ autoSwitchProperty(key: AutoSwitchKey): number | null;
1446
+ /**
1447
+ * Seed {@link autoSwitchRaw} from the CLOUD SHADOW (the last value the robot
1448
+ * pushed for `AUTO_SWITCH_SETTINGS`, siid 4 piid 50) WITHOUT waking it. Like the
1449
+ * AI bundle these are STATIC settings the robot rarely re-pushes over MQTT, so a
1450
+ * fresh connect to an idle robot has no value cached — call this on activate to
1451
+ * surface the current settings. Returns the resolved raw value (`null` when the
1452
+ * shadow carries none yet).
1453
+ */
1454
+ refreshAutoSwitch(): Promise<AutoSwitchRaw>;
1455
+ /**
1456
+ * Set ONE auto-switch setting. Mirrors Tasshack `set_auto_switch_property`: a
1457
+ * single-key `{"k":<key>,"v":<int>}` write the device merges server-side (the
1458
+ * other settings are preserved without a read-modify-write). Rejects when the
1459
+ * model does not report the bundle.
1460
+ */
1461
+ setAutoSwitchProperty(key: AutoSwitchKey, value: number): Promise<unknown>;
1373
1462
  /**
1374
1463
  * Start cleaning (MIoT action siid 2 aiid 1). Named `startCleaning` — NOT
1375
1464
  * `start` — because `BaseDevice.start()` is the lifecycle method that opens
@@ -2318,4 +2407,4 @@ declare function createDumper(target: DumperDevice, options?: DumperOptions): Du
2318
2407
  */
2319
2408
  declare function createClientDumper(client: Nodreame, options?: DumperOptions): Dumper[];
2320
2409
 
2321
- export { AI_FEATURE_BIT, AI_FEATURE_JSON_KEY, type AiDetectionRaw, 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, type MapBoundingBox, type MapCleanedAreaOverlay, 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 MowerContour, MowerControlAction, type MowerControlState, MowerDevice, type MowerDeviceInput, MowerFault, type MowerMap, type MowerMapBoundary, type MowerMowPath, type MowerPathEntry, type MowerPoint, type MowerSpotArea, MowerStatus, type MowerTaskDescriptor, MowerTaskStatus, 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, encodeAiFeatureWrite, getMowerCapabilities, getVacuumCapabilities, isDreameConsumableKey, renderMowerSvg, renderVacuumPng, resolveCapabilities };
2410
+ 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, type MapBoundingBox, type MapCleanedAreaOverlay, 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 MowerContour, MowerControlAction, type MowerControlState, MowerDevice, type MowerDeviceInput, MowerFault, type MowerMap, type MowerMapBoundary, type MowerMowPath, type MowerPathEntry, type MowerPoint, type MowerSpotArea, MowerStatus, type MowerTaskDescriptor, MowerTaskStatus, 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, getMowerCapabilities, getVacuumCapabilities, isDreameConsumableKey, 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.7.2";
3
+ var LIBRARY_VERSION = "1.8.1";
4
4
 
5
5
  // src/transport/errors.ts
6
6
  var DreameError = class extends Error {
@@ -1157,6 +1157,12 @@ var VACUUM_PROP = {
1157
1157
  * via `ai-detection.ts` ({@link decodeAiFeature} / {@link encodeAiFeatureWrite}).
1158
1158
  */
1159
1159
  AI_DETECTION: { siid: 4, piid: 22 },
1160
+ /**
1161
+ * Auto-switch settings bundle (Tasshack types.py — `AUTO_SWITCH_SETTINGS`,
1162
+ * siid 4 piid 50). A JSON string packing every secondary toggle/setting as
1163
+ * `[{"k":<key>,"v":<int>}, …]`. Decode/encode per-setting via `auto-switch.ts`.
1164
+ */
1165
+ AUTO_SWITCH_SETTINGS: { siid: 4, piid: 50 },
1160
1166
  /** VERIFIED r2532a 2026-05-03 — task progress percentage 0..100. */
1161
1167
  TASK_PROGRESS_PCT: { siid: 4, piid: 63 },
1162
1168
  /** VERIFIED r2532a — mop-drying progress (minutes ticking during MopDrying). */
@@ -1570,6 +1576,105 @@ function encodeAiFeatureWrite(raw, feature, value) {
1570
1576
  );
1571
1577
  }
1572
1578
 
1579
+ // src/models/vacuum/auto-switch.ts
1580
+ var AUTO_SWITCH_JSON_KEY = {
1581
+ collisionAvoidance: "LessColl",
1582
+ fillLight: "FillinLight",
1583
+ autoDrying: "AutoDry",
1584
+ stainAvoidance: "StainIdentify",
1585
+ moppingType: "CleanType",
1586
+ cleanGenius: "SmartHost",
1587
+ widerCornerCoverage: "MeticulousTwist",
1588
+ floorDirectionCleaning: "MaterialDirectionClean",
1589
+ petFocusedCleaning: "PetPartClean",
1590
+ autoRecleaning: "SmartAutoMop",
1591
+ autoRewashing: "SmartAutoWash",
1592
+ mopPadSwing: "MopScalable",
1593
+ autoCharging: "SmartCharge",
1594
+ humanFollow: "MonitorHumanFollow",
1595
+ maxSuctionPower: "SuctionMax",
1596
+ smartDrying: "SmartDrying",
1597
+ drainageConfirmResult: "FluctuationConfirmResult",
1598
+ drainageTestResult: "FluctuationTestResult",
1599
+ hotWashing: "HotWash",
1600
+ uvSterilization: "UVLight",
1601
+ cleaningRoute: "CleanRoute",
1602
+ customMoppingMode: "MopEffectSwitch",
1603
+ moppingMode: "MopEffectState",
1604
+ selfCleanFrequency: "BackWashType",
1605
+ intensiveCarpetCleaning: "CarpetFineClean",
1606
+ gapCleaningExtension: "LacuneMopScalable",
1607
+ moppingUnderFurnitures: "MopScalable2",
1608
+ ultraCleanMode: "SuperWash",
1609
+ streamingVoicePrompt: "MonitorPromptLevel",
1610
+ mopExtend: "MopExtrSwitch",
1611
+ mopExtendFrequency: "ExtrFreq",
1612
+ sideReach: "SbrushExtrSwitch",
1613
+ intelligentStainCleaning: "HeavyStainSmart"
1614
+ };
1615
+ var JSON_KEY_TO_CANONICAL = Object.fromEntries(
1616
+ Object.entries(AUTO_SWITCH_JSON_KEY).map(([k, v]) => [v, k])
1617
+ );
1618
+ function coerceInt(v) {
1619
+ if (typeof v === "number") return Number.isFinite(v) ? v : null;
1620
+ if (typeof v === "string" && v.trim() !== "") {
1621
+ const n = Number(v);
1622
+ return Number.isFinite(n) ? n : null;
1623
+ }
1624
+ return null;
1625
+ }
1626
+ function parseAutoSwitchMap(raw) {
1627
+ if (typeof raw !== "string" || raw.length <= 2) return null;
1628
+ let parsed;
1629
+ try {
1630
+ parsed = JSON.parse(raw);
1631
+ } catch {
1632
+ return null;
1633
+ }
1634
+ const out = /* @__PURE__ */ new Map();
1635
+ const add = (entry) => {
1636
+ if (entry === null || typeof entry !== "object") return;
1637
+ const rec = entry;
1638
+ if (typeof rec["k"] !== "string") return;
1639
+ const value = coerceInt(rec["v"]);
1640
+ if (value !== null) out.set(rec["k"], value);
1641
+ };
1642
+ if (Array.isArray(parsed)) {
1643
+ for (const entry of parsed) add(entry);
1644
+ } else {
1645
+ add(parsed);
1646
+ }
1647
+ return out.size > 0 ? out : null;
1648
+ }
1649
+ function decodeAutoSwitch(raw, key2) {
1650
+ const map = parseAutoSwitchMap(raw);
1651
+ if (map === null) return null;
1652
+ const jsonKey = AUTO_SWITCH_JSON_KEY[key2];
1653
+ return map.has(jsonKey) ? map.get(jsonKey) ?? null : null;
1654
+ }
1655
+ function supportedAutoSwitchKeys(raw) {
1656
+ const map = parseAutoSwitchMap(raw);
1657
+ if (map === null) return [];
1658
+ const present = [];
1659
+ for (const key2 of Object.keys(AUTO_SWITCH_JSON_KEY)) {
1660
+ if (map.has(AUTO_SWITCH_JSON_KEY[key2])) present.push(key2);
1661
+ }
1662
+ return present;
1663
+ }
1664
+ function decodeAutoSwitchAll(raw) {
1665
+ const map = parseAutoSwitchMap(raw);
1666
+ if (map === null) return {};
1667
+ const out = {};
1668
+ for (const [jsonKey, value] of map) {
1669
+ const canonical = JSON_KEY_TO_CANONICAL[jsonKey];
1670
+ if (canonical !== void 0) out[canonical] = value;
1671
+ }
1672
+ return out;
1673
+ }
1674
+ function encodeAutoSwitchWrite(key2, value) {
1675
+ return JSON.stringify({ k: AUTO_SWITCH_JSON_KEY[key2], v: Math.trunc(value) });
1676
+ }
1677
+
1573
1678
  // src/models/vacuum/consumables.ts
1574
1679
  var VACUUM_CONSUMABLES = [
1575
1680
  { key: "main-brush", label: "Main Brush", life: { siid: 9, piid: 2 }, reset: { siid: 9, aiid: 1 } },
@@ -1777,11 +1882,43 @@ function unwrapEnvelope(value, opts = {}) {
1777
1882
  }
1778
1883
  bytes = aesCbcDecrypt(bytes, key2, opts.iv);
1779
1884
  }
1885
+ let inflated;
1780
1886
  try {
1781
- return zlib.inflateSync(bytes);
1887
+ inflated = zlib.inflateSync(bytes);
1782
1888
  } catch (err) {
1783
1889
  throw new MapDecodeError("envelope: zlib inflate failed", { cause: err });
1784
1890
  }
1891
+ let guard = 0;
1892
+ while (guard < MAX_EXTRA_WRAP_LAYERS && looksLikeBase64Zlib(inflated)) {
1893
+ const text = inflated.toString("latin1").replace(/-/g, "+").replace(/_/g, "/");
1894
+ try {
1895
+ inflated = zlib.inflateSync(Buffer.from(text, "base64"));
1896
+ } catch (err) {
1897
+ throw new MapDecodeError("envelope: nested zlib inflate failed", { cause: err });
1898
+ }
1899
+ guard += 1;
1900
+ }
1901
+ return inflated;
1902
+ }
1903
+ var MAX_EXTRA_WRAP_LAYERS = 4;
1904
+ function looksLikeBase64Zlib(buf) {
1905
+ if (buf.length < 8) return false;
1906
+ for (const b of buf) {
1907
+ const isB64 = b >= 65 && b <= 90 || // A-Z
1908
+ b >= 97 && b <= 122 || // a-z
1909
+ b >= 48 && b <= 57 || // 0-9
1910
+ b === 43 || b === 47 || // + /
1911
+ b === 45 || b === 95 || // - _ (url-safe)
1912
+ b === 61;
1913
+ if (!isB64) return false;
1914
+ }
1915
+ try {
1916
+ const prefix = buf.subarray(0, 16).toString("latin1").replace(/-/g, "+").replace(/_/g, "/");
1917
+ const decoded = Buffer.from(prefix, "base64");
1918
+ return decoded.length >= 2 && decoded[0] === 120;
1919
+ } catch {
1920
+ return false;
1921
+ }
1785
1922
  }
1786
1923
  function aesCbcDecrypt(cipher, rawKey, iv) {
1787
1924
  const keyBytes = Buffer.from(
@@ -2417,7 +2554,7 @@ function decodeCleanedAreaPixels(pixels, width, height) {
2417
2554
 
2418
2555
  // src/models/vacuum/map/decode.ts
2419
2556
  function decodeVacuumMap(input, opts = {}) {
2420
- const inflated = typeof input === "string" ? unwrapEnvelope(input, opts) : input;
2557
+ const inflated = typeof input === "string" ? unwrapEnvelope(input, opts) : looksLikeBase64Zlib(input) ? unwrapEnvelope(input.toString("latin1"), opts) : input;
2421
2558
  const { header, tail } = parseFrame(inflated);
2422
2559
  const dimensions = mergeDimensions(header, tail);
2423
2560
  const robot = pose(header.robotX, header.robotY, header.robotA, tail.nr === true);
@@ -2886,6 +3023,63 @@ var VacuumDevice = class _VacuumDevice extends BaseDevice {
2886
3023
  const next = encodeAiFeatureWrite(this.aiDetectionRaw, feature, value);
2887
3024
  return this.setProperty({ ...VACUUM_PROP.AI_DETECTION, value: next });
2888
3025
  }
3026
+ // -- auto-switch settings -----------------------------------------------
3027
+ /**
3028
+ * The raw `AUTO_SWITCH_SETTINGS` value (siid 4 piid 50) — a JSON string packing
3029
+ * every secondary toggle/setting — or `null` when not yet observed. Prefer the
3030
+ * decoded {@link autoSwitchProperty} / {@link supportedAutoSwitchKeys} surface.
3031
+ */
3032
+ get autoSwitchRaw() {
3033
+ const v = this.getProperty(
3034
+ VACUUM_PROP.AUTO_SWITCH_SETTINGS.siid,
3035
+ VACUUM_PROP.AUTO_SWITCH_SETTINGS.piid
3036
+ )?.value;
3037
+ return typeof v === "string" ? v : null;
3038
+ }
3039
+ /** Whether this model reports the packed auto-switch bundle at all. */
3040
+ get hasAutoSwitchSettings() {
3041
+ return this.autoSwitchRaw !== null;
3042
+ }
3043
+ /**
3044
+ * The auto-switch settings this model reports, decoded from the packed value.
3045
+ * Presence-driven (a key appears iff the payload carries it) — mirrors
3046
+ * Tasshack `auto_switch_data`.
3047
+ */
3048
+ get supportedAutoSwitchKeys() {
3049
+ return supportedAutoSwitchKeys(this.autoSwitchRaw);
3050
+ }
3051
+ /**
3052
+ * Read ONE auto-switch setting's int value, decoded from the packed
3053
+ * `AUTO_SWITCH_SETTINGS` payload. `null` when the value is unobserved or the
3054
+ * key is not present. The value is an opaque int (boolean 0/1, a small enum, or
3055
+ * a `-1`/`-n` "not applicable" sentinel) — the caller interprets it.
3056
+ */
3057
+ autoSwitchProperty(key2) {
3058
+ return decodeAutoSwitch(this.autoSwitchRaw, key2);
3059
+ }
3060
+ /**
3061
+ * Seed {@link autoSwitchRaw} from the CLOUD SHADOW (the last value the robot
3062
+ * pushed for `AUTO_SWITCH_SETTINGS`, siid 4 piid 50) WITHOUT waking it. Like the
3063
+ * AI bundle these are STATIC settings the robot rarely re-pushes over MQTT, so a
3064
+ * fresh connect to an idle robot has no value cached — call this on activate to
3065
+ * surface the current settings. Returns the resolved raw value (`null` when the
3066
+ * shadow carries none yet).
3067
+ */
3068
+ async refreshAutoSwitch() {
3069
+ await this.refreshCachedProperties([VACUUM_PROP.AUTO_SWITCH_SETTINGS]);
3070
+ return this.autoSwitchRaw;
3071
+ }
3072
+ /**
3073
+ * Set ONE auto-switch setting. Mirrors Tasshack `set_auto_switch_property`: a
3074
+ * single-key `{"k":<key>,"v":<int>}` write the device merges server-side (the
3075
+ * other settings are preserved without a read-modify-write). Rejects when the
3076
+ * model does not report the bundle.
3077
+ */
3078
+ async setAutoSwitchProperty(key2, value) {
3079
+ this.#requireCap(this.hasAutoSwitchSettings, "setAutoSwitchProperty", "auto-switch settings");
3080
+ const next = encodeAutoSwitchWrite(key2, value);
3081
+ return this.setProperty({ ...VACUUM_PROP.AUTO_SWITCH_SETTINGS, value: next });
3082
+ }
2889
3083
  // -- command helpers ----------------------------------------------------
2890
3084
  #resolveCleanOpts(opts) {
2891
3085
  const repeats = Math.max(1, Math.trunc(opts.repeats ?? 1));
@@ -4800,6 +4994,7 @@ function createClientDumper(client, options) {
4800
4994
  export {
4801
4995
  AI_FEATURE_BIT,
4802
4996
  AI_FEATURE_JSON_KEY,
4997
+ AUTO_SWITCH_JSON_KEY,
4803
4998
  BaseDevice,
4804
4999
  ChargingStatus,
4805
5000
  CleaningMode,
@@ -4832,12 +5027,16 @@ export {
4832
5027
  createClientDumper,
4833
5028
  createDumper,
4834
5029
  decodeAiFeature,
5030
+ decodeAutoSwitch,
5031
+ decodeAutoSwitchAll,
4835
5032
  encodeAiFeatureWrite,
5033
+ encodeAutoSwitchWrite,
4836
5034
  getMowerCapabilities,
4837
5035
  getVacuumCapabilities,
4838
5036
  isDreameConsumableKey,
4839
5037
  renderMowerSvg,
4840
5038
  renderVacuumPng,
4841
- resolveCapabilities
5039
+ resolveCapabilities,
5040
+ supportedAutoSwitchKeys
4842
5041
  };
4843
5042
  //# sourceMappingURL=index.js.map