Skip to content

Improve/fix Insteon event handling#168663

Open
gogglespisano wants to merge 9 commits intohome-assistant:devfrom
gogglespisano:leak_sensor
Open

Improve/fix Insteon event handling#168663
gogglespisano wants to merge 9 commits intohome-assistant:devfrom
gogglespisano:leak_sensor

Conversation

@gogglespisano
Copy link
Copy Markdown

Proposed change

Insteon sensor events are missing the data about the event.

This change passes the lower level event data into the HA event.

In the case of the leak sensor, the heartbeat event looked the same regardless of whether it was from the device heartbeat or the heartbeat manager missed heartbeat event, resulting in the heartbeat state never changing to "Problem" when the heartbeat is missed.

This also cleans up the event names by removed the redundant "event" suffix on most of the events and also simplifies the event processing code.

Both the existing events and the new events without the "event" suffix are fired for backwards compatibility with existing automations. A deprecation warning is added to the event data.

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

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:

This fixes bug home-assistant#162946.

Insteon sensor events are missing the data about the event.

In the case of the leak sensor, the heartbeat event looked the same regardless of whether it was from the device heartbeat or the heartbeat manager missed heartbeat event.

This needs pyinsteon pull request pyinsteon/pyinsteon#442 in order to have the full data in the event.

This also cleans up the event names by removed the redundant "event" suffix on most of the events and also simplifies the event processing code.

Both the existing events and the new events without the "event" suffix are fired for compatibility with existing automations.  A deprecation warning is added to the event data.
Copilot AI review requested due to automatic review settings April 20, 2026 22:28
Copy link
Copy Markdown

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

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

Hi @gogglespisano

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant home-assistant bot added cla-needed dependency Pull requests marked as a dependency upgrade integration: insteon labels Apr 20, 2026
@home-assistant home-assistant bot marked this pull request as draft April 20, 2026 22:28
@home-assistant
Copy link
Copy Markdown

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant
Copy link
Copy Markdown

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

Code owner commands

Code owners of insteon 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 insteon 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

Improves Insteon event handling by propagating additional low-level event details into Home Assistant events and introducing cleaner event names (without the redundant _event suffix) while attempting to preserve backward compatibility.

Changes:

  • Refactors Insteon event firing to enrich event payloads (battery/heartbeat/moisture/button).
  • Implements “new” event names (suffix removed) and also fires legacy events with a deprecation notice.
  • Updates Insteon constants to support the new event payload fields.

Reviewed changes

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

File Description
homeassistant/components/insteon/utils.py Refactors event subscription and HA event firing, adds new event payload fields and legacy event emission.
homeassistant/components/insteon/const.py Removes old button event constants and adds new event payload field keys.

Comment thread homeassistant/components/insteon/utils.py Outdated
Comment thread homeassistant/components/insteon/utils.py Outdated
Comment thread homeassistant/components/insteon/utils.py
Comment thread homeassistant/components/insteon/utils.py Outdated
Comment thread homeassistant/components/insteon/utils.py Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 20, 2026 22:39
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 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread homeassistant/components/insteon/utils.py Outdated
Comment thread homeassistant/components/insteon/utils.py Outdated
Copy link
Copy Markdown
Author

@gogglespisano gogglespisano left a comment

Choose a reason for hiding this comment

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

Made the suggested code changes

Comment thread homeassistant/components/insteon/utils.py Outdated
rename heartbeat to heartbeat_missed.
make a legacy copy of the event schema.
only send legacy event if it's different from new event.
Copilot AI review requested due to automatic review settings April 20, 2026 23:33
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 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread homeassistant/components/insteon/utils.py
Comment thread homeassistant/components/insteon/utils.py Outdated
Comment thread homeassistant/components/insteon/utils.py Outdated
Copilot AI review requested due to automatic review settings April 21, 2026 00:26
@gogglespisano gogglespisano marked this pull request as ready for review April 21, 2026 00:49
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Insteon Integration Leak Sensor (2852-222) Heartbeat not recognized.

3 participants