Skip to content

Fix infrared NEC test command to a valid 8-bit value#176573

Merged
abmantis merged 2 commits into
home-assistant:devfrom
Dr-Blank:fix-infrared-nec-8bit-command
Jul 15, 2026
Merged

Fix infrared NEC test command to a valid 8-bit value#176573
abmantis merged 2 commits into
home-assistant:devfrom
Dr-Blank:fix-infrared-nec-8bit-command

Conversation

@Dr-Blank

Copy link
Copy Markdown
Contributor

Proposed change

tests/components/infrared/test_init.py defined its module-level TEST_COMMAND with command=0x08F7, which is not a valid 8-bit NEC command. Until now the infrared-protocols library silently masked it (command & 0xFF0xF7), so the invalid literal went unnoticed.

In infrared-protocols 7.1.0, the library added explicit range validation for NEC address/command bytes (home-assistant-libs/infrared-protocols#68, commit home-assistant-libs/infrared-protocols@eb7987ba751), which now raises ValueError: command must be an 8-bit value (0-0xFF), got 0x8f7 at test-collection time when the library is upgraded past 7.0.0.

This changes the constant to command=0x00F7 (0xF7), which is the exact value the encoder always used (the high byte was previously discarded by the mask), so the test's behavior is unchanged. It is valid under the current pinned 7.0.0 as well, so this PR is safe on dev today.

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: needed by Add LG AC support to lg_infrared integration #174142, which bumps infrared-protocols to 7.2.0 and currently fails CI on this collection error
  • 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 review requested due to automatic review settings July 15, 2026 19:59
@home-assistant

Copy link
Copy Markdown
Contributor

Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (infrared) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of infrared 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 infrared 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.

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

Updates the infrared tests for compatibility with stricter NEC command validation.

Changes:

  • Replaces the invalid 0x08F7 command with its effective 8-bit value, 0x00F7.

@Dr-Blank

Copy link
Copy Markdown
Contributor Author

This is split out as its own PR (rather than folded into the dependency-bump PR) per the Home Assistant policy that a PR should fix only one thing and unrelated changes belong in separate PRs.

Comment thread tests/components/infrared/test_init.py Outdated
Co-authored-by: Manu <tr4nt0r@uber.space>
Copilot AI review requested due to automatic review settings July 15, 2026 21:58

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

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

@abmantis abmantis marked this pull request as ready for review July 15, 2026 22:01
@abmantis abmantis requested a review from a team as a code owner July 15, 2026 22:01

@abmantis abmantis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the fix @Dr-Blank !

@abmantis abmantis merged commit c032767 into home-assistant:dev Jul 15, 2026
33 checks passed
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.

4 participants