@riddix/hamh 2.1.0-alpha.684 → 2.1.0-alpha.686

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.
@@ -172783,6 +172783,43 @@ var supportsTiltPositionControl = (agent) => {
172783
172783
  const supportedFeatures = attributes5(homeAssistant.entity.state).supported_features ?? 0;
172784
172784
  return (supportedFeatures & CoverSupportedFeatures.support_set_tilt_position) !== 0;
172785
172785
  };
172786
+ var liftShouldUseTilt = (supportedFeatures) => (supportedFeatures & CoverSupportedFeatures.support_open) === 0 && (supportedFeatures & CoverSupportedFeatures.support_open_tilt) !== 0;
172787
+ var liftFallsBackToTilt = (agent) => {
172788
+ const homeAssistant = agent.get(HomeAssistantEntityBehavior);
172789
+ const supportedFeatures = attributes5(homeAssistant.entity.state).supported_features ?? 0;
172790
+ return liftShouldUseTilt(supportedFeatures);
172791
+ };
172792
+ var openLiftAction = (agent) => ({
172793
+ action: shouldSwapOpenClose(agent) ? "cover.close_cover" : "cover.open_cover"
172794
+ });
172795
+ var closeLiftAction = (agent) => ({
172796
+ action: shouldSwapOpenClose(agent) ? "cover.open_cover" : "cover.close_cover"
172797
+ });
172798
+ var openTiltAction = (agent) => ({
172799
+ action: shouldSwapOpenClose(agent) ? "cover.close_cover_tilt" : "cover.open_cover_tilt"
172800
+ });
172801
+ var closeTiltAction = (agent) => ({
172802
+ action: shouldSwapOpenClose(agent) ? "cover.open_cover_tilt" : "cover.close_cover_tilt"
172803
+ });
172804
+ var setTiltPositionAction = (position, agent) => {
172805
+ if (!supportsTiltPositionControl(agent)) {
172806
+ const adjustedPosition = adjustPositionForWriting2(position, agent);
172807
+ const shouldOpen = adjustedPosition != null && adjustedPosition >= 50;
172808
+ const swapped = shouldSwapOpenClose(agent);
172809
+ if (shouldOpen) {
172810
+ return {
172811
+ action: swapped ? "cover.close_cover_tilt" : "cover.open_cover_tilt"
172812
+ };
172813
+ }
172814
+ return {
172815
+ action: swapped ? "cover.open_cover_tilt" : "cover.close_cover_tilt"
172816
+ };
172817
+ }
172818
+ return {
172819
+ action: "cover.set_cover_tilt_position",
172820
+ data: { tilt_position: adjustPositionForWriting2(position, agent) }
172821
+ };
172822
+ };
172786
172823
  var config5 = {
172787
172824
  getCurrentLiftPosition: (entity, agent) => {
172788
172825
  let position = attributes5(entity).current_position;
@@ -172815,14 +172852,14 @@ var config5 = {
172815
172852
  return WindowCovering3.MovementStatus.Stopped;
172816
172853
  },
172817
172854
  stopCover: () => ({ action: "cover.stop_cover" }),
172818
- // Open/close can be swapped via coverSwapOpenClose flag for Alexa compatibility
172819
- openCoverLift: (_, agent) => ({
172820
- action: shouldSwapOpenClose(agent) ? "cover.close_cover" : "cover.open_cover"
172821
- }),
172822
- closeCoverLift: (_, agent) => ({
172823
- action: shouldSwapOpenClose(agent) ? "cover.open_cover" : "cover.close_cover"
172824
- }),
172855
+ // Open/close can be swapped via coverSwapOpenClose flag for Alexa
172856
+ // compatibility. Tilt-only covers route Lift commands to tilt (#350).
172857
+ openCoverLift: (_, agent) => liftFallsBackToTilt(agent) ? openTiltAction(agent) : openLiftAction(agent),
172858
+ closeCoverLift: (_, agent) => liftFallsBackToTilt(agent) ? closeTiltAction(agent) : closeLiftAction(agent),
172825
172859
  setLiftPosition: (position, agent) => {
172860
+ if (liftFallsBackToTilt(agent)) {
172861
+ return setTiltPositionAction(position, agent);
172862
+ }
172826
172863
  if (!supportsPositionControl(agent)) {
172827
172864
  const adjustedPosition = adjustPositionForWriting2(position, agent);
172828
172865
  const shouldOpen = adjustedPosition != null && adjustedPosition >= 50;
@@ -172838,31 +172875,9 @@ var config5 = {
172838
172875
  };
172839
172876
  },
172840
172877
  // Tilt open/close also respects the swap flag
172841
- openCoverTilt: (_, agent) => ({
172842
- action: shouldSwapOpenClose(agent) ? "cover.close_cover_tilt" : "cover.open_cover_tilt"
172843
- }),
172844
- closeCoverTilt: (_, agent) => ({
172845
- action: shouldSwapOpenClose(agent) ? "cover.open_cover_tilt" : "cover.close_cover_tilt"
172846
- }),
172847
- setTiltPosition: (position, agent) => {
172848
- if (!supportsTiltPositionControl(agent)) {
172849
- const adjustedPosition = adjustPositionForWriting2(position, agent);
172850
- const shouldOpen = adjustedPosition != null && adjustedPosition >= 50;
172851
- const swapped = shouldSwapOpenClose(agent);
172852
- if (shouldOpen) {
172853
- return {
172854
- action: swapped ? "cover.close_cover_tilt" : "cover.open_cover_tilt"
172855
- };
172856
- }
172857
- return {
172858
- action: swapped ? "cover.open_cover_tilt" : "cover.close_cover_tilt"
172859
- };
172860
- }
172861
- return {
172862
- action: "cover.set_cover_tilt_position",
172863
- data: { tilt_position: adjustPositionForWriting2(position, agent) }
172864
- };
172865
- }
172878
+ openCoverTilt: (_, agent) => openTiltAction(agent),
172879
+ closeCoverTilt: (_, agent) => closeTiltAction(agent),
172880
+ setTiltPosition: (position, agent) => setTiltPositionAction(position, agent)
172866
172881
  };
172867
172882
  var CoverWindowCoveringServer = WindowCoveringServer2(config5);
172868
172883