Skip to content

Commit

Permalink
Merge pull request #68 from basbruss/feature
Browse files Browse the repository at this point in the history
Add maximum position variable
  • Loading branch information
basbruss authored Mar 13, 2024
2 parents fc0348c + b173da6 commit 86c5a66
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 2 deletions.
10 changes: 8 additions & 2 deletions custom_components/adaptive_cover/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions custom_components/adaptive_cover/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
CONF_HEIGHT_WIN,
CONF_INVERSE_STATE,
CONF_LENGTH_AWNING,
CONF_MAX_POSITION,
CONF_MODE,
CONF_PRESENCE_ENTITY,
CONF_SENSOR_TYPE,
Expand Down Expand Up @@ -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")
),
Expand Down Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions custom_components/adaptive_cover/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions custom_components/adaptive_cover/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = [
Expand Down
12 changes: 12 additions & 0 deletions custom_components/adaptive_cover/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions custom_components/adaptive_cover/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions custom_components/adaptive_cover/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit 86c5a66

Please sign in to comment.