@riddix/hamh 2.1.0-alpha.782 → 2.1.0-alpha.784

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.
@@ -154247,53 +154247,6 @@ init_home_assistant_entity_behavior();
154247
154247
  // src/matter/endpoints/legacy/cover/behaviors/cover-as-light.ts
154248
154248
  init_dist();
154249
154249
  init_home_assistant_entity_behavior();
154250
- var attributes6 = (entity) => entity.attributes;
154251
- function coverOpenness(entity) {
154252
- const position = attributes6(entity).current_position;
154253
- if (position != null) {
154254
- return Math.min(1, Math.max(0, position / 100));
154255
- }
154256
- if (entity.state === CoverDeviceState.open) return 1;
154257
- if (entity.state === CoverDeviceState.closed) return 0;
154258
- return null;
154259
- }
154260
- function coverLevelAction(percent3, supportsPosition) {
154261
- const position = Math.round(Math.min(1, Math.max(0, percent3)) * 100);
154262
- if (supportsPosition) {
154263
- return { action: "cover.set_cover_position", data: { position } };
154264
- }
154265
- return { action: position >= 50 ? "cover.open_cover" : "cover.close_cover" };
154266
- }
154267
- var supportsPositionControl = (agent) => {
154268
- const entity = agent.get(HomeAssistantEntityBehavior).entity.state;
154269
- const supportedFeatures = attributes6(entity).supported_features ?? 0;
154270
- return (supportedFeatures & CoverSupportedFeatures.support_set_position) !== 0;
154271
- };
154272
- var CoverAsLightOnOffServer = OnOffServer2({
154273
- isOn: (entity) => entity.state !== CoverDeviceState.closed,
154274
- turnOn: () => ({ action: "cover.open_cover" }),
154275
- turnOff: () => ({ action: "cover.close_cover" })
154276
- });
154277
- var CoverAsLightLevelControlServer = LevelControlServer2({
154278
- getValuePercent: (entity) => coverOpenness(entity),
154279
- moveToLevelPercent: (percent3, agent) => coverLevelAction(percent3, supportsPositionControl(agent))
154280
- });
154281
- var baseBehaviors = [
154282
- IdentifyServer2,
154283
- BasicInformationServer2,
154284
- HomeAssistantEntityBehavior,
154285
- GroupsServer,
154286
- ScenesManagementServer,
154287
- CoverAsLightOnOffServer,
154288
- CoverAsLightLevelControlServer
154289
- ];
154290
- var CoverAsDimmableLightType = DimmableLightDevice.with(
154291
- ...baseBehaviors
154292
- );
154293
- var CoverAsDimmableLightWithBatteryType = DimmableLightDevice.with(
154294
- ...baseBehaviors,
154295
- DefaultPowerSourceServer
154296
- );
154297
154250
 
154298
154251
  // src/matter/endpoints/legacy/cover/behaviors/cover-window-covering-server.ts
154299
154252
  init_dist();
@@ -154652,7 +154605,7 @@ function adjustPositionForWriting(position, flags2, matterSemantics) {
154652
154605
 
154653
154606
  // src/matter/endpoints/legacy/cover/behaviors/cover-window-covering-server.ts
154654
154607
  var logger207 = Logger.get("CoverWindowCoveringServer");
154655
- var attributes7 = (entity) => entity.attributes;
154608
+ var attributes6 = (entity) => entity.attributes;
154656
154609
  var DEVICE_CLASS_TO_MATTER_TYPE = {
154657
154610
  curtain: {
154658
154611
  type: WindowCovering3.WindowCoveringType.Drapery,
@@ -154688,7 +154641,7 @@ var deviceClassMapping = (entity) => {
154688
154641
  if (typeof raw !== "string") return void 0;
154689
154642
  const mapping = DEVICE_CLASS_TO_MATTER_TYPE[raw.toLowerCase()];
154690
154643
  if (!mapping) return void 0;
154691
- const supportedFeatures = attributes7(entity).supported_features ?? 0;
154644
+ const supportedFeatures = attributes6(entity).supported_features ?? 0;
154692
154645
  const hasLift = (supportedFeatures & CoverSupportedFeatures.support_open) !== 0;
154693
154646
  const hasTilt = (supportedFeatures & CoverSupportedFeatures.support_open_tilt) !== 0;
154694
154647
  if (mapping.type === WindowCovering3.WindowCoveringType.TiltBlindTiltOnly) {
@@ -154738,20 +154691,20 @@ var shouldSwapOpenClose = (agent) => {
154738
154691
  const { featureFlags } = agent.env.get(BridgeDataProvider);
154739
154692
  return featureFlags?.coverSwapOpenClose === true;
154740
154693
  };
154741
- var supportsPositionControl2 = (agent) => {
154694
+ var supportsPositionControl = (agent) => {
154742
154695
  const homeAssistant = agent.get(HomeAssistantEntityBehavior);
154743
- const supportedFeatures = attributes7(homeAssistant.entity.state).supported_features ?? 0;
154696
+ const supportedFeatures = attributes6(homeAssistant.entity.state).supported_features ?? 0;
154744
154697
  return (supportedFeatures & CoverSupportedFeatures.support_set_position) !== 0;
154745
154698
  };
154746
154699
  var supportsTiltPositionControl = (agent) => {
154747
154700
  const homeAssistant = agent.get(HomeAssistantEntityBehavior);
154748
- const supportedFeatures = attributes7(homeAssistant.entity.state).supported_features ?? 0;
154701
+ const supportedFeatures = attributes6(homeAssistant.entity.state).supported_features ?? 0;
154749
154702
  return (supportedFeatures & CoverSupportedFeatures.support_set_tilt_position) !== 0;
154750
154703
  };
154751
154704
  var liftShouldUseTilt = (supportedFeatures) => (supportedFeatures & CoverSupportedFeatures.support_open) === 0 && (supportedFeatures & CoverSupportedFeatures.support_open_tilt) !== 0;
154752
154705
  var liftFallsBackToTilt = (agent) => {
154753
154706
  const homeAssistant = agent.get(HomeAssistantEntityBehavior);
154754
- const supportedFeatures = attributes7(homeAssistant.entity.state).supported_features ?? 0;
154707
+ const supportedFeatures = attributes6(homeAssistant.entity.state).supported_features ?? 0;
154755
154708
  return liftShouldUseTilt(supportedFeatures);
154756
154709
  };
154757
154710
  var openLiftAction = (agent) => ({
@@ -154787,7 +154740,7 @@ var setTiltPositionAction = (position, agent) => {
154787
154740
  };
154788
154741
  var config6 = {
154789
154742
  getCurrentLiftPosition: (entity, agent) => {
154790
- let position = attributes7(entity).current_position;
154743
+ let position = attributes6(entity).current_position;
154791
154744
  if (position == null) {
154792
154745
  const coverState = entity.state;
154793
154746
  position = coverState === CoverDeviceState.closed ? 0 : coverState === CoverDeviceState.open ? 100 : void 0;
@@ -154795,7 +154748,7 @@ var config6 = {
154795
154748
  return position == null ? null : adjustPositionForReading2(position, agent);
154796
154749
  },
154797
154750
  getCurrentTiltPosition: (entity, agent) => {
154798
- let position = attributes7(entity).current_tilt_position;
154751
+ let position = attributes6(entity).current_tilt_position;
154799
154752
  if (position == null) {
154800
154753
  const coverState = entity.state;
154801
154754
  position = coverState === CoverDeviceState.closed ? 0 : coverState === CoverDeviceState.open ? 100 : void 0;
@@ -154825,7 +154778,7 @@ var config6 = {
154825
154778
  if (liftFallsBackToTilt(agent)) {
154826
154779
  return setTiltPositionAction(position, agent);
154827
154780
  }
154828
- if (!supportsPositionControl2(agent)) {
154781
+ if (!supportsPositionControl(agent)) {
154829
154782
  const adjustedPosition = adjustPositionForWriting2(position, agent);
154830
154783
  const shouldOpen = adjustedPosition != null && adjustedPosition >= 50;
154831
154784
  const swapped = shouldSwapOpenClose(agent);
@@ -154846,6 +154799,66 @@ var config6 = {
154846
154799
  };
154847
154800
  var CoverWindowCoveringServer = WindowCoveringServer2(config6);
154848
154801
 
154802
+ // src/matter/endpoints/legacy/cover/behaviors/cover-as-light.ts
154803
+ var attributes7 = (entity) => entity.attributes;
154804
+ function coverOpenness(entity) {
154805
+ const position = attributes7(entity).current_position;
154806
+ if (position != null) {
154807
+ return Math.min(1, Math.max(0, position / 100));
154808
+ }
154809
+ const tilt = attributes7(entity).current_tilt_position;
154810
+ if (tilt != null) {
154811
+ return Math.min(1, Math.max(0, tilt / 100));
154812
+ }
154813
+ if (entity.state === CoverDeviceState.open) return 1;
154814
+ if (entity.state === CoverDeviceState.closed) return 0;
154815
+ return null;
154816
+ }
154817
+ function coverLevelAction(percent3, supportedFeatures) {
154818
+ const position = Math.round(Math.min(1, Math.max(0, percent3)) * 100);
154819
+ if (liftShouldUseTilt(supportedFeatures)) {
154820
+ if ((supportedFeatures & CoverSupportedFeatures.support_set_tilt_position) !== 0) {
154821
+ return {
154822
+ action: "cover.set_cover_tilt_position",
154823
+ data: { tilt_position: position }
154824
+ };
154825
+ }
154826
+ return {
154827
+ action: position >= 50 ? "cover.open_cover_tilt" : "cover.close_cover_tilt"
154828
+ };
154829
+ }
154830
+ if ((supportedFeatures & CoverSupportedFeatures.support_set_position) !== 0) {
154831
+ return { action: "cover.set_cover_position", data: { position } };
154832
+ }
154833
+ return { action: position >= 50 ? "cover.open_cover" : "cover.close_cover" };
154834
+ }
154835
+ var supportedFeaturesOf = (agent) => attributes7(agent.get(HomeAssistantEntityBehavior).entity.state).supported_features ?? 0;
154836
+ var CoverAsLightOnOffServer = OnOffServer2({
154837
+ isOn: (entity) => entity.state !== CoverDeviceState.closed,
154838
+ turnOn: (_value, agent) => liftShouldUseTilt(supportedFeaturesOf(agent)) ? { action: "cover.open_cover_tilt" } : { action: "cover.open_cover" },
154839
+ turnOff: (_value, agent) => liftShouldUseTilt(supportedFeaturesOf(agent)) ? { action: "cover.close_cover_tilt" } : { action: "cover.close_cover" }
154840
+ });
154841
+ var CoverAsLightLevelControlServer = LevelControlServer2({
154842
+ getValuePercent: (entity) => coverOpenness(entity),
154843
+ moveToLevelPercent: (percent3, agent) => coverLevelAction(percent3, supportedFeaturesOf(agent))
154844
+ });
154845
+ var baseBehaviors = [
154846
+ IdentifyServer2,
154847
+ BasicInformationServer2,
154848
+ HomeAssistantEntityBehavior,
154849
+ GroupsServer,
154850
+ ScenesManagementServer,
154851
+ CoverAsLightOnOffServer,
154852
+ CoverAsLightLevelControlServer
154853
+ ];
154854
+ var CoverAsDimmableLightType = DimmableLightDevice.with(
154855
+ ...baseBehaviors
154856
+ );
154857
+ var CoverAsDimmableLightWithBatteryType = DimmableLightDevice.with(
154858
+ ...baseBehaviors,
154859
+ DefaultPowerSourceServer
154860
+ );
154861
+
154849
154862
  // src/matter/endpoints/legacy/cover/index.ts
154850
154863
  var logger208 = Logger.get("CoverDevice");
154851
154864
  var CoverDeviceType = (supportedFeatures, hasBattery, entityId) => {