WIP: attempting to add support for A1 Ultra (help needed)#11
WIP: attempting to add support for A1 Ultra (help needed)#11itay-sho wants to merge 5 commits intoairy10:mainfrom
Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @itay-sho, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces preliminary support for the A1 Ultra-JM device into the tuya_ble Home Assistant integration. The changes involve registering the device and mapping several of its key functionalities, such as a BLE unlock button, beep volume settings, and alarm status reporting. The author has indicated that they are currently facing challenges with device discovery within Home Assistant and are seeking assistance to resolve this issue.
Highlights
- New Device Support: Initial integration of the A1 Ultra-JM device by adding its product ID (
hc7n0urm) and defining its core capabilities within thetuya_blecustom component. - Device Capabilities: Added specific mappings for the A1 Ultra-JM, including a BLE unlock button (DP ID 71), beep volume control (DP ID 31) with 'mute' and 'normal' options, and an alarm lock sensor (DP ID 21) for 'low_battery' and 'power_off' states.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
Hi, thanks for your contribution! Adding support for new devices is always welcome.
The code changes for defining the new device A1 Ultra-JM (product ID hc7n0urm) look correct and consistent with how other devices are defined in this integration. You've correctly added the device to the mappings in button.py, devices.py, select.py, and sensor.py.
Regarding the issue you're facing with device discovery ("No unconfigured devices found"), this message typically comes from the configuration flow when it can't find any new Tuya BLE devices from your Tuya Cloud account that aren't already set up in Home Assistant. Since your code changes define how to handle the device after it's discovered and set up, they won't affect this initial discovery step.
Here are a few pointers to help you investigate the discovery issue:
- Tuya IoT Platform: Double-check on the Tuya IoT Platform that your device is listed under your project and that its "Communication Type" is indeed Bluetooth (BLE).
- Debug Logging: This is often the most helpful step. You can enable debug logging for this component by adding the following to your
configuration.yaml:After restarting Home Assistant, try adding the integration again and check thelogger: default: info logs: custom_components.tuya_ble: debug homeassistant.components.bluetooth: debug bleak: debug
home-assistant.logfile for any errors or clues related totuya_bleor your device's address/ID. devices.json: You mentioned trying to usedevices.json. As you suspected, this integration does not seem to use adevices.jsonfile for manual configuration. That approach might be from a different Tuya integration or an older version.
The problem is most likely related to how the device is being reported by the Tuya Cloud API, or how the integration is processing that list of devices during the config flow. The debug logs should give you more insight into what's happening under the hood.
Your changes are a good first step, and once the discovery issue is resolved, they should allow Home Assistant to create the correct entities for your A1 Ultra.
| "hc7n0urm": # A1 Ultra-JM | ||
| [ | ||
| TuyaBLEButtonMapping( | ||
| dp_id=71, # On click it opens the lock, just like connecting via Smart Life App and holding the center button | ||
| description=ButtonEntityDescription( | ||
| key="ble_unlock_check", | ||
| icon="mdi:lock-open-variant-outline", | ||
| ), | ||
| ), | ||
| ], |
There was a problem hiding this comment.
This new mapping for hc7n0urm appears to be an exact duplicate of the existing mapping for xicdxood (lines 127-136). This introduces code duplication, which can make future maintenance more difficult if both devices need to be updated simultaneously.
The codebase already uses dict.fromkeys in other places to apply the same configuration to multiple product IDs (e.g., lines 71-82 in this file). For future changes, consider using this pattern to improve maintainability.
Since a full refactoring would involve modifying lines outside of the current diff, it's acceptable for now, but it's a good practice to keep in mind.
Hey, I am trying to add support for my A1 Ultra device.
I based my work on @raphaeleduardo42 work in #2.
Every config I have added was checked compared to Tuya's API - there are still many configs I didn't import for this device and will be added over time.
Problem is I cannot find the device while running home assistant.
So, the problem as for now is the fact that I can't find my device.
I know all of the required stuff (uuid, device id, local_key) but home assistant just not recognizing it.
that being said I know for a fact there is a reception to the device.
when I attempt to find the new device by adding the integration and logging in to the cloud, I get the following: "No unconfigured devices found."
I read a little bit on a ticket of the original repo and saw that people sometimes used a manual config. this could be useful for me since I know all of the configs I need. unfortunately I couldn't ever see the device after configuring it with devices.json as they've suggested. I don't see any code that collects data from this file either.
At this point, I don't really know how to continue investigate and would like to get some tips.
thank you