From 353817337edc9329f6b127dd82ae4d3cd42d455d Mon Sep 17 00:00:00 2001 From: Vaarlion <59558433+Vaarlion@users.noreply.github.com> Date: Fri, 7 Aug 2020 22:28:49 +0200 Subject: [PATCH] Automatically switch mpd between resume and start playing on media_play (#37854) * 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. --- homeassistant/components/mpd/media_player.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/mpd/media_player.py b/homeassistant/components/mpd/media_player.py index ba9b2f73d3c..201e8ed64e1 100644 --- a/homeassistant/components/mpd/media_player.py +++ b/homeassistant/components/mpd/media_player.py @@ -307,7 +307,10 @@ class MpdDevice(MediaPlayerEntity): def media_play(self): """Service to send the MPD the command for play/pause.""" - self._client.pause(0) + if self._status["state"] == "pause": + self._client.pause(0) + else: + self._client.play() def media_pause(self): """Service to send the MPD the command for play/pause."""