Skip to content

Rename trigger behavior options#172348

Merged
emontnemery merged 2 commits into
devfrom
rename_trigger_behavior
May 27, 2026
Merged

Rename trigger behavior options#172348
emontnemery merged 2 commits into
devfrom
rename_trigger_behavior

Conversation

@emontnemery

@emontnemery emontnemery commented May 27, 2026

Copy link
Copy Markdown
Contributor

Breaking change

The trigger behavior options for triggers in labs have been renamed. In your automations and scripts, replace behavior: any with behavior: each and behavior: last with behavior: all.

Proposed change

Rename trigger behavior options as requested in #166950

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Renames the Labs purpose-specific trigger behavior option keys to better reflect their semantics (anyeach, lastall) and updates validation, selectors, defaults, and tests accordingly.

Changes:

  • Update homeassistant.helpers.trigger to use behavior: each|first|all (default each) instead of any|first|last.
  • Update the automation behavior selector to expose each/all for trigger mode and adjust selector tests.
  • Update integration triggers.yaml defaults and refactor all affected tests/helpers to use the new option keys and helper names.

Reviewed changes

Copilot reviewed 71 out of 71 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
homeassistant/helpers/trigger.py Renames supported trigger behavior option values and updates trigger validation/logic defaults.
homeassistant/helpers/selector.py Updates automation behavior selector options for trigger mode (adds each, keeps any for condition mode).
homeassistant/components/air_quality/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/alarm_control_panel/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/assist_satellite/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/battery/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/climate/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/counter/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/cover/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/door/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/fan/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/garage_door/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/gate/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/humidifier/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/humidity/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/illuminance/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/lawn_mower/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/light/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/lock/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/media_player/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/moisture/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/motion/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/occupancy/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/power/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/remote/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/schedule/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/siren/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/switch/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/temperature/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/timer/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/update/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/vacuum/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/valve/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/water_heater/triggers.yaml Updates default trigger behavior to each.
homeassistant/components/window/triggers.yaml Updates default trigger behavior to each.
tests/helpers/test_trigger.py Updates helper-trigger tests to use BEHAVIOR_EACH/ALL constants and renamed semantics.
tests/helpers/test_selector.py Updates selector tests for new trigger behavior choices (each/all) and removed ones (any/last) in trigger mode.
tests/components/common.py Renames shared trigger test helpers (assert_trigger_behavior_any/last...each/all) and updates behavior validation loop.
tests/components/air_quality/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/alarm_control_panel/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/assist_satellite/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/battery/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/climate/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/counter/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/cover/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/door/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/fan/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/garage_door/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/gate/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/humidifier/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/humidity/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/illuminance/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/lawn_mower/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/light/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/lock/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/media_player/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/moisture/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/motion/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/occupancy/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/power/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/remote/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/schedule/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/siren/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/switch/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/temperature/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/timer/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/update/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/vacuum/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/valve/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/water_heater/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.
tests/components/window/test_trigger.py Updates imports and behavior-specific trigger tests to each/all.

Comment thread homeassistant/helpers/trigger.py Outdated
Comment on lines 340 to 345
ENTITY_STATE_TRIGGER_SCHEMA_FIRST_LAST = ENTITY_STATE_TRIGGER_SCHEMA.extend(
{
vol.Required(CONF_OPTIONS, default={}): {
vol.Required(ATTR_BEHAVIOR, default=BEHAVIOR_ANY): vol.In(
[BEHAVIOR_FIRST, BEHAVIOR_LAST, BEHAVIOR_ANY]
vol.Required(ATTR_BEHAVIOR, default=BEHAVIOR_EACH): vol.In(
[BEHAVIOR_FIRST, BEHAVIOR_ALL, BEHAVIOR_EACH]
),
Comment on lines 274 to +285
@@ -282,7 +282,7 @@ async def test_window_trigger_binary_sensor_behavior_last(
states: list[TriggerStateDescription],
) -> None:
"""Test window trigger fires when the last binary_sensor changes state."""
await assert_trigger_behavior_last(
await assert_trigger_behavior_all(
Comment on lines 367 to +378
@@ -375,7 +375,7 @@ async def test_water_heater_state_trigger_behavior_last(
states: list[TriggerStateDescription],
) -> None:
"""Test water heater state trigger fires on last entity change."""
await assert_trigger_behavior_last(
await assert_trigger_behavior_all(
@emontnemery emontnemery merged commit f8a65a7 into dev May 27, 2026
48 checks passed
@emontnemery emontnemery deleted the rename_trigger_behavior branch May 27, 2026 14:01
@frenck frenck removed this from the 2026.6.0b0 milestone May 27, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators May 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants