Hi all, if anyone is interested, I have made some little buttons in lovelace using the custom button card that change the playlist to the one listed on the button. Maybe it will save some of you some time to do the same. There’s probably a cleaner way to do this with the rest_command, but this worked.
So first I defined the switches in my configuration.yaml pretty much as described above, except I made both toggle on and toggle off assigned to turn the playlist on. If I want a different playlist, I will just click that button, so the playlist button should always assign the chosen playlist regardless of state.
switch:
- platform: command_line
switches:
mix:
friendly_name: Mix
command_on: "curl -X PUT http://x.x.x.x:8181/playlists/a-45-star/play"
command_off: "curl -X PUT http://x.x.x.x:8181/playlists/a-45-star/play"
- platform: command_line
switches:
jazz:
friendly_name: Jazz
command_on: "curl -X PUT http://x.x.x.x:8181/playlists/best-jazz/play"
command_off: "curl -X PUT http://x.x.x.x:8181/playlists/best-jazz/play"
- platform: command_line
switches:
rock:
friendly_name: Rock
command_on: "curl -X PUT http://x.x.x.x:8181/playlists/best-rock/play"
command_off: "curl -X PUT http://x.x.x.x:8181/playlists/best-rock/play"
- platform: command_line
switches:
pop:
friendly_name: Pop
command_on: "curl -X PUT http://x.x.x.x:8181/playlists/best-pop/play"
command_off: "curl -X PUT http://x.x.x.x:8181/playlists/best-pop/play"
Then in ui-lovelace.yaml I defined the buttons as below (4 simple small text buttons in a row, but much more fancy ones are possible. I will probably make mine nicer someday)
- type: horizontal-stack
cards:
- type: "custom:button-card"
name: Mix
action: service
service:
domain: switch
action: toggle
data:
entity_id: switch.mix
- type: "custom:button-card"
name: Jazz
action: service
service:
domain: switch
action: toggle
data:
entity_id: switch.jazz
- type: "custom:button-card"
name: Rock
action: service
service:
domain: switch
action: toggle
data:
entity_id: switch.rock
- type: "custom:button-card"
name: Pop
action: service
service:
domain: switch
action: toggle
data:
entity_id: switch.pop