Hello all,
I was shown this wonderful project from Hoveeman (https://github.com/hoveeman/music-cards) where he has RFID cards as his Albums and uses Google Music to play around his home.
I don’t have Google devices, but do have Spotify and SONOS so thought I’d have a go at converting it to my devices then share back to the community.
I’ve only just started playing with all this sort of technology and codeing and found some of it confusing. I’m suree the documentation is good, but for a complete beginner is difficult to understand/follow. Is there a more English version anywhere?
I’ve managed to get it to do most of the functions I require but still some leg work required (and help on this would be wonderful)
The areas I have changed so far are:
-
I could not get my SONOS to play a Spotify playlist/ablum unless it is a SONOS favorite which shows up as an “input” for SONOS. Trouble with this method is that HA does not seem to pick up the new SONOS favorites unless it is restarted - not that big of a deal because when I add a new card to the system, I can just restart HA. I won’t be adding lots of albums all the time I suppose.
-
The card reading client does not like spaces in a playlist or album name so I have changed two bits here. The first by the card reading program to pass the card number, not the playlist and the script that calls HA now finds the playlist.
-
I have a card that “switches on or off” the SONOS. This required a change to the HA calling script to stop the media players in HA.What I would like to do is to make the “Off” card act as a toggle. From a default state of “Off” it would group the SONOS devices and set a global volume. I have an HA script that does this already. I also have an HA script that will ungroup the devices and stop the music. I can’t fathom out how to flip flop between these two states yet. I could do it on the card reader server but there must be a HA way of doing this.
What I had hoped for here is to have an HA script I can execute via the RESTapi which will examine a variable, perfrom one of my two existing scripts then set a vaiable that I can test the next time I use the On/Off card to know what to do. I expect it will be so simple when I see what to do - just can;t get there at the moment.
What I have so far is this:
music_on:
alias: "Group SONOS for playback, set volume to 30%"
sequence:
#
- service: homeassistant.turn_off
entity_id: script.music_on
#
- service: media_player.sonos_unjoin
entity_id:
- media_player.sitting_room
- media_player.dining_room
- media_player.hallway
#
- service: media_player.sonos_join
data:
master: media_player.hallway
entity_id:
- media_player.sitting_room
- media_player.dining_room
#
- service: media_player.volume_set
entity_id:
- media_player.sitting_room
- media_player.dining_room
- media_player.hallway
data:
volume_level: 0.3
#
musicoff:
alias: Turn off the Music
sequence:
- service: media_player.turn_off
entity_id: media_player.hallway
and to switch off the music, I do this from my card reader script:
curl -X POST -H "x-ha-access: <PASSWORD HERE>" -H "Content-Type: application/json" http://1.0.0.2:8123/api/services/script/musicoff
and that will switch off the music.