-
-
Notifications
You must be signed in to change notification settings - Fork 35k
Add new integration for AiDot #137504
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
base: dev
Are you sure you want to change the base?
Add new integration for AiDot #137504
Conversation
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.
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!
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
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.
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
vol.Required( | ||
CONF_COUNTRY, | ||
default=DEFAULT_COUNTRY_NAME, | ||
): vol.In(SUPPORTED_COUNTRY_NAMES), |
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.
What are the countries we support? Can we use a CountrySelector?
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.
The previous reviewer asked this question, but not all countries support it, so it is not suitable to directly use CountrySelectors
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.
What countries do we not support?
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.
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
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.
But these are all in the ISO_3166-1 and thus we can use the country selector here
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.
As suggested by @joostlek , please change to use a CountrySelector
. Here's an example of how it can be used:
core/homeassistant/components/buienradar/config_flow.py
Lines 32 to 36 in 815b26d
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, |
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.
What is this?
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 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
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.
What kind of data is that? Why do we need to use the cloud here?
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.
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
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.
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.
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.
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 |
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 do we set status.online to false?
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.
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
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.
But if self.device_client.status.online
is already False
, why do we still need to set it?
Hello, may I ask if there are any further questions? Can we proceed with the review now. |
@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, |
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.
What kind of data is that? Why do we need to use the cloud here?
vol.Required( | ||
CONF_COUNTRY, | ||
default=DEFAULT_COUNTRY_NAME, | ||
): vol.In(SUPPORTED_COUNTRY_NAMES), |
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.
What countries do we not support?
_LOGGER, | ||
config_entry=config_entry, | ||
name=DOMAIN, | ||
update_interval=timedelta(seconds=5), |
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.
5 seconds is very very low, how is that an appropriate amount for polling?
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 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
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.
any chance for a push based approach?
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.
We currently do not support push notifications. Do you have any other suggestions?
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.
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.
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.
Can we configure the device's push connection from Home Assistant then and make HA the target
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.
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
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 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
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.
Our devices are also all local, Will not read the status through the external network
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 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.
# 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 |
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.
Please evaluate all rules
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.
Can you be more specific? I don't quite understand what you mean
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.
We should not put everything to todo, but reflect what the current state of the integration is
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.
So, can we delete these todo items?
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.
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() |
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 discovery, is this async safe?
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.
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
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.
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:
436c077987742a2e82a3c9986039eff4e526a74c
- This commit has something that looks like an email address (hongjinbin@leedarson.com). Maybe try linking that to GitHub?.
Unfortunately, we are unable to accept this pull request until this situation is corrected.
Here are your options:
-
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.
-
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
(substituting "Author Name" and "
git commit --amend --author="Author Name <email@address.com>"
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:
- 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.
- 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.
- If you only made a single commit you should be able to run
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! ❤️
436c077
to
c9f2079
Compare
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.
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
andAidotDeviceUpdateCoordinator
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."""
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@s1eedz please fix the CLA error reported by the bot here #137504 (review) |
_LOGGER = logging.getLogger(__name__) | ||
|
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.
Not used, remove it
_LOGGER = logging.getLogger(__name__) |
import logging | ||
|
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.
import logging |
# 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 |
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 comment adds no value
# 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 |
coordinator = entry.runtime_data | ||
coordinator.cleanup() |
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.
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, |
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.
Will there ever be a need to renew the login info, for example if the password is changed?
vol.Required( | ||
CONF_COUNTRY, | ||
default=DEFAULT_COUNTRY_NAME, | ||
): vol.In(SUPPORTED_COUNTRY_NAMES), |
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.
As suggested by @joostlek , please change to use a CountrySelector
. Here's an example of how it can be used:
core/homeassistant/components/buienradar/config_flow.py
Lines 32 to 36 in 815b26d
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), |
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 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} |
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.
Do all lights with support for rgbw also support cct?
Breaking change
Proposed change
Type 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: