mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-17 01:04:05 +02:00
Compare commits
5 commits
main
...
add_flat_l
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31d9552c38 |
||
|
|
aad2eaf595 |
||
|
|
090c0abc6d | ||
|
|
cb27264d6a |
||
|
|
f18c5f161b |
5 changed files with 53 additions and 32 deletions
|
|
@ -91,7 +91,7 @@ The YAML and frontend configuration methods support all of the options listed be
|
||||||
<!-- START_OUTPUT -->
|
<!-- START_OUTPUT -->
|
||||||
<!-- THIS CONTENT IS AUTOMATICALLY GENERATED -->
|
<!-- THIS CONTENT IS AUTOMATICALLY GENERATED -->
|
||||||
| Variable name | Description | Default | Type |
|
| Variable name | Description | Default | Type |
|
||||||
|:-------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------|:-------------------------------------|
|
|:-------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------|:-------------------------------------|
|
||||||
| `lights` | List of light entity_ids to be controlled (may be empty). 🌟 | `[]` | list of `entity_id`s |
|
| `lights` | List of light entity_ids to be controlled (may be empty). 🌟 | `[]` | list of `entity_id`s |
|
||||||
| `prefer_rgb_color` | Whether to prefer RGB color adjustment over light color temperature when possible. 🌈 | `False` | `bool` |
|
| `prefer_rgb_color` | Whether to prefer RGB color adjustment over light color temperature when possible. 🌈 | `False` | `bool` |
|
||||||
| `include_config_in_attributes` | Show all options as attributes on the switch in Home Assistant when set to `true`. 📝 | `False` | `bool` |
|
| `include_config_in_attributes` | Show all options as attributes on the switch in Home Assistant when set to `true`. 📝 | `False` | `bool` |
|
||||||
|
|
@ -115,6 +115,7 @@ The YAML and frontend configuration methods support all of the options listed be
|
||||||
| `min_sunset_time` | Set the earliest virtual sunset time (HH:MM:SS), allowing for later real sunsets. 🌇 | `None` | `str` |
|
| `min_sunset_time` | Set the earliest virtual sunset time (HH:MM:SS), allowing for later real sunsets. 🌇 | `None` | `str` |
|
||||||
| `sunset_offset` | Adjust sunset time with a positive or negative offset in seconds. ⏰ | `0` | `int` |
|
| `sunset_offset` | Adjust sunset time with a positive or negative offset in seconds. ⏰ | `0` | `int` |
|
||||||
| `only_once` | Adapt lights only when they are turned on (`true`) or keep adapting them (`false`). 🔄 | `False` | `bool` |
|
| `only_once` | Adapt lights only when they are turned on (`true`) or keep adapting them (`false`). 🔄 | `False` | `bool` |
|
||||||
|
| `flat_limits` | When True, will not calculate between the max/min supported limits of your light. Example: when adapting brightness to 50% while max_brightness is set to 80%, Adaptive Lighting will use 80% instead of 90% | `False` | `bool` |
|
||||||
| `take_over_control` | Disable Adaptive Lighting if another source calls `light.turn_on` while lights are on and being adapted. Note that this calls `homeassistant.update_entity` every `interval`! 🔒 | `True` | `bool` |
|
| `take_over_control` | Disable Adaptive Lighting if another source calls `light.turn_on` while lights are on and being adapted. Note that this calls `homeassistant.update_entity` every `interval`! 🔒 | `True` | `bool` |
|
||||||
| `detect_non_ha_changes` | Detect non-`light.turn_on` state changes and stop adapting lights. Requires `take_over_control`. 🕵️ | `False` | `bool` |
|
| `detect_non_ha_changes` | Detect non-`light.turn_on` state changes and stop adapting lights. Requires `take_over_control`. 🕵️ | `False` | `bool` |
|
||||||
| `separate_turn_on_commands` | Use separate `light.turn_on` calls for color and brightness, needed for some light types. 🔀 | `False` | `bool` |
|
| `separate_turn_on_commands` | Use separate `light.turn_on` calls for color and brightness, needed for some light types. 🔀 | `False` | `bool` |
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,14 @@ DOCS[CONF_MIN_BRIGHTNESS] = "Minimum brightness percentage. 💡"
|
||||||
CONF_MIN_COLOR_TEMP, DEFAULT_MIN_COLOR_TEMP = "min_color_temp", 2000
|
CONF_MIN_COLOR_TEMP, DEFAULT_MIN_COLOR_TEMP = "min_color_temp", 2000
|
||||||
DOCS[CONF_MIN_COLOR_TEMP] = "Warmest color temperature in Kelvin. 🔥"
|
DOCS[CONF_MIN_COLOR_TEMP] = "Warmest color temperature in Kelvin. 🔥"
|
||||||
|
|
||||||
|
CONF_FLAT_LIMITS, DEFAULT_FLAT_LIMITS = "flat_limits", False
|
||||||
|
DOCS[CONF_FLAT_LIMITS] = (
|
||||||
|
"When True, will not calculate between the"
|
||||||
|
" max/min supported limits of your light. Example: when adapting brightness to 50% while "
|
||||||
|
+ CONF_MAX_BRIGHTNESS
|
||||||
|
+ " is set to 80%, Adaptive Lighting will use 80% instead of 90%"
|
||||||
|
)
|
||||||
|
|
||||||
CONF_ONLY_ONCE, DEFAULT_ONLY_ONCE = "only_once", False
|
CONF_ONLY_ONCE, DEFAULT_ONLY_ONCE = "only_once", False
|
||||||
DOCS[CONF_ONLY_ONCE] = (
|
DOCS[CONF_ONLY_ONCE] = (
|
||||||
"Adapt lights only when they are turned on (`true`) or keep adapting them "
|
"Adapt lights only when they are turned on (`true`) or keep adapting them "
|
||||||
|
|
@ -261,6 +269,7 @@ VALIDATION_TUPLES = [
|
||||||
(CONF_MIN_SUNSET_TIME, NONE_STR, str),
|
(CONF_MIN_SUNSET_TIME, NONE_STR, str),
|
||||||
(CONF_SUNSET_OFFSET, DEFAULT_SUNSET_OFFSET, int),
|
(CONF_SUNSET_OFFSET, DEFAULT_SUNSET_OFFSET, int),
|
||||||
(CONF_ONLY_ONCE, DEFAULT_ONLY_ONCE, bool),
|
(CONF_ONLY_ONCE, DEFAULT_ONLY_ONCE, bool),
|
||||||
|
(CONF_FLAT_LIMITS, DEFAULT_FLAT_LIMITS, bool),
|
||||||
(CONF_TAKE_OVER_CONTROL, DEFAULT_TAKE_OVER_CONTROL, bool),
|
(CONF_TAKE_OVER_CONTROL, DEFAULT_TAKE_OVER_CONTROL, bool),
|
||||||
(CONF_DETECT_NON_HA_CHANGES, DEFAULT_DETECT_NON_HA_CHANGES, bool),
|
(CONF_DETECT_NON_HA_CHANGES, DEFAULT_DETECT_NON_HA_CHANGES, bool),
|
||||||
(CONF_SEPARATE_TURN_ON_COMMANDS, DEFAULT_SEPARATE_TURN_ON_COMMANDS, bool),
|
(CONF_SEPARATE_TURN_ON_COMMANDS, DEFAULT_SEPARATE_TURN_ON_COMMANDS, bool),
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@
|
||||||
"min_sunset_time": "min_sunset_time: Set the earliest virtual sunset time (HH:MM:SS), allowing for later real sunsets. 🌇",
|
"min_sunset_time": "min_sunset_time: Set the earliest virtual sunset time (HH:MM:SS), allowing for later real sunsets. 🌇",
|
||||||
"sunset_offset": "sunset_offset: Adjust sunset time with a positive or negative offset in seconds. ⏰",
|
"sunset_offset": "sunset_offset: Adjust sunset time with a positive or negative offset in seconds. ⏰",
|
||||||
"only_once": "only_once: Adapt lights only when they are turned on (`true`) or keep adapting them (`false`). 🔄",
|
"only_once": "only_once: Adapt lights only when they are turned on (`true`) or keep adapting them (`false`). 🔄",
|
||||||
|
"flat_limits": "flat_limits: When True, will not calculate between the max/min supported limits of your light. Example: when adapting brightness to 50% while max_brightness is set to 80%, Adaptive Lighting will use 80% instead of 90%",
|
||||||
"take_over_control": "take_over_control: Disable Adaptive Lighting if another source calls `light.turn_on` while lights are on and being adapted. Note that this calls `homeassistant.update_entity` every `interval`! 🔒",
|
"take_over_control": "take_over_control: Disable Adaptive Lighting if another source calls `light.turn_on` while lights are on and being adapted. Note that this calls `homeassistant.update_entity` every `interval`! 🔒",
|
||||||
"detect_non_ha_changes": "detect_non_ha_changes: Detect non-`light.turn_on` state changes and stop adapting lights. Requires `take_over_control`. 🕵️",
|
"detect_non_ha_changes": "detect_non_ha_changes: Detect non-`light.turn_on` state changes and stop adapting lights. Requires `take_over_control`. 🕵️",
|
||||||
"separate_turn_on_commands": "separate_turn_on_commands: Use separate `light.turn_on` calls for color and brightness, needed for some light types. 🔀",
|
"separate_turn_on_commands": "separate_turn_on_commands: Use separate `light.turn_on` calls for color and brightness, needed for some light types. 🔀",
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ from .const import (
|
||||||
CONF_ADAPT_UNTIL_SLEEP,
|
CONF_ADAPT_UNTIL_SLEEP,
|
||||||
CONF_AUTORESET_CONTROL,
|
CONF_AUTORESET_CONTROL,
|
||||||
CONF_DETECT_NON_HA_CHANGES,
|
CONF_DETECT_NON_HA_CHANGES,
|
||||||
|
CONF_FLAT_LIMITS,
|
||||||
CONF_INCLUDE_CONFIG_IN_ATTRIBUTES,
|
CONF_INCLUDE_CONFIG_IN_ATTRIBUTES,
|
||||||
CONF_INITIAL_TRANSITION,
|
CONF_INITIAL_TRANSITION,
|
||||||
CONF_INTERVAL,
|
CONF_INTERVAL,
|
||||||
|
|
@ -934,6 +935,7 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity):
|
||||||
name=self._name,
|
name=self._name,
|
||||||
astral_location=location,
|
astral_location=location,
|
||||||
adapt_until_sleep=data[CONF_ADAPT_UNTIL_SLEEP],
|
adapt_until_sleep=data[CONF_ADAPT_UNTIL_SLEEP],
|
||||||
|
flat_limits=data[CONF_FLAT_LIMITS],
|
||||||
max_brightness=data[CONF_MAX_BRIGHTNESS],
|
max_brightness=data[CONF_MAX_BRIGHTNESS],
|
||||||
max_color_temp=data[CONF_MAX_COLOR_TEMP],
|
max_color_temp=data[CONF_MAX_COLOR_TEMP],
|
||||||
min_brightness=data[CONF_MIN_BRIGHTNESS],
|
min_brightness=data[CONF_MIN_BRIGHTNESS],
|
||||||
|
|
@ -1473,6 +1475,7 @@ class SunLightSettings:
|
||||||
name: str
|
name: str
|
||||||
astral_location: astral.Location
|
astral_location: astral.Location
|
||||||
adapt_until_sleep: bool
|
adapt_until_sleep: bool
|
||||||
|
flat_limits: bool
|
||||||
max_brightness: int
|
max_brightness: int
|
||||||
max_color_temp: int
|
max_color_temp: int
|
||||||
min_brightness: int
|
min_brightness: int
|
||||||
|
|
@ -1612,8 +1615,14 @@ class SunLightSettings:
|
||||||
return self.sleep_brightness
|
return self.sleep_brightness
|
||||||
if percent > 0:
|
if percent > 0:
|
||||||
return self.max_brightness
|
return self.max_brightness
|
||||||
delta_brightness = self.max_brightness - self.min_brightness
|
|
||||||
percent = 1 + percent
|
percent = 1 + percent
|
||||||
|
if self.flat_limits:
|
||||||
|
if percent * 100 > self.max_brightness:
|
||||||
|
return self.max_brightness
|
||||||
|
elif percent * 100 < self.min_brightness:
|
||||||
|
return self.min_brightness
|
||||||
|
return percent * 100
|
||||||
|
delta_brightness = self.max_brightness - self.min_brightness
|
||||||
return (delta_brightness * percent) + self.min_brightness
|
return (delta_brightness * percent) + self.min_brightness
|
||||||
|
|
||||||
def calc_color_temp_kelvin(self, percent: float) -> int:
|
def calc_color_temp_kelvin(self, percent: float) -> int:
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@
|
||||||
"min_sunset_time": "min_sunset_time: Set the earliest virtual sunset time (HH:MM:SS), allowing for later real sunsets. 🌇",
|
"min_sunset_time": "min_sunset_time: Set the earliest virtual sunset time (HH:MM:SS), allowing for later real sunsets. 🌇",
|
||||||
"sunset_offset": "sunset_offset: Adjust sunset time with a positive or negative offset in seconds. ⏰",
|
"sunset_offset": "sunset_offset: Adjust sunset time with a positive or negative offset in seconds. ⏰",
|
||||||
"only_once": "only_once: Adapt lights only when they are turned on (`true`) or keep adapting them (`false`). 🔄",
|
"only_once": "only_once: Adapt lights only when they are turned on (`true`) or keep adapting them (`false`). 🔄",
|
||||||
|
"flat_limits": "flat_limits: When True, will not calculate between the max/min supported limits of your light. Example: when adapting brightness to 50% while max_brightness is set to 80%, Adaptive Lighting will use 80% instead of 90%",
|
||||||
"take_over_control": "take_over_control: Disable Adaptive Lighting if another source calls `light.turn_on` while lights are on and being adapted. Note that this calls `homeassistant.update_entity` every `interval`! 🔒",
|
"take_over_control": "take_over_control: Disable Adaptive Lighting if another source calls `light.turn_on` while lights are on and being adapted. Note that this calls `homeassistant.update_entity` every `interval`! 🔒",
|
||||||
"detect_non_ha_changes": "detect_non_ha_changes: Detect non-`light.turn_on` state changes and stop adapting lights. Requires `take_over_control`. 🕵️",
|
"detect_non_ha_changes": "detect_non_ha_changes: Detect non-`light.turn_on` state changes and stop adapting lights. Requires `take_over_control`. 🕵️",
|
||||||
"separate_turn_on_commands": "separate_turn_on_commands: Use separate `light.turn_on` calls for color and brightness, needed for some light types. 🔀",
|
"separate_turn_on_commands": "separate_turn_on_commands: Use separate `light.turn_on` calls for color and brightness, needed for some light types. 🔀",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue