Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for room sensor accessories assigned to a Honeywell (Lyric) Thermostat #104343

Merged

Conversation

dalinicus
Copy link
Contributor

Breaking change

Proposed change

For the Lyric integration, adds additional sensors for room sensor accessories assigned to a thermostat. Each room sensor accessory will have a device created for it, sensors created for temperature and humidity, and via_device assigned to the respective thermostat.

image

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

  • 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 Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

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 link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

- Update coordinator to refresh and grab information about room sensor accessories assigned to a thermostat
- Add sensor entities for room humidity and room temperature
- Add devices to the registry for each room accessory
- "via_device" these entities through the assigned thermostat.
@home-assistant
Copy link

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 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 add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@emontnemery emontnemery changed the title Add support for room sensor accessories assgined to a Honeywell (Lyric) Thermostat Add support for room sensor accessories assigned to a Honeywell (Lyric) Thermostat Nov 22, 2023
@emontnemery emontnemery self-assigned this Nov 22, 2023
@@ -158,8 +165,43 @@ class LyricDeviceEntity(LyricEntity):
def device_info(self) -> DeviceInfo:
"""Return device information about this Honeywell Lyric instance."""
return DeviceInfo(
identifiers={(dr.CONNECTION_NETWORK_MAC, self._mac_id)},
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the mac address added as an identifier, is it to make via_device work for the sub devices?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct.

location: LyricLocation,
device: LyricDevice,
room: LyricRoom,
accessory: LyricAccessories,
Copy link
Contributor

Choose a reason for hiding this comment

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

The class name suggests plural, but the variable name suggests singular. Which one is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its singular. Looks like its misnamed in the aiolyric library that his object comes from.

homeassistant/components/lyric/__init__.py Outdated Show resolved Hide resolved
)


class LyricAccessoryEntity(LyricDeviceEntity):
Copy link
Member

Choose a reason for hiding this comment

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

One question that I have, currently an Accessory is bound to a room. Are there more types of accessories? Are all accessories bound to a room?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not aware of any other thermostat accessories for this device, but they all appear to have the same data structure from the Lyric API. The only values I have observed for accessories are Thermostat (which is a duplicate of the parent thermostat) and IndoorAirSensor, and looking at their product pages I can only find the one model of air sensor and no other accessories. IndoorAirSensor is the only value they use from within their API reference as well.

Air sensors must assigned a "room" from the Honeywell app in order to be operable, yes.

@joostlek joostlek marked this pull request as draft November 22, 2023 11:01
- update docstring to reflect ownership by thermostat
- fixed potential issue where a sensor would not be added if its temperature value was 0
@dalinicus dalinicus marked this pull request as ready for review November 22, 2023 14:59
@dalinicus
Copy link
Contributor Author

Good Morning (or whatever greeting appropriate for your time zone) @emontnemery and @joostlek ,

I have made and tested the requested code changes, and answered the questions you posed. I have re-marked the PR for review. Please don't hesitate to ask followup questions or recommend further changes. Appreciate all your help on this.

for location in lyric.locations:
for device in location.devices:
if device.deviceClass == "Thermostat":
await lyric.get_thermostat_rooms(
Copy link

Choose a reason for hiding this comment

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

Maybe it would be more performant to await all promises altogether?

https://docs.python.org/3/library/asyncio-task.html#asyncio.gather

@disforw
Copy link
Contributor

disforw commented Nov 24, 2023

@dalinicus nice! Any possibility you can grab the motion as a binary_sensor as well??? Pwwease 🙏

@dalinicus
Copy link
Contributor Author

dalinicus commented Nov 24, 2023

@dalinicus nice! Any possibility you can grab the motion as a binary_sensor as well??? Pwwease 🙏

Yup! Have it mostly coded but requires the addition of the binary_sensor platform which is new to this integration. As soon as this one is approved and merged, I'll add that in a second pull request shortly after

@disforw
Copy link
Contributor

disforw commented Nov 24, 2023

Sweet deal. I will be looking out for it!
Happy holidays mate..

@dalinicus
Copy link
Contributor Author

@emontnemery and @joostlek, figured I'd check in with y'all since its been a month. Any additional feedback on this change? I'd be looking to make additional changes to add motion sensor support once this base functionally has been merged.

Hope you're both having a happy holidays.

@dalinicus dalinicus marked this pull request as draft January 27, 2024 21:46
Copy link

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes.
Thank you for your contribution!

@github-actions github-actions bot added the stale label Mar 27, 2024
@github-actions github-actions bot closed this Apr 3, 2024
@joostlek
Copy link
Member

joostlek commented Apr 3, 2024

Wait was this now ready for review or not

@disforw
Copy link
Contributor

disforw commented Apr 3, 2024

I believe it was ready 👍

@joostlek joostlek reopened this Apr 3, 2024
@github-actions github-actions bot removed the stale label Apr 4, 2024
@dalinicus dalinicus marked this pull request as ready for review April 4, 2024 15:09
@dalinicus dalinicus marked this pull request as draft April 4, 2024 15:42
@dalinicus dalinicus marked this pull request as ready for review April 4, 2024 16:31
@dalinicus
Copy link
Contributor Author

Wait was this now ready for review or not

Looks like there was some merge conflicts since I last worked on this. I've synced up with dev, resolved the conflicts, and re-tested.

Working locally. Everything should be good for a review 👍🏻

Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

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

Looks good, just a minor comment.

Comment on lines 81 to 86
for location in lyric.locations:
for device in location.devices:
if device.deviceClass == "Thermostat":
await lyric.get_thermostat_rooms(
location.locationID, device.deviceID
)
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @t3hk0d3, please use asyncio.gather instead, something like:

Suggested change
for location in lyric.locations:
for device in location.devices:
if device.deviceClass == "Thermostat":
await lyric.get_thermostat_rooms(
location.locationID, device.deviceID
)
asyncio.gather(
lyric.get_thermostat_rooms(
location.locationID, device.deviceID
)
for device in location.devices
for location in lyric.locations
if device.deviceClass == "Thermostat"
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated per suggestion; thanks for the code snippet. Re-tested locally and it continues to work as expected.

@home-assistant
Copy link

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 April 15, 2024 14:56
@dalinicus dalinicus marked this pull request as ready for review April 18, 2024 16:12
Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @dalinicus 👍

@emontnemery emontnemery merged commit 05c3764 into home-assistant:dev Apr 18, 2024
24 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 19, 2024
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.

None yet

5 participants