From 2790dbaa8be8f12db1e0d5eb8261d69bf16078a3 Mon Sep 17 00:00:00 2001 From: Sang Nguyen Date: Wed, 19 Feb 2025 09:00:23 +1000 Subject: [PATCH] Add vertical distance for vertical cover Add option to specify the vertical distance from the workarea to the base of the fully extended vertical cover. --- README.md | 3 ++- custom_components/adaptive_cover/calculation.py | 3 ++- custom_components/adaptive_cover/config_flow.py | 7 +++++++ custom_components/adaptive_cover/const.py | 1 + custom_components/adaptive_cover/coordinator.py | 2 ++ custom_components/adaptive_cover/strings.json | 2 ++ custom_components/adaptive_cover/translations/en.json | 2 ++ 7 files changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 038d0366..3d878548 100644 --- a/README.md +++ b/README.md @@ -191,7 +191,8 @@ This mode is split up in two types of strategies; [Presence](https://github.com/ | Variables | Default | Range | Description | | ----------------- | ------- | ----- | ------------------------------------------------------------------------------------------- | | Window Height | 2.1 | 0.1-6 | Length of fully extended cover/window | -| Workarea Distance | 0.5 | 0.1-2 | The distance to the workarea on equal height to the bottom of the cover when fully extended | +| Window Position | 1.0 | 0.1-6 | The vertical distance from the workarea to the base of the cover when fully extended | +| Workarea Distance | 0.5 | 0.1-2 | The horizontal distance from the workarea to the cover | ### Horizontal diff --git a/custom_components/adaptive_cover/calculation.py b/custom_components/adaptive_cover/calculation.py index db21832f..4723cf92 100644 --- a/custom_components/adaptive_cover/calculation.py +++ b/custom_components/adaptive_cover/calculation.py @@ -438,12 +438,13 @@ class AdaptiveVerticalCover(AdaptiveGeneralCover): distance: float h_win: float + p_win: float def calculate_position(self) -> float: """Calculate blind height.""" # calculate blind height blind_height = np.clip( - (self.distance / cos(rad(self.gamma))) * tan(rad(self.sol_elev)), + ((self.distance / cos(rad(self.gamma))) * tan(rad(self.sol_elev))) - self.p_win, 0, self.h_win, ) diff --git a/custom_components/adaptive_cover/config_flow.py b/custom_components/adaptive_cover/config_flow.py index 077de481..558a803a 100644 --- a/custom_components/adaptive_cover/config_flow.py +++ b/custom_components/adaptive_cover/config_flow.py @@ -52,6 +52,7 @@ CONF_MIN_ELEVATION, CONF_MODE, CONF_OUTSIDETEMP_ENTITY, + CONF_POSITION_WIN, CONF_PRESENCE_ENTITY, CONF_RETURN_SUNSET, CONF_SENSOR_TYPE, @@ -168,6 +169,11 @@ min=0.1, max=6, step=0.01, mode="slider", unit_of_measurement="m" ) ), + vol.Required(CONF_POSITION_WIN, default=1.0): selector.NumberSelector( + selector.NumberSelectorConfig( + min=0, max=10, step=0.01, mode="slider", unit_of_measurement="m" + ) + ), vol.Required(CONF_DISTANCE, default=0.5): selector.NumberSelector( selector.NumberSelectorConfig( min=0.1, max=2, step=0.1, mode="slider", unit_of_measurement="m" @@ -572,6 +578,7 @@ async def async_step_update(self, user_input: dict[str, Any] | None = None): CONF_MODE: self.mode, CONF_AZIMUTH: self.config.get(CONF_AZIMUTH), CONF_HEIGHT_WIN: self.config.get(CONF_HEIGHT_WIN), + CONF_POSITION_WIN: self.config.get(CONF_POSITION_WIN), CONF_DISTANCE: self.config.get(CONF_DISTANCE), CONF_DEFAULT_HEIGHT: self.config.get(CONF_DEFAULT_HEIGHT), CONF_MAX_POSITION: self.config.get(CONF_MAX_POSITION), diff --git a/custom_components/adaptive_cover/const.py b/custom_components/adaptive_cover/const.py index b80d3802..1a583fc6 100644 --- a/custom_components/adaptive_cover/const.py +++ b/custom_components/adaptive_cover/const.py @@ -12,6 +12,7 @@ CONF_AZIMUTH = "set_azimuth" CONF_BLUEPRINT = "blueprint" CONF_HEIGHT_WIN = "window_height" +CONF_POSITION_WIN = "window_position" CONF_DISTANCE = "distance_shaded_area" CONF_DEFAULT_HEIGHT = "default_percentage" CONF_FOV_LEFT = "fov_left" diff --git a/custom_components/adaptive_cover/coordinator.py b/custom_components/adaptive_cover/coordinator.py index 515b8e19..3bc1b13d 100644 --- a/custom_components/adaptive_cover/coordinator.py +++ b/custom_components/adaptive_cover/coordinator.py @@ -78,6 +78,7 @@ CONF_MIN_POSITION, CONF_OUTSIDE_THRESHOLD, CONF_OUTSIDETEMP_ENTITY, + CONF_POSITION_WIN, CONF_PRESENCE_ENTITY, CONF_RETURN_SUNSET, CONF_START_ENTITY, @@ -665,6 +666,7 @@ def vertical_data(self, options): return [ options.get(CONF_DISTANCE), options.get(CONF_HEIGHT_WIN), + options.get(CONF_POSITION_WIN), ] def horizontal_data(self, options): diff --git a/custom_components/adaptive_cover/strings.json b/custom_components/adaptive_cover/strings.json index 7a20c176..a047f05a 100644 --- a/custom_components/adaptive_cover/strings.json +++ b/custom_components/adaptive_cover/strings.json @@ -38,6 +38,7 @@ "data": { "set_azimuth": "Window Azimuth", "window_height": "Window Height", + "window_position": "Window Position", "distance_shaded_area": "Shaded area", "default_percentage": "Default Position", "max_position": "Maximum Position", @@ -258,6 +259,7 @@ "data": { "set_azimuth": "Window Azimuth", "window_height": "Window Height", + "window_position": "Window Position", "distance_shaded_area": "Shaded area", "default_percentage": "Default Position", "max_position": "Maximum Position", diff --git a/custom_components/adaptive_cover/translations/en.json b/custom_components/adaptive_cover/translations/en.json index 8b5f93a8..8571f090 100644 --- a/custom_components/adaptive_cover/translations/en.json +++ b/custom_components/adaptive_cover/translations/en.json @@ -38,6 +38,7 @@ "data": { "set_azimuth": "Window Azimuth", "window_height": "Window Height", + "window_position": "Window Position", "distance_shaded_area": "Shaded area", "default_percentage": "Default Position", "min_position": "Minimum Position", @@ -271,6 +272,7 @@ "data": { "set_azimuth": "Window Azimuth", "window_height": "Window Height", + "window_position": "Window Position", "distance_shaded_area": "Shaded area", "default_percentage": "Default Position", "min_position": "Minimum Position",