diff --git a/custom_components/adaptive_cover/calculation.py b/custom_components/adaptive_cover/calculation.py index ec759df..3f84021 100644 --- a/custom_components/adaptive_cover/calculation.py +++ b/custom_components/adaptive_cover/calculation.py @@ -28,6 +28,7 @@ class AdaptiveGeneralCover(ABC): fov_right: int win_azi: int h_def: int + max_pos: int sun_data: SunData = field(init=False) def __post_init__(self): @@ -130,6 +131,8 @@ def get_state(self) -> int: self.cover.default, ) result = np.clip(state, 0, 100) + if result > self.cover.max_pos: + return self.cover.max_pos return result @@ -287,9 +290,12 @@ def tilt_state(self): def get_state(self) -> int: """Return state.""" + result = self.normal_type_cover() if self.climate_data.blind_type == "cover_tilt": - return self.tilt_state() - return self.normal_type_cover() + result = self.tilt_state() + if result > self.cover.max_pos: + return self.cover.max_pos + return result @dataclass diff --git a/custom_components/adaptive_cover/config_flow.py b/custom_components/adaptive_cover/config_flow.py index 4eb6fa4..16ae48c 100644 --- a/custom_components/adaptive_cover/config_flow.py +++ b/custom_components/adaptive_cover/config_flow.py @@ -28,6 +28,7 @@ CONF_HEIGHT_WIN, CONF_INVERSE_STATE, CONF_LENGTH_AWNING, + CONF_MAX_POSITION, CONF_MODE, CONF_PRESENCE_ENTITY, CONF_SENSOR_TYPE, @@ -76,6 +77,9 @@ vol.Required(CONF_DEFAULT_HEIGHT, default=60): selector.NumberSelector( selector.NumberSelectorConfig(min=1, max=100, step=1, mode="slider") ), + vol.Optional(CONF_MAX_POSITION, default=100): selector.NumberSelector( + selector.NumberSelectorConfig(min=1, max=100, step=1, mode="slider") + ), vol.Required(CONF_FOV_LEFT, default=90): selector.NumberSelector( selector.NumberSelectorConfig(min=1, max=90, step=1, mode="slider") ), @@ -298,6 +302,7 @@ async def async_step_update(self, user_input: dict[str, Any] | None = None): CONF_HEIGHT_WIN: self.config.get(CONF_HEIGHT_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), CONF_FOV_LEFT: self.config.get(CONF_FOV_LEFT), CONF_FOV_RIGHT: self.config.get(CONF_FOV_RIGHT), CONF_ENTITIES: self.config.get(CONF_ENTITIES), diff --git a/custom_components/adaptive_cover/const.py b/custom_components/adaptive_cover/const.py index d371c7c..07dd058 100644 --- a/custom_components/adaptive_cover/const.py +++ b/custom_components/adaptive_cover/const.py @@ -33,6 +33,7 @@ CONF_MODE = "mode" CONF_CLIMATE_MODE = "climate_mode" CONF_WEATHER_STATE = "weather_state" +CONF_MAX_POSITION = "max_position" STRATEGY_MODE_BASIC = "basic" STRATEGY_MODE_CLIMATE = "climate" diff --git a/custom_components/adaptive_cover/coordinator.py b/custom_components/adaptive_cover/coordinator.py index 7d32d55..371f049 100644 --- a/custom_components/adaptive_cover/coordinator.py +++ b/custom_components/adaptive_cover/coordinator.py @@ -28,6 +28,7 @@ CONF_HEIGHT_WIN, CONF_INVERSE_STATE, CONF_LENGTH_AWNING, + CONF_MAX_POSITION, CONF_PRESENCE_ENTITY, CONF_SUNSET_OFFSET, CONF_SUNSET_POS, @@ -96,6 +97,7 @@ async def _async_update_data(self) -> AdaptiveCoverData: self.config_entry.options.get(CONF_FOV_RIGHT), self.config_entry.options.get(CONF_AZIMUTH), self.config_entry.options.get(CONF_DEFAULT_HEIGHT), + self.config_entry.options.get(CONF_MAX_POSITION, 100), ] vertical_data = [ diff --git a/custom_components/adaptive_cover/strings.json b/custom_components/adaptive_cover/strings.json index 0bf76d6..665a063 100644 --- a/custom_components/adaptive_cover/strings.json +++ b/custom_components/adaptive_cover/strings.json @@ -15,6 +15,7 @@ "window_height": "Window Height", "distance_shaded_area": "Shaded area", "default_percentage": "Default Position", + "max_position": "Maximum Position", "fov_left": "Field of view left", "fov_right": "Field of view right", "group": "Cover Entities", @@ -28,6 +29,7 @@ "window_height": "Set the height of the window(s) in meters", "distance_shaded_area": "Distance from cover to shaded area in meters", "default_percentage": "Default posistion of cover in percentages", + "max_position": "Highest position the cover may be adjusted to in percentages", "fov_left": "Degrees to take in account from the left side of the center of the window", "fov_right": "Degrees to take in account from the right side of the center of the window", "group": "Select entities to be controlled with the Blueprint", @@ -73,6 +75,7 @@ "angle": "Awning Angle", "distance_shaded_area": "Shaded area", "default_percentage": "Default Position", + "max_position": "Maximum Position", "fov_left": "Field of view left", "fov_right": "Field of view right", "group": "Cover Entities", @@ -90,6 +93,7 @@ "angle": "The angle of the attached awning measured perpendicular from the wall downward to the floor", "distance_shaded_area": "Distance from cover to shaded area in meters", "default_percentage": "Default posistion of cover in percentages", + "max_position": "Highest position the cover may be adjusted to in percentages", "fov_left": "Degrees to take in account from the left side of the center of the window", "fov_right": "Degrees to take in account from the right side of the center of the window", "group": "Select entities to be controlled with the Blueprint", @@ -106,6 +110,7 @@ "slat_depth": "Slat Depth", "slat_distance": "Slat Spacing", "default_percentage": "Default Position", + "max_position": "Maximum Position", "fov_left": "Field of view left", "fov_right": "Field of view right", "group": "Cover Entities", @@ -120,6 +125,7 @@ "slat_depth": "Depth of individual slat in cm", "slat_distance": "Vertical distance between two slats in cm", "default_percentage": "Default posistion of cover in percentages", + "max_position": "Highest position the cover may be adjusted to in percentages", "fov_left": "Degrees to take in account from the left side of the center of the window", "fov_right": "Degrees to take in account from the right side of the center of the window", "group": "Select entities to be controlled with the Blueprint", @@ -141,6 +147,7 @@ "window_height": "Window Height", "distance_shaded_area": "Shaded area", "default_percentage": "Default Position", + "max_position": "Maximum Position", "fov_left": "Field of view left", "fov_right": "Field of view right", "group": "Cover Entities", @@ -154,6 +161,7 @@ "window_height": "Set the height of the window(s) in meters", "distance_shaded_area": "Distance from cover to shaded area in meters", "default_percentage": "Default posistion of cover in percentages", + "max_position": "Highest position the cover may be adjusted to in percentages", "fov_left": "Degrees to take in account from the left side of the center of the window", "fov_right": "Degrees to take in account from the right side of the center of the window", "group": "Select entities to be controlled with the Blueprint", @@ -199,6 +207,7 @@ "angle": "Awning Angle", "distance_shaded_area": "Shaded area", "default_percentage": "Default Position", + "max_position": "Maximum Position", "fov_left": "Field of view left", "fov_right": "Field of view right", "group": "Cover Entities", @@ -216,6 +225,7 @@ "angle": "The angle of the attached awning measured perpendicular from the wall downward to the floor", "distance_shaded_area": "Distance from cover to shaded area in meters", "default_percentage": "Default posistion of cover in percentages", + "max_position": "Highest position the cover may be adjusted to in percentages", "fov_left": "Degrees to take in account from the left side of the center of the window", "fov_right": "Degrees to take in account from the right side of the center of the window", "group": "Select entities to be controlled with the Blueprint", @@ -232,6 +242,7 @@ "slat_depth": "Slat Depth", "slat_distance": "Slat Spacing", "default_percentage": "Default Position", + "max_position": "Maximum Position", "fov_left": "Field of view left", "fov_right": "Field of view right", "group": "Cover Entities", @@ -246,6 +257,7 @@ "slat_depth": "Depth of individual slat in cm", "slat_distance": "Vertical distance between two slats in cm", "default_percentage": "Default posistion of cover in percentages", + "max_position": "Highest position the cover may be adjusted to in percentages", "fov_left": "Degrees to take in account from the left side of the center of the window", "fov_right": "Degrees to take in account from the right side of the center of the window", "group": "Select entities to be controlled with the Blueprint", diff --git a/custom_components/adaptive_cover/translations/en.json b/custom_components/adaptive_cover/translations/en.json index 0bf76d6..665a063 100644 --- a/custom_components/adaptive_cover/translations/en.json +++ b/custom_components/adaptive_cover/translations/en.json @@ -15,6 +15,7 @@ "window_height": "Window Height", "distance_shaded_area": "Shaded area", "default_percentage": "Default Position", + "max_position": "Maximum Position", "fov_left": "Field of view left", "fov_right": "Field of view right", "group": "Cover Entities", @@ -28,6 +29,7 @@ "window_height": "Set the height of the window(s) in meters", "distance_shaded_area": "Distance from cover to shaded area in meters", "default_percentage": "Default posistion of cover in percentages", + "max_position": "Highest position the cover may be adjusted to in percentages", "fov_left": "Degrees to take in account from the left side of the center of the window", "fov_right": "Degrees to take in account from the right side of the center of the window", "group": "Select entities to be controlled with the Blueprint", @@ -73,6 +75,7 @@ "angle": "Awning Angle", "distance_shaded_area": "Shaded area", "default_percentage": "Default Position", + "max_position": "Maximum Position", "fov_left": "Field of view left", "fov_right": "Field of view right", "group": "Cover Entities", @@ -90,6 +93,7 @@ "angle": "The angle of the attached awning measured perpendicular from the wall downward to the floor", "distance_shaded_area": "Distance from cover to shaded area in meters", "default_percentage": "Default posistion of cover in percentages", + "max_position": "Highest position the cover may be adjusted to in percentages", "fov_left": "Degrees to take in account from the left side of the center of the window", "fov_right": "Degrees to take in account from the right side of the center of the window", "group": "Select entities to be controlled with the Blueprint", @@ -106,6 +110,7 @@ "slat_depth": "Slat Depth", "slat_distance": "Slat Spacing", "default_percentage": "Default Position", + "max_position": "Maximum Position", "fov_left": "Field of view left", "fov_right": "Field of view right", "group": "Cover Entities", @@ -120,6 +125,7 @@ "slat_depth": "Depth of individual slat in cm", "slat_distance": "Vertical distance between two slats in cm", "default_percentage": "Default posistion of cover in percentages", + "max_position": "Highest position the cover may be adjusted to in percentages", "fov_left": "Degrees to take in account from the left side of the center of the window", "fov_right": "Degrees to take in account from the right side of the center of the window", "group": "Select entities to be controlled with the Blueprint", @@ -141,6 +147,7 @@ "window_height": "Window Height", "distance_shaded_area": "Shaded area", "default_percentage": "Default Position", + "max_position": "Maximum Position", "fov_left": "Field of view left", "fov_right": "Field of view right", "group": "Cover Entities", @@ -154,6 +161,7 @@ "window_height": "Set the height of the window(s) in meters", "distance_shaded_area": "Distance from cover to shaded area in meters", "default_percentage": "Default posistion of cover in percentages", + "max_position": "Highest position the cover may be adjusted to in percentages", "fov_left": "Degrees to take in account from the left side of the center of the window", "fov_right": "Degrees to take in account from the right side of the center of the window", "group": "Select entities to be controlled with the Blueprint", @@ -199,6 +207,7 @@ "angle": "Awning Angle", "distance_shaded_area": "Shaded area", "default_percentage": "Default Position", + "max_position": "Maximum Position", "fov_left": "Field of view left", "fov_right": "Field of view right", "group": "Cover Entities", @@ -216,6 +225,7 @@ "angle": "The angle of the attached awning measured perpendicular from the wall downward to the floor", "distance_shaded_area": "Distance from cover to shaded area in meters", "default_percentage": "Default posistion of cover in percentages", + "max_position": "Highest position the cover may be adjusted to in percentages", "fov_left": "Degrees to take in account from the left side of the center of the window", "fov_right": "Degrees to take in account from the right side of the center of the window", "group": "Select entities to be controlled with the Blueprint", @@ -232,6 +242,7 @@ "slat_depth": "Slat Depth", "slat_distance": "Slat Spacing", "default_percentage": "Default Position", + "max_position": "Maximum Position", "fov_left": "Field of view left", "fov_right": "Field of view right", "group": "Cover Entities", @@ -246,6 +257,7 @@ "slat_depth": "Depth of individual slat in cm", "slat_distance": "Vertical distance between two slats in cm", "default_percentage": "Default posistion of cover in percentages", + "max_position": "Highest position the cover may be adjusted to in percentages", "fov_left": "Degrees to take in account from the left side of the center of the window", "fov_right": "Degrees to take in account from the right side of the center of the window", "group": "Select entities to be controlled with the Blueprint", diff --git a/custom_components/adaptive_cover/translations/nl.json b/custom_components/adaptive_cover/translations/nl.json index a5c6daf..f7b9e87 100644 --- a/custom_components/adaptive_cover/translations/nl.json +++ b/custom_components/adaptive_cover/translations/nl.json @@ -18,6 +18,7 @@ "window_height": "Raam Hoogte", "distance_shaded_area": "Schaduwgebied", "default_percentage": "Standaard Positie", + "max_position": "Maximale Posistie", "fov_left": "Gezichtsveld links", "fov_right": "Gezichtsveld rechts", "group": "Cover Entities", @@ -31,6 +32,7 @@ "window_height": "Zet de hoogte van het raam/de ramen in meters", "distance_shaded_area": "Afstand van de cover tot het schaduwgebied in meters", "default_percentage": "Standaard posistie van de cover in percentages", + "max_position": "Maximale posistie tot waar de cover aangepast mag worden in percentages", "fov_left": "Aantal graden aan de linker kant vanuit het midden gezien van het raam", "fov_right": "Aantal graden aan de rechter kant vanuit het midden gezien van het raam", "group": "Selecteer de entities die worden bestuurd met de Blueprint", @@ -70,6 +72,7 @@ "angle": "Montage Hoek", "distance_shaded_area": "Schaduwgebied", "default_percentage": "Standaard Positie", + "max_position": "Maximale Posistie", "fov_left": "Gezichtsveld links", "fov_right": "Gezichtsveld rechts", "group": "Cover Entities", @@ -87,6 +90,7 @@ "angle": "De hoek gemeten vanaf de muur richting de grond waarin het scherm is gemonteerd", "distance_shaded_area": "Afstand van de cover tot het schaduwgebied in meters", "default_percentage": "Standaard posistie van de cover in percentages", + "max_position": "Maximale posistie tot waar de cover aangepast mag worden in percentages", "fov_left": "Aantal graden aan de linker kant vanuit het midden gezien van het raam", "fov_right": "Aantal graden aan de rechter kant vanuit het midden gezien van het raam", "group": "Selecteer de entities die worden bestuurd met de Blueprint", @@ -103,6 +107,7 @@ "slat_depth": "Lat diepte", "slat_distance": "Ruimte tussen latten", "default_percentage": "Standaard Positie", + "max_position": "Maximale Posistie", "fov_left": "Gezichtsveld links", "fov_right": "Gezichtsveld rechts", "group": "Cover Entities", @@ -117,6 +122,7 @@ "slat_depth": "Diepte van een individuele lat in cm", "slat_distance": "Verticale afstand tussen twee latten in cm", "default_percentage": "Standaard posistie van de cover in percentages", + "max_position": "Maximale posistie tot waar de cover aangepast mag worden in percentages", "fov_left": "Aantal graden aan de linker kant vanuit het midden gezien van het raam", "fov_right": "Aantal graden aan de rechter kant vanuit het midden gezien van het raam", "group": "Selecteer de entities die worden bestuurd met de Blueprint", @@ -139,6 +145,7 @@ "window_height": "Raam Hoogte", "distance_shaded_area": "Schaduwgebied", "default_percentage": "Standaard Positie", + "max_position": "Maximale Posistie", "fov_left": "Gezichtsveld links", "fov_right": "Gezichtsveld rechts", "group": "Cover Entities", @@ -152,6 +159,7 @@ "window_height": "Zet de hoogte van het raam/de ramen in meters", "distance_shaded_area": "Afstand van de cover tot het schaduwgebied in meters", "default_percentage": "Standaard posistie van de cover in percentages", + "max_position": "Maximale posistie tot waar de cover aangepast mag worden in percentages", "fov_left": "Aantal graden aan de linker kant vanuit het midden gezien van het raam", "fov_right": "Aantal graden aan de rechter kant vanuit het midden gezien van het raam", "group": "Selecteer de entities die worden bestuurd met de Blueprint", @@ -191,6 +199,7 @@ "angle": "Montage Hoek", "distance_shaded_area": "Schaduwgebied", "default_percentage": "Standaard Positie", + "max_position": "Maximale Posistie", "fov_left": "Gezichtsveld links", "fov_right": "Gezichtsveld rechts", "group": "Cover Entities", @@ -208,6 +217,7 @@ "angle": "De hoek gemeten vanaf de muur richting de grond waarin het scherm is gemonteerd", "distance_shaded_area": "Afstand van de cover tot het schaduwgebied in meters", "default_percentage": "Standaard posistie van de cover in percentages", + "max_position": "Maximale posistie tot waar de cover aangepast mag worden in percentages", "fov_left": "Aantal graden aan de linker kant vanuit het midden gezien van het raam", "fov_right": "Aantal graden aan de rechter kant vanuit het midden gezien van het raam", "group": "Selecteer de entities die worden bestuurd met de Blueprint", @@ -224,6 +234,7 @@ "slat_depth": "Lat diepte", "slat_distance": "Ruimte tussen latten", "default_percentage": "Standaard Positie", + "max_position": "Maximale Posistie", "fov_left": "Gezichtsveld links", "fov_right": "Gezichtsveld rechts", "group": "Cover Entities", @@ -238,6 +249,7 @@ "slat_depth": "Diepte van een individuele lat in cm", "slat_distance": "Verticale afstand tussen twee latten in cm", "default_percentage": "Standaard posistie van de cover in percentages", + "max_position": "Maximale posistie tot waar de cover aangepast mag worden in percentages", "fov_left": "Aantal graden aan de linker kant vanuit het midden gezien van het raam", "fov_right": "Aantal graden aan de rechter kant vanuit het midden gezien van het raam", "group": "Selecteer de entities die worden bestuurd met de Blueprint",