@apocaliss92/nodedreame 1.10.0 → 1.11.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/dist/index.cjs +168 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -1
- package/dist/index.d.ts +46 -1
- package/dist/index.js +165 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1825,6 +1825,30 @@ interface MowerControlState {
|
|
|
1825
1825
|
statusCode: number | null;
|
|
1826
1826
|
zones: number[][];
|
|
1827
1827
|
}
|
|
1828
|
+
/** Canonical CMS consumable counter keys (blade, brush, robot maintenance). */
|
|
1829
|
+
type MowerConsumableKey = 'blade' | 'brush' | 'maintenance';
|
|
1830
|
+
/** One CMS consumable counter: minutes used + total + remaining %. */
|
|
1831
|
+
interface MowerConsumableReading {
|
|
1832
|
+
readonly key: MowerConsumableKey;
|
|
1833
|
+
/** Minutes of run-time accrued on this counter (counts UP). */
|
|
1834
|
+
readonly usedMinutes: number;
|
|
1835
|
+
/** Counter's full-life duration in minutes. */
|
|
1836
|
+
readonly totalMinutes: number;
|
|
1837
|
+
/** Remaining life percentage (0..100, one decimal). */
|
|
1838
|
+
readonly remainingPercent: number;
|
|
1839
|
+
}
|
|
1840
|
+
/** Map a consumable key (incl. aliases) to its CMS counter index. */
|
|
1841
|
+
declare function mowerConsumableIndex(item: string): number | null;
|
|
1842
|
+
/**
|
|
1843
|
+
* Extract the raw `[blade, brush, robot]` minute counters from a CMS getter
|
|
1844
|
+
* result, or null if the response is malformed. Cast-free, no throw.
|
|
1845
|
+
*/
|
|
1846
|
+
declare function extractMowerConsumableValues(result: unknown): number[] | null;
|
|
1847
|
+
/**
|
|
1848
|
+
* Parse a CMS getter result into typed consumable readings (blade/brush/
|
|
1849
|
+
* maintenance) with remaining %. Returns null on a malformed response.
|
|
1850
|
+
*/
|
|
1851
|
+
declare function parseMowerConsumables(result: unknown): readonly MowerConsumableReading[] | null;
|
|
1828
1852
|
|
|
1829
1853
|
/**
|
|
1830
1854
|
* Per-model mower capability records + a resolver adapting the rich record into
|
|
@@ -2063,6 +2087,27 @@ declare class MowerDevice extends BaseDevice {
|
|
|
2063
2087
|
startMowingEdges(contourIds: number[][]): Promise<unknown>;
|
|
2064
2088
|
/** Spot mowing (2:50 o:103). */
|
|
2065
2089
|
startMowingSpots(spotAreaIds: number[]): Promise<unknown>;
|
|
2090
|
+
/**
|
|
2091
|
+
* Read the raw CMS consumable counters `[blade, brush, robot]` (minutes used),
|
|
2092
|
+
* via the SCHEDULING_TASK (2:50) custom-action getter `{m:'g',t:'CMS'}`. This
|
|
2093
|
+
* is a LIVE device action (it wakes the mower); rejects with
|
|
2094
|
+
* {@link DreameDeviceOfflineError} when the mower is unreachable. Returns null
|
|
2095
|
+
* if the response is malformed.
|
|
2096
|
+
*/
|
|
2097
|
+
getConsumableValues(): Promise<readonly number[] | null>;
|
|
2098
|
+
/**
|
|
2099
|
+
* Read the CMS consumables as typed readings (blade/brush/maintenance) with
|
|
2100
|
+
* remaining %. LIVE action — see {@link getConsumableValues}. Returns null on
|
|
2101
|
+
* a malformed response.
|
|
2102
|
+
*/
|
|
2103
|
+
getConsumables(): Promise<readonly MowerConsumableReading[] | null>;
|
|
2104
|
+
/**
|
|
2105
|
+
* Reset one CMS consumable counter to zero. Reads the current counters, zeroes
|
|
2106
|
+
* the selected one (leaving the others), and writes them back via the
|
|
2107
|
+
* `{m:'s',t:'CMS',d:{value:[…]}}` setter. LIVE action. Throws on an unknown
|
|
2108
|
+
* item or when the current counters cannot be read.
|
|
2109
|
+
*/
|
|
2110
|
+
resetConsumable(item: MowerConsumableKey): Promise<void>;
|
|
2066
2111
|
/**
|
|
2067
2112
|
* Seed the cache from the CLOUD SHADOW (last-known values) WITHOUT waking the
|
|
2068
2113
|
* mower — reads {@link MowerDevice.DEFAULT_PROPS} from the cloud-cached
|
|
@@ -2448,4 +2493,4 @@ declare function createDumper(target: DumperDevice, options?: DumperOptions): Du
|
|
|
2448
2493
|
*/
|
|
2449
2494
|
declare function createClientDumper(client: Nodreame, options?: DumperOptions): Dumper[];
|
|
2450
2495
|
|
|
2451
|
-
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 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 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 };
|
|
2496
|
+
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 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 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, extractMowerConsumableValues, getMowerCapabilities, getVacuumCapabilities, isDreameConsumableKey, mowerConsumableIndex, parseMowerConsumables, renderMowerSvg, renderVacuumPng, resolveCapabilities, supportedAutoSwitchKeys };
|
package/dist/index.d.ts
CHANGED
|
@@ -1825,6 +1825,30 @@ interface MowerControlState {
|
|
|
1825
1825
|
statusCode: number | null;
|
|
1826
1826
|
zones: number[][];
|
|
1827
1827
|
}
|
|
1828
|
+
/** Canonical CMS consumable counter keys (blade, brush, robot maintenance). */
|
|
1829
|
+
type MowerConsumableKey = 'blade' | 'brush' | 'maintenance';
|
|
1830
|
+
/** One CMS consumable counter: minutes used + total + remaining %. */
|
|
1831
|
+
interface MowerConsumableReading {
|
|
1832
|
+
readonly key: MowerConsumableKey;
|
|
1833
|
+
/** Minutes of run-time accrued on this counter (counts UP). */
|
|
1834
|
+
readonly usedMinutes: number;
|
|
1835
|
+
/** Counter's full-life duration in minutes. */
|
|
1836
|
+
readonly totalMinutes: number;
|
|
1837
|
+
/** Remaining life percentage (0..100, one decimal). */
|
|
1838
|
+
readonly remainingPercent: number;
|
|
1839
|
+
}
|
|
1840
|
+
/** Map a consumable key (incl. aliases) to its CMS counter index. */
|
|
1841
|
+
declare function mowerConsumableIndex(item: string): number | null;
|
|
1842
|
+
/**
|
|
1843
|
+
* Extract the raw `[blade, brush, robot]` minute counters from a CMS getter
|
|
1844
|
+
* result, or null if the response is malformed. Cast-free, no throw.
|
|
1845
|
+
*/
|
|
1846
|
+
declare function extractMowerConsumableValues(result: unknown): number[] | null;
|
|
1847
|
+
/**
|
|
1848
|
+
* Parse a CMS getter result into typed consumable readings (blade/brush/
|
|
1849
|
+
* maintenance) with remaining %. Returns null on a malformed response.
|
|
1850
|
+
*/
|
|
1851
|
+
declare function parseMowerConsumables(result: unknown): readonly MowerConsumableReading[] | null;
|
|
1828
1852
|
|
|
1829
1853
|
/**
|
|
1830
1854
|
* Per-model mower capability records + a resolver adapting the rich record into
|
|
@@ -2063,6 +2087,27 @@ declare class MowerDevice extends BaseDevice {
|
|
|
2063
2087
|
startMowingEdges(contourIds: number[][]): Promise<unknown>;
|
|
2064
2088
|
/** Spot mowing (2:50 o:103). */
|
|
2065
2089
|
startMowingSpots(spotAreaIds: number[]): Promise<unknown>;
|
|
2090
|
+
/**
|
|
2091
|
+
* Read the raw CMS consumable counters `[blade, brush, robot]` (minutes used),
|
|
2092
|
+
* via the SCHEDULING_TASK (2:50) custom-action getter `{m:'g',t:'CMS'}`. This
|
|
2093
|
+
* is a LIVE device action (it wakes the mower); rejects with
|
|
2094
|
+
* {@link DreameDeviceOfflineError} when the mower is unreachable. Returns null
|
|
2095
|
+
* if the response is malformed.
|
|
2096
|
+
*/
|
|
2097
|
+
getConsumableValues(): Promise<readonly number[] | null>;
|
|
2098
|
+
/**
|
|
2099
|
+
* Read the CMS consumables as typed readings (blade/brush/maintenance) with
|
|
2100
|
+
* remaining %. LIVE action — see {@link getConsumableValues}. Returns null on
|
|
2101
|
+
* a malformed response.
|
|
2102
|
+
*/
|
|
2103
|
+
getConsumables(): Promise<readonly MowerConsumableReading[] | null>;
|
|
2104
|
+
/**
|
|
2105
|
+
* Reset one CMS consumable counter to zero. Reads the current counters, zeroes
|
|
2106
|
+
* the selected one (leaving the others), and writes them back via the
|
|
2107
|
+
* `{m:'s',t:'CMS',d:{value:[…]}}` setter. LIVE action. Throws on an unknown
|
|
2108
|
+
* item or when the current counters cannot be read.
|
|
2109
|
+
*/
|
|
2110
|
+
resetConsumable(item: MowerConsumableKey): Promise<void>;
|
|
2066
2111
|
/**
|
|
2067
2112
|
* Seed the cache from the CLOUD SHADOW (last-known values) WITHOUT waking the
|
|
2068
2113
|
* mower — reads {@link MowerDevice.DEFAULT_PROPS} from the cloud-cached
|
|
@@ -2448,4 +2493,4 @@ declare function createDumper(target: DumperDevice, options?: DumperOptions): Du
|
|
|
2448
2493
|
*/
|
|
2449
2494
|
declare function createClientDumper(client: Nodreame, options?: DumperOptions): Dumper[];
|
|
2450
2495
|
|
|
2451
|
-
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 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 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 };
|
|
2496
|
+
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 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 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, extractMowerConsumableValues, getMowerCapabilities, getVacuumCapabilities, isDreameConsumableKey, mowerConsumableIndex, parseMowerConsumables, 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.
|
|
3
|
+
var LIBRARY_VERSION = "1.11.0";
|
|
4
4
|
|
|
5
5
|
// src/transport/errors.ts
|
|
6
6
|
var DreameError = class extends Error {
|
|
@@ -3850,6 +3850,19 @@ function buildEdgePayload(contourIds) {
|
|
|
3850
3850
|
function buildSpotPayload(spotAreaIds) {
|
|
3851
3851
|
return { m: "a", p: 0, o: TASK_OPCODE.SPOT, d: { area: [...spotAreaIds] } };
|
|
3852
3852
|
}
|
|
3853
|
+
function buildGetConsumablePayload() {
|
|
3854
|
+
return { m: "g", t: "CMS" };
|
|
3855
|
+
}
|
|
3856
|
+
function buildSetConsumablePayload(values) {
|
|
3857
|
+
const normalized = values.map((v) => Math.trunc(v));
|
|
3858
|
+
if (normalized.length !== 3) {
|
|
3859
|
+
throw new RangeError(`CMS values must contain exactly 3 counters; got ${normalized.length}`);
|
|
3860
|
+
}
|
|
3861
|
+
if (normalized.some((v) => v < 0)) {
|
|
3862
|
+
throw new RangeError(`CMS values cannot be negative; got ${JSON.stringify(normalized)}`);
|
|
3863
|
+
}
|
|
3864
|
+
return { m: "s", t: "CMS", d: { value: normalized } };
|
|
3865
|
+
}
|
|
3853
3866
|
|
|
3854
3867
|
// src/models/mower/enums.ts
|
|
3855
3868
|
var MowerStatus = /* @__PURE__ */ ((MowerStatus2) => {
|
|
@@ -4041,6 +4054,104 @@ function parseControlStatus(value) {
|
|
|
4041
4054
|
zones
|
|
4042
4055
|
};
|
|
4043
4056
|
}
|
|
4057
|
+
var MOWER_CONSUMABLES = [
|
|
4058
|
+
{ key: "blade", index: 0, totalMinutes: 6e3 },
|
|
4059
|
+
{ key: "brush", index: 1, totalMinutes: 3e4 },
|
|
4060
|
+
{ key: "maintenance", index: 2, totalMinutes: 3600 }
|
|
4061
|
+
];
|
|
4062
|
+
function mowerConsumableIndex(item) {
|
|
4063
|
+
switch (item.trim().toLowerCase()) {
|
|
4064
|
+
case "blade":
|
|
4065
|
+
case "blades":
|
|
4066
|
+
return 0;
|
|
4067
|
+
case "brush":
|
|
4068
|
+
case "cleaning_brush":
|
|
4069
|
+
return 1;
|
|
4070
|
+
case "robot":
|
|
4071
|
+
case "maintenance":
|
|
4072
|
+
case "robot_maintenance":
|
|
4073
|
+
return 2;
|
|
4074
|
+
default:
|
|
4075
|
+
return null;
|
|
4076
|
+
}
|
|
4077
|
+
}
|
|
4078
|
+
function toInt(v) {
|
|
4079
|
+
if (typeof v === "number" && Number.isFinite(v)) {
|
|
4080
|
+
return Math.trunc(v);
|
|
4081
|
+
}
|
|
4082
|
+
if (typeof v === "string") {
|
|
4083
|
+
const n = Number(v);
|
|
4084
|
+
return Number.isFinite(n) ? Math.trunc(n) : null;
|
|
4085
|
+
}
|
|
4086
|
+
return null;
|
|
4087
|
+
}
|
|
4088
|
+
function extractCustomActionData(result) {
|
|
4089
|
+
if (!isRecord2(result)) {
|
|
4090
|
+
return null;
|
|
4091
|
+
}
|
|
4092
|
+
if (Array.isArray(result["value"])) {
|
|
4093
|
+
return result;
|
|
4094
|
+
}
|
|
4095
|
+
if (isRecord2(result["d"])) {
|
|
4096
|
+
return result["d"];
|
|
4097
|
+
}
|
|
4098
|
+
const out = result["out"];
|
|
4099
|
+
if (!Array.isArray(out)) {
|
|
4100
|
+
return null;
|
|
4101
|
+
}
|
|
4102
|
+
for (const entry of out) {
|
|
4103
|
+
if (!isRecord2(entry)) {
|
|
4104
|
+
continue;
|
|
4105
|
+
}
|
|
4106
|
+
const r = entry["r"];
|
|
4107
|
+
const code = entry["code"];
|
|
4108
|
+
const rError = r !== void 0 && r !== null && r !== 0;
|
|
4109
|
+
const codeError = code !== void 0 && code !== null && code !== 0;
|
|
4110
|
+
if (rError && codeError) {
|
|
4111
|
+
continue;
|
|
4112
|
+
}
|
|
4113
|
+
if (isRecord2(entry["d"])) {
|
|
4114
|
+
return entry["d"];
|
|
4115
|
+
}
|
|
4116
|
+
}
|
|
4117
|
+
return null;
|
|
4118
|
+
}
|
|
4119
|
+
function extractMowerConsumableValues(result) {
|
|
4120
|
+
const data = extractCustomActionData(result);
|
|
4121
|
+
if (data === null) {
|
|
4122
|
+
return null;
|
|
4123
|
+
}
|
|
4124
|
+
const values = data["value"];
|
|
4125
|
+
if (!Array.isArray(values) || values.length < 3) {
|
|
4126
|
+
return null;
|
|
4127
|
+
}
|
|
4128
|
+
const out = [];
|
|
4129
|
+
for (const v of values.slice(0, 3)) {
|
|
4130
|
+
const n = toInt(v);
|
|
4131
|
+
if (n === null) {
|
|
4132
|
+
return null;
|
|
4133
|
+
}
|
|
4134
|
+
out.push(n);
|
|
4135
|
+
}
|
|
4136
|
+
return out;
|
|
4137
|
+
}
|
|
4138
|
+
function parseMowerConsumables(result) {
|
|
4139
|
+
const values = extractMowerConsumableValues(result);
|
|
4140
|
+
if (values === null) {
|
|
4141
|
+
return null;
|
|
4142
|
+
}
|
|
4143
|
+
return MOWER_CONSUMABLES.map((c) => {
|
|
4144
|
+
const used = values[c.index] ?? 0;
|
|
4145
|
+
const remaining = c.totalMinutes - used;
|
|
4146
|
+
const pct = Math.max(0, Math.min(100, Math.round(remaining / c.totalMinutes * 1e3) / 10));
|
|
4147
|
+
return {
|
|
4148
|
+
key: c.key,
|
|
4149
|
+
usedMinutes: used,
|
|
4150
|
+
totalMinutes: c.totalMinutes,
|
|
4151
|
+
remainingPercent: pct
|
|
4152
|
+
};
|
|
4153
|
+
});
|
|
4154
|
+
}
|
|
4044
4155
|
|
|
4045
4156
|
// src/models/mower/capabilities.ts
|
|
4046
4157
|
var FALLBACK2 = {
|
|
@@ -4806,6 +4917,56 @@ var MowerDevice = class _MowerDevice extends BaseDevice {
|
|
|
4806
4917
|
}
|
|
4807
4918
|
return this.#sendTask(buildSpotPayload(spotAreaIds.map((s) => Math.trunc(s))));
|
|
4808
4919
|
}
|
|
4920
|
+
// -- CMS consumables ----------------------------------------------------
|
|
4921
|
+
/**
|
|
4922
|
+
* Read the raw CMS consumable counters `[blade, brush, robot]` (minutes used),
|
|
4923
|
+
* via the SCHEDULING_TASK (2:50) custom-action getter `{m:'g',t:'CMS'}`. This
|
|
4924
|
+
* is a LIVE device action (it wakes the mower); rejects with
|
|
4925
|
+
* {@link DreameDeviceOfflineError} when the mower is unreachable. Returns null
|
|
4926
|
+
* if the response is malformed.
|
|
4927
|
+
*/
|
|
4928
|
+
async getConsumableValues() {
|
|
4929
|
+
const result = await this.callAction(
|
|
4930
|
+
MOWER_PROP.SCHEDULING_TASK.siid,
|
|
4931
|
+
MOWER_PROP.SCHEDULING_TASK.piid,
|
|
4932
|
+
[buildGetConsumablePayload()]
|
|
4933
|
+
);
|
|
4934
|
+
return extractMowerConsumableValues(result);
|
|
4935
|
+
}
|
|
4936
|
+
/**
|
|
4937
|
+
* Read the CMS consumables as typed readings (blade/brush/maintenance) with
|
|
4938
|
+
* remaining %. LIVE action — see {@link getConsumableValues}. Returns null on
|
|
4939
|
+
* a malformed response.
|
|
4940
|
+
*/
|
|
4941
|
+
async getConsumables() {
|
|
4942
|
+
const result = await this.callAction(
|
|
4943
|
+
MOWER_PROP.SCHEDULING_TASK.siid,
|
|
4944
|
+
MOWER_PROP.SCHEDULING_TASK.piid,
|
|
4945
|
+
[buildGetConsumablePayload()]
|
|
4946
|
+
);
|
|
4947
|
+
return parseMowerConsumables(result);
|
|
4948
|
+
}
|
|
4949
|
+
/**
|
|
4950
|
+
* Reset one CMS consumable counter to zero. Reads the current counters, zeroes
|
|
4951
|
+
* the selected one (leaving the others), and writes them back via the
|
|
4952
|
+
* `{m:'s',t:'CMS',d:{value:[…]}}` setter. LIVE action. Throws on an unknown
|
|
4953
|
+
* item or when the current counters cannot be read.
|
|
4954
|
+
*/
|
|
4955
|
+
async resetConsumable(item) {
|
|
4956
|
+
const index = mowerConsumableIndex(item);
|
|
4957
|
+
if (index === null) {
|
|
4958
|
+
throw new DreameError(`resetConsumable: unknown consumable item "${item}"`);
|
|
4959
|
+
}
|
|
4960
|
+
const current = await this.getConsumableValues();
|
|
4961
|
+
if (current === null) {
|
|
4962
|
+
throw new DreameError("resetConsumable: failed to read current CMS counters");
|
|
4963
|
+
}
|
|
4964
|
+
const next = [...current];
|
|
4965
|
+
next[index] = 0;
|
|
4966
|
+
await this.callAction(MOWER_PROP.SCHEDULING_TASK.siid, MOWER_PROP.SCHEDULING_TASK.piid, [
|
|
4967
|
+
buildSetConsumablePayload(next)
|
|
4968
|
+
]);
|
|
4969
|
+
}
|
|
4809
4970
|
/**
|
|
4810
4971
|
* Seed the cache from the CLOUD SHADOW (last-known values) WITHOUT waking the
|
|
4811
4972
|
* mower — reads {@link MowerDevice.DEFAULT_PROPS} from the cloud-cached
|
|
@@ -5507,9 +5668,12 @@ export {
|
|
|
5507
5668
|
decodeAutoSwitchAll,
|
|
5508
5669
|
encodeAiFeatureWrite,
|
|
5509
5670
|
encodeAutoSwitchWrite,
|
|
5671
|
+
extractMowerConsumableValues,
|
|
5510
5672
|
getMowerCapabilities,
|
|
5511
5673
|
getVacuumCapabilities,
|
|
5512
5674
|
isDreameConsumableKey,
|
|
5675
|
+
mowerConsumableIndex,
|
|
5676
|
+
parseMowerConsumables,
|
|
5513
5677
|
renderMowerSvg,
|
|
5514
5678
|
renderVacuumPng,
|
|
5515
5679
|
resolveCapabilities,
|