#Toggle media player shuffle

1 messages · Page 1 of 1 (latest)

terse pecan
#

So I'm working on a script that takes a media_player as a field and than tries to toggle that players shuffle state. I came as far as having the input field, the target for the "set shuffle" and calling set shuffle with the current shuffle state, doing nothing. How would I invert the state_attr?

#

also I wanted to test and came across this where I can't actually select the media player in the ui

unborn pond
terse pecan
unborn pond
#

The attribute is a boolean right? Just use {{ not state_attr(media_player. entity_id, 'shuffle') }}

terse pecan
unborn pond
#

you'd need to edit in YAML

terse pecan
unborn pond
#

please post the full yaml and format it as code, this screenshot cuts parts off, and if I'd want to give suggestions I'd have to type it all over again

lean lindenBOT
#

To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.

terse pecan
#
action: media_player.repeat_set
metadata: {}
target:
  entity_id: "{{ media_player }}"
data:
  repeat: |
    {% if state_attr(media_player, \"repeat\") == 'all' %}
      one
    {% elif state_attr(media_player, \"repeat\") == 'one' %}
      off
    {% else %}
      all
    {% endif %}

unborn pond
#

Why are you escaping the quotes? There is no need for that.
Besides that I guess this should work.

#

I would also advise to stick to one type of quotes inside your template. You are now mixing single and double quotes (where you are escaping the double quotes)