Skip to content

Add Priority Status sensor to Lyric integration - #177065

Draft
clutch2sft wants to merge 5 commits into
home-assistant:devfrom
clutch2sft:sensor-priority-status
Draft

Add Priority Status sensor to Lyric integration#177065
clutch2sft wants to merge 5 commits into
home-assistant:devfrom
clutch2sft:sensor-priority-status

Conversation

@clutch2sft

@clutch2sft clutch2sft commented Jul 22, 2026

Copy link
Copy Markdown

Resideo's priority endpoint reports a top-level hold status (e.g. "NoHold") alongside the room priority data already used by the Room Priority select entity. This was parsed but never surfaced. Adds a dedicated diagnostic sensor reading from priorities_dict, gated the same way as the existing select entity (thermostat device with populated room data).

Proposed change

Resideo's priority endpoint reports a top-level hold status (e.g. "NoHold")
alongside the room priority data already used by the Room Priority select entity.
This was parsed but never surfaced. Adds a dedicated diagnostic sensor reading from
priorities_dict, gated the same way as the existing select entity (thermostat
device with populated room data).

Dependency note: needs both #177022 (coordinator fetching priority data) and the
pending aiolyric field-name fix (LyricPriority.status currently reads the wrong
JSON key) to report the real value. Safe to merge independently — it'll report
unavailable/an incorrect value until both land.

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:

Resideo's priority endpoint reports a top-level hold status (e.g.
"NoHold") alongside the room priority data already used by the
Room Priority select entity. This was parsed but never surfaced.
Adds a dedicated diagnostic sensor reading from priorities_dict,
gated the same way as the existing select entity (thermostat device
with populated room data).
@home-assistant

Copy link
Copy Markdown
Contributor

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

Code owner commands

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

Adds a diagnostic Lyric sensor exposing the thermostat’s room-priority hold status.

Changes:

  • Creates the sensor for thermostats with room data.
  • Reads status from priorities_dict.
  • Adds the entity translation.

Reviewed changes

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

File Description
homeassistant/components/lyric/sensor.py Implements and registers the priority-status sensor.
homeassistant/components/lyric/strings.json Adds the sensor name.

Comment on lines +295 to +298
priority = self.coordinator.data.priorities_dict.get(self._mac_id)
if priority is None:
return None
return priority.status
Comment on lines +274 to +275
_attr_entity_category = EntityCategory.DIAGNOSTIC
_attr_translation_key = "priority_status"

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.

Please address this one

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Lyric binary sensor and new sensors docs
#46986

if accessory_sensor.suitable_fn(room, accessory)
)

async_add_entities(

@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.

Please keep this as draft until the other PR fixing the coordinator is merged.
We don't want to add a new sensor that is always unavailable.

if accessory_sensor.suitable_fn(room, accessory)
)

async_add_entities(

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.

although this integration was already doing it, usually async_add_entities is called once, with the full list of entities to add.
I think it is ok to keep it, but would be nice to change it later for consistency

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agreed — this follows the pattern already established in the file (two separate async_add_entities calls existed before this PR for DEVICE_SENSORS/ACCESSORY_SENSORS). Happy to consolidate all three into a single call in a small follow-up cleanup PR if that's useful, rather than expanding this one's diff. Let me know if you'd rather I just do it here.

Comment on lines +274 to +275
_attr_entity_category = EntityCategory.DIAGNOSTIC
_attr_translation_key = "priority_status"

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.

Please address this one

@home-assistant

Copy link
Copy Markdown
Contributor

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
home-assistant Bot marked this pull request as draft July 22, 2026 22:15
@clutch2sft
clutch2sft requested a review from abmantis July 23, 2026 10:30
- Port the shared conftest.py fixtures from the sibling binary-sensor
  branch (real config-entry setup, aiolyric client patched at the
  Lyric.get_locations/get_thermostat_rooms boundary rather than mocked
  HTTP), since this branch predates that infrastructure.
- Add an xfail(strict=True) end-to-end test documenting that the entity
  isn't created at all today: its creation gate reads rooms_dict, which
  never populates under the currently-pinned aiolyric (same
  currentPriority/priority key bug as the room_motion entity), and even
  if it did, LyricPriority.status reads the wrong JSON key too. Both are
  fixed in the same upstream aiolyric#165 diff.
- Add direct unit tests for LyricPriorityStatusSensor.native_value
  (present/missing priority data), which don't depend on that fix and
  give real, non-xfail coverage of the new entity class and the
  async_add_entities gating logic - closing the codecov/patch gap
  Copilot flagged (new code in an already well-covered sensor.py).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 27, 2026 12:50

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 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread tests/components/lyric/test_sensor.py Outdated
Comment on lines +36 to +38
@pytest.mark.xfail(
strict=True,
reason=(
…ntirely

Same fixture/patching cleanup already applied to the sibling branches,
plus the bigger change joostlek's "let's not add failing tests
directly" pushed toward: replace the xfail end-to-end test and the two
direct LyricPriorityStatusSensor.native_value unit tests with a single
real snapshot_platform test.

- fixtures/locations.json now has two devices: one with a priority
  entry (state "NoHold"), one with room data but no priority entry
  (state "unknown") - both branches of native_value get exercised
  through real entity state instead of direct property calls.
- rooms_dict/priorities_dict are set directly with lightweight stand-ins
  rather than real LyricPriority objects, since LyricPriority.status/
  current_priority's field-name bugs (aiolyric#165) are aiolyric's own
  test suite's concern, not this integration's - this fixture tests our
  gating/display logic assuming the data contract is met, independent
  of whether the currently-pinned library can produce it today.
- Verified new code (the async_add_entities generator + the whole
  LyricPriorityStatusSensor class) has zero coverage gaps; the only
  remaining "missing" lines are pre-existing, unrelated to this PR.
Copilot AI review requested due to automatic review settings July 28, 2026 20:12

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 7 out of 7 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

tests/components/lyric/conftest.py:81

  • Condense this fixture docstring to the non-obvious upstream constraint. Most of it narrates the setup and coverage already visible below, making the fixture harder to maintain.
    """Mock the aiolyric client, backed by a real Location and directly-set priority data.

    Patches Lyric where the integration imports it (autospec, like the
    mealie client mock). Location/device data comes from a real
    LyricLocation parsed from a live-shaped fixture, so field-name

tests/components/lyric/test_sensor.py:38

  • Move these unused fixtures to a @pytest.mark.usefixtures decorator. Neither fixture value is consumed by the test, so keeping them as parameters obscures which inputs the assertions actually use.
    setup_credentials: None,
    mock_lyric_api: MagicMock,

…ract

Resideo's own API docs document locationID as an Integer, and aiolyric's
get_thermostat_rooms already types it int, but this fixture quoted it
as a string - inherited from early in this session before checking the
real docs. No behavior change (the value is only ever interpolated into
a URL), but the fixture now matches reality.
- Condense mock_lyric_api's docstring to the non-obvious constraint
  (the aiolyric field-name bug and why the second device exists);
  drop the narration of setup mechanics already visible in the code
  below.
- Apply setup_credentials/mock_lyric_api via usefixtures in test_sensor
  instead of injecting them as unused parameters, matching our own
  "don't inject unused fixture arguments" rule.
Copilot AI review requested due to automatic review settings July 28, 2026 21:16

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 7 out of 7 changed files in this pull request and generated no new comments.

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