Skip to content

Conversation

s1eedz
Copy link

@s1eedz s1eedz commented Feb 6, 2025

Breaking change

Proposed change

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

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
Copy link

home-assistant bot commented Feb 6, 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.

@s1eedz s1eedz changed the title Feature/aidot wifi lights improve Add new integration for AiDot Feb 6, 2025
@s1eedz s1eedz marked this pull request as ready for review February 6, 2025 08:41
Copy link
Author

@s1eedz s1eedz left a comment

Choose a reason for hiding this comment

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

Hi all,
Do I need to modify anything in this current PR? I see that there has been no new news for a long time. What is wrong with this PR? What can I modify so that it can be merged smoothly?
Regards

Comment on lines +52 to +55
vol.Required(
CONF_COUNTRY,
default=DEFAULT_COUNTRY_NAME,
): vol.In(SUPPORTED_COUNTRY_NAMES),
Copy link
Member

Choose a reason for hiding this comment

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

What are the countries we support? Can we use a CountrySelector?

Copy link
Author

@s1eedz s1eedz Mar 27, 2025

Choose a reason for hiding this comment

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

The previous reviewer asked this question, but not all countries support it, so it is not suitable to directly use CountrySelectors

Copy link
Member

Choose a reason for hiding this comment

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

What countries do we not support?

Copy link
Author

Choose a reason for hiding this comment

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

We have not unified which countries we do not support. I can provide the following list of countries we support:
Albania
Antigua and Barbuda
Argentina
Austria
Anguilla
Afghanistan
Armenia
Azerbaijan
Australia
Bolivia
Brazil
Bulgaria
Bahamas
Belgium
Belize
Barbados
Bermuda
Brunei
Bahrain
Bangladesh
Bhutan
Canada
Chile
Colombia
Costa Rica
Cuba
Czech Republic
Croatia
Cayman Islands
Cambodia
Cyprus
Denmark
Dominican Republic
Ecuador
El Salvador
Estonia
Finland
France
French Guiana
Greece
Guatemala
Guyana
Germany
Grenada
Georgia
Haiti
Honduras
Hungary
Iceland
Ireland
Italy
India
Indonesia
Iran
Iraq
Israel
Jamaica
Japan
Jordan
Kazakhstan
Korea
Kuwait
Kyrgyzstan
Latvia
Lithuania
Luxembourg
Liechtenstein
Laos
Lebanon
Malta
Mexico
Moldova
Monaco
Montserrat
Montenegro
Malaysia
Maldives
Mongolia
Myanmar
Netherlands
Nicaragua
Norway
North Macedonia
New Zealand
Nepal
North Korea
Oman
Panama
Paraguay
Peru
Portugal
Pakistan
Palestine
Philippines
Qatar
Romania
Russia
San Marino
Slovenia
Spain
St.Lucia
Suriname
Sweden
Slovakia
Serbia
St.Kitts and Nevis
St.Vincent and the Grenadines
Saudi Arabia
Singapore
Sri Lanka
Syria
Switzerland
Trinidad and Tobago
Turks & Caicos
Tajikistan
Thailand
Togo
Turkey
Turkmenistan
Ukraine
United Kingdom
United States
Uruguay
United Arab Emirates
Uzbekistan
Venezuela
Virgin Islands
Vietnam
Yemen

Copy link
Member

Choose a reason for hiding this comment

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

But these are all in the ISO_3166-1 and thus we can use the country selector here

Copy link
Contributor

Choose a reason for hiding this comment

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

As suggested by @joostlek , please change to use a CountrySelector. Here's an example of how it can be used:

vol.Optional(
CONF_COUNTRY_CODE, default=DEFAULT_COUNTRY
): selector.CountrySelector(
selector.CountrySelectorConfig(countries=SUPPORTED_COUNTRY_CODES)
),

return self.async_create_entry(
title=f"{user_input[CONF_USERNAME]} {user_input[CONF_COUNTRY]}",
data={
CONF_LOGIN_INFO: login_info,
Copy link
Member

Choose a reason for hiding this comment

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

What is this?

Copy link
Author

Choose a reason for hiding this comment

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

This is the login information. After successfully logging in from the cloud, we will use this login information to search for devices on the local area network and connect them

Copy link
Member

Choose a reason for hiding this comment

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

What kind of data is that? Why do we need to use the cloud here?

Copy link
Author

Choose a reason for hiding this comment

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

Our devices need to be added through the Aidot APP first, and then the home assistant needs to pull the list of all devices from the server to the local area network for control. I think this mechanism has been explained very clearly to the previous reviewer. Thank you

Copy link
Author

Choose a reason for hiding this comment

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

Firstly, we need to add devices through our app (Aidot), and once added, the devices will be saved to the cloud. Then HomeAssistant logs into our APP account to retrieve the device list from the cloud. Once they receive the device list, they will automatically scan the devices within the local area network to match them. The matched devices can be controlled within the local area network.

Copy link
Contributor

Choose a reason for hiding this comment

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

Will there ever be a need to renew the login info, for example if the password is changed?

status = await self.device_client.read_status()
except AidotNotLogin:
status = self.device_client.status
status.online = False
Copy link
Member

Choose a reason for hiding this comment

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

why do we set status.online to false?

Copy link
Author

Choose a reason for hiding this comment

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

When a login exception occurs, the device_client has already set online to false, and the business code does not need to be processed repeatedly

Copy link
Member

Choose a reason for hiding this comment

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

But if self.device_client.status.online is already False, why do we still need to set it?

@home-assistant home-assistant bot marked this pull request as draft March 26, 2025 17:16
@joostlek joostlek removed the second-opinion-wanted Add this label when a reviewer needs a second opinion from another member. label Mar 26, 2025
@joostlek joostlek removed this from the 2025.4.0b0 milestone Mar 26, 2025
@s1eedz s1eedz marked this pull request as ready for review March 28, 2025 06:00
@home-assistant home-assistant bot requested review from zweckj and joostlek March 28, 2025 06:00
@s1eedz
Copy link
Author

s1eedz commented Apr 7, 2025

Hello, may I ask if there are any further questions? Can we proceed with the review now.

@s1eedz
Copy link
Author

s1eedz commented Apr 18, 2025

@zweckj @joostlek Hello, what should I do next? Thank you

@s1eedz
Copy link
Author

s1eedz commented May 6, 2025

@joostlek Hello, can you continue with the review? It has been a long time since my last submission, and I don't know what to do next. Can you give me an accurate reply? Thank you

return self.async_create_entry(
title=f"{user_input[CONF_USERNAME]} {user_input[CONF_COUNTRY]}",
data={
CONF_LOGIN_INFO: login_info,
Copy link
Member

Choose a reason for hiding this comment

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

What kind of data is that? Why do we need to use the cloud here?

Comment on lines +52 to +55
vol.Required(
CONF_COUNTRY,
default=DEFAULT_COUNTRY_NAME,
): vol.In(SUPPORTED_COUNTRY_NAMES),
Copy link
Member

Choose a reason for hiding this comment

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

What countries do we not support?

_LOGGER,
config_entry=config_entry,
name=DOMAIN,
update_interval=timedelta(seconds=5),
Copy link
Member

Choose a reason for hiding this comment

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

5 seconds is very very low, how is that an appropriate amount for polling?

Copy link
Author

Choose a reason for hiding this comment

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

I need to read the status of the device in real-time, for example, if the device status changes, the page needs to follow the real-time changes. Or do you have any suggestions on your end? Thank you

Copy link
Member

Choose a reason for hiding this comment

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

any chance for a push based approach?

Copy link
Author

Choose a reason for hiding this comment

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

We currently do not support push notifications. Do you have any other suggestions?

Copy link
Member

Choose a reason for hiding this comment

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

then it is what it is. For your own (servers) sake- if you really want to have real time updates (especially if you thinking about implementing events later) websocket (or at a minimum webhooks, if you don't want a standing connection) would be my recommendation.

Copy link
Member

Choose a reason for hiding this comment

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

Can we configure the device's push connection from Home Assistant then and make HA the target

Copy link
Author

Choose a reason for hiding this comment

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

Can we maintain the current logic and pull the device status once every 5 seconds? I have referenced others who have also done the same. We will implement configuration push later

Copy link
Member

Choose a reason for hiding this comment

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

I think 5 seconds is very fast, also given that this is only a light. This would put way too much stress on the system by default, while the information itself isn't as relevant. There are other integrations doing a fast update interval, but most of them are local.

If a user want to indeed go very low, they can follow these steps to fix that https://www.home-assistant.io/common-tasks/general/#defining-a-custom-polling-interval

Copy link
Author

Choose a reason for hiding this comment

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

Our devices are also all local, Will not read the status through the external network

Copy link
Contributor

Choose a reason for hiding this comment

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

I think 5 seconds is OK if the polling is indeed happening over the local network, there are other integrations with such a short poll interval.

Comment on lines +42 to +67
# Gold
devices: todo
diagnostics: todo
discovery-update-info: todo
discovery: todo
docs-data-update: todo
docs-examples: todo
docs-known-limitations: todo
docs-supported-devices: todo
docs-supported-functions: todo
docs-troubleshooting: todo
docs-use-cases: todo
dynamic-devices: todo
entity-category: todo
entity-device-class: todo
entity-translations: done
exception-translations: todo
icon-translations: todo
reconfiguration-flow: todo
repair-issues: todo
stale-devices: todo
entity-disabled-by-default: todo
# Platinum
async-dependency: done
inject-websession: todo
strict-typing: todo
Copy link
Member

Choose a reason for hiding this comment

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

Please evaluate all rules

Copy link
Author

Choose a reason for hiding this comment

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

Can you be more specific? I don't quite understand what you mean

Copy link
Member

Choose a reason for hiding this comment

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

We should not put everything to todo, but reflect what the current state of the integration is

Copy link
Author

Choose a reason for hiding this comment

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

So, can we delete these todo items?

Copy link
Member

Choose a reason for hiding this comment

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

No, check if you implemented the rule and update the rule to todo or done or exempt :)

async def _async_update_data(self) -> None:
"""Update data async."""
try:
data = await self.client.async_get_all_device()
Copy link
Member

Choose a reason for hiding this comment

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

This discovery, is this async safe?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, this is safe. We will regularly pull the device list from the server to synchronize whether the devices have been added, deleted, or modified

@home-assistant home-assistant bot marked this pull request as draft June 12, 2025 15:54
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.

Hello @s1eedz,

When attempting to inspect the commits of your pull request for CLA signature status among all authors we encountered commit(s) which were not linked to a GitHub account, thus not allowing us to determine their status(es).

The commits that are missing a linked GitHub account are the following:

Unfortunately, we are unable to accept this pull request until this situation is corrected.

Here are your options:

  1. If you had an email address set for the commit that simply wasn't linked to your GitHub account you can link that email now and it will retroactively apply to your commits. The simplest way to do this is to click the link to one of the above commits and look for a blue question mark in a blue circle in the top left. Hovering over that bubble will show you what email address you used. Clicking on that button will take you to your email address settings on GitHub. Just add the email address on that page and you're all set. GitHub has more information about this option in their help center.

  2. If you didn't use an email address at all, it was an invalid email, or it's one you can't link to your GitHub, you will need to change the authorship information of the commit and your global Git settings so this doesn't happen again going forward. GitHub provides some great instructions on how to change your authorship information in their help center.

    • If you only made a single commit you should be able to run
      git commit --amend --author="Author Name <email@address.com>"
      
      (substituting "Author Name" and "email@address.com" for your actual information) to set the authorship information.
    • If you made more than one commit and the commit with the missing authorship information is not the most recent one you have two options:
      1. You can re-create all commits missing authorship information. This is going to be the easiest solution for developers that aren't extremely confident in their Git and command line skills.
      2. You can use this script that GitHub provides to rewrite history. Please note: this should be used only if you are very confident in your abilities and understand its impacts.
    • Whichever method you choose, I will come by to re-check the pull request once you push the fixes to this branch.

We apologize for this inconvenience, especially since it usually bites new contributors to Home Assistant. We hope you understand the need for us to protect ourselves and the great community we all have built legally. The best thing to come out of this is that you only need to fix this once and it benefits the entire Home Assistant and GitHub community.

Thanks, I look forward to checking this PR again soon! ❤️

fix

fix
@s1eedz s1eedz force-pushed the feature/aidot-wifi-lights-improve branch from 436c077 to c9f2079 Compare June 17, 2025 11:54
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 Home Assistant integration for AiDot Wi-Fi lights, including configuration flow, coordinator logic, light platform, and comprehensive tests.

  • Implements AidotDeviceManagerCoordinator and AidotDeviceUpdateCoordinator for polling and dynamic device management
  • Adds a light platform (light.py) with on/off, brightness, color temperature, and RGBW support
  • Provides config flow, manifest, strings, quality scale, and end-to-end tests for init, config flow, and light behavior

Reviewed Changes

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

Show a summary per file
File Description
homeassistant/components/aidot/coordinator.py Implements polling of device list and per-device status
homeassistant/components/aidot/light.py Defines AidotLight entity with full color support
homeassistant/components/aidot/config_flow.py Adds user config flow with login and abort logic
homeassistant/components/aidot/strings.json User-facing messages for config flow
tests/components/aidot/test_light.py Tests for light entity state and dynamic add/remove
tests/components/aidot/test_config_flow.py Tests for the config flow paths
tests/components/aidot/test_init.py Tests for unloading the integration
Comments suppressed due to low confidence (3)

tests/components/aidot/test_light.py:167

  • The docstring for test_dynamic_device_remove is incorrect—it describes adding a device but this test checks removal. Please update the docstring to reflect that it's testing dynamic removal of devices.
    """Test if adding a new device dynamically creates the corresponding light entity."""

tests/components/aidot/test_config_flow.py:20

  • The docstring here mentions a failed config flow but the test is for a successful login. Please correct the docstring to describe a successful cloud login scenario.
async def test_config_flow_cloud_login_success(

homeassistant/components/aidot/light.py:36

  • The callback docstring says 'Add sensor entities' but this is in the light platform. Please update to 'Add light entities' or similar.
        """Add sensor entities."""

s1eedz and others added 3 commits June 27, 2025 14:27
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@emontnemery
Copy link
Contributor

@s1eedz please fix the CLA error reported by the bot here #137504 (review)

Comment on lines +12 to +13
_LOGGER = logging.getLogger(__name__)

Copy link
Contributor

Choose a reason for hiding this comment

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

Not used, remove it

Suggested change
_LOGGER = logging.getLogger(__name__)

Comment on lines +5 to +6
import logging

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import logging

Comment on lines +29 to +31
# This is called when an entry/configured device is to be removed. The class
# needs to unload itself, and remove callbacks. See the classes for further
# details
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment adds no value

Suggested change
# This is called when an entry/configured device is to be removed. The class
# needs to unload itself, and remove callbacks. See the classes for further
# details

Comment on lines +32 to +33
coordinator = entry.runtime_data
coordinator.cleanup()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
coordinator = entry.runtime_data
coordinator.cleanup()
entry.runtime_data.cleanup()

return self.async_create_entry(
title=f"{user_input[CONF_USERNAME]} {user_input[CONF_COUNTRY]}",
data={
CONF_LOGIN_INFO: login_info,
Copy link
Contributor

Choose a reason for hiding this comment

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

Will there ever be a need to renew the login info, for example if the password is changed?

Comment on lines +52 to +55
vol.Required(
CONF_COUNTRY,
default=DEFAULT_COUNTRY_NAME,
): vol.In(SUPPORTED_COUNTRY_NAMES),
Copy link
Contributor

Choose a reason for hiding this comment

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

As suggested by @joostlek , please change to use a CountrySelector. Here's an example of how it can be used:

vol.Optional(
CONF_COUNTRY_CODE, default=DEFAULT_COUNTRY
): selector.CountrySelector(
selector.CountrySelectorConfig(countries=SUPPORTED_COUNTRY_CODES)
),

_LOGGER,
config_entry=config_entry,
name=DOMAIN,
update_interval=timedelta(seconds=5),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think 5 seconds is OK if the polling is indeed happening over the local network, there are other integrations with such a short poll interval.

)
if coordinator.device_client.info.enable_rgbw:
self._attr_color_mode = ColorMode.RGBW
self._attr_supported_color_modes = {ColorMode.RGBW, ColorMode.COLOR_TEMP}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do all lights with support for rgbw also support cct?

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.

7 participants