mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-11 22:34:04 +02:00
Merge pull request #358 from Hypfer/min_and_max_time_overrides
Add max_sunrise_time and min_sunset_time overrides
This commit is contained in:
commit
a1442c74b6
5 changed files with 35 additions and 2 deletions
|
|
@ -48,7 +48,7 @@ adaptive_lighting:
|
|||
|
||||
### Options
|
||||
| option | description | required | default | type |
|
||||
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------------- | ------- |
|
||||
|---------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -------- | -------------- | ------- |
|
||||
| name | The name to use when displaying this switch. | False | default | string |
|
||||
| lights | List of light entities for Adaptive Lighting to control (may be empty). | False | list | [] |
|
||||
| prefer_rgb_color | Whether to use RGB color adjustment instead of native light color temperature. | False | False | boolean |
|
||||
|
|
@ -65,8 +65,10 @@ adaptive_lighting:
|
|||
| sleep_rgb_color | List of three numbers between 0-255, indicating the RGB color in sleep mode (only used when sleep_rgb_or_color_temp is 'rgb_color'). | False | `[255, 56, 0]` | list |
|
||||
| sleep_color_temp | Color temperature of lights while the sleep mode is enabled (only used when sleep_rgb_or_color_temp is 'color_temp'). | False | 1000 | integer |
|
||||
| sunrise_time | Override the sunrise time with a fixed time. | False | time | |
|
||||
| max_sunrise_time | Make the virtual sun always rise at at most a specific time while still allowing for even earlier times based on the real sun | False | time | |
|
||||
| sunrise_offset | Change the sunrise time with a positive or negative offset. | False | 0 | time |
|
||||
| sunset_time | Override the sunset time with a fixed time. | False | time | |
|
||||
| min_sunset_time | Make the virtual sun always set at at least a specific time while still allowing for even later times based on the real sun | False | time | |
|
||||
| sunset_offset | Change the sunset time with a positive or negative offset. | False | 0 | time |
|
||||
| only_once | Whether to keep adapting the lights (false) or to only adapt the lights as soon as they are turned on (true). | False | False | boolean |
|
||||
| take_over_control | If another source calls `light.turn_on` while the lights are on and being adapted, disable Adaptive Lighting. | False | True | boolean |
|
||||
|
|
|
|||
|
|
@ -39,8 +39,10 @@ CONF_SLEEP_RGB_OR_COLOR_TEMP, DEFAULT_SLEEP_RGB_OR_COLOR_TEMP = (
|
|||
)
|
||||
CONF_SUNRISE_OFFSET, DEFAULT_SUNRISE_OFFSET = "sunrise_offset", 0
|
||||
CONF_SUNRISE_TIME = "sunrise_time"
|
||||
CONF_MAX_SUNRISE_TIME = "max_sunrise_time"
|
||||
CONF_SUNSET_OFFSET, DEFAULT_SUNSET_OFFSET = "sunset_offset", 0
|
||||
CONF_SUNSET_TIME = "sunset_time"
|
||||
CONF_MIN_SUNSET_TIME = "min_sunset_time"
|
||||
CONF_TAKE_OVER_CONTROL, DEFAULT_TAKE_OVER_CONTROL = "take_over_control", True
|
||||
CONF_TRANSITION, DEFAULT_TRANSITION = "transition", 45
|
||||
|
||||
|
|
@ -97,8 +99,10 @@ VALIDATION_TUPLES = [
|
|||
selector.ColorRGBSelector(selector.ColorRGBSelectorConfig()),
|
||||
),
|
||||
(CONF_SUNRISE_TIME, NONE_STR, str),
|
||||
(CONF_MAX_SUNRISE_TIME, NONE_STR, str),
|
||||
(CONF_SUNRISE_OFFSET, DEFAULT_SUNRISE_OFFSET, int),
|
||||
(CONF_SUNSET_TIME, NONE_STR, str),
|
||||
(CONF_MIN_SUNSET_TIME, NONE_STR, str),
|
||||
(CONF_SUNSET_OFFSET, DEFAULT_SUNSET_OFFSET, int),
|
||||
(CONF_ONLY_ONCE, DEFAULT_ONLY_ONCE, bool),
|
||||
(CONF_TAKE_OVER_CONTROL, DEFAULT_TAKE_OVER_CONTROL, bool),
|
||||
|
|
@ -122,8 +126,10 @@ EXTRA_VALIDATION = {
|
|||
CONF_INTERVAL: (cv.time_period, timedelta_as_int),
|
||||
CONF_SUNRISE_OFFSET: (cv.time_period, timedelta_as_int),
|
||||
CONF_SUNRISE_TIME: (cv.time, str),
|
||||
CONF_MAX_SUNRISE_TIME: (cv.time, str),
|
||||
CONF_SUNSET_OFFSET: (cv.time_period, timedelta_as_int),
|
||||
CONF_SUNSET_TIME: (cv.time, str),
|
||||
CONF_MIN_SUNSET_TIME: (cv.time, str),
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -36,8 +36,10 @@
|
|||
"sleep_color_temp": "sleep_color_temp: Color temperature setting for Sleep Mode. (Kelvin)",
|
||||
"sunrise_offset": "sunrise_offset: How long before(-) or after(+) to define the sunrise point of the cycle (+/- seconds)",
|
||||
"sunrise_time": "sunrise_time: Manual override of the sunrise time, if 'None', it uses the actual sunrise time at your location (HH:MM:SS)",
|
||||
"max_sunrise_time": "max_sunrise_time: Manual override of the maximum sunrise time, if 'None', it uses the actual sunrise time at your location (HH:MM:SS)",
|
||||
"sunset_offset": "sunset_offset: How long before(-) or after(+) to define the sunset point of the cycle (+/- seconds)",
|
||||
"sunset_time": "sunset_time: Manual override of the sunset time, if 'None', it uses the actual sunrise time at your location (HH:MM:SS)",
|
||||
"min_sunset_time": "min_sunset_time: Manual override of the minimum sunset time, if 'None', it uses the actual sunrise time at your location (HH:MM:SS)",
|
||||
"take_over_control": "take_over_control: If anything but Adaptive Lighting calls 'light.turn_on' when a light is already on, stop adapting that light until it (or the switch) toggles off -> on.",
|
||||
"detect_non_ha_changes": "detect_non_ha_changes: detects all >10% changes made to the lights (also outside of HA), requires 'take_over_control' to be enabled (calls 'homeassistant.update_entity' every 'interval'!)",
|
||||
"transition": "Transition time when applying a change to the lights (seconds)",
|
||||
|
|
|
|||
|
|
@ -106,8 +106,10 @@ from .const import (
|
|||
CONF_MANUAL_CONTROL,
|
||||
CONF_MAX_BRIGHTNESS,
|
||||
CONF_MAX_COLOR_TEMP,
|
||||
CONF_MAX_SUNRISE_TIME,
|
||||
CONF_MIN_BRIGHTNESS,
|
||||
CONF_MIN_COLOR_TEMP,
|
||||
CONF_MIN_SUNSET_TIME,
|
||||
CONF_ONLY_ONCE,
|
||||
CONF_PREFER_RGB_COLOR,
|
||||
CONF_SEPARATE_TURN_ON_COMMANDS,
|
||||
|
|
@ -593,8 +595,10 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity):
|
|||
sleep_rgb_or_color_temp=data[CONF_SLEEP_RGB_OR_COLOR_TEMP],
|
||||
sunrise_offset=data[CONF_SUNRISE_OFFSET],
|
||||
sunrise_time=data[CONF_SUNRISE_TIME],
|
||||
max_sunrise_time=data[CONF_MAX_SUNRISE_TIME],
|
||||
sunset_offset=data[CONF_SUNSET_OFFSET],
|
||||
sunset_time=data[CONF_SUNSET_TIME],
|
||||
min_sunset_time=data[CONF_MIN_SUNSET_TIME],
|
||||
time_zone=self.hass.config.time_zone,
|
||||
transition=data[CONF_TRANSITION],
|
||||
)
|
||||
|
|
@ -1089,8 +1093,10 @@ class SunLightSettings:
|
|||
sleep_rgb_color: tuple[int, int, int]
|
||||
sunrise_offset: datetime.timedelta | None
|
||||
sunrise_time: datetime.time | None
|
||||
max_sunrise_time: datetime.time | None
|
||||
sunset_offset: datetime.timedelta | None
|
||||
sunset_time: datetime.time | None
|
||||
min_sunset_time: datetime.time | None
|
||||
time_zone: datetime.tzinfo
|
||||
transition: int
|
||||
|
||||
|
|
@ -1135,7 +1141,22 @@ class SunLightSettings:
|
|||
else _replace_time(date, "sunset")
|
||||
) + self.sunset_offset
|
||||
|
||||
if self.sunrise_time is None and self.sunset_time is None:
|
||||
if self.max_sunrise_time is not None:
|
||||
max_sunrise = _replace_time(date, "max_sunrise")
|
||||
if max_sunrise < sunrise:
|
||||
sunrise = max_sunrise
|
||||
|
||||
if self.min_sunset_time is not None:
|
||||
min_sunset = _replace_time(date, "min_sunset")
|
||||
if min_sunset > sunset:
|
||||
sunset = min_sunset
|
||||
|
||||
if (
|
||||
self.sunrise_time is None
|
||||
and self.sunset_time is None
|
||||
and self.max_sunrise_time is None
|
||||
and self.min_sunset_time is None
|
||||
):
|
||||
try:
|
||||
# Astral v1
|
||||
solar_noon = location.solar_noon(date, local=False)
|
||||
|
|
|
|||
|
|
@ -37,8 +37,10 @@
|
|||
"sleep_color_temp": "sleep_color_temp: Color temperature setting for Sleep Mode. (Kelvin)",
|
||||
"sunrise_offset": "sunrise_offset: How long before(-) or after(+) to define the sunrise point of the cycle (+/- seconds)",
|
||||
"sunrise_time": "sunrise_time: Manual override of the sunrise time, if 'None', it uses the actual sunrise time at your location (HH:MM:SS)",
|
||||
"max_sunrise_time": "max_sunrise_time: Manual override of the maximum sunrise time, if 'None', it uses the actual sunrise time at your location (HH:MM:SS)",
|
||||
"sunset_offset": "sunset_offset: How long before(-) or after(+) to define the sunset point of the cycle (+/- seconds)",
|
||||
"sunset_time": "sunset_time: Manual override of the sunset time, if 'None', it uses the actual sunrise time at your location (HH:MM:SS)",
|
||||
"min_sunset_time": "min_sunset_time: Manual override of the minimum sunset time, if 'None', it uses the actual sunrise time at your location (HH:MM:SS)",
|
||||
"take_over_control": "take_over_control: If anything but Adaptive Lighting calls 'light.turn_on' when a light is already on, stop adapting that light until it (or the switch) toggles off -> on.",
|
||||
"detect_non_ha_changes": "detect_non_ha_changes: detects all >10% changes made to the lights (also outside of HA), requires 'take_over_control' to be enabled (calls 'homeassistant.update_entity' every 'interval'!)",
|
||||
"transition": "Transition time when applying a change to the lights (seconds)",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue