Skip to content

Add device triggers to ISY994 integration#169694

Open
shbatm wants to merge 6 commits intohome-assistant:devfrom
shbatm:isy994-device-triggers
Open

Add device triggers to ISY994 integration#169694
shbatm wants to merge 6 commits intohome-assistant:devfrom
shbatm:isy994-device-triggers

Conversation

@shbatm
Copy link
Copy Markdown
Contributor

@shbatm shbatm commented May 3, 2026

Proposed change

Adds a device-trigger platform to the ISY994 integration so users can build automations that react to physical Insteon button presses (on, off, fast on, fast off, fade up, fade down, fade stop) instead of just state changes. This distinction matters for KeypadLinc secondary buttons, which emit control events without changing any HA entity state, and for differentiating fast/fade presses on dimmers from regular on/off.

Historically, this has required custom event trigger automations to catch the isy994_control command events (e.g. DON DFON DOF DFOF) which is not very user frendly and frequently a pain point in Insteon discussions.

Triggers are exposed for entities whose underlying ISY node has a supported node_def_id (SwitchLinc dimmers/relays, KeypadLinc loads, and KeypadButton_ADV secondary buttons). They piggyback on the existing isy994_control event bus emit in ISYEntity.async_on_control — no changes to the event payload — and filter via the standard event-trigger machinery on entity_id + control code. NOTE: This is a deliberate subset of "known to work" devices that emit these controls and also represents the most common Insteon devices that take physical input (KeypadLincs, DimmerLincs, and On/Off SwitchLincs). Support for additional device types can be added in a future PR.

The hardcoded "isy994_control" string in entity.py is lifted to a new EVENT_ISY994_CONTROL constant in const.py so the device-trigger module and the entity emit stay in sync.

Coexists with the built-in light/switch domain device triggers (which are state-change based) — both are useful and address different use cases. The strings used are deliberately using <x> was switched <command> which both distinguishes from the normal "turned on/off" status change triggers and matches the language used in the Universal Devices Admin Console which is used for programming the controller. The Fast On and Fast Off also matches Insteon-specific language (as opposed to KeyPressed and KeyPressed2X typical for Z-Wave).

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:

Exposes Insteon button-press events (on/off, fast on/off, fade
up/down/stop) as device triggers for SwitchLinc, KeypadLinc loads,
and KeypadLinc secondary buttons. Triggers are wired to the existing
isy994_control event bus so automations fire on physical device
presses independent of state changes.
@home-assistant
Copy link
Copy Markdown
Contributor

home-assistant Bot commented May 3, 2026

Hey there @bdraco, mind taking a look at this pull request as it has been labeled with an integration (isy994) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of isy994 can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant mark-draft Mark the pull request as draft.
  • @home-assistant ready-for-review Remove the draft status from the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign isy994 Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant update-branch Update the pull request branch with the base branch.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds device-trigger support to the ISY994 integration so automations can react to raw Insteon control events such as fast on/off and fade actions, not just entity state changes. It extends the integration’s existing event emission path and adds tests around trigger discovery and firing behavior.

Changes:

  • Added a new isy994 device trigger platform that maps supported node types to Insteon control-event triggers.
  • Moved the isy994_control event name to a shared constant and reused it from both the entity event emitter and the trigger platform.
  • Added user-facing trigger translations and a new test module covering trigger enumeration and automation firing.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/components/isy994/test_device_trigger.py Adds tests for trigger discovery, matching, and button isolation behavior.
homeassistant/components/isy994/strings.json Adds localized labels for the new device trigger types.
homeassistant/components/isy994/entity.py Switches event emission to the shared event-name constant.
homeassistant/components/isy994/device_trigger.py Implements ISY994 device trigger discovery and event-based attachment.
homeassistant/components/isy994/const.py Defines the shared EVENT_ISY994_CONTROL constant.

Comment on lines +59 to +70
SUPPORTED_NODE_DEF_IDS: Final = frozenset(
{
"BallastRelayLampSwitch_ADV",
"DimmerLampSwitch_ADV",
"DimmerSwitchOnly_ADV",
"KeypadButton_ADV",
"KeypadDimmer_ADV",
"KeypadRelay_ADV",
"RelayLampOnly_ADV",
"RelayLampSwitch_ADV",
"RelaySwitchOnlyPlusQuery_ADV",
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Non-_ADV devices are older generation and I do not have any to test that they emit the same control events. This subset was chosen to represent the intitial "known working" set of device types within insteon and can be expanded later.

Comment thread homeassistant/components/isy994/device_trigger.py Outdated
Comment thread tests/components/isy994/test_device_trigger.py
Comment thread tests/components/isy994/test_device_trigger.py
shbatm added 2 commits May 3, 2026 16:20
…uttons

- async_attach_trigger now rejects subtypes whose node_def_id is not
  in SUPPORTED_NODE_DEF_IDS, preventing hand-written YAML from
  attaching to unsupported ISY nodes that share the unique-id prefix.
- Tests now register KeypadButton child entities under the sensor
  domain to match how the integration actually classifies them.
Adds tests for unknown/unloaded device lookups, entity-skip paths,
empty trigger capabilities, and the three InvalidDeviceAutomationConfig
error paths in async_attach_trigger. Brings coverage of
device_trigger.py to 100%.
Copilot AI review requested due to automatic review settings May 3, 2026 16:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread homeassistant/components/isy994/device_trigger.py Outdated
Comment thread homeassistant/components/isy994/device_trigger.py
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 3, 2026 16:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI review requested due to automatic review settings May 3, 2026 17:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@shbatm shbatm marked this pull request as ready for review May 3, 2026 17:34
@shbatm shbatm requested a review from bdraco as a code owner May 3, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants