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 mpd shuffle/random status #19308

Merged
merged 3 commits into from Dec 27, 2018

Conversation

Projects
None yet
4 participants
@apetrycki
Copy link
Contributor

apetrycki commented Dec 14, 2018

MPD always shows true for shuffle. For some reason casting the 0 or 1 as a boolean does not work. Now returns 'true' or 'false' based on the value of 'random'.

Not sure if there's a better way to do this, but it works.

Fix shuffle/random status
MPD always shows true for shuffle.  For some reason casting the 0 or 1 as a boolean does not work.  Now returns 'true' or 'false' based on the value of 'random'.

@apetrycki apetrycki requested a review from fabaff as a code owner Dec 14, 2018

@homeassistant

This comment has been minimized.

Copy link

homeassistant commented Dec 14, 2018

Hi @apetrycki,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@MartinHjelmare
Copy link
Member

MartinHjelmare left a comment

Converting to int first before bool should do the trick.

Show resolved Hide resolved homeassistant/components/media_player/mpd.py Outdated
Show resolved Hide resolved homeassistant/components/media_player/mpd.py Outdated

@MartinHjelmare MartinHjelmare changed the title Fix shuffle/random status Fix mpd shuffle/random status Dec 20, 2018

Update homeassistant/components/media_player/mpd.py
Change to correct way of returning shuffle boolean. 'random' needs to be cast as an integer before being cast as a boolean.

Co-Authored-By: apetrycki <34962392+apetrycki@users.noreply.github.com>
@@ -319,7 +319,10 @@ def play_media(self, media_type, media_id, **kwargs):
@property
def shuffle(self):
"""Boolean if shuffle is enabled."""
return bool(self._status['random'])
return bool(int(self._status['random']))
return 'true'

This comment has been minimized.

@houndci-bot

houndci-bot Dec 26, 2018

IndentationError: unexpected indent
unexpected indentation

Remove incorrect string code
Original fix method returns a string instead of a boolean.  Removed in favor of MartinHjelmare's method.

@MartinHjelmare MartinHjelmare merged commit cd0da4e into home-assistant:dev Dec 27, 2018

5 checks passed

Hound No violations found. Woof!
WIP ready for review
Details
cla-bot Everyone involved has signed the CLA
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.2%) to 93.056%
Details

@wafflebot wafflebot bot removed the in progress label Dec 27, 2018

@balloob balloob referenced this pull request Jan 10, 2019

Merged

0.85.0 #19897

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment