-
-
Notifications
You must be signed in to change notification settings - Fork 29k
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 sensor platform to laundrify integration #121378
base: dev
Are you sure you want to change the base?
Conversation
async def async_update(self) -> None: | ||
"""Fetch latest power measurement from the device.""" | ||
try: | ||
power = await self._device.get_power() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This integration uses a coordinator, shouldn't that be used instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose to use a non-coordinated entity for the PowerSensor
since the latest power measurements are polled locally from each individual power plug.
Opposed to that, the latest updates for the EnergySensor
and BinarySensor
are fetched from the backend in a single call (using the LaundrifyUpdateCoordinator
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use a coordinator per device to handle this? As in, that would allow you to use coordinator entities, retry logic, and unavailable logic that is all provided by the datacoordinator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding of a coordinator was to group data polling for several entities/devices to a single, coordinated API call.
Using a coordinator per device sounds a bit counter-intuitive to me. As per the developer docs:
If you can map exactly one device endpoint to a single entity, you can fetch the data for this entity inside the
update()
/async_update()
methods.
Let me know if I miss something.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Hi @frenck, Thanks for your prompt and thorough review. I addressed the requested changes in my latest commits, referenced the corresponding commits in a comment and resolved the discussion if applicable. Some discussions required further information and are left unresolved. Would be great if you could double-check them. Enjoy your weekend! // EDIT: |
Proposed change
This PR adds the sensor platform to the laundrify integration implementing two entities with the following device classes:
power
: showing the latest measurement in Wattsenergy
: showing the total consumption in kWhType of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: