From c88e4445291cf4cf86af981c50b340da4cea387a Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Sun, 6 Sep 2026 11:56:48 -0700 Subject: [PATCH] Name external turn-on policy after manual-control behavior --- README.md | 4 ++-- custom_components/adaptive_lighting/const.py | 20 ++++++++++-------- .../adaptive_lighting/services.yaml | 4 ++-- .../adaptive_lighting/strings.json | 8 +++---- custom_components/adaptive_lighting/switch.py | 19 ++++++++++------- .../adaptive_lighting/translations/en.json | 8 +++---- docs/advanced/manual-control.md | 8 +++---- docs/configuration.md | 2 +- docs/troubleshooting.md | 2 +- tests/test_config_flow.py | 8 +++---- tests/test_switch.py | 21 +++++++++++-------- 11 files changed, 57 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 27890a06..d15c5249 100644 --- a/README.md +++ b/README.md @@ -157,7 +157,7 @@ The YAML and frontend configuration methods support all of the options listed be | `autoreset_control_seconds` | Automatically reset the manual control after a number of seconds. Set to 0 to disable. ⏲️ | `0` | `int` 0-31536000 | | `only_once` | Adapt lights only when they are turned on (`true`) or keep adapting them (`false`). πŸ”„ | `False` | `bool` | | `adapt_only_on_bare_turn_on` | When turning lights on initially. If set to `true`, AL adapts only if `light.turn_on` is invoked without specifying color or brightness. ❌🌈 This e.g., prevents adaptation when activating a scene and marks the light as manually controlled. If `false`, AL adapts regardless of the presence of color or brightness in the initial `service_data`. Needs `take_over_control` enabled. πŸ•΅οΈ | `False` | `bool` | -| `adapt_only_on_ha_turn_on` | Only adapt an `off` to `on` event when its context exactly matches the latest recorded Home Assistant `light.turn_on` context for that light. Unmatched turn-ons are marked as manually controlled and left unchanged. This still allows `detect_non_ha_changes` for lights that are already on. Needs `take_over_control` enabled. πŸ•΅οΈ | `False` | `bool` | +| `manual_control_on_external_turn_on` | Treat turn-ons without a matching Home Assistant `light.turn_on` context as manual control. Normal manual-control resets apply. Still allows `detect_non_ha_changes` for already-on lights. Needs `take_over_control` enabled. πŸ•΅οΈ | `False` | `bool` | | `reset_manual_control_on_sleep_mode_change` | Reset manual control when the sleep mode switch is toggled. Set to `false` to preserve manual control across sleep mode changes. 😴 | `True` | `bool` | | `separate_turn_on_commands` | Use separate `light.turn_on` calls for color and brightness, needed for some light types. πŸ”€ | `False` | `bool` | | `send_split_delay` | Delay (ms) between `separate_turn_on_commands` for lights that don't support simultaneous brightness and color setting. ⏲️ | `0` | `int` 0-10000 | @@ -770,7 +770,7 @@ Addressing these issues will significantly improve your Home Assistant experienc In case lights are suddenly turning on by themselves, this is most likely due to the light incorrectly reporting an "on" state to Home Assistant, leading to an undesired Adaptive Lighting action. To prevent adapting in cases *where the state of the light is suddenly "on" and only adapt if there is an associated `light.turn_on` service call*, set `detect_non_ha_changes: false`. -To keep detecting manual changes to lights that are already on while leaving unmatched `off` to `on` state events unchanged, enable `adapt_only_on_ha_turn_on`. Matching uses the exact context of the most recently recorded `light.turn_on` call. Some integrations replace or omit that context, so Adaptive Lighting cannot distinguish every physical versus Home Assistant turn-on source. +To keep detecting manual changes to lights that are already on while leaving unmatched `off` to `on` state events unchanged, enable `manual_control_on_external_turn_on`. Matching uses the exact context of the most recently recorded `light.turn_on` call. Some integrations replace or omit that context, so Adaptive Lighting cannot distinguish every physical versus Home Assistant turn-on source. #### :signal_strength: WiFi Networks diff --git a/custom_components/adaptive_lighting/const.py b/custom_components/adaptive_lighting/const.py index efe7a4d2..7acf2781 100644 --- a/custom_components/adaptive_lighting/const.py +++ b/custom_components/adaptive_lighting/const.py @@ -100,16 +100,14 @@ DOCS[CONF_ADAPT_ONLY_ON_BARE_TURN_ON] = ( "Needs `take_over_control` enabled. πŸ•΅οΈ" ) -CONF_ADAPT_ONLY_ON_HA_TURN_ON, DEFAULT_ADAPT_ONLY_ON_HA_TURN_ON = ( - "adapt_only_on_ha_turn_on", +CONF_MANUAL_CONTROL_ON_EXTERNAL_TURN_ON, DEFAULT_MANUAL_CONTROL_ON_EXTERNAL_TURN_ON = ( + "manual_control_on_external_turn_on", False, ) -DOCS[CONF_ADAPT_ONLY_ON_HA_TURN_ON] = ( - "Only adapt an `off` to `on` event when its context exactly matches the latest " - "recorded Home Assistant `light.turn_on` context for that light. Unmatched turn-ons " - "are marked as manually controlled and left unchanged. This still allows " - "`detect_non_ha_changes` for lights that are already on. Needs `take_over_control` " - "enabled. πŸ•΅οΈ" +DOCS[CONF_MANUAL_CONTROL_ON_EXTERNAL_TURN_ON] = ( + "Treat turn-ons without a matching Home Assistant `light.turn_on` context as " + "manual control. Normal manual-control resets apply. Still allows " + "`detect_non_ha_changes` for already-on lights. Needs `take_over_control` enabled. πŸ•΅οΈ" ) CONF_PREFER_RGB_COLOR, DEFAULT_PREFER_RGB_COLOR = "prefer_rgb_color", False @@ -428,7 +426,11 @@ VALIDATION_TUPLES: list[tuple[str, Any, Any]] = [ ), (CONF_ONLY_ONCE, DEFAULT_ONLY_ONCE, bool), (CONF_ADAPT_ONLY_ON_BARE_TURN_ON, DEFAULT_ADAPT_ONLY_ON_BARE_TURN_ON, bool), - (CONF_ADAPT_ONLY_ON_HA_TURN_ON, DEFAULT_ADAPT_ONLY_ON_HA_TURN_ON, bool), + ( + CONF_MANUAL_CONTROL_ON_EXTERNAL_TURN_ON, + DEFAULT_MANUAL_CONTROL_ON_EXTERNAL_TURN_ON, + bool, + ), ( CONF_RESET_MANUAL_CONTROL_ON_SLEEP_MODE_CHANGE, DEFAULT_RESET_MANUAL_CONTROL_ON_SLEEP_MODE_CHANGE, diff --git a/custom_components/adaptive_lighting/services.yaml b/custom_components/adaptive_lighting/services.yaml index d31dcd99..23e8ceda 100644 --- a/custom_components/adaptive_lighting/services.yaml +++ b/custom_components/adaptive_lighting/services.yaml @@ -238,8 +238,8 @@ change_switch_settings: example: false selector: boolean: null - adapt_only_on_ha_turn_on: - description: Only adapt an `off` to `on` event when its context exactly matches the latest recorded Home Assistant `light.turn_on` context for that light. Unmatched turn-ons are marked as manually controlled and left unchanged. This still allows `detect_non_ha_changes` for lights that are already on. Needs `take_over_control` enabled. πŸ•΅οΈ + manual_control_on_external_turn_on: + description: Treat turn-ons without a matching Home Assistant `light.turn_on` context as manual control. Normal manual-control resets apply. Still allows `detect_non_ha_changes` for already-on lights. Needs `take_over_control` enabled. πŸ•΅οΈ required: false example: false selector: diff --git a/custom_components/adaptive_lighting/strings.json b/custom_components/adaptive_lighting/strings.json index 618be6c6..6e07c69d 100644 --- a/custom_components/adaptive_lighting/strings.json +++ b/custom_components/adaptive_lighting/strings.json @@ -70,7 +70,7 @@ "autoreset_control_seconds": "autoreset_control_seconds", "only_once": "only_once: Adapt lights only when they are turned on (`true`) or keep adapting them (`false`). πŸ”„", "adapt_only_on_bare_turn_on": "adapt_only_on_bare_turn_on: When turning lights on initially. If set to `true`, AL adapts only if `light.turn_on` is invoked without specifying color or brightness. ❌🌈 This e.g., prevents adaptation when activating a scene and marks the light as manually controlled. If `false`, AL adapts regardless of the presence of color or brightness in the initial `service_data`. Needs `take_over_control` enabled. πŸ•΅οΈ", - "adapt_only_on_ha_turn_on": "adapt_only_on_ha_turn_on: Only adapt an `off` to `on` event when its context exactly matches the latest recorded Home Assistant `light.turn_on` context for that light. Unmatched turn-ons are marked as manually controlled and left unchanged. This still allows `detect_non_ha_changes` for lights that are already on. Needs `take_over_control` enabled. πŸ•΅οΈ", + "manual_control_on_external_turn_on": "manual_control_on_external_turn_on: Treat turn-ons without a matching Home Assistant `light.turn_on` context as manual control. Normal manual-control resets apply. Still allows `detect_non_ha_changes` for already-on lights. Needs `take_over_control` enabled. πŸ•΅οΈ", "reset_manual_control_on_sleep_mode_change": "reset_manual_control_on_sleep_mode_change: Reset manual control when the sleep mode switch is toggled. Set to `false` to preserve manual control across sleep mode changes. 😴", "separate_turn_on_commands": "separate_turn_on_commands: Use separate `light.turn_on` calls for color and brightness, needed for some light types. πŸ”€", "send_split_delay": "send_split_delay", @@ -271,9 +271,9 @@ "description": "Detects and halts adaptations for non-`light.turn_on` state changes. Needs `take_over_control` enabled. πŸ•΅οΈ Caution: ⚠️ Some lights might falsely indicate an 'on' state, which could result in lights turning on unexpectedly. Note that this calls `homeassistant.update_entity` every `interval`! Disable this feature if you encounter such issues.", "name": "detect_non_ha_changes" }, - "adapt_only_on_ha_turn_on": { - "description": "Only adapt an `off` to `on` event when its context exactly matches the latest recorded Home Assistant `light.turn_on` context for that light. Unmatched turn-ons are marked as manually controlled and left unchanged. This still allows `detect_non_ha_changes` for lights that are already on. Needs `take_over_control` enabled. πŸ•΅οΈ", - "name": "adapt_only_on_ha_turn_on" + "manual_control_on_external_turn_on": { + "description": "Treat turn-ons without a matching Home Assistant `light.turn_on` context as manual control. Normal manual-control resets apply. Still allows `detect_non_ha_changes` for already-on lights. Needs `take_over_control` enabled. πŸ•΅οΈ", + "name": "manual_control_on_external_turn_on" }, "transition": { "description": "Duration of transition when lights change, in seconds. πŸ•‘", diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index f215dcba..ab9273df 100644 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -92,7 +92,6 @@ from .const import ( ATTR_ADAPTIVE_LIGHTING_MANAGER, CONF_ADAPT_DELAY, CONF_ADAPT_ONLY_ON_BARE_TURN_ON, - CONF_ADAPT_ONLY_ON_HA_TURN_ON, CONF_ADAPT_UNTIL_SLEEP, CONF_AUTORESET_CONTROL, CONF_BRIGHTNESS_MODE, @@ -105,6 +104,7 @@ from .const import ( CONF_INTERVAL, CONF_LIGHTS, CONF_MANUAL_CONTROL, + CONF_MANUAL_CONTROL_ON_EXTERNAL_TURN_ON, CONF_MAX_BRIGHTNESS, CONF_MAX_COLOR_TEMP, CONF_MAX_SUNRISE_TIME, @@ -958,11 +958,11 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity): if not data[CONF_TAKE_OVER_CONTROL] and ( data[CONF_DETECT_NON_HA_CHANGES] or data[CONF_ADAPT_ONLY_ON_BARE_TURN_ON] - or data[CONF_ADAPT_ONLY_ON_HA_TURN_ON] + or data[CONF_MANUAL_CONTROL_ON_EXTERNAL_TURN_ON] ): _LOGGER.warning( "%s: Config mismatch: `detect_non_ha_changes`, `adapt_only_on_bare_turn_on`, " - "or `adapt_only_on_ha_turn_on` set to `true` requires `take_over_control` to be " + "or `manual_control_on_external_turn_on` set to `true` requires `take_over_control` to be " "enabled. Adjusting config and continuing setup with `take_over_control: true`.", self._name, ) @@ -972,7 +972,9 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity): ) self._detect_non_ha_changes = data[CONF_DETECT_NON_HA_CHANGES] self._adapt_only_on_bare_turn_on = data[CONF_ADAPT_ONLY_ON_BARE_TURN_ON] - self._adapt_only_on_ha_turn_on = data[CONF_ADAPT_ONLY_ON_HA_TURN_ON] + self._manual_control_on_external_turn_on = data[ + CONF_MANUAL_CONTROL_ON_EXTERNAL_TURN_ON + ] self._auto_reset_manual_control_time = data[CONF_AUTORESET_CONTROL] self._reset_manual_control_on_sleep_mode_change = data[ CONF_RESET_MANUAL_CONTROL_ON_SLEEP_MODE_CHANGE @@ -1607,7 +1609,10 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity): ) if ( self._take_over_control - and (not self._detect_non_ha_changes or self._adapt_only_on_ha_turn_on) + and ( + not self._detect_non_ha_changes + or self._manual_control_on_external_turn_on + ) and not from_turn_on ): # There is an edge case where 2 switches control the same light, e.g., @@ -1618,12 +1623,12 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity): # `light.turn_on` context for the entity. Hand control over when either: # - `detect_non_ha_changes` is False (we can't reliably track manual changes # to already-on lights anyway), or - # - `adapt_only_on_ha_turn_on` is True (the user explicitly wants external + # - `manual_control_on_external_turn_on` is True (the user explicitly wants external # turn-ons left untouched, even while `detect_non_ha_changes` is enabled). _LOGGER.debug( "%s: Ignoring 'off' β†’ 'on' event for '%s' with context.id='%s'" " because it does not match a tracked 'light.turn_on' context and" - " ('detect_non_ha_changes' is False or 'adapt_only_on_ha_turn_on' is True)", + " ('detect_non_ha_changes' is False or 'manual_control_on_external_turn_on' is True)", self._name, entity_id, event.context.id, diff --git a/custom_components/adaptive_lighting/translations/en.json b/custom_components/adaptive_lighting/translations/en.json index bf31b165..2f1a7085 100644 --- a/custom_components/adaptive_lighting/translations/en.json +++ b/custom_components/adaptive_lighting/translations/en.json @@ -71,7 +71,7 @@ "autoreset_control_seconds": "autoreset_control_seconds", "only_once": "only_once: Adapt lights only when they are turned on (`true`) or keep adapting them (`false`). πŸ”„", "adapt_only_on_bare_turn_on": "adapt_only_on_bare_turn_on: When turning lights on initially. If set to `true`, AL adapts only if `light.turn_on` is invoked without specifying color or brightness. ❌🌈 This e.g., prevents adaptation when activating a scene and marks the light as manually controlled. If `false`, AL adapts regardless of the presence of color or brightness in the initial `service_data`. Needs `take_over_control` enabled. πŸ•΅οΈ", - "adapt_only_on_ha_turn_on": "adapt_only_on_ha_turn_on: Only adapt an `off` to `on` event when its context exactly matches the latest recorded Home Assistant `light.turn_on` context for that light. Unmatched turn-ons are marked as manually controlled and left unchanged. This still allows `detect_non_ha_changes` for lights that are already on. Needs `take_over_control` enabled. πŸ•΅οΈ", + "manual_control_on_external_turn_on": "manual_control_on_external_turn_on: Treat turn-ons without a matching Home Assistant `light.turn_on` context as manual control. Normal manual-control resets apply. Still allows `detect_non_ha_changes` for already-on lights. Needs `take_over_control` enabled. πŸ•΅οΈ", "reset_manual_control_on_sleep_mode_change": "reset_manual_control_on_sleep_mode_change: Reset manual control when the sleep mode switch is toggled. Set to `false` to preserve manual control across sleep mode changes. 😴", "separate_turn_on_commands": "separate_turn_on_commands: Use separate `light.turn_on` calls for color and brightness, needed for some light types. πŸ”€", "send_split_delay": "send_split_delay", @@ -272,9 +272,9 @@ "description": "Detects and halts adaptations for non-`light.turn_on` state changes. Needs `take_over_control` enabled. πŸ•΅οΈ Caution: ⚠️ Some lights might falsely indicate an 'on' state, which could result in lights turning on unexpectedly. Note that this calls `homeassistant.update_entity` every `interval`! Disable this feature if you encounter such issues.", "name": "detect_non_ha_changes" }, - "adapt_only_on_ha_turn_on": { - "description": "Only adapt an `off` to `on` event when its context exactly matches the latest recorded Home Assistant `light.turn_on` context for that light. Unmatched turn-ons are marked as manually controlled and left unchanged. This still allows `detect_non_ha_changes` for lights that are already on. Needs `take_over_control` enabled. πŸ•΅οΈ", - "name": "adapt_only_on_ha_turn_on" + "manual_control_on_external_turn_on": { + "description": "Treat turn-ons without a matching Home Assistant `light.turn_on` context as manual control. Normal manual-control resets apply. Still allows `detect_non_ha_changes` for already-on lights. Needs `take_over_control` enabled. πŸ•΅οΈ", + "name": "manual_control_on_external_turn_on" }, "transition": { "description": "Duration of transition when lights change, in seconds. πŸ•‘", diff --git a/docs/advanced/manual-control.md b/docs/advanced/manual-control.md index 84dc5bf3..cfb48b33 100644 --- a/docs/advanced/manual-control.md +++ b/docs/advanced/manual-control.md @@ -112,13 +112,13 @@ adaptive_lighting: adapt_only_on_bare_turn_on: true ``` -### adapt_only_on_ha_turn_on +### manual_control_on_external_turn_on -When enabled, a light that turns on from `off` is only adapted if the state-change context exactly matches the most recent Home Assistant `light.turn_on` context recorded for that light. An unmatched turn-on is marked as manually controlled and left at its reported brightness and color. +When enabled, a turn-on without a state-change context matching the latest recorded Home Assistant `light.turn_on` is treated as manual control. This pauses brightness and color adaptation until manual control resets, rather than skipping just the first adjustment. The usual off/on, explicit reset, and configured timeout rules apply. A later unmatched turn-on marks the light manually controlled again. Manual-control flags are shared by profiles controlling the same light. Use the same turn-on policy on those profiles; mixed policies can allow an earlier profile to adapt before another marks the light manually controlled. -This is the option to reach for when turning a light on with its local switch (or a native Lutron/CasΓ©ta scene) makes Adaptive Lighting override your brightness a moment later, forcing you to set it twice. +Enable this if you want turn-ons from physical controls or native scenes to preserve their brightness and color. Leave it disabled if those controls should start normal adaptation. Its advantage over simply disabling `detect_non_ha_changes` is that the two behaviors are decoupled: you can keep `detect_non_ha_changes: true` to catch manual dimming of lights that are *already on*, while leaving unmatched turn-ons untouched. @@ -131,7 +131,7 @@ adaptive_lighting: - light.living_room take_over_control: true detect_non_ha_changes: true # still catch manual changes to already-on lights - adapt_only_on_ha_turn_on: true # leave unmatched offβ†’on events unchanged + manual_control_on_external_turn_on: true # leave unmatched offβ†’on events unchanged ``` ## Checking Manual Control Status diff --git a/docs/configuration.md b/docs/configuration.md index 0ff353f9..2a7402f0 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -66,7 +66,7 @@ All configuration options are listed below with their default values. These opti | `autoreset_control_seconds` | Automatically reset the manual control after a number of seconds. Set to 0 to disable. ⏲️ | `0` | `int` 0-31536000 | | `only_once` | Adapt lights only when they are turned on (`true`) or keep adapting them (`false`). πŸ”„ | `False` | `bool` | | `adapt_only_on_bare_turn_on` | When turning lights on initially. If set to `true`, AL adapts only if `light.turn_on` is invoked without specifying color or brightness. ❌🌈 This e.g., prevents adaptation when activating a scene and marks the light as manually controlled. If `false`, AL adapts regardless of the presence of color or brightness in the initial `service_data`. Needs `take_over_control` enabled. πŸ•΅οΈ | `False` | `bool` | -| `adapt_only_on_ha_turn_on` | Only adapt an `off` to `on` event when its context exactly matches the latest recorded Home Assistant `light.turn_on` context for that light. Unmatched turn-ons are marked as manually controlled and left unchanged. This still allows `detect_non_ha_changes` for lights that are already on. Needs `take_over_control` enabled. πŸ•΅οΈ | `False` | `bool` | +| `manual_control_on_external_turn_on` | Treat turn-ons without a matching Home Assistant `light.turn_on` context as manual control. Normal manual-control resets apply. Still allows `detect_non_ha_changes` for already-on lights. Needs `take_over_control` enabled. πŸ•΅οΈ | `False` | `bool` | | `reset_manual_control_on_sleep_mode_change` | Reset manual control when the sleep mode switch is toggled. Set to `false` to preserve manual control across sleep mode changes. 😴 | `True` | `bool` | | `separate_turn_on_commands` | Use separate `light.turn_on` calls for color and brightness, needed for some light types. πŸ”€ | `False` | `bool` | | `send_split_delay` | Delay (ms) between `separate_turn_on_commands` for lights that don't support simultaneous brightness and color setting. ⏲️ | `0` | `int` 0-10000 | diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index e1e3a679..f39c62bc 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -59,7 +59,7 @@ Addressing these issues will significantly improve your Home Assistant experienc In case lights are suddenly turning on by themselves, this is most likely due to the light incorrectly reporting an "on" state to Home Assistant, leading to an undesired Adaptive Lighting action. To prevent adapting in cases *where the state of the light is suddenly "on" and only adapt if there is an associated `light.turn_on` service call*, set `detect_non_ha_changes: false`. -To keep detecting manual changes to lights that are already on while leaving unmatched `off` to `on` state events unchanged, enable `adapt_only_on_ha_turn_on`. Matching uses the exact context of the most recently recorded `light.turn_on` call. Some integrations replace or omit that context, so Adaptive Lighting cannot distinguish every physical versus Home Assistant turn-on source. +To keep detecting manual changes to lights that are already on while leaving unmatched `off` to `on` state events unchanged, enable `manual_control_on_external_turn_on`. Matching uses the exact context of the most recently recorded `light.turn_on` call. Some integrations replace or omit that context, so Adaptive Lighting cannot distinguish every physical versus Home Assistant turn-on source. #### :signal_strength: WiFi Networks diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index ddef8d17..241bd5ae 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -11,11 +11,11 @@ except ImportError: from voluptuous_serialize import convert as to_field_list from homeassistant.components.adaptive_lighting.const import ( BASIC_OPTIONS, - CONF_ADAPT_ONLY_ON_HA_TURN_ON, CONF_INITIAL_TRANSITION, + CONF_MANUAL_CONTROL_ON_EXTERNAL_TURN_ON, CONF_SUNRISE_TIME, CONF_SUNSET_TIME, - DEFAULT_ADAPT_ONLY_ON_HA_TURN_ON, + DEFAULT_MANUAL_CONTROL_ON_EXTERNAL_TURN_ON, DEFAULT_NAME, DOMAIN, NONE_STR, @@ -152,8 +152,8 @@ async def test_options_schema_has_each_setting_once(hass): assert advanced.options == {"collapsed": True} assert ( - _schema_defaults(advanced.schema)[CONF_ADAPT_ONLY_ON_HA_TURN_ON] - is DEFAULT_ADAPT_ONLY_ON_HA_TURN_ON + _schema_defaults(advanced.schema)[CONF_MANUAL_CONTROL_ON_EXTERNAL_TURN_ON] + is DEFAULT_MANUAL_CONTROL_ON_EXTERNAL_TURN_ON ) assert {key.schema for key in schema if key.schema != "advanced"} == BASIC_OPTIONS assert {key.schema for key in advanced.schema.schema} == set( diff --git a/tests/test_switch.py b/tests/test_switch.py index d6e07f24..1765fb5e 100644 --- a/tests/test_switch.py +++ b/tests/test_switch.py @@ -31,7 +31,6 @@ from homeassistant.components.adaptive_lighting.const import ( ATTR_ADAPT_COLOR, ATTR_ADAPTIVE_LIGHTING_MANAGER, CONF_ADAPT_ONLY_ON_BARE_TURN_ON, - CONF_ADAPT_ONLY_ON_HA_TURN_ON, CONF_ADAPT_UNTIL_SLEEP, CONF_AUTORESET_CONTROL, CONF_BRIGHTNESS_MODE, @@ -40,6 +39,7 @@ from homeassistant.components.adaptive_lighting.const import ( CONF_DETECT_NON_HA_CHANGES, CONF_INITIAL_TRANSITION, CONF_MANUAL_CONTROL, + CONF_MANUAL_CONTROL_ON_EXTERNAL_TURN_ON, CONF_MAX_BRIGHTNESS, CONF_MAX_COLOR_TEMP, CONF_MIN_BRIGHTNESS, @@ -4475,12 +4475,15 @@ async def test_automation_turn_on_from_off_not_marked_as_manual_control(hass): @pytest.mark.parametrize("intercept", [True, False]) -async def test_adapt_only_on_ha_turn_on_allows_tracked_service_call(hass, intercept): +async def test_manual_control_on_external_turn_on_allows_tracked_service_call( + hass, + intercept, +): """Test a real HA turn-on remains eligible for initial adaptation.""" switch, _ = await setup_lights_and_switch( hass, { - CONF_ADAPT_ONLY_ON_HA_TURN_ON: True, + CONF_MANUAL_CONTROL_ON_EXTERNAL_TURN_ON: True, CONF_DETECT_NON_HA_CHANGES: True, CONF_INTERCEPT: intercept, CONF_MIN_BRIGHTNESS: 50, @@ -4515,7 +4518,7 @@ async def test_adapt_only_on_ha_turn_on_allows_tracked_service_call(hass, interc @pytest.mark.parametrize("intercept", [True, False]) @pytest.mark.parametrize( ( - "adapt_only_on_ha_turn_on", + "manual_control_on_external_turn_on", "detect_non_ha_changes", "expected_manual_control", "expected_adaptation", @@ -4527,11 +4530,11 @@ async def test_adapt_only_on_ha_turn_on_allows_tracked_service_call(hass, interc (False, False, LightControlAttributes.ALL, False), ], ) -async def test_adapt_only_on_ha_turn_on_external_state_change( +async def test_manual_control_on_external_turn_on_external_state_change( hass, freezer, intercept, - adapt_only_on_ha_turn_on, + manual_control_on_external_turn_on, detect_non_ha_changes, expected_manual_control, expected_adaptation, @@ -4540,7 +4543,7 @@ async def test_adapt_only_on_ha_turn_on_external_state_change( switch, _ = await setup_lights_and_switch( hass, { - CONF_ADAPT_ONLY_ON_HA_TURN_ON: adapt_only_on_ha_turn_on, + "manual_control_on_external_turn_on": manual_control_on_external_turn_on, CONF_DETECT_NON_HA_CHANGES: detect_non_ha_changes, CONF_INTERCEPT: intercept, CONF_MIN_BRIGHTNESS: 50, @@ -4580,7 +4583,7 @@ async def test_adapt_only_on_ha_turn_on_external_state_change( @pytest.mark.parametrize("intercept", [True, False]) -async def test_adapt_only_on_ha_turn_on_keeps_non_ha_change_detection( +async def test_manual_control_on_external_turn_on_keeps_non_ha_change_detection( hass, intercept, ): @@ -4588,7 +4591,7 @@ async def test_adapt_only_on_ha_turn_on_keeps_non_ha_change_detection( switch, (light, *_) = await setup_lights_and_switch( hass, { - CONF_ADAPT_ONLY_ON_HA_TURN_ON: True, + CONF_MANUAL_CONTROL_ON_EXTERNAL_TURN_ON: True, CONF_DETECT_NON_HA_CHANGES: True, CONF_INTERCEPT: intercept, CONF_MIN_BRIGHTNESS: 50,