@riddix/hamh 2.1.0-alpha.766 → 2.1.0-alpha.768

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.
@@ -126316,6 +126316,7 @@ WARNING: ${includeIdentity ? "This backup contains sensitive Matter identity dat
126316
126316
  climateAutoMode: config11.climateAutoMode,
126317
126317
  customServiceAreas: config11.customServiceAreas,
126318
126318
  customFanSpeedTags: config11.customFanSpeedTags,
126319
+ fanWindPresets: config11.fanWindPresets,
126319
126320
  composedEntities: config11.composedEntities
126320
126321
  });
126321
126322
  mappingsRestored++;
@@ -126466,6 +126467,7 @@ WARNING: ${includeIdentity ? "This backup contains sensitive Matter identity dat
126466
126467
  climateAutoMode: config11.climateAutoMode,
126467
126468
  customServiceAreas: config11.customServiceAreas,
126468
126469
  customFanSpeedTags: config11.customFanSpeedTags,
126470
+ fanWindPresets: config11.fanWindPresets,
126469
126471
  composedEntities: config11.composedEntities
126470
126472
  });
126471
126473
  mappingsRestored++;
@@ -127300,6 +127302,7 @@ function entityMappingApi(mappingStorage) {
127300
127302
  mopIntensityEntity: body.mopIntensityEntity,
127301
127303
  customServiceAreas: body.customServiceAreas,
127302
127304
  customFanSpeedTags: body.customFanSpeedTags,
127305
+ fanWindPresets: body.fanWindPresets,
127303
127306
  currentRoomEntity: body.currentRoomEntity,
127304
127307
  cleanedAreaEntity: body.cleanedAreaEntity,
127305
127308
  disableCustomAreaRoomModes: body.disableCustomAreaRoomModes,
@@ -127785,6 +127788,7 @@ function configToProfileEntry(config11) {
127785
127788
  mopIntensityEntity: config11.mopIntensityEntity,
127786
127789
  customServiceAreas: config11.customServiceAreas,
127787
127790
  customFanSpeedTags: config11.customFanSpeedTags,
127791
+ fanWindPresets: config11.fanWindPresets,
127788
127792
  valetudoIdentifier: config11.valetudoIdentifier,
127789
127793
  coverSwapOpenClose: config11.coverSwapOpenClose,
127790
127794
  coverSliderDebounceMs: config11.coverSliderDebounceMs,
@@ -127912,6 +127916,7 @@ function mappingProfileApi(mappingStorage) {
127912
127916
  mopIntensityEntity: entry.mopIntensityEntity,
127913
127917
  customServiceAreas: entry.customServiceAreas,
127914
127918
  customFanSpeedTags: entry.customFanSpeedTags,
127919
+ fanWindPresets: entry.fanWindPresets,
127915
127920
  valetudoIdentifier: entry.valetudoIdentifier,
127916
127921
  coverSwapOpenClose: entry.coverSwapOpenClose,
127917
127922
  coverSliderDebounceMs: entry.coverSliderDebounceMs,
@@ -132068,6 +132073,7 @@ var EntityMappingStorage = class extends Service {
132068
132073
  (a) => a.name?.trim() && a.service?.trim()
132069
132074
  ) ?? void 0,
132070
132075
  customFanSpeedTags: request.customFanSpeedTags && Object.keys(request.customFanSpeedTags).length > 0 ? request.customFanSpeedTags : void 0,
132076
+ fanWindPresets: request.fanWindPresets && ((request.fanWindPresets.natural?.length ?? 0) > 0 || (request.fanWindPresets.sleep?.length ?? 0) > 0) ? request.fanWindPresets : void 0,
132071
132077
  currentRoomEntity: request.currentRoomEntity?.trim() || void 0,
132072
132078
  cleanedAreaEntity: request.cleanedAreaEntity?.trim() || void 0,
132073
132079
  disableCustomAreaRoomModes: request.disableCustomAreaRoomModes || void 0,
@@ -132083,7 +132089,7 @@ var EntityMappingStorage = class extends Service {
132083
132089
  climateAutoMode: request.climateAutoMode || void 0,
132084
132090
  composedEntities: request.composedEntities?.filter((e) => e.entityId?.trim()) ?? void 0
132085
132091
  };
132086
- if (!config11.matterDeviceType && !config11.customName && !config11.customProductName && !config11.customVendorName && !config11.customSerialNumber && config11.customVendorId === void 0 && config11.disabled !== true && !config11.filterLifeEntity && !config11.cleaningModeEntity && !config11.temperatureEntity && !config11.humidityEntity && !config11.batteryEntity && !config11.chargingStateEntity && !config11.roomEntities && !config11.disableLockPin && !config11.powerEntity && !config11.energyEntity && !config11.pressureEntity && !config11.suctionLevelEntity && !config11.mopIntensityEntity && (!config11.customServiceAreas || config11.customServiceAreas.length === 0) && (!config11.customFanSpeedTags || Object.keys(config11.customFanSpeedTags).length === 0) && !config11.currentRoomEntity && !config11.cleanedAreaEntity && !config11.disableCustomAreaRoomModes && !config11.valetudoIdentifier && !config11.coverSwapOpenClose && !config11.coverExposeAsDimmableLight && !config11.coverSliderDebounceMs && !config11.updateThrottleMs && !config11.disableClimateOnOff && !config11.disableClimateFanControl && !config11.climateKeepModeOnIdle && !config11.climateExposeFan && !config11.climateAutoMode && (!config11.composedEntities || config11.composedEntities.length === 0)) {
132092
+ if (!config11.matterDeviceType && !config11.customName && !config11.customProductName && !config11.customVendorName && !config11.customSerialNumber && config11.customVendorId === void 0 && config11.disabled !== true && !config11.filterLifeEntity && !config11.cleaningModeEntity && !config11.temperatureEntity && !config11.humidityEntity && !config11.batteryEntity && !config11.chargingStateEntity && !config11.roomEntities && !config11.disableLockPin && !config11.powerEntity && !config11.energyEntity && !config11.pressureEntity && !config11.suctionLevelEntity && !config11.mopIntensityEntity && (!config11.customServiceAreas || config11.customServiceAreas.length === 0) && (!config11.customFanSpeedTags || Object.keys(config11.customFanSpeedTags).length === 0) && (!config11.fanWindPresets || (config11.fanWindPresets.natural?.length ?? 0) === 0 && (config11.fanWindPresets.sleep?.length ?? 0) === 0) && !config11.currentRoomEntity && !config11.cleanedAreaEntity && !config11.disableCustomAreaRoomModes && !config11.valetudoIdentifier && !config11.coverSwapOpenClose && !config11.coverExposeAsDimmableLight && !config11.coverSliderDebounceMs && !config11.updateThrottleMs && !config11.disableClimateOnOff && !config11.disableClimateFanControl && !config11.climateKeepModeOnIdle && !config11.climateExposeFan && !config11.climateAutoMode && (!config11.composedEntities || config11.composedEntities.length === 0)) {
132087
132093
  bridgeMap.delete(request.entityId);
132088
132094
  } else {
132089
132095
  bridgeMap.set(request.entityId, config11);
@@ -148478,6 +148484,7 @@ var PluginManager = class {
148478
148484
  init_dist();
148479
148485
 
148480
148486
  // src/utils/json/create-bridge-server-config.ts
148487
+ init_esm();
148481
148488
  import crypto5 from "node:crypto";
148482
148489
 
148483
148490
  // ../../node_modules/.pnpm/@matter+main@0.17.3/node_modules/@matter/main/dist/esm/endpoints.js
@@ -148736,7 +148743,14 @@ function createBridgeServerConfig(data) {
148736
148743
  type: ServerNode.RootEndpoint,
148737
148744
  id: data.id,
148738
148745
  network: {
148739
- port: data.port
148746
+ port: data.port,
148747
+ // No jitter: matter.js adds up to 10s over the controller's max interval,
148748
+ // pushing our keepalive past Google's ceiling so it drops the sub (#386).
148749
+ subscriptionOptions: {
148750
+ minInterval: Seconds(2),
148751
+ maxInterval: Seconds(60),
148752
+ randomizationWindow: Seconds(0)
148753
+ }
148740
148754
  },
148741
148755
  productDescription: {
148742
148756
  name: data.name,
@@ -151235,7 +151249,14 @@ function FanControlServer2(config11, defaults = {}) {
151235
151249
  }
151236
151250
 
151237
151251
  // src/matter/endpoints/legacy/fan/behaviors/fan-fan-control-server.ts
151252
+ init_home_assistant_entity_behavior();
151238
151253
  var attributes2 = (e) => e.attributes;
151254
+ var windPresets = (agent) => agent.get(HomeAssistantEntityBehavior).state.mapping?.fanWindPresets ?? {};
151255
+ var isEnglishNatural = (m) => {
151256
+ const lower = m.toLowerCase();
151257
+ return lower === "natural" || lower === "nature";
151258
+ };
151259
+ var isEnglishSleep = (m) => m.toLowerCase() === "sleep";
151239
151260
  var fanControlConfig = {
151240
151261
  getPercentage: (state) => state.state === "off" ? 0 : attributes2(state).percentage,
151241
151262
  getStepSize: (state) => attributes2(state).percentage_step,
@@ -151254,17 +151275,22 @@ var fanControlConfig = {
151254
151275
  attributes2(state).supported_features ?? 0,
151255
151276
  FanDeviceFeature.OSCILLATE
151256
151277
  ),
151257
- // Wind mode support - check if preset_modes contains natural/sleep
151258
- getWindMode: (state) => {
151259
- const mode = attributes2(state).preset_mode?.toLowerCase();
151260
- if (mode === "natural" || mode === "nature") return "natural";
151261
- if (mode === "sleep") return "sleep";
151278
+ // Wind mode support - localized presets via mapping, english as fallback
151279
+ getWindMode: (state, agent) => {
151280
+ const mode = attributes2(state).preset_mode;
151281
+ if (!mode) return void 0;
151282
+ const presets = windPresets(agent);
151283
+ if (presets.natural?.includes(mode)) return "natural";
151284
+ if (presets.sleep?.includes(mode)) return "sleep";
151285
+ if (isEnglishNatural(mode)) return "natural";
151286
+ if (isEnglishSleep(mode)) return "sleep";
151262
151287
  return void 0;
151263
151288
  },
151264
- supportsWind: (state) => {
151289
+ supportsWind: (state, agent) => {
151265
151290
  const modes = attributes2(state).preset_modes ?? [];
151291
+ const presets = windPresets(agent);
151266
151292
  return modes.some(
151267
- (m) => m.toLowerCase() === "natural" || m.toLowerCase() === "nature" || m.toLowerCase() === "sleep"
151293
+ (m) => isEnglishNatural(m) || isEnglishSleep(m) || !!presets.natural?.includes(m) || !!presets.sleep?.includes(m)
151268
151294
  );
151269
151295
  },
151270
151296
  turnOff: () => ({ action: "fan.turn_off" }),
@@ -151287,12 +151313,29 @@ var fanControlConfig = {
151287
151313
  action: "fan.oscillate",
151288
151314
  data: { oscillating }
151289
151315
  }),
151290
- setWindMode: (mode) => ({
151291
- action: "fan.set_preset_mode",
151292
- data: {
151293
- preset_mode: mode === "natural" ? "Natural" : mode === "sleep" ? "Sleep" : "Normal"
151316
+ setWindMode: (mode, agent) => {
151317
+ const presets = windPresets(agent);
151318
+ let presetMode;
151319
+ if (mode === "natural") {
151320
+ presetMode = presets.natural?.[0] ?? "Natural";
151321
+ } else if (mode === "sleep") {
151322
+ presetMode = presets.sleep?.[0] ?? "Sleep";
151323
+ } else {
151324
+ const wind = /* @__PURE__ */ new Set([
151325
+ ...presets.natural ?? [],
151326
+ ...presets.sleep ?? []
151327
+ ]);
151328
+ const entityState = agent.get(HomeAssistantEntityBehavior).state.entity.state;
151329
+ const modes = attributes2(entityState).preset_modes ?? [];
151330
+ presetMode = modes.find(
151331
+ (m) => !wind.has(m) && !isEnglishNatural(m) && !isEnglishSleep(m)
151332
+ ) ?? "Normal";
151294
151333
  }
151295
- })
151334
+ return {
151335
+ action: "fan.set_preset_mode",
151336
+ data: { preset_mode: presetMode }
151337
+ };
151338
+ }
151296
151339
  };
151297
151340
  var FanFanControlServer = FanControlServer2(fanControlConfig);
151298
151341
 
@@ -155147,7 +155190,7 @@ function FanDevice2(homeAssistantEntity) {
155147
155190
  features3.add("MultiSpeed");
155148
155191
  features3.add("Step");
155149
155192
  }
155150
- if (hasPresetMode) {
155193
+ if (hasPresetMode && presetModes.some((m) => /auto/i.test(m))) {
155151
155194
  features3.add("Auto");
155152
155195
  }
155153
155196
  if (testBit(supportedFeatures, FanDeviceFeature.DIRECTION)) {
@@ -155156,8 +155199,9 @@ function FanDevice2(homeAssistantEntity) {
155156
155199
  if (testBit(supportedFeatures, FanDeviceFeature.OSCILLATE)) {
155157
155200
  features3.add("Rocking");
155158
155201
  }
155202
+ const windPresets2 = homeAssistantEntity.mapping?.fanWindPresets;
155159
155203
  const hasWindModes = presetModes.some(
155160
- (m) => m.toLowerCase() === "natural" || m.toLowerCase() === "nature" || m.toLowerCase() === "sleep"
155204
+ (m) => m.toLowerCase() === "natural" || m.toLowerCase() === "nature" || m.toLowerCase() === "sleep" || !!windPresets2?.natural?.includes(m) || !!windPresets2?.sleep?.includes(m)
155161
155205
  );
155162
155206
  if (hasWindModes) {
155163
155207
  features3.add("Wind");