Skip to content

Commit

Permalink
Merge pull request #320 from basbruss/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
basbruss authored Oct 20, 2024
2 parents 8d6a418 + 5d191fc commit 522fda6
Show file tree
Hide file tree
Showing 5 changed files with 1,078 additions and 219 deletions.
2 changes: 2 additions & 0 deletions config/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,5 @@ template:
state: "{{21}}"
device_class: temperature
unit_of_measurement: "°C"

kitchen_sink:
238 changes: 175 additions & 63 deletions custom_components/adaptive_cover/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Any

import voluptuous as vol
from homeassistant import data_entry_flow
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
Expand All @@ -26,6 +27,8 @@
CONF_DELTA_TIME,
CONF_DISTANCE,
CONF_ENABLE_BLIND_SPOT,
CONF_ENABLE_MAX_POSITION,
CONF_ENABLE_MIN_POSITION,
CONF_END_ENTITY,
CONF_END_TIME,
CONF_ENTITIES,
Expand All @@ -50,7 +53,9 @@
CONF_MAX_ELEVATION,
CONF_MAX_POSITION,
CONF_MIN_ELEVATION,
CONF_MIN_POSITION,
CONF_MODE,
CONF_OUTSIDE_THRESHOLD,
CONF_OUTSIDETEMP_ENTITY,
CONF_PRESENCE_ENTITY,
CONF_RETURN_SUNSET,
Expand All @@ -69,12 +74,8 @@
CONF_TRANSPARENT_BLIND,
CONF_WEATHER_ENTITY,
CONF_WEATHER_STATE,
CONF_OUTSIDE_THRESHOLD,
DOMAIN,
SensorType,
CONF_MIN_POSITION,
CONF_ENABLE_MAX_POSITION,
CONF_ENABLE_MIN_POSITION,
)

# DEFAULT_NAME = "Adaptive Cover"
Expand All @@ -99,32 +100,74 @@
}
)

OPTIONS = vol.Schema(
ELEVATION = vol.Schema(
{
vol.Required(CONF_AZIMUTH, default=180): selector.NumberSelector(
vol.Optional(CONF_MIN_ELEVATION, default=0): selector.NumberSelector(
selector.NumberSelectorConfig(
min=0, max=359, mode="slider", unit_of_measurement="°"
min=0, max=90, mode="slider", unit_of_measurement="°"
)
),
vol.Required(CONF_DEFAULT_HEIGHT, default=60): selector.NumberSelector(
vol.Optional(CONF_MAX_ELEVATION, default=90): selector.NumberSelector(
selector.NumberSelectorConfig(
min=0, max=100, step=1, mode="slider", unit_of_measurement="%"
min=0, max=90, mode="slider", unit_of_measurement="°"
)
),
vol.Optional(CONF_MAX_POSITION): vol.All(
vol.Coerce(int), vol.Range(min=1, max=100)
}
)

LUX = vol.Schema(
{
vol.Optional(CONF_LUX_ENTITY, default=vol.UNDEFINED): selector.EntitySelector(
selector.EntityFilterSelectorConfig(
domain=["sensor"], device_class="illuminance"
)
),
vol.Optional(CONF_ENABLE_MAX_POSITION, default=False): bool,
vol.Optional(CONF_MIN_POSITION): vol.All(
vol.Coerce(int), vol.Range(min=0, max=99)
vol.Optional(CONF_LUX_THRESHOLD, default=1000): selector.NumberSelector(
selector.NumberSelectorConfig(mode="box", unit_of_measurement="lux")
),
vol.Optional(CONF_ENABLE_MIN_POSITION, default=False): bool,
vol.Optional(CONF_MIN_ELEVATION): vol.All(
vol.Coerce(int), vol.Range(min=0, max=90)
}
)

IRRADIANCE = vol.Schema(
{
vol.Optional(
CONF_IRRADIANCE_ENTITY, default=vol.UNDEFINED
): selector.EntitySelector(
selector.EntityFilterSelectorConfig(
domain=["sensor"], device_class="irradiance"
)
),
vol.Optional(CONF_MAX_ELEVATION): vol.All(
vol.Coerce(int), vol.Range(min=0, max=90)
vol.Optional(CONF_IRRADIANCE_THRESHOLD, default=300): selector.NumberSelector(
selector.NumberSelectorConfig(mode="box", unit_of_measurement="W/m²")
),
}
)

TEMPERATURE = vol.Schema(
{
vol.Required(CONF_TEMP_ENTITY): selector.EntitySelector(
selector.EntityFilterSelectorConfig(domain=["climate", "sensor"])
),
vol.Required(CONF_TEMP_LOW, default=21): selector.NumberSelector(
selector.NumberSelectorConfig(
min=0, max=86, step=1, mode="slider", unit_of_measurement="°"
)
),
vol.Required(CONF_TEMP_HIGH, default=25): selector.NumberSelector(
selector.NumberSelectorConfig(
min=0, max=90, step=1, mode="slider", unit_of_measurement="°"
)
),
vol.Optional(
CONF_OUTSIDETEMP_ENTITY, default=vol.UNDEFINED
): selector.EntitySelector(
selector.EntityFilterSelectorConfig(domain=["sensor"])
),
}
)

FOV = vol.Schema(
{
vol.Required(CONF_FOV_LEFT, default=90): selector.NumberSelector(
selector.NumberSelectorConfig(
min=1, max=90, step=1, mode="slider", unit_of_measurement="°"
Expand All @@ -135,17 +178,120 @@
min=1, max=90, step=1, mode="slider", unit_of_measurement="°"
)
),
}
)


DEFAULT = vol.Schema(
{
vol.Required(CONF_DEFAULT_HEIGHT, default=60): selector.NumberSelector(
selector.NumberSelectorConfig(
min=0, max=100, step=1, mode="slider", unit_of_measurement="%"
)
),
vol.Required(CONF_SUNSET_POS, default=0): selector.NumberSelector(
selector.NumberSelectorConfig(
min=0, max=100, step=1, mode="slider", unit_of_measurement="%"
)
),
}
)

SUN_OFFSET = vol.Schema(
{
vol.Required(CONF_SUNSET_OFFSET, default=0): selector.NumberSelector(
selector.NumberSelectorConfig(mode="box", unit_of_measurement="minutes")
),
vol.Required(CONF_SUNRISE_OFFSET, default=0): selector.NumberSelector(
selector.NumberSelectorConfig(mode="box", unit_of_measurement="minutes")
),
}
)

POSITION_LIMITS = vol.Schema(
{
vol.Optional(CONF_MAX_POSITION, default=100): selector.NumberSelector(
selector.NumberSelectorConfig(
min=1, max=100, mode="slider", unit_of_measurement="°"
)
),
vol.Optional(CONF_ENABLE_MAX_POSITION, default=False): bool,
vol.Optional(CONF_MIN_POSITION, default=0): selector.NumberSelector(
selector.NumberSelectorConfig(
min=0, max=99, mode="slider", unit_of_measurement="°"
)
),
vol.Optional(CONF_ENABLE_MIN_POSITION, default=False): bool,
}
)

DELTA = vol.Schema(
{
vol.Required(CONF_DELTA_POSITION, default=1): selector.NumberSelector(
selector.NumberSelectorConfig(
min=1, max=90, step=1, mode="slider", unit_of_measurement="%"
)
),
vol.Optional(CONF_DELTA_TIME, default=2): selector.NumberSelector(
selector.NumberSelectorConfig(
min=2, mode="box", unit_of_measurement="minutes"
)
),
}
)

START = vol.Schema(
{
vol.Optional(CONF_START_TIME, default="00:00:00"): selector.TimeSelector(),
vol.Optional(CONF_START_ENTITY): selector.EntitySelector(
selector.EntitySelectorConfig(domain=["sensor", "input_datetime"])
),
}
)

END = vol.Schema(
{
vol.Optional(CONF_END_TIME, default="00:00:00"): selector.TimeSelector(),
vol.Optional(CONF_END_ENTITY): selector.EntitySelector(
selector.EntitySelectorConfig(domain=["sensor", "input_datetime"])
),
vol.Optional(CONF_RETURN_SUNSET, default=False): bool,
}
)

MANUAL = vol.Schema(
{
vol.Required(
CONF_MANUAL_OVERRIDE_DURATION, default={"minutes": 15}
): selector.DurationSelector(),
vol.Required(CONF_MANUAL_OVERRIDE_RESET, default=False): bool,
vol.Optional(CONF_MANUAL_THRESHOLD): vol.All(
vol.Coerce(int), vol.Range(min=0, max=99)
),
vol.Optional(CONF_MANUAL_IGNORE_INTERMEDIATE, default=False): bool,
}
)

OPTIONS = vol.Schema(
{
vol.Required(CONF_AZIMUTH, default=180): selector.NumberSelector(
selector.NumberSelectorConfig(
min=0, max=359, mode="slider", unit_of_measurement="°"
)
),
vol.Required("section_fov"): data_entry_flow.section(FOV, {"collapsed": False}),
vol.Required("section_default"): data_entry_flow.section(
DEFAULT, {"collapsed": False}
),
vol.Optional("section_sun_offset"): data_entry_flow.section(
SUN_OFFSET, {"collapsed": True}
),
vol.Optional("section_elevation"): data_entry_flow.section(
ELEVATION, {"collapsed": True}
),
vol.Optional("section_position_limits"): data_entry_flow.section(
POSITION_LIMITS, {"collapsed": True}
),
vol.Required(CONF_INVERSE_STATE, default=False): bool,
vol.Required(CONF_ENABLE_BLIND_SPOT, default=False): bool,
vol.Required(CONF_INTERP, default=False): bool,
Expand Down Expand Up @@ -241,33 +387,16 @@
): selector.EntitySelector(
selector.EntityFilterSelectorConfig(domain=["sensor"])
),
vol.Optional(CONF_OUTSIDE_THRESHOLD, default=0): vol.All(
vol.Coerce(int), vol.Range(min=0, max=100)
),
vol.Optional(
CONF_PRESENCE_ENTITY, default=vol.UNDEFINED
): selector.EntitySelector(
selector.EntityFilterSelectorConfig(
domain=["device_tracker", "zone", "binary_sensor", "input_boolean"]
)
),
vol.Optional(CONF_LUX_ENTITY, default=vol.UNDEFINED): selector.EntitySelector(
selector.EntityFilterSelectorConfig(
domain=["sensor"], device_class="illuminance"
)
),
vol.Optional(CONF_LUX_THRESHOLD, default=1000): selector.NumberSelector(
selector.NumberSelectorConfig(mode="box", unit_of_measurement="lux")
),
vol.Optional(
CONF_IRRADIANCE_ENTITY, default=vol.UNDEFINED
): selector.EntitySelector(
selector.EntityFilterSelectorConfig(
domain=["sensor"], device_class="irradiance"
)
),
vol.Optional(CONF_IRRADIANCE_THRESHOLD, default=300): selector.NumberSelector(
selector.NumberSelectorConfig(mode="box", unit_of_measurement="W/m²")
vol.Optional("section_lux"): data_entry_flow.section(LUX, {"collapsed": True}),
vol.Optional("section_irradiance"): data_entry_flow.section(
IRRADIANCE, {"collapsed": True}
),
vol.Optional(CONF_TRANSPARENT_BLIND, default=False): selector.BooleanSelector(),
vol.Optional(
Expand Down Expand Up @@ -312,33 +441,16 @@

AUTOMATION_CONFIG = vol.Schema(
{
vol.Required(CONF_DELTA_POSITION, default=1): selector.NumberSelector(
selector.NumberSelectorConfig(
min=1, max=90, step=1, mode="slider", unit_of_measurement="%"
)
vol.Required("section_delta"): data_entry_flow.section(
DELTA, {"collapsed": False}
),
vol.Optional(CONF_DELTA_TIME, default=2): selector.NumberSelector(
selector.NumberSelectorConfig(
min=2, mode="box", unit_of_measurement="minutes"
)
vol.Optional("section_start"): data_entry_flow.section(
START, {"collapsed": True}
),
vol.Optional(CONF_START_TIME, default="00:00:00"): selector.TimeSelector(),
vol.Optional(CONF_START_ENTITY): selector.EntitySelector(
selector.EntitySelectorConfig(domain=["sensor", "input_datetime"])
vol.Optional("section_end"): data_entry_flow.section(END, {"collapsed": True}),
vol.Optional("section_manual"): data_entry_flow.section(
MANUAL, {"collapsed": True}
),
vol.Required(
CONF_MANUAL_OVERRIDE_DURATION, default={"minutes": 15}
): selector.DurationSelector(),
vol.Required(CONF_MANUAL_OVERRIDE_RESET, default=False): bool,
vol.Optional(CONF_MANUAL_THRESHOLD): vol.All(
vol.Coerce(int), vol.Range(min=0, max=99)
),
vol.Optional(CONF_MANUAL_IGNORE_INTERMEDIATE, default=False): bool,
vol.Optional(CONF_END_TIME, default="00:00:00"): selector.TimeSelector(),
vol.Optional(CONF_END_ENTITY): selector.EntitySelector(
selector.EntitySelectorConfig(domain=["sensor", "input_datetime"])
),
vol.Optional(CONF_RETURN_SUNSET, default=False): bool,
}
)

Expand Down
Loading

0 comments on commit 522fda6

Please sign in to comment.