danimtb / dasshio

Hass.io add-on to easily use Amazon Dash Buttons with Home Assistant
Apache License 2.0
192 stars 63 forks source link

Trying to pause Sonos, domain error? #90

Closed dopemanfunk closed 4 years ago

dopemanfunk commented 5 years ago

Been searching for a bit, but can't find anything related to my problem. Sorry if it's glaringly obvious, new to this.

While working from home I listen to music on my Sonos speakers. If I get a call, I can't pause my music through my phone and have to physically get up or run over to my speakers and hit the pause button on there. I'm trying to setup an Amazon Dash button so that it toggles pause/play (mainly just pause, since after the phone call I can use the app to start it again) but keep running into errors. I'm using Hass.io v 0.94.4 on a RPi 3 hardwired into my router (tried wireless too). I can setup Hass.io just fine, and I use the Dasshio add-on to trigger the dash button.

My code for dasshio is:

{
  "timeout": 20,
  "buttons": [
    {
      "name": "Angelsoft",
      "address": "00:FC:8B:04:EC:92",
      "domain": "sonos",
      "service": "media_player.media__play_pause",
      "service_data": "{\"entity_id\": \"media_player.living_room\"}"
    }
  ]
}

And the errors I'm getting are:

2019-06-22 11:40:16,322 | INFO | Reading config file: /data/options.json 2019-06-22 11:40:16,326 | INFO | Starting... 2019-06-22 11:40:16,326 | INFO | Starting sniffing... 2019-06-22 11:40:20,360 | INFO | Angelsoft button pressed! 2019-06-22 11:40:20,411 | INFO | Request: http://hassio/homeassistant/api/services/homeassistant/media_player.media__play_pause - body: {"entity_id": "media_player.living_room"} 2019-06-22 11:40:20,412 | INFO | Status Code: 400 2019-06-22 11:40:20,412 | ERROR | Bad request 2019-06-22 11:40:20,446 | INFO | Finishing sniffing 2019-06-22 11:40:20,447 | INFO | Starting sniffing...

So it can see the button is being pushed, it just can't find that service I guess. I believe my error is in the domain, but I can't seem to figure out which domain I should use.

I also can't seem to find info on a status code 400 for a bad request. I can use the developer services tool on the bottom left of the hass.io screen to trigger the sonos. This is how I got the service/entity id.

Any help is very much appreciated, this seems overly complicated for a simple button to pause music, but I am learning a lot.

neilma1 commented 5 years ago

Have you tried creating a script for this and then calling the script in the Dashio add on? So it looks roughly like this....

{ "timeout": 20, "buttons": [ { "name": "Angelsoft", "address": "00:FC:8B:04:EC:92", "domain": "script", "service": "whateveryoucallthescript", "service_data": "{}" } ] }

Then create a scripts.yaml file if you havent already got one. Then in there create what you want like this....

whateveryoucallthescript: alias: giveitanicename sequence:

I think that should work - There is probably a way of doing it with the media player pause that you have above too - I was just copying an example that I had.

Hope that helps?

Neil

murmelbahn commented 5 years ago

I have the same problem as @dopemanfunk but as @neilma1 suggested, it works if you use a script for a mediaplayer action for sonos.

dopemanfunk commented 5 years ago

@neilma1 that worked! Thank you so much!