@riddix/hamh 2.1.0-alpha.489 → 2.1.0-alpha.491
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/backend/cli.js
CHANGED
|
@@ -146411,6 +146411,7 @@ var init_vacuum = __esm({
|
|
|
146411
146411
|
VacuumDeviceFeature2[VacuumDeviceFeature2["MAP"] = 2048] = "MAP";
|
|
146412
146412
|
VacuumDeviceFeature2[VacuumDeviceFeature2["STATE"] = 4096] = "STATE";
|
|
146413
146413
|
VacuumDeviceFeature2[VacuumDeviceFeature2["START"] = 8192] = "START";
|
|
146414
|
+
VacuumDeviceFeature2[VacuumDeviceFeature2["CLEAN_AREA"] = 16384] = "CLEAN_AREA";
|
|
146414
146415
|
})(VacuumDeviceFeature || (VacuumDeviceFeature = {}));
|
|
146415
146416
|
(function(VacuumFanSpeed2) {
|
|
146416
146417
|
VacuumFanSpeed2["off"] = "off";
|
|
@@ -149283,6 +149284,9 @@ function testMatchers(matchers, device, entity, mode = "any", entityState, label
|
|
|
149283
149284
|
);
|
|
149284
149285
|
}
|
|
149285
149286
|
function testMatcher(matcher, device, entity, entityState, labels) {
|
|
149287
|
+
if (matcher.value == null) {
|
|
149288
|
+
return false;
|
|
149289
|
+
}
|
|
149286
149290
|
switch (matcher.type) {
|
|
149287
149291
|
case "domain":
|
|
149288
149292
|
return entity.entity_id.split(".")[0] === matcher.value;
|
|
@@ -175703,6 +175707,28 @@ function createCustomServiceAreaServer(customAreas) {
|
|
|
175703
175707
|
currentArea: null
|
|
175704
175708
|
});
|
|
175705
175709
|
}
|
|
175710
|
+
function createCleanAreaServiceAreaServer(cleanAreaRooms) {
|
|
175711
|
+
const supportedAreas = cleanAreaRooms.map((room) => ({
|
|
175712
|
+
areaId: room.areaId,
|
|
175713
|
+
mapId: null,
|
|
175714
|
+
areaInfo: {
|
|
175715
|
+
locationInfo: {
|
|
175716
|
+
locationName: room.name,
|
|
175717
|
+
floorNumber: null,
|
|
175718
|
+
areaType: null
|
|
175719
|
+
},
|
|
175720
|
+
landmarkInfo: null
|
|
175721
|
+
}
|
|
175722
|
+
}));
|
|
175723
|
+
logger190.info(
|
|
175724
|
+
`Using ${cleanAreaRooms.length} HA areas via CLEAN_AREA: ${cleanAreaRooms.map((r) => r.name).join(", ")}`
|
|
175725
|
+
);
|
|
175726
|
+
return ServiceAreaServer2({
|
|
175727
|
+
supportedAreas,
|
|
175728
|
+
selectedAreas: [],
|
|
175729
|
+
currentArea: null
|
|
175730
|
+
});
|
|
175731
|
+
}
|
|
175706
175732
|
|
|
175707
175733
|
// src/matter/endpoints/legacy/vacuum/behaviors/vacuum-rvc-run-mode-server.ts
|
|
175708
175734
|
var logger191 = Logger.get("VacuumRvcRunModeServer");
|
|
@@ -175774,6 +175800,16 @@ function handleCustomServiceAreas(selectedAreas, customAreas, homeAssistant, ser
|
|
|
175774
175800
|
data: first.data
|
|
175775
175801
|
};
|
|
175776
175802
|
}
|
|
175803
|
+
function resolveCleanAreaIds(selectedAreas, cleanAreaRooms) {
|
|
175804
|
+
const haAreaIds = [];
|
|
175805
|
+
for (const areaId of selectedAreas) {
|
|
175806
|
+
const room = cleanAreaRooms.find((r) => r.areaId === areaId);
|
|
175807
|
+
if (room) {
|
|
175808
|
+
haAreaIds.push(room.haAreaId);
|
|
175809
|
+
}
|
|
175810
|
+
}
|
|
175811
|
+
return haAreaIds;
|
|
175812
|
+
}
|
|
175777
175813
|
var vacuumRvcRunModeConfig = {
|
|
175778
175814
|
getCurrentMode: (entity) => {
|
|
175779
175815
|
const state = entity.state;
|
|
@@ -175812,6 +175848,20 @@ var vacuumRvcRunModeConfig = {
|
|
|
175812
175848
|
serviceArea
|
|
175813
175849
|
);
|
|
175814
175850
|
}
|
|
175851
|
+
const cleanAreaRooms = homeAssistant.state.mapping?.cleanAreaRooms;
|
|
175852
|
+
if (cleanAreaRooms && cleanAreaRooms.length > 0) {
|
|
175853
|
+
const haAreaIds = resolveCleanAreaIds(selectedAreas, cleanAreaRooms);
|
|
175854
|
+
serviceArea.state.selectedAreas = [];
|
|
175855
|
+
if (haAreaIds.length > 0) {
|
|
175856
|
+
logger191.info(
|
|
175857
|
+
`CLEAN_AREA: cleaning HA areas: ${haAreaIds.join(", ")}`
|
|
175858
|
+
);
|
|
175859
|
+
return {
|
|
175860
|
+
action: "vacuum.clean_area",
|
|
175861
|
+
data: { cleaning_area_id: haAreaIds }
|
|
175862
|
+
};
|
|
175863
|
+
}
|
|
175864
|
+
}
|
|
175815
175865
|
const roomEntities = homeAssistant.state.mapping?.roomEntities;
|
|
175816
175866
|
if (roomEntities && roomEntities.length > 0) {
|
|
175817
175867
|
const buttonEntityIds = [];
|
|
@@ -175945,6 +175995,23 @@ var vacuumRvcRunModeConfig = {
|
|
|
175945
175995
|
const entity = homeAssistant.entity;
|
|
175946
175996
|
const attributes7 = entity.state.attributes;
|
|
175947
175997
|
logger191.info(`cleanRoom called: roomMode=${roomMode}`);
|
|
175998
|
+
const cleanAreaRooms = homeAssistant.state.mapping?.cleanAreaRooms;
|
|
175999
|
+
if (cleanAreaRooms && cleanAreaRooms.length > 0) {
|
|
176000
|
+
const sorted = [...cleanAreaRooms].sort(
|
|
176001
|
+
(a, b) => a.name.localeCompare(b.name)
|
|
176002
|
+
);
|
|
176003
|
+
const areaIndex = roomMode - ROOM_MODE_BASE2 - 1;
|
|
176004
|
+
if (areaIndex >= 0 && areaIndex < sorted.length) {
|
|
176005
|
+
const area = sorted[areaIndex];
|
|
176006
|
+
logger191.info(
|
|
176007
|
+
`cleanRoom: CLEAN_AREA "${area.name}" \u2192 vacuum.clean_area(${area.haAreaId})`
|
|
176008
|
+
);
|
|
176009
|
+
return {
|
|
176010
|
+
action: "vacuum.clean_area",
|
|
176011
|
+
data: { cleaning_area_id: [area.haAreaId] }
|
|
176012
|
+
};
|
|
176013
|
+
}
|
|
176014
|
+
}
|
|
175948
176015
|
const customAreas = homeAssistant.state.mapping?.customServiceAreas;
|
|
175949
176016
|
if (customAreas && customAreas.length > 0) {
|
|
175950
176017
|
const sorted = [...customAreas].sort(
|
|
@@ -176080,6 +176147,39 @@ function createVacuumRvcRunModeServer(attributes7, includeUnnamedRooms = false,
|
|
|
176080
176147
|
currentMode: 0 /* Idle */
|
|
176081
176148
|
});
|
|
176082
176149
|
}
|
|
176150
|
+
function createCleanAreaRvcRunModeServer(cleanAreaRooms) {
|
|
176151
|
+
const modes = [
|
|
176152
|
+
{
|
|
176153
|
+
label: "Idle",
|
|
176154
|
+
mode: 0 /* Idle */,
|
|
176155
|
+
modeTags: [{ value: RvcRunMode3.ModeTag.Idle }]
|
|
176156
|
+
},
|
|
176157
|
+
{
|
|
176158
|
+
label: "Cleaning",
|
|
176159
|
+
mode: 1 /* Cleaning */,
|
|
176160
|
+
modeTags: [{ value: RvcRunMode3.ModeTag.Cleaning }]
|
|
176161
|
+
}
|
|
176162
|
+
];
|
|
176163
|
+
const sorted = [...cleanAreaRooms].sort(
|
|
176164
|
+
(a, b) => a.name.localeCompare(b.name)
|
|
176165
|
+
);
|
|
176166
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
176167
|
+
const modeValue = ROOM_MODE_BASE2 + i + 1;
|
|
176168
|
+
if (modeValue > 255) continue;
|
|
176169
|
+
modes.push({
|
|
176170
|
+
label: sorted[i].name,
|
|
176171
|
+
mode: modeValue,
|
|
176172
|
+
modeTags: [{ value: RvcRunMode3.ModeTag.Cleaning }]
|
|
176173
|
+
});
|
|
176174
|
+
}
|
|
176175
|
+
logger191.info(
|
|
176176
|
+
`Creating CLEAN_AREA RvcRunModeServer with ${cleanAreaRooms.length} HA areas, ${modes.length} total modes`
|
|
176177
|
+
);
|
|
176178
|
+
return RvcRunModeServer2(vacuumRvcRunModeConfig, {
|
|
176179
|
+
supportedModes: modes,
|
|
176180
|
+
currentMode: 0 /* Idle */
|
|
176181
|
+
});
|
|
176182
|
+
}
|
|
176083
176183
|
var VacuumRvcRunModeServer = RvcRunModeServer2(vacuumRvcRunModeConfig);
|
|
176084
176184
|
|
|
176085
176185
|
// src/matter/endpoints/legacy/vacuum/behaviors/vacuum-on-off-server.ts
|
|
@@ -177077,8 +177177,9 @@ function VacuumDevice(homeAssistantEntity, includeOnOff = false, cleaningModeOpt
|
|
|
177077
177177
|
logger196.info(
|
|
177078
177178
|
`Creating vacuum endpoint for ${entityId}, mapping: ${JSON.stringify(homeAssistantEntity.mapping ?? "none")}`
|
|
177079
177179
|
);
|
|
177180
|
+
const cleanAreaRooms = homeAssistantEntity.mapping?.cleanAreaRooms;
|
|
177080
177181
|
let device = VacuumEndpointType.with(
|
|
177081
|
-
createVacuumRvcRunModeServer(
|
|
177182
|
+
cleanAreaRooms && cleanAreaRooms.length > 0 ? createCleanAreaRvcRunModeServer(cleanAreaRooms) : createVacuumRvcRunModeServer(
|
|
177082
177183
|
attributes7,
|
|
177083
177184
|
false,
|
|
177084
177185
|
customAreas && customAreas.length > 0 ? customAreas : void 0
|
|
@@ -177092,9 +177193,14 @@ function VacuumDevice(homeAssistantEntity, includeOnOff = false, cleaningModeOpt
|
|
|
177092
177193
|
const roomEntities = homeAssistantEntity.mapping?.roomEntities;
|
|
177093
177194
|
const rooms = parseVacuumRooms(attributes7);
|
|
177094
177195
|
logger196.info(
|
|
177095
|
-
`${entityId}: customAreas=${customAreas?.length ?? 0}, roomEntities=${JSON.stringify(roomEntities ?? [])}, parsedRooms=${rooms.length}`
|
|
177196
|
+
`${entityId}: customAreas=${customAreas?.length ?? 0}, roomEntities=${JSON.stringify(roomEntities ?? [])}, parsedRooms=${rooms.length}, cleanAreaRooms=${cleanAreaRooms?.length ?? 0}`
|
|
177096
177197
|
);
|
|
177097
|
-
if (
|
|
177198
|
+
if (cleanAreaRooms && cleanAreaRooms.length > 0) {
|
|
177199
|
+
logger196.info(
|
|
177200
|
+
`${entityId}: Adding ServiceArea (${cleanAreaRooms.length} HA areas via CLEAN_AREA)`
|
|
177201
|
+
);
|
|
177202
|
+
device = device.with(createCleanAreaServiceAreaServer(cleanAreaRooms));
|
|
177203
|
+
} else if (customAreas && customAreas.length > 0) {
|
|
177098
177204
|
logger196.info(
|
|
177099
177205
|
`${entityId}: Adding ServiceArea (${customAreas.length} custom areas)`
|
|
177100
177206
|
);
|
|
@@ -177653,8 +177759,23 @@ var LegacyEndpoint = class _LegacyEndpoint extends EntityEndpoint {
|
|
|
177653
177759
|
`Auto-assigned mopIntensity ${vacuumEntities.mopIntensityEntity} to ${entityId}`
|
|
177654
177760
|
);
|
|
177655
177761
|
}
|
|
177762
|
+
const supportedFeatures = state.attributes.supported_features ?? 0;
|
|
177763
|
+
const cleanAreaRooms = await registry2.resolveCleanAreaRooms(
|
|
177764
|
+
entityId,
|
|
177765
|
+
supportedFeatures
|
|
177766
|
+
);
|
|
177767
|
+
if (cleanAreaRooms.length > 0) {
|
|
177768
|
+
effectiveMapping = {
|
|
177769
|
+
...effectiveMapping,
|
|
177770
|
+
entityId: effectiveMapping?.entityId ?? entityId,
|
|
177771
|
+
cleanAreaRooms
|
|
177772
|
+
};
|
|
177773
|
+
logger198.debug(
|
|
177774
|
+
`Using ${cleanAreaRooms.length} HA areas via CLEAN_AREA for ${entityId}`
|
|
177775
|
+
);
|
|
177776
|
+
}
|
|
177656
177777
|
const vacAttrs = state.attributes;
|
|
177657
|
-
if (!vacAttrs.rooms && !vacAttrs.segments && !vacAttrs.room_mapping) {
|
|
177778
|
+
if (cleanAreaRooms.length === 0 && !vacAttrs.rooms && !vacAttrs.segments && !vacAttrs.room_mapping) {
|
|
177658
177779
|
const valetudoRooms = registry2.findValetudoMapSegments(
|
|
177659
177780
|
entity.device_id
|
|
177660
177781
|
);
|
|
@@ -178850,6 +178971,54 @@ var BridgeRegistry = class _BridgeRegistry {
|
|
|
178850
178971
|
return [];
|
|
178851
178972
|
}
|
|
178852
178973
|
}
|
|
178974
|
+
static cleanAreaLogger = Logger.get("CleanAreaRooms");
|
|
178975
|
+
/**
|
|
178976
|
+
* Resolve HA areas mapped to vacuum segments via HA 2026.3 CLEAN_AREA.
|
|
178977
|
+
* Fetches the full entity registry entry (including options.vacuum.area_mapping)
|
|
178978
|
+
* and resolves HA area names from the area registry.
|
|
178979
|
+
* Returns CleanAreaRoom[] sorted alphabetically, or empty array if
|
|
178980
|
+
* CLEAN_AREA is not supported or no area_mapping is configured.
|
|
178981
|
+
*/
|
|
178982
|
+
async resolveCleanAreaRooms(entityId, supportedFeatures) {
|
|
178983
|
+
if (!this.client) return [];
|
|
178984
|
+
if (!(supportedFeatures & VacuumDeviceFeature.CLEAN_AREA)) return [];
|
|
178985
|
+
try {
|
|
178986
|
+
const entry = await this.client.connection.sendMessagePromise({
|
|
178987
|
+
type: "config/entity_registry/get",
|
|
178988
|
+
entity_id: entityId
|
|
178989
|
+
});
|
|
178990
|
+
const vacuumOptions = entry?.options?.vacuum;
|
|
178991
|
+
const areaMapping = vacuumOptions?.area_mapping;
|
|
178992
|
+
if (!areaMapping || Object.keys(areaMapping).length === 0) {
|
|
178993
|
+
_BridgeRegistry.cleanAreaLogger.debug(
|
|
178994
|
+
`${entityId}: CLEAN_AREA supported but no area_mapping configured`
|
|
178995
|
+
);
|
|
178996
|
+
return [];
|
|
178997
|
+
}
|
|
178998
|
+
const rooms = [];
|
|
178999
|
+
for (const haAreaId of Object.keys(areaMapping)) {
|
|
179000
|
+
const areaName = this.registry.areas.get(haAreaId) ?? haAreaId;
|
|
179001
|
+
rooms.push({
|
|
179002
|
+
areaId: hashAreaId(haAreaId),
|
|
179003
|
+
haAreaId,
|
|
179004
|
+
name: areaName
|
|
179005
|
+
});
|
|
179006
|
+
}
|
|
179007
|
+
rooms.sort((a, b) => a.name.localeCompare(b.name));
|
|
179008
|
+
if (rooms.length > 0) {
|
|
179009
|
+
_BridgeRegistry.cleanAreaLogger.info(
|
|
179010
|
+
`${entityId}: Resolved ${rooms.length} HA areas via CLEAN_AREA mapping`
|
|
179011
|
+
);
|
|
179012
|
+
}
|
|
179013
|
+
return rooms;
|
|
179014
|
+
} catch (error) {
|
|
179015
|
+
const msg = error instanceof Error ? error.message : typeof error === "object" && error !== null ? JSON.stringify(error) : String(error);
|
|
179016
|
+
_BridgeRegistry.cleanAreaLogger.warn(
|
|
179017
|
+
`${entityId}: Failed to resolve CLEAN_AREA mapping: ${msg}`
|
|
179018
|
+
);
|
|
179019
|
+
return [];
|
|
179020
|
+
}
|
|
179021
|
+
}
|
|
178853
179022
|
/**
|
|
178854
179023
|
* Find a pressure sensor entity that belongs to the same HA device.
|
|
178855
179024
|
* Returns the entity_id of the pressure sensor, or undefined if none found.
|
|
@@ -179080,6 +179249,15 @@ var BridgeRegistry = class _BridgeRegistry {
|
|
|
179080
179249
|
return true;
|
|
179081
179250
|
}
|
|
179082
179251
|
};
|
|
179252
|
+
function hashAreaId(areaId) {
|
|
179253
|
+
let hash2 = 0;
|
|
179254
|
+
for (let i = 0; i < areaId.length; i++) {
|
|
179255
|
+
const char = areaId.charCodeAt(i);
|
|
179256
|
+
hash2 = (hash2 << 5) - hash2 + char;
|
|
179257
|
+
hash2 |= 0;
|
|
179258
|
+
}
|
|
179259
|
+
return Math.abs(hash2);
|
|
179260
|
+
}
|
|
179083
179261
|
|
|
179084
179262
|
// src/services/bridges/server-mode-bridge.ts
|
|
179085
179263
|
init_dist();
|
|
@@ -179455,17 +179633,24 @@ function ServerModeVacuumDevice(homeAssistantEntity, includeOnOff = false, clean
|
|
|
179455
179633
|
return void 0;
|
|
179456
179634
|
}
|
|
179457
179635
|
const attributes7 = homeAssistantEntity.entity.state.attributes;
|
|
179636
|
+
const cleanAreaRooms = homeAssistantEntity.mapping?.cleanAreaRooms;
|
|
179637
|
+
const customAreas = homeAssistantEntity.mapping?.customServiceAreas;
|
|
179458
179638
|
let device = ServerModeVacuumEndpointType.with(
|
|
179459
|
-
createVacuumRvcRunModeServer(
|
|
179639
|
+
cleanAreaRooms && cleanAreaRooms.length > 0 ? createCleanAreaRvcRunModeServer(cleanAreaRooms) : createVacuumRvcRunModeServer(
|
|
179640
|
+
attributes7,
|
|
179641
|
+
false,
|
|
179642
|
+
customAreas && customAreas.length > 0 ? customAreas : void 0
|
|
179643
|
+
)
|
|
179460
179644
|
).set({ homeAssistantEntity });
|
|
179461
179645
|
if (includeOnOff) {
|
|
179462
179646
|
device = device.with(VacuumOnOffServer);
|
|
179463
179647
|
}
|
|
179464
179648
|
device = device.with(VacuumPowerSourceServer);
|
|
179465
|
-
const customAreas = homeAssistantEntity.mapping?.customServiceAreas;
|
|
179466
179649
|
const roomEntities = homeAssistantEntity.mapping?.roomEntities;
|
|
179467
179650
|
const rooms = parseVacuumRooms(attributes7);
|
|
179468
|
-
if (
|
|
179651
|
+
if (cleanAreaRooms && cleanAreaRooms.length > 0) {
|
|
179652
|
+
device = device.with(createCleanAreaServiceAreaServer(cleanAreaRooms));
|
|
179653
|
+
} else if (customAreas && customAreas.length > 0) {
|
|
179469
179654
|
device = device.with(createCustomServiceAreaServer(customAreas));
|
|
179470
179655
|
} else if (rooms.length > 0 || roomEntities && roomEntities.length > 0) {
|
|
179471
179656
|
device = device.with(
|
|
@@ -179563,8 +179748,23 @@ var ServerModeVacuumEndpoint = class _ServerModeVacuumEndpoint extends EntityEnd
|
|
|
179563
179748
|
`${entityId}: Auto-assigned mopIntensity ${vacuumEntities.mopIntensityEntity}`
|
|
179564
179749
|
);
|
|
179565
179750
|
}
|
|
179751
|
+
const supportedFeatures = state.attributes.supported_features ?? 0;
|
|
179752
|
+
const cleanAreaRooms = await registry2.resolveCleanAreaRooms(
|
|
179753
|
+
entityId,
|
|
179754
|
+
supportedFeatures
|
|
179755
|
+
);
|
|
179756
|
+
if (cleanAreaRooms.length > 0) {
|
|
179757
|
+
effectiveMapping = {
|
|
179758
|
+
...effectiveMapping,
|
|
179759
|
+
entityId: effectiveMapping?.entityId ?? entityId,
|
|
179760
|
+
cleanAreaRooms
|
|
179761
|
+
};
|
|
179762
|
+
logger201.info(
|
|
179763
|
+
`${entityId}: Using ${cleanAreaRooms.length} HA areas via CLEAN_AREA`
|
|
179764
|
+
);
|
|
179765
|
+
}
|
|
179566
179766
|
const vacAttrs = state.attributes;
|
|
179567
|
-
if (!vacAttrs.rooms && !vacAttrs.segments && !vacAttrs.room_mapping) {
|
|
179767
|
+
if (cleanAreaRooms.length === 0 && !vacAttrs.rooms && !vacAttrs.segments && !vacAttrs.room_mapping) {
|
|
179568
179768
|
const valetudoRooms = registry2.findValetudoMapSegments(
|
|
179569
179769
|
entity.device_id
|
|
179570
179770
|
);
|