-
Notifications
You must be signed in to change notification settings - Fork 16
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
fix: One media entity for all; minor refactorings; support RestIot in rest_media_entity.py along with favorites + specific sounds from app #121
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5eb8290
One media entity for all; minor refactorings; support RestIot in rest…
ChrisCarini 7e6b4e2
Merge remote-tracking branch 'origin/main' into ChrisCarini/changes
ChrisCarini deeae23
bump deps including HA 2024.4.1
ChrisCarini e3e8f19
Removing commented out test code
ChrisCarini File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
colorlog==6.8.2 | ||
homeassistant==2023.5.1 | ||
pip>=8.0.3,<24.1 | ||
ruff==0.3.4 | ||
hatch-rest-api==1.22.0 | ||
homeassistant==2024.4.1 | ||
pip>=24 | ||
ruff>=0.3.5 | ||
hatch-rest-api==1.24.0 |
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.
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 appears to remove support for gen1 rest plus. why are you merging the gen1 and gen2 entities? As discussed in the api review, history has shown you will not get users to test a gen2 change against their gen1 devices. Please leave gen2 with their riot prefixes like the other gen2 entities.
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 change should still support gen1 rest plus - its captured by the implicit
else
return statement here. I initially merged these two media entities because of the sheer amount of duplicate logic/code between the two of them.Yup - that was not mentioned prior to me implementing this change (I did both the lib and this change concurrently). 😅
Sure - do you mind if I clean up the code in both of these media entities? The way the current code (that is, the code in main branch, not in this PR) is, is a bit funky, IMO; specifically:
media_player.py
:elif
statement here as opposed to a genericelse
? The two conditions are a bit confusing, because it says "if restiot or restore iot, create gen2 device, otherwise if not restore iot (aka restiot would possibly be valid, if not already returned), create gen1 device". This is a bit confusing. and IMO should be fixed for correctness (i.e. if restiot or restoreiot, create gen2, else create gen1); something like:rest_entity.py
has leakage ofRestPlus
specific implementation for turning on - if we want to keep gen1 and gen2 separate, then that should be moved into the specific media entity to prevent leakage into the base class.RestEntity
, or are you opposed to that entirely? I'm specifically thinking:self._attr_supported_features
features that are applicable across both gen1 and gen2 devices - only gen1 enetity for restplus would need overridingset_volume_level()
methodmedia_pause()
method_update_local_state()
method@dahlb let me know your thoughts please! :)
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.
Sorry I missed the rest plus return before you pointed it out, looks like an extra line break within the function confused the GitHub diff so that the return was listed after another function was listed as removed.
yeah that else is ugly and should be updated, thanks
we can move the turn on method out of the rest entity and into each of it's sub classes, note though you should check references as rest entity is used for more then the media player, one example being the rest light entity.
you could make another parent class for identical methods between rest plus and iot entity, but since rest entity is shared between different kinds of entities, things like supported features don't belong there.