adaptive-lighting/custom_components/adaptive_lighting
Ahmad Tawakol 7d0f4b610a
Fix TypeError when 'light.turn_off' is called with a string transition (#1589)
* Fix TypeError when 'light.turn_off' is called with a string transition

`EVENT_CALL_SERVICE` carries the *raw* service data, not the data
`light.turn_off`'s schema produced for the service handler, so its
`vol.Coerce(float)` never reaches `AdaptiveLightingManager`. A caller
passing `transition: "2"` — a template rendering to a string, or any
JSON payload where the value was quoted — therefore stores a `str` in
`turn_off_event`.

Both places that derive a delay from it compare it against an int:

    delay = max(transition or 0, TURNING_OFF_DELAY)  # during turn-off
    delay = max(transition, TURNING_OFF_DELAY)       # just_turned_off

which raises `TypeError: '>' not supported between instances of 'int'
and 'str'`. Because `just_turned_off` runs inside the state-change
listener task, the exception is swallowed: it surfaces only as
"Error doing job: Task exception was never retrieved (task: None)",
while the light quietly stops being adapted after that turn-off.

Read the transition through a helper that coerces to float. Schema
validation runs before the event fires, so whatever reaches the helper
is coercible.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* Normalize turn-off transitions with the light service validator

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Bas Nijholt <bas@nijho.lt>
2026-09-08 14:03:07 +02:00
..
translations feat: add expand_light_groups option (#1462) 2026-09-06 21:13:35 +02:00
__init__.py Register service actions in async_setup for Bronze tier compliance (#1403) 2026-09-06 13:04:18 +02:00
_docs_helpers.py Register service actions in async_setup for Bronze tier compliance (#1403) 2026-09-06 13:04:18 +02:00
adaptation_utils.py Fix missing follow-up commands during multi-light interception (#1560) 2026-09-06 14:03:08 +02:00
color_and_brightness.py fix: keep adapting during polar night and midnight sun (#1489) 2026-09-06 00:23:21 -07:00
config_flow.py Implement collapsible sections for options flow (#1313) 2026-09-06 17:18:42 +02:00
const.py feat: add expand_light_groups option (#1462) 2026-09-06 21:13:35 +02:00
diagnostics.py Add on-demand Home Assistant diagnostics (#1575) 2026-09-06 19:11:55 +02:00
docs_gen.py Migrate to markdown-code-runner's built-in include_section() (#1417) 2026-01-26 09:01:50 +01:00
hass_utils.py fix: track mixed targets during light turn-off (#1584) 2026-09-07 07:41:28 +02:00
helpers.py Friendly names (#1258) 2025-11-27 12:01:05 -08:00
manifest.json chore: release v1.32.0 (#1580) 2026-09-06 22:06:43 +02:00
services.yaml feat: add expand_light_groups option (#1462) 2026-09-06 21:13:35 +02:00
strings.json feat: add expand_light_groups option (#1462) 2026-09-06 21:13:35 +02:00
switch.py Fix TypeError when 'light.turn_off' is called with a string transition (#1589) 2026-09-08 14:03:07 +02:00