-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
Add support for Tuya fault sensors #125098
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?
Conversation
…ing bitmap lookups
Hey there @tuya, @zlinoliver, @frenck, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
I'm aware that some code changes might be needed, for example extracting the new logic in |
This commit refactors the Tuya binary sensor setup in the `async_setup_entry` function. It introduces two new helper functions: `_get_fault_labels` and `_get_fault_sensors`. These functions are responsible for retrieving fault labels and creating fault sensors for the Tuya binary sensor device.
I've done some cleanup of the code and extracted the new logic to separate methods. |
@frenck it looks like several PR's have been opened since I opened mine back in September, trying to solve the same issue: We should probably figure out which one should be merged, and close the others as they solve the same problem. @epenet and @jbouwh I can see that you have been reviewing one of the other PR's but it looks like the author hasn't gotten back yet - maybe you can help me get this reviewed and merged, so we can get this feature added? |
I think this PR looks like the most promising of the three alternatives. @MrAdam Could you please add some tests though? Note that we really want tests to set up the integration and check the resulting state in the state machine unlike what the tests in the alternative PRs do. Please feel free to reach out to me on Discord if you need some help with implementing tests. |
I'll give it a try. |
I leave some review comments. Also, I think we need to expand this code to whole bitmap types not for |
I resolve some own coments on this PR MrAdam#1 |
@MrAdam, take a look, for pr to this branch, maybe it would be simple to merge it MrAdam#1 About bitmaps - padding is needed only when converted to binary string representation, bitwise shift with & works well with "all" numbers. Tuya API returning dec number, so loss is not possible. |
It will probably take some time before I can look at this again (I have started looking into tests), as I just started a new job this week, and am a bit swamped. |
Proposed change
Added support for Tuya fault sensors, indicating any active fault sensors on a Tuya product.
I no 8000 ticed that my MeacoDry Arete Two 12L exposed a field called
fault
, with a type of Bitmap, and the following spec:I then found out through Tuya documentation that this is a general field, so I decided to try and implement detection and parsing of this field.
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: