Skip to content

Add quality scale file to vesync integration#156663

Merged
joostlek merged 15 commits into
home-assistant:devfrom
cdnninja:qualityScoreVesync
Dec 29, 2025
Merged

Add quality scale file to vesync integration#156663
joostlek merged 15 commits into
home-assistant:devfrom
cdnninja:qualityScoreVesync

Conversation

@cdnninja
Copy link
Copy Markdown
Contributor

Proposed change

Adding the quality score file and initial evaluation.

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

To help with the load of incoming pull requests:

@home-assistant
Copy link
Copy Markdown
Contributor

Hey there @markperdue, @webdjoe, @TheGardenMonkey, @iprak, @SapuSeven, mind taking a look at this pull request as it has been labeled with an integration (vesync) you are listed as a code owner for? Thanks!

Code owner commands

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

@cdnninja
Copy link
Copy Markdown
Contributor Author

Creating as draft to show the progress. I will spend more time to run through the blank items. Once that is done will set to ready for review and start adding PRs for to do items.

@cdnninja cdnninja marked this pull request as ready for review November 15, 2025 19:08
@cdnninja cdnninja requested a review from a team as a code owner November 15, 2025 19:08
@cdnninja
Copy link
Copy Markdown
Contributor Author

I have reviewed the items. A few items I put as todo for future levels as needs more code review to confirm. As well docs while in okay shape I think need updates.

Copy link
Copy Markdown
Member

@joostlek joostlek left a comment

Choose a reason for hiding this comment

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

Let's put the things we agree on fixing in the comments in the file and merge it and improve it from there

icon-translations: todo
reconfiguration-flow: todo
repair-issues: done
stale-devices: todo
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.

You did implement async_remove_config_entry_device though, which also makes me wonder, when a device is offline, is it removed from the API? Or can we safely assume when a device is actually gone? Because in the latter I would say that we can just remove the device automatically and remove the manual method to do so

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, from reading the rule my understanding is auto remove if possible. Two APIs exist in vesync. One gets a list of registered devices, another gets the status of a device. The code I added will update the device list, and compare. If missing it removes it. If offline it will still be in that list. So I listed this as to-do as I automate that on a schedule. I only want to call it from time to time though as it uses API calls. Say once a day or hour, when a device is removed it would auto remove from HA.

@@ -0,0 +1,66 @@
rules:
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.

Would it make sense to at some point split the energy from the normal device coordinator?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

To clarify would this be a second coordinator?

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.

Yes

Comment thread homeassistant/components/vesync/quality_scale.yaml Outdated
Comment thread homeassistant/components/vesync/quality_scale.yaml Outdated
Comment thread homeassistant/components/vesync/quality_scale.yaml
@@ -0,0 +1,66 @@
rules:
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.

_attr_available_modes can be used in the humidifer

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.

I am actually not sure why we collect a separate map here, as in, there are no duplicates so I think we can just create a global humdifier mode map instead of an entity specific one

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Are you able to point me to where you see that? I only see a single humidifier mode map. A different one exists for fan though.

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.

        # Populate maps once.
        for vs_mode in self.device.mist_modes:
            ha_mode = _get_ha_mode(vs_mode)
            if ha_mode:
                self._available_modes.append(ha_mode)
                self._ha_to_vs_mode_map[ha_mode] = vs_mode

        self._available_modes.sort()

More like, instead of using the generic map, we build a new map based on the existing values. I only think there's a benefit for this if you have humidifier modes that map to the same thing (so let's say device A has mode X and device B has mode Y and they're mapped to the same value in HA, then this would make sense as this would make sure that we don't ask for mode Y on device A)

@@ -0,0 +1,66 @@
rules:
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.

Why does the display turn off when we move to sleep mode?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This matches the behavior of the native app. We could decouple if preferred.

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.

Ideally we do that, the less abstractions we have on the HA side the better (as in, you might have someone who doesn't want that to happen and then you'd have to add a configuration, and that can become a slippery slope)

@@ -0,0 +1,66 @@
rules:
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.

Is getting a non-int light brightness usual?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure! I believe that was carry over so haven't touched it recently. How would we track this in the quality score?

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.

No real place

@@ -0,0 +1,66 @@
rules:
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.

I think we need to get rid of the is_<type> methods at some point because they use isinstance and that's relatively expensive

Copy link
Copy Markdown
Contributor Author

@cdnninja cdnninja Nov 28, 2025

Choose a reason for hiding this comment

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

This was an effort to start moving away from rgettattr. I either need to safely detect if the data exists, or confirm the class where they exist is used. I can think on this and see if the is_supported would work but I don't think that applies across all classes.

Comment thread homeassistant/components/vesync/quality_scale.yaml
@home-assistant home-assistant Bot marked this pull request as draft November 27, 2025 17:30
@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.

@cdnninja cdnninja marked this pull request as ready for review November 28, 2025 03:20
@home-assistant home-assistant Bot requested a review from joostlek November 28, 2025 03:20
@cdnninja cdnninja mentioned this pull request Dec 24, 2025
21 tasks
@@ -0,0 +1,66 @@
rules:
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.

There's no place for that or a rule to explicitly deny it, but I would consider this a thing that makes the integration of good quality. You could put it under strict-typing

@@ -0,0 +1,66 @@
rules:
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.

        # Populate maps once.
        for vs_mode in self.device.mist_modes:
            ha_mode = _get_ha_mode(vs_mode)
            if ha_mode:
                self._available_modes.append(ha_mode)
                self._ha_to_vs_mode_map[ha_mode] = vs_mode

        self._available_modes.sort()

More like, instead of using the generic map, we build a new map based on the existing values. I only think there's a benefit for this if you have humidifier modes that map to the same thing (so let's say device A has mode X and device B has mode Y and they're mapped to the same value in HA, then this would make sense as this would make sure that we don't ask for mode Y on device A)

@@ -0,0 +1,66 @@
rules:
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.

Ideally we do that, the less abstractions we have on the HA side the better (as in, you might have someone who doesn't want that to happen and then you'd have to add a configuration, and that can become a slippery slope)

@@ -0,0 +1,66 @@
rules:
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.

No real place

@joostlek joostlek merged commit 8c9a6cc into home-assistant:dev Dec 29, 2025
35 of 36 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 30, 2025
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.

2 participants