@riddix/hamh 2.1.0-alpha.412 → 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.
@@ -166104,6 +166104,7 @@ var LevelControlServerBase = class extends FeaturedBase4 {
166104
166104
  if (this.state.maxLevel == null) {
166105
166105
  this.state.maxLevel = 254;
166106
166106
  }
166107
+ this.state.onLevel = null;
166107
166108
  logger157.debug(`initialize: calling super.initialize()`);
166108
166109
  try {
166109
166110
  await super.initialize();
@@ -172690,7 +172691,7 @@ function createCustomServiceAreaServer(customAreas) {
172690
172691
 
172691
172692
  // src/matter/endpoints/legacy/vacuum/behaviors/vacuum-rvc-run-mode-server.ts
172692
172693
  var logger181 = Logger.get("VacuumRvcRunModeServer");
172693
- function buildSupportedModes2(attributes7, includeUnnamedRooms = false) {
172694
+ function buildSupportedModes2(attributes7, includeUnnamedRooms = false, customAreas) {
172694
172695
  const modes = [
172695
172696
  {
172696
172697
  label: "Idle",
@@ -172703,16 +172704,31 @@ function buildSupportedModes2(attributes7, includeUnnamedRooms = false) {
172703
172704
  modeTags: [{ value: RvcRunMode3.ModeTag.Cleaning }]
172704
172705
  }
172705
172706
  ];
172706
- const rooms = parseVacuumRooms(attributes7, includeUnnamedRooms);
172707
- rooms.sort((a, b) => a.name.localeCompare(b.name));
172708
- for (const room of rooms) {
172709
- const modeValue = getRoomModeValue(room);
172710
- if (modeValue > 255) continue;
172711
- modes.push({
172712
- label: room.name,
172713
- mode: modeValue,
172714
- modeTags: [{ value: RvcRunMode3.ModeTag.Cleaning }]
172715
- });
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
+ }
172716
172732
  }
172717
172733
  return modes;
172718
172734
  }
@@ -172897,22 +172913,15 @@ var vacuumRvcRunModeConfig = {
172897
172913
  const homeAssistant = agent.get(HomeAssistantEntityBehavior);
172898
172914
  const entity = homeAssistant.entity;
172899
172915
  const attributes7 = entity.state.attributes;
172900
- const rooms = parseVacuumRooms(attributes7);
172901
- const numericIdFromMode = getRoomIdFromMode(roomMode);
172902
- logger181.info(
172903
- `cleanRoom called: roomMode=${roomMode}, numericIdFromMode=${numericIdFromMode}`
172904
- );
172905
- logger181.info(
172906
- `Available rooms: ${JSON.stringify(rooms.map((r) => ({ id: r.id, name: r.name, modeValue: getRoomModeValue(r) })))}`
172907
- );
172908
- const room = rooms.find((r) => getRoomModeValue(r) === roomMode);
172909
- logger181.info(
172910
- `Found room by mode match: ${room ? `${room.name} (id=${room.id})` : "none"}`
172911
- );
172916
+ logger181.info(`cleanRoom called: roomMode=${roomMode}`);
172912
172917
  const customAreas = homeAssistant.state.mapping?.customServiceAreas;
172913
- if (customAreas && customAreas.length > 0 && room) {
172914
- const area = customAreas.find((a) => a.name === room.name);
172915
- 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];
172916
172925
  logger181.info(
172917
172926
  `cleanRoom: custom service area "${area.name}" \u2192 ${area.service}`
172918
172927
  );
@@ -172923,6 +172932,12 @@ var vacuumRvcRunModeConfig = {
172923
172932
  };
172924
172933
  }
172925
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);
172926
172941
  if (room) {
172927
172942
  const commandId3 = room.originalId ?? room.id;
172928
172943
  const vacuumEntityId = entity.entity_id;
@@ -172991,11 +173006,15 @@ var vacuumRvcRunModeConfig = {
172991
173006
  return { action: "vacuum.start" };
172992
173007
  }
172993
173008
  };
172994
- function createVacuumRvcRunModeServer(attributes7, includeUnnamedRooms = false) {
173009
+ function createVacuumRvcRunModeServer(attributes7, includeUnnamedRooms = false, customAreas) {
172995
173010
  const allRooms = parseVacuumRooms(attributes7, true);
172996
173011
  const rooms = includeUnnamedRooms ? allRooms : parseVacuumRooms(attributes7, false);
172997
173012
  const filteredCount = allRooms.length - rooms.length;
172998
- const supportedModes = buildSupportedModes2(attributes7, includeUnnamedRooms);
173013
+ const supportedModes = buildSupportedModes2(
173014
+ attributes7,
173015
+ includeUnnamedRooms,
173016
+ customAreas
173017
+ );
172999
173018
  logger181.info(
173000
173019
  `Creating VacuumRvcRunModeServer with ${rooms.length} rooms, ${supportedModes.length} total modes`
173001
173020
  );
@@ -173993,11 +174012,16 @@ function VacuumDevice(homeAssistantEntity, includeOnOff = false, minimalClusters
173993
174012
  }
173994
174013
  const entityId = homeAssistantEntity.entity.entity_id;
173995
174014
  const attributes7 = homeAssistantEntity.entity.state.attributes;
174015
+ const customAreas = homeAssistantEntity.mapping?.customServiceAreas;
173996
174016
  logger186.info(
173997
174017
  `Creating vacuum endpoint for ${entityId}, mapping: ${JSON.stringify(homeAssistantEntity.mapping ?? "none")}`
173998
174018
  );
173999
174019
  let device = VacuumEndpointType.with(
174000
- createVacuumRvcRunModeServer(attributes7)
174020
+ createVacuumRvcRunModeServer(
174021
+ attributes7,
174022
+ false,
174023
+ customAreas && customAreas.length > 0 ? customAreas : void 0
174024
+ )
174001
174025
  ).set({ homeAssistantEntity });
174002
174026
  if (includeOnOff) {
174003
174027
  logger186.info(`${entityId}: Adding OnOff cluster (vacuumOnOff flag enabled)`);
@@ -174006,7 +174030,6 @@ function VacuumDevice(homeAssistantEntity, includeOnOff = false, minimalClusters
174006
174030
  if (!minimalClusters) {
174007
174031
  device = device.with(VacuumPowerSourceServer);
174008
174032
  }
174009
- const customAreas = homeAssistantEntity.mapping?.customServiceAreas;
174010
174033
  const roomEntities = homeAssistantEntity.mapping?.roomEntities;
174011
174034
  const rooms = parseVacuumRooms(attributes7);
174012
174035
  logger186.info(