-
Notifications
You must be signed in to change notification settings - Fork 79
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
Use EntityCategory enum instead of strings #504
Conversation
Please, @mdegat01 check your code style, and configure correctly pre-commit, check the contribution guidelines. |
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.
That's nice, thank you!
Are we sure it's backwards competitive and won't break the integration for those using latest stable HA image? 🤔 :)
Well, I don't think so. If not, maybe we should wait until the stable version is released, and then use the new method, which won't be compatible with HA However, this should be tested. Edit: in fact, the PR from HA is labeled as "breaking-change", so this is something to take into consideration. |
After a bit of searching I've found this on StackOverflow, so maybe something like this can be used: if version >= "2022.4":
from homeassistant.const import ENTITY_CATEGORY_CONFIG
else:
from homeassistant.helpers.entity import EntityCategory.CONFIG as ENTITY_CATEGORY_CONFIG Which will allow to keep using _attr_entity_category = ENTITY_CATEGORY_CONFIG Not sure about this, it has to be tested and further investigation must be performed, just a suggestion that might work out until it's marked as not backward-compatible by HA. |
@ArnyminerZ This repository lists version That's why I said it would be fine to merge immediately. All versions of home assistant this integration supports are after that was merged into core and the enum shipped. I'll fix the formatting and stuff though sorry about that. Was cranking through a couple of these based on users reporting the same issues in the beta channel of ha |
Also just to get everyone on the same page, 2022.4 is the release when providing an entitycategory as a string instead of an enum goes from being deprecated to being unsupported. It's not the release when HA introduced the entitycategory enum, that was 2021.12 (the pr we both linked was committed into core on 12/1/2021). So essentially this component no longer works at all starting in 2022.4 without this change. With this change it works fine for all releases of ha >= 2021.12 which covers all releases of ha supported by this component according to its HACS.json. |
a66b62e
to
a92f1af
Compare
Okey @mdegat01, thanks for making it clear. Then we can merge this without any issues. Agree @leikoilja ? |
Since no further issues have been reported, merging this one 🚀 |
This issue does not appear to be resolved, check #507 for update |
Awesome, thank you, gents 💪 💥 🔥 |
Thanks very much for your efforts resolving this. |
Using the entity category strings doesn't work anymore starting in
2022.4
. Using the enums instead fixes #503 .The enums have been accepted since
2021.12
(PR) which covers your supported versions so it is safe to make immediately, don't have to wait for2022.4
.