@riddix/hamh 2.1.0-alpha.794 → 2.1.0-alpha.796

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.
@@ -127325,6 +127325,9 @@ function entityMappingApi(mappingStorage) {
127325
127325
  valetudoIdentifier: body.valetudoIdentifier,
127326
127326
  coverSwapOpenClose: body.coverSwapOpenClose,
127327
127327
  coverExposeAsDimmableLight: body.coverExposeAsDimmableLight,
127328
+ selectExposeAsSwitch: body.selectExposeAsSwitch,
127329
+ selectSwitchOnOption: body.selectSwitchOnOption,
127330
+ selectSwitchOffOption: body.selectSwitchOffOption,
127328
127331
  coverSliderDebounceMs: body.coverSliderDebounceMs,
127329
127332
  updateThrottleMs: body.updateThrottleMs,
127330
127333
  disableClimateOnOff: body.disableClimateOnOff,
@@ -132133,6 +132136,9 @@ var EntityMappingStorage = class extends Service {
132133
132136
  valetudoIdentifier: request.valetudoIdentifier?.trim() || void 0,
132134
132137
  coverSwapOpenClose: request.coverSwapOpenClose || void 0,
132135
132138
  coverExposeAsDimmableLight: request.coverExposeAsDimmableLight || void 0,
132139
+ selectExposeAsSwitch: request.selectExposeAsSwitch || void 0,
132140
+ selectSwitchOnOption: request.selectSwitchOnOption || void 0,
132141
+ selectSwitchOffOption: request.selectSwitchOffOption || void 0,
132136
132142
  coverSliderDebounceMs: sanitizeDebounceMs(request.coverSliderDebounceMs),
132137
132143
  updateThrottleMs: sanitizeThrottleMs(request.updateThrottleMs),
132138
132144
  disableClimateOnOff: request.disableClimateOnOff || void 0,
@@ -132142,7 +132148,7 @@ var EntityMappingStorage = class extends Service {
132142
132148
  climateAutoMode: request.climateAutoMode || void 0,
132143
132149
  composedEntities: request.composedEntities?.filter((e) => e.entityId?.trim()) ?? void 0
132144
132150
  };
132145
- 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.fanRestoreSpeedOnPowerOn && !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)) {
132151
+ 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.fanRestoreSpeedOnPowerOn && !config11.currentRoomEntity && !config11.cleanedAreaEntity && !config11.disableCustomAreaRoomModes && !config11.valetudoIdentifier && !config11.coverSwapOpenClose && !config11.coverExposeAsDimmableLight && !config11.selectExposeAsSwitch && !config11.selectSwitchOnOption && !config11.selectSwitchOffOption && !config11.coverSliderDebounceMs && !config11.updateThrottleMs && !config11.disableClimateOnOff && !config11.disableClimateFanControl && !config11.climateKeepModeOnIdle && !config11.climateExposeFan && !config11.climateAutoMode && (!config11.composedEntities || config11.composedEntities.length === 0)) {
132146
132152
  bridgeMap.delete(request.entityId);
132147
132153
  } else {
132148
132154
  bridgeMap.set(request.entityId, config11);
@@ -151301,7 +151307,7 @@ var FanControlServerBase = class extends FeaturedBase5 {
151301
151307
  `[${homeAssistant.entityId}] power-on write ${percentage}%: restore flag=${restoreOnPowerOn}, last speed=${remembered.percent}`
151302
151308
  );
151303
151309
  }
151304
- if (restoreOnPowerOn && wasOff && remembered.percent > 0 && percentage > 0) {
151310
+ if (restoreOnPowerOn && wasOff && remembered.percent > 0 && percentage >= 100) {
151305
151311
  percentage = remembered.percent;
151306
151312
  try {
151307
151313
  applyPatchState(this.state, {
@@ -158252,6 +158258,43 @@ var SelectModeServer = buildSelectModeServer("select.select_option");
158252
158258
  var InputSelectModeServer = buildSelectModeServer(
158253
158259
  "input_select.select_option"
158254
158260
  );
158261
+ function buildSelectSwitchType(action) {
158262
+ const option = (agent, key) => {
158263
+ const mapping = agent.get(HomeAssistantEntityBehavior).state.mapping;
158264
+ return key === "on" ? mapping?.selectSwitchOnOption : mapping?.selectSwitchOffOption;
158265
+ };
158266
+ return OnOffPlugInUnitDevice.with(
158267
+ BasicInformationServer2,
158268
+ IdentifyServer2,
158269
+ HomeAssistantEntityBehavior,
158270
+ GroupsServer,
158271
+ ScenesManagementServer,
158272
+ OnOffServer2({
158273
+ // Case-insensitive like the ModeSelect path, some integrations
158274
+ // report options with different casing.
158275
+ isOn: (state, agent) => state.state?.toLowerCase() === option(agent, "on")?.toLowerCase(),
158276
+ turnOn: (_, agent) => ({
158277
+ action,
158278
+ data: { option: option(agent, "on") }
158279
+ }),
158280
+ turnOff: (_, agent) => ({
158281
+ action,
158282
+ data: { option: option(agent, "off") }
158283
+ })
158284
+ })
158285
+ );
158286
+ }
158287
+ var SelectSwitchType = buildSelectSwitchType("select.select_option");
158288
+ var InputSelectSwitchType = buildSelectSwitchType(
158289
+ "input_select.select_option"
158290
+ );
158291
+ function selectAsSwitch(homeAssistantEntity, type) {
158292
+ const mapping = homeAssistantEntity.mapping;
158293
+ if (mapping?.selectExposeAsSwitch !== true || !mapping.selectSwitchOnOption || !mapping.selectSwitchOffOption) {
158294
+ return void 0;
158295
+ }
158296
+ return type.set({ homeAssistantEntity });
158297
+ }
158255
158298
  var SelectEndpointType = ModeSelectDevice.with(
158256
158299
  BasicInformationServer2,
158257
158300
  IdentifyServer2,
@@ -158265,6 +158308,10 @@ var InputSelectEndpointType = ModeSelectDevice.with(
158265
158308
  InputSelectModeServer
158266
158309
  );
158267
158310
  function SelectDevice(homeAssistantEntity) {
158311
+ const asSwitch = selectAsSwitch(homeAssistantEntity, SelectSwitchType);
158312
+ if (asSwitch) {
158313
+ return asSwitch;
158314
+ }
158268
158315
  const attrs = homeAssistantEntity.entity.state.attributes;
158269
158316
  const options = attrs.options ?? [];
158270
158317
  if (options.length === 0) {
@@ -158282,6 +158329,10 @@ function SelectDevice(homeAssistantEntity) {
158282
158329
  });
158283
158330
  }
158284
158331
  function InputSelectDevice(homeAssistantEntity) {
158332
+ const asSwitch = selectAsSwitch(homeAssistantEntity, InputSelectSwitchType);
158333
+ if (asSwitch) {
158334
+ return asSwitch;
158335
+ }
158285
158336
  const attrs = homeAssistantEntity.entity.state.attributes;
158286
158337
  const options = attrs.options ?? [];
158287
158338
  if (options.length === 0) {