Skip to content

Add Dreo integration #135107

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

Draft
wants to merge 336 commits into
base: dev
Choose a base branch
from
Draft

Add Dreo integration #135107

wants to merge 336 commits into from

Conversation

w-xtao
Copy link

@w-xtao w-xtao commented Jan 8, 2025

Breaking change

Proposed change

Add dreo integration with fan platform.

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 Ruff (ruff format 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.

To help with the load of incoming pull requests:

Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

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

Hi @w-xtao

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant home-assistant bot marked this pull request as draft January 8, 2025 15:30
@home-assistant
Copy link

home-assistant bot commented Jan 8, 2025

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.

Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

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

Hi @w-xtao

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@w-xtao w-xtao marked this pull request as ready for review January 9, 2025 02:12
@home-assistant home-assistant bot dismissed stale reviews from themself January 9, 2025 02:12

Stale

@w-xtao w-xtao marked this pull request as draft January 9, 2025 06:13
@w-xtao w-xtao marked this pull request as ready for review January 9, 2025 06:16
@home-assistant home-assistant bot marked this pull request as draft March 3, 2025 14:31
@w-xtao w-xtao marked this pull request as ready for review March 11, 2025 14:23
@home-assistant home-assistant bot requested a review from edenhaus March 11, 2025 14:23
@home-assistant home-assistant bot marked this pull request as draft March 12, 2025 15:12
@w-xtao w-xtao marked this pull request as ready for review March 15, 2025 07:09
@home-assistant home-assistant bot requested a review from abmantis March 15, 2025 07:09
Thulrus and others added 4 commits June 24, 2025 06:55
* Initial commit for VegeHub integration

* Moved several pieces to library, continuing.

* All device contact moved to library

* Updated documentation link

* Fixed an error in strings.json

* Removed commented out code and unused file

* Removed unneeded info logging, and a few missed lines of commented code

* Added/removed comments for clarity

* Converted integration to use webhooks.

* Update __init__.py to remove unnecessary code.

Co-authored-by: Josef Zweck <[email protected]>

* Remove unnecessary code from config_flow.py

Co-authored-by: Josef Zweck <[email protected]>

* Simplify unique_id assertion.

* Switch to CONF_ constant for user input

* Added explanation for passing exception.

* Got rid of try-except, since I don't really handle the exceptions her anyway.

* Moved data transform to vegehub library

* Changed references to use HA constants.

* Fixed assigning and returning _attr properties.

* Moved temperature sensor transform to the library.

* Moved sensor names to strings.json

* Made webhook names unique to avoid collisions when multiple devices are added.

* Converted to using entry.runtime_data

* Removed options flow for first PR

* Removed switch support to limit PR to one platform

* Removed/updated outdated tests

* Update homeassistant/components/vegehub/__init__.py

Co-authored-by: Josef Zweck <[email protected]>

* Got rid of strings in favor of constants.

* Got rid of unnecessary check

* Imported constant directly.

* Added custom type for entry

* Expanded CONF_ constants into sensor.py

* Get rid of extra `str` and `get`

Co-authored-by: Josef Zweck <[email protected]>

* Added type to errors

* Added try/except to MAC address retrieval

* Moved functionality out of ConfigFlow that shouldn't have been there

* Removed IP:MAC tracking from ConfigFlow

* Added retries to VegeHub PyPI package, and implemented them in integration

* Removed different sensor types for now

* Fixed typo

* Changed abort to error

* Fixed error reporting in config flow

* Further simplify sensor.py to handle all sensors the same

* Added comment to clarify

* Got rid of unused constants

* Removed unused strings in strings.json

* Added quality_scale.yaml

* Fixed problems in sensor init

* Moved config url and sw version storage into vegehub package

* Get rid of extra declaration

Co-authored-by: Josef Zweck <[email protected]>

* Removed unnecessary task

* Fix type for entry

* Added a test before setup

* Fixed tests and got test coverage of config flow to 100%

* Fixed test descriptions

* Implemented a coordinator

* Removed unused property

* Fixed a few minor issues with the coordinator implementation

* Removed unused function

* Fixed some tests

* Trying to fix a problem with re-initialization when server reboots. Mostly working.

* Moved hub.setup from async_setup_entry to config flow to avoid running it on system reboot

* Delete tests/testing_config/.storage/http.auth

* Fixed errors in coordinator.py

* Added IP validation for manual input IP addresses

* Moved data into self._discovered to simplify

* Removed redundant typing

* Shortened sensor unique ID and added coordinator handler

* Added call to super()._handle_coordinator_update() so state gets handled correctly

* Fixed == and is

* Got rid of "slot" and moved functionality to lib

* Got rid of mocked aiohttp calls in favor of just mocking the vegehub library

* Rewrote config flow to make more sense.

* Changed order of data and data_description

* Changes to sensor.py

* Got rid of async_update_data in coordinator and moved async_set_updated_data into webhook callback

* Changed sensor updates so that they keep using last known values if update doesn't contain data for them

* Changed config flow to use homeassistant.helpers.service_info zeroconf instead of homeassistant.components zeroconf

* Added types to test parameters

* Changes and notes in config_flow.py

* Minor fix to get existing tests working before making changes to tests

* Removed unused data and simplified data passing

* Fixed tests, removed unused data, moved sensor tests to snapshots

* Mocked async_setup_entry and async_unload_entry

* Eliminated retry step so that retries just happen in the user flow or zeroconf_confirm

* Bumped the library version

* Bumped library version again

* Changed test-before-setup test

* Improved use of coordinator

* Almost done reworking tests. A few more changes still needed.

* Added via device to sensor.py and key reference to strings.json

* Webhook tests are almost, but not quite, working

* Fully functional again

* Change error to assert

* made identifiers and via_device the same

* made the via_device just be the mac

* Fixed strings.json and updated translations

* Fixed test_sensor.py

* Cleaned up tests and added autouse to several fixtures to simplify

* Switched from error to assert, and added exemption to quality scale.

* Cleaned up some tests and added update of IP if unique ID of discovered device is the same.

* Improved zeroconfig to update IP and hostname, and added a test to make sure those work.

* Fixed a comment.

* Improved ip/hostname update test.

* Changed Hub to VegeHub in strings.json for clarity.

* Switched to using a base entity to simplify and make adding platforms in the future easier.

* Moved the vegehub object into the coordinator to simplify.

* Removed actuators from sensors, and added unique name for battery sensor

* Changed coordinator to manage its own data, changed sensors to use descriptions and return their value as a property

* Updated data retrieval keys

* Minor updates to several files

* Fixed a few things for pytest

* Reverted to explicit check for None for pytest

* Fixed a comment and a variable name

* Fixed a comment

* Fix

* Bumped depenency version to eliminate pytest from dependencies.

---------

Co-authored-by: Josef Zweck <[email protected]>
Co-authored-by: Josef Zweck <[email protected]>
Co-authored-by: Joostlek <[email protected]>
@Atum-zhulong
Copy link

Atum-zhulong commented Jun 24, 2025

Hi @abmantis
Thank you for the detailed review! I have addressed all the issues you raised:

All Issues Fixed

Code Structure & Logic:

  • Removed unused SYNC_INTERVAL - No longer present in the codebase
  • Fixed device_id handling - Changed from str(device.get("deviceSn", "")) to device.get("deviceSn") in fan.py
  • Implemented data processor pattern - Moved device type logic to coordinator __init__ as suggested
  • Proper exception handling - Using UpdateFailed exceptions instead of returning None
  • Consistent parameter naming - Using error_translation_key throughout
  • Removed unnecessary initialization - No longer calling _update_attributes() in fan __init__
  • Proper availability handling - Let CoordinatorEntity base class handle availability automatically

Testing:

  • Removed test_entity.py - As suggested, testing entity functionality through platform tests
  • Simplified test_coordinator.py - Now only contains core algorithm tests (speed conversion, data type conversion,
    edge cases) that cannot be tested through platforms

Architecture Changes Explanation

I'd also like to explain three significant architectural improvements made during this integration:

  1. Device Command Management Redesign
    Previously, device commands were hardcoded as constants in the hscloud package. This approach had limitations:

    • Required publishing new versions of the underlying package for device command changes
    • Difficult to manage when new models of the same device type were introduced
    • Tight coupling between device specifications and the client library
      New approach: The device list API now directly returns deviceType and config information, making the integration more flexible and maintainable.
  2. Package Migration (hscloud → pydreo-cloud)
    Due to company organizational restructuring, the underlying package has been migrated from hscloud to pydreo-cloud. This change:

    • Reflects the new company structure
    • Provides better package naming alignment with the Dreo brand
    • Maintains the same functionality with improved API design
  3. Improved Maintainability
    The new architecture eliminates the need to:

    • Publish underlying package updates for device command changes
    • Maintain device-specific constants in the client library
      Please let me know if you have any further questions or concerns! Thanks

@w-xtao w-xtao marked this pull request as ready for review June 24, 2025 09:04
@abmantis abmantis requested review from Copilot and removed request for NoRi2909 June 26, 2025 21:55
Copilot

This comment was marked as outdated.

@frenck frenck requested a review from Copilot June 27, 2025 06:38
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new Dreo integration featuring support for the fan platform along with comprehensive tests and configuration flow updates. Key changes include:

  • Implementation of the Dreo integration (config flow, fan platform, coordinator, and entity logic).
  • Updates to tests for both the Dreo and PlayStation Network integrations to accommodate new patch targets and mocking patterns.
  • Addition of new dependency requirements, manifest, quality_scale, and CODEOWNERS entries for the Dreo integration.

Reviewed Changes

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

File Description
tests/components/playstation_network/test_config_flow.py Update of mocking to target the parse_npsso_token method instead of the MagicMock itself.
tests/components/playstation_network/conftest.py Updated patch target for parse_npsso_token to reflect the new module path.
homeassistant/components/playstation_network/strings.json Updated description text with a wording change.
Remaining files (tests/components/dreo, homeassistant/components/dreo/**) New Dreo integration implementation and associated tests.
Comments suppressed due to low confidence (1)

tests/components/playstation_network/conftest.py:129

  • The patch target has been updated to use the new module path for parse_npsso_token. Verify that this updated target matches the current project structure and add a clarifying comment if needed.
        "psnawp_api.utils.misc.parse_npsso_token",

@emontnemery
Copy link
Contributor

Something went wrong when updating the branch, the PR now includes unrelated commits.
@w-xtao Please mark the PR "ready for review" when you've fixed the branch.

@emontnemery emontnemery marked this pull request as draft June 30, 2025 08:47
@w-xtao w-xtao marked this pull request as ready for review June 30, 2025 09:44
@abmantis abmantis marked this pull request as draft June 30, 2025 15:51
@abmantis
Copy link
Member

abmantis commented Jun 30, 2025

@w-xtao Please don't mark this as ready until the unrelated component files, as pointed by @emontnemery , are cleared from this PR. Also, there is no reason to merge from dev so frequently. It is just creating unnecessary commits and noise on the PR. It is ok to do it from time to time, but no need for doing it daily.

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.