@riddix/hamh 2.1.0-alpha.413 → 2.1.0-alpha.414

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.
@@ -172691,7 +172691,7 @@ function createCustomServiceAreaServer(customAreas) {
172691
172691
 
172692
172692
  // src/matter/endpoints/legacy/vacuum/behaviors/vacuum-rvc-run-mode-server.ts
172693
172693
  var logger181 = Logger.get("VacuumRvcRunModeServer");
172694
- function buildSupportedModes2(attributes7, includeUnnamedRooms = false) {
172694
+ function buildSupportedModes2(attributes7, includeUnnamedRooms = false, customAreas) {
172695
172695
  const modes = [
172696
172696
  {
172697
172697
  label: "Idle",
@@ -172704,16 +172704,31 @@ function buildSupportedModes2(attributes7, includeUnnamedRooms = false) {
172704
172704
  modeTags: [{ value: RvcRunMode3.ModeTag.Cleaning }]
172705
172705
  }
172706
172706
  ];
172707
- const rooms = parseVacuumRooms(attributes7, includeUnnamedRooms);
172708
- rooms.sort((a, b) => a.name.localeCompare(b.name));
172709
- for (const room of rooms) {
172710
- const modeValue = getRoomModeValue(room);
172711
- if (modeValue > 255) continue;
172712
- modes.push({
172713
- label: room.name,
172714
- mode: modeValue,
172715
- modeTags: [{ value: RvcRunMode3.ModeTag.Cleaning }]
172716
- });
172707
+ if (customAreas && customAreas.length > 0) {
172708
+ const sorted = [...customAreas].sort(
172709
+ (a, b) => a.name.localeCompare(b.name)
172710
+ );
172711
+ for (let i = 0; i < sorted.length; i++) {
172712
+ const modeValue = ROOM_MODE_BASE2 + i + 1;
172713
+ if (modeValue > 255) continue;
172714
+ modes.push({
172715
+ label: sorted[i].name,
172716
+ mode: modeValue,
172717
+ modeTags: [{ value: RvcRunMode3.ModeTag.Cleaning }]
172718
+ });
172719
+ }
172720
+ } else {
172721
+ const rooms = parseVacuumRooms(attributes7, includeUnnamedRooms);
172722
+ rooms.sort((a, b) => a.name.localeCompare(b.name));
172723
+ for (const room of rooms) {
172724
+ const modeValue = getRoomModeValue(room);
172725
+ if (modeValue > 255) continue;
172726
+ modes.push({
172727
+ label: room.name,
172728
+ mode: modeValue,
172729
+ modeTags: [{ value: RvcRunMode3.ModeTag.Cleaning }]
172730
+ });
172731
+ }
172717
172732
  }
172718
172733
  return modes;
172719
172734
  }
@@ -172898,22 +172913,15 @@ var vacuumRvcRunModeConfig = {
172898
172913
  const homeAssistant = agent.get(HomeAssistantEntityBehavior);
172899
172914
  const entity = homeAssistant.entity;
172900
172915
  const attributes7 = entity.state.attributes;
172901
- const rooms = parseVacuumRooms(attributes7);
172902
- const numericIdFromMode = getRoomIdFromMode(roomMode);
172903
- logger181.info(
172904
- `cleanRoom called: roomMode=${roomMode}, numericIdFromMode=${numericIdFromMode}`
172905
- );
172906
- logger181.info(
172907
- `Available rooms: ${JSON.stringify(rooms.map((r) => ({ id: r.id, name: r.name, modeValue: getRoomModeValue(r) })))}`
172908
- );
172909
- const room = rooms.find((r) => getRoomModeValue(r) === roomMode);
172910
- logger181.info(
172911
- `Found room by mode match: ${room ? `${room.name} (id=${room.id})` : "none"}`
172912
- );
172916
+ logger181.info(`cleanRoom called: roomMode=${roomMode}`);
172913
172917
  const customAreas = homeAssistant.state.mapping?.customServiceAreas;
172914
- if (customAreas && customAreas.length > 0 && room) {
172915
- const area = customAreas.find((a) => a.name === room.name);
172916
- if (area) {
172918
+ if (customAreas && customAreas.length > 0) {
172919
+ const sorted = [...customAreas].sort(
172920
+ (a, b) => a.name.localeCompare(b.name)
172921
+ );
172922
+ const areaIndex = roomMode - ROOM_MODE_BASE2 - 1;
172923
+ if (areaIndex >= 0 && areaIndex < sorted.length) {
172924
+ const area = sorted[areaIndex];
172917
172925
  logger181.info(
172918
172926
  `cleanRoom: custom service area "${area.name}" \u2192 ${area.service}`
172919
172927
  );
@@ -172924,6 +172932,12 @@ var vacuumRvcRunModeConfig = {
172924
172932
  };
172925
172933
  }
172926
172934
  }
172935
+ const rooms = parseVacuumRooms(attributes7);
172936
+ const numericIdFromMode = getRoomIdFromMode(roomMode);
172937
+ logger181.info(
172938
+ `cleanRoom: numericIdFromMode=${numericIdFromMode}, available rooms: ${JSON.stringify(rooms.map((r) => ({ id: r.id, name: r.name, modeValue: getRoomModeValue(r) })))}`
172939
+ );
172940
+ const room = rooms.find((r) => getRoomModeValue(r) === roomMode);
172927
172941
  if (room) {
172928
172942
  const commandId3 = room.originalId ?? room.id;
172929
172943
  const vacuumEntityId = entity.entity_id;
@@ -172992,11 +173006,15 @@ var vacuumRvcRunModeConfig = {
172992
173006
  return { action: "vacuum.start" };
172993
173007
  }
172994
173008
  };
172995
- function createVacuumRvcRunModeServer(attributes7, includeUnnamedRooms = false) {
173009
+ function createVacuumRvcRunModeServer(attributes7, includeUnnamedRooms = false, customAreas) {
172996
173010
  const allRooms = parseVacuumRooms(attributes7, true);
172997
173011
  const rooms = includeUnnamedRooms ? allRooms : parseVacuumRooms(attributes7, false);
172998
173012
  const filteredCount = allRooms.length - rooms.length;
172999
- const supportedModes = buildSupportedModes2(attributes7, includeUnnamedRooms);
173013
+ const supportedModes = buildSupportedModes2(
173014
+ attributes7,
173015
+ includeUnnamedRooms,
173016
+ customAreas
173017
+ );
173000
173018
  logger181.info(
173001
173019
  `Creating VacuumRvcRunModeServer with ${rooms.length} rooms, ${supportedModes.length} total modes`
173002
173020
  );
@@ -173994,11 +174012,16 @@ function VacuumDevice(homeAssistantEntity, includeOnOff = false, minimalClusters
173994
174012
  }
173995
174013
  const entityId = homeAssistantEntity.entity.entity_id;
173996
174014
  const attributes7 = homeAssistantEntity.entity.state.attributes;
174015
+ const customAreas = homeAssistantEntity.mapping?.customServiceAreas;
173997
174016
  logger186.info(
173998
174017
  `Creating vacuum endpoint for ${entityId}, mapping: ${JSON.stringify(homeAssistantEntity.mapping ?? "none")}`
173999
174018
  );
174000
174019
  let device = VacuumEndpointType.with(
174001
- createVacuumRvcRunModeServer(attributes7)
174020
+ createVacuumRvcRunModeServer(
174021
+ attributes7,
174022
+ false,
174023
+ customAreas && customAreas.length > 0 ? customAreas : void 0
174024
+ )
174002
174025
  ).set({ homeAssistantEntity });
174003
174026
  if (includeOnOff) {
174004
174027
  logger186.info(`${entityId}: Adding OnOff cluster (vacuumOnOff flag enabled)`);
@@ -174007,7 +174030,6 @@ function VacuumDevice(homeAssistantEntity, includeOnOff = false, minimalClusters
174007
174030
  if (!minimalClusters) {
174008
174031
  device = device.with(VacuumPowerSourceServer);
174009
174032
  }
174010
- const customAreas = homeAssistantEntity.mapping?.customServiceAreas;
174011
174033
  const roomEntities = homeAssistantEntity.mapping?.roomEntities;
174012
174034
  const rooms = parseVacuumRooms(attributes7);
174013
174035
  logger186.info(