mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-11 22:34:04 +02:00
Merge pull request #384 from Mark-Niemeyer/send_split_delay
add a delay between sending commands using separate_turn_on_commands
This commit is contained in:
commit
2029319997
6 changed files with 9 additions and 0 deletions
|
|
@ -77,6 +77,7 @@ adaptive_lighting:
|
|||
| `take_over_control` | If another source calls `light.turn_on` while the lights are on and being adapted, disable Adaptive Lighting. | False | True | boolean |
|
||||
| `detect_non_ha_changes` | Whether to detect state changes and stop adapting lights, even not from `light.turn_on`. Needs `take_over_control` to be enabled. Note that by enabling this option, it calls 'homeassistant.update_entity' every 'interval'! | False | False | boolean |
|
||||
| `separate_turn_on_commands` | Whether to use separate `light.turn_on` calls for color and brightness, needed for some types of lights | False | False | boolean |
|
||||
| `send_split_delay` | Wait between commands (milliseconds), when separate_turn_on_commands is used. May ensure that both commands are handled by the bulb correctly. | False | 0 | integer |
|
||||
| `adapt_delay` | Wait time in seconds between light turn on, and Adaptive Lights applying changes to the light state. May avoid flickering. | False | 0 | integer |
|
||||
|
||||
Full example:
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ CONF_TURN_ON_LIGHTS = "turn_on_lights"
|
|||
|
||||
CONF_ADAPT_DELAY, DEFAULT_ADAPT_DELAY = "adapt_delay", 0
|
||||
TURNING_OFF_DELAY = 5
|
||||
CONF_SEND_SPLIT_DELAY, DEFAULT_SEND_SPLIT_DELAY = "send_split_delay", 0
|
||||
|
||||
|
||||
def int_between(min_int, max_int):
|
||||
|
|
@ -108,6 +109,7 @@ VALIDATION_TUPLES = [
|
|||
(CONF_TAKE_OVER_CONTROL, DEFAULT_TAKE_OVER_CONTROL, bool),
|
||||
(CONF_DETECT_NON_HA_CHANGES, DEFAULT_DETECT_NON_HA_CHANGES, bool),
|
||||
(CONF_SEPARATE_TURN_ON_COMMANDS, DEFAULT_SEPARATE_TURN_ON_COMMANDS, bool),
|
||||
(CONF_SEND_SPLIT_DELAY, DEFAULT_SEND_SPLIT_DELAY, int_between(0, 10000)),
|
||||
(CONF_ADAPT_DELAY, DEFAULT_ADAPT_DELAY, int_between(0, 10000)),
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
"only_once": "only_once: Only adapt the lights when turning them on.",
|
||||
"prefer_rgb_color": "prefer_rgb_color: Use 'rgb_color' rather than 'color_temp' when possible.",
|
||||
"separate_turn_on_commands": "separate_turn_on_commands: Separate the commands for each attribute (color, brightness, etc.) in 'light.turn_on' (required for some lights).",
|
||||
"send_split_delay": "send_split_delay: wait between commands (milliseconds), when separate_turn_on_commands is used. May ensure that both commands are handled by the bulb correctly.",
|
||||
"sleep_brightness": "sleep_brightness, Brightness setting for Sleep Mode. (%)",
|
||||
"sleep_rgb_or_color_temp": "sleep_rgb_or_color_temp, use 'rgb_color' or 'color_temp'",
|
||||
"sleep_rgb_color": "sleep_rgb_color, in RGB",
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ from .const import (
|
|||
CONF_MIN_SUNSET_TIME,
|
||||
CONF_ONLY_ONCE,
|
||||
CONF_PREFER_RGB_COLOR,
|
||||
CONF_SEND_SPLIT_DELAY,
|
||||
CONF_SEPARATE_TURN_ON_COMMANDS,
|
||||
CONF_SLEEP_BRIGHTNESS,
|
||||
CONF_SLEEP_COLOR_TEMP,
|
||||
|
|
@ -574,6 +575,7 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity):
|
|||
self._take_over_control = data[CONF_TAKE_OVER_CONTROL]
|
||||
self._transition = data[CONF_TRANSITION]
|
||||
self._adapt_delay = data[CONF_ADAPT_DELAY]
|
||||
self._send_split_delay = data[CONF_SEND_SPLIT_DELAY]
|
||||
_loc = get_astral_location(self.hass)
|
||||
if isinstance(_loc, tuple):
|
||||
# Astral v2.2
|
||||
|
|
@ -873,6 +875,7 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity):
|
|||
transition = service_datas[0].get(ATTR_TRANSITION)
|
||||
if transition is not None:
|
||||
await asyncio.sleep(transition)
|
||||
await asyncio.sleep(self._send_split_delay / 1000.0)
|
||||
await turn_on(service_datas[1])
|
||||
|
||||
async def _update_attrs_and_maybe_adapt_lights(
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
"only_once": "only_once, passe die Lichter nur beim Einschalten an",
|
||||
"prefer_rgb_color": "prefer_rgb_color, nutze 'rgb_color' vor 'color_temp', wenn möglich",
|
||||
"separate_turn_on_commands": "separate_turn_on_commands, für jedes Attribut (Farbe, Helligkeit usw.) in 'light.turn_on' werden separate Befehle gesendet. Wird für manche Leuchtmittel benötigt.",
|
||||
"send_split_delay": "send_split_delay: Wartezeit zwischen dem Senden der Befehle (Millisekunden), wenn separate_turn_on_commands genutzt wird. Kann helfen, wenn die Leuchtmittel die separaten Befehle nicht korrekt umsetzen.",
|
||||
"sleep_brightness": "sleep_brightness, Schlafhelligkeit in %",
|
||||
"sleep_rgb_or_color_temp": "sleep_rgb_or_color_temp, nutze 'rgb_color' oder 'color_temp'",
|
||||
"sleep_rgb_color": "sleep_rgb_color, in RGB",
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
"only_once": "only_once: Only adapt the lights when turning them on.",
|
||||
"prefer_rgb_color": "prefer_rgb_color: Use 'rgb_color' rather than 'color_temp' when possible.",
|
||||
"separate_turn_on_commands": "separate_turn_on_commands: Separate the commands for each attribute (color, brightness, etc.) in 'light.turn_on' (required for some lights).",
|
||||
"send_split_delay": "send_split_delay: wait between commands (milliseconds), when separate_turn_on_commands is used. May ensure that both commands are handled by the bulb correctly.",
|
||||
"sleep_brightness": "sleep_brightness, Brightness setting for Sleep Mode. (%)",
|
||||
"sleep_rgb_or_color_temp": "sleep_rgb_or_color_temp, use 'rgb_color' or 'color_temp'",
|
||||
"sleep_rgb_color": "sleep_rgb_color, in RGB",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue