Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Refactor switch for vesync #134409
Refactor switch for vesync #134409
Changes from 13 commits
0d67c7b
033cac8
3a663de
6604d26
f4352fd
f143594
1337372
7b0510d
8db10fb
0ce2086
0fc9e81
4a2fa3f
0288768
c12b55d
9043ba7
ff5f13c
8f13594
5b08b11
e32f14f
139d4e1
10e9925
8b38c47
85fdfdd
70e2cdf
c6d2088
27c255e
1013880
51d1ead
d963ec7
b39778e
bde6507
765b86b
918ff0e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Check warning on line 22 in homeassistant/components/vesync/common.py
homeassistant/components/vesync/common.py#L22
Check warning on line 25 in homeassistant/components/vesync/common.py
homeassistant/components/vesync/common.py#L25
Check warning on line 29 in homeassistant/components/vesync/common.py
homeassistant/components/vesync/common.py#L29
Check warning on line 32 in homeassistant/components/vesync/common.py
homeassistant/components/vesync/common.py#L32
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 need to define
_attr_unique_id
otherwise adding another switch entity fails.Something like this will work -
self._attr_unique_id = f"{super().unique_id}-{description.key}"
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.
For the two devices exposed today if we change this it will be a breaking change. However I could add a filter to only do the above unique ID on ones other than the outlet and switch on we offer today. It would set us up for future.
Thoughts on that 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.
I suppose that will work. @joostlek might have reviewed code which ran into similar shortcoming and if the _attr_unique_id was defined as a breaking change.
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.
Oh that is a good catch. If that is the case we should migrate first. I don't feel like merging this as it will create entities with not unique unique ids. So we should have a preliminary PR where we migrate all the unique ids of the switches to something else and then we can set up new ones
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.
Okay, today this code doesn't conflict or impact unique ID, however since trying to setup for growth makes sense we fix this now. I will update this code to have the unique ID as mentioned above and chat with iprak around getting a PR for that migration that will merge first.
Check warning on line 108 in homeassistant/components/vesync/switch.py
homeassistant/components/vesync/switch.py#L108
Check warning on line 116 in homeassistant/components/vesync/switch.py
homeassistant/components/vesync/switch.py#L116
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.
Shouldn't schedule_update_ha_state be only called if turn_on succeeds?