I’m a newbie with Home Assistant. I’m running Home Assistant with Sonos devices, and I’d like to send a POST command using the RESTful API to have one of the Sonos devices say something. This works fine from the Home Assistant home page, where my Sonos devices are listed.
I’m sending the POST in the following format, and I get a message back saying “Method not allowed”. I’m not that familiar with JSON formatting, and I’m also not sure I have the url right. Can someone correct the following:
URL: http://192.168.86.200:8123/api/services
Headers: Content-Type: application/json
Data: { "service": "google_say", "entity_id": "media_player.upstairs_study", "data":{"message": "May the Force be with you." }}
The response I get is ‘The remote server returned an error: (405) Method Not Allowed.’
Important: forgot to mention that I am coding this in VBA on another home automation platform (Homeseer), so the strings above are being sent using the POST command (called ‘urlAction’) in VBA. I’m not sure if I am translating the Python examples in the documentation properly into the three strings above.
To update further, here’s the POST I’m trying now:
url = "http://192.168.86.200:8123/api/services/tts/google_say?api_password=xxxxxx"
headers="Content-Type: application/json"
data = "{entity_id: 'media_player.upstairs_study', data:{message: 'May the Force be with you.' }}"