* Do not use a persistent connection to MPD
In other words, don't rely on the connection management provided by
"python-mpd2". Instead of keeping the connection to MPD open, we
explicitly connect before and disconnect after each command.
There is probably a bit of overhead to this, but as the integration
uses a local-polling approach to begin with, no functionality is lost or
degraded.
This change greatly hardens the MPD integration against both network
issues and problems with the daemon itself. All connection-related
failure modes have effectively been removed.
* Update state retrieval methods
Only "async_get_media_image" attempts to connect, all others are either
called from there, or from the main "async_update" method (see previous
commit) which also attempts to connect.
So, this commit mainly revolves around gracefully handling situations
where no connection is available when trying to retrieve MPD state.
Finally, note the removal of "self._commands". This property is only
used at the start of "_async_get_file_image_response" and was thus
changed into a local variable.
* Update media-player control methods
These all need to explicitly connect to MPD as part of their flow.
* Correct ruff failure (auto-fixed)
* Use "async_timeout.timeout" context manager
* Minor changes
* Replace "async_timeout" with "asyncio.timeout"
* Initialise "self._status" to empty dictionary
Used to be initialised as None, which caused "NoneType is not iterable"
type of issues in case of an unexpected disconnect (at which point
status gets set to None again). Instead of guarding against None
everywhere, using an empty dictionary seemed more prudent...
Furthermore, more cautiously access its members to prevent potential
KeyError-s in similar cases.
* Fix livelock in "async_mute_volume()"
This method doesn't need a connection; it calls into two other methods
that actually connect to MPD – attempting to connect from here resulted
in a livelock.
* Use EntityFeature in melcloud
* Use EntityFeature in mystrom
* Use EntityFeature in mysensors
* Use EntityFeature in myq
* Use EntityFeature in mpd
* Use EntityFeature in monoprice
* Use EntityFeature in moehlenhoff_alpha2
* Use EntityFeature in modern_forms
* Use EntityFeature in modbus
* Use EntityFeature in melissa
* Use EntityFeature in mediaroom
* Use EntityFeature in maxcube
* Use EntityFeature in manual_mqtt
* Fix maxcube tests
* Revert "Use EntityFeature in modbus"
This reverts commit 56cf9d900d.
* Revert "Use EntityFeature in myq"
This reverts commit 44a31b1a03.
* Revert "Use EntityFeature in mystrom"
This reverts commit 7260ee0384.
* Revert "Revert "Use EntityFeature in modbus""
This reverts commit 916a612a60.
* Revert "Revert "Use EntityFeature in myq""
This reverts commit a6be42fa17.
* Add album art support in the mpd component
Uses `readpicture` to retrieve embedded artwork and `albumart` to
acquire cover art located in the media directory.
As the mpd component supports multiple different implementations (think
mopidy, PI MusicBox, etc.) we check for the availability of each command
before using them.
Tested against mpd 0.22.3, which includes support for both.
* fixup! Add album art support in the mpd component
* Automatically switch between resume and start playing
* Fix Black issue
Weirdly when i run it i had an error `1544 files left unchanged, 3313 files failed to reformat.`
I didn't watch the commit check output afterward.
* Pull track position from MPD status()
This allows the progress bar to work when using the media-control card in lovelace.
* Actually commit flake8 fix!
* Extra documentation.
Mainly to trigger CI rerun.
* Updated to use self._media_position
* Consolidate
* Fix tests
* Update imports
* Fix import
* Use importlib because integration and package share name
* Fix more tests
* Update .coveragerc and CODEOWNERS