I’m trying to implement an automation with a series of RESTful Commands executed on my Yamaha Music Cast system (way beyond the available services in the standard integration). The challenge I’m facing is that when I call those commands I get a Client error
error. Those commands are for sure correct, I can run them in the same sequence from web browser and they work ok. I can also run them in a shell script (as curl) and it also works OK. But not when I run that from a HA script. Example configuration below:
Restfull Command:
rest_command:
musiccast_setlist:
url: >
{% if type=='select' or type=='play' %}
'http://{{ip_address}}/YamahaExtendedControl/v1/netusb/setListControl?list_id=main&type={{type}}&index={{index}}&zone=main'
{% else %}
'http://{{ip_address}}/YamahaExtendedControl/v1/netusb/setListControl?list_id=main&type={{type}}&zone=main'
{% endif %}
musiccast_getlistinfotidal:
url: 'http://{{ip_address}}/YamahaExtendedControl/v1/netusb/getListInfo?input=tidal&size=8&lang=en'
Script that is calling the sequence of those Rest commands:
media_play_tidal_last_added_album:
alias: Media - Play Tidal last added album Szary
sequence:
- choose:
- conditions:
- condition: not
conditions:
- condition: state
entity_id: media_player.szary_main
state: 'off'
sequence:
- service: rest_command.musiccast_getlistinfotidal
data:
ip_address: 10.144.1.158
- delay: 00:00:04
- service: rest_command.musiccast_setlist
data:
type: return
ip_address: 10.144.1.158
index: '1'
- delay: 00:00:02
- service: rest_command.musiccast_setlist
data:
type: return
ip_address: 10.144.1.158
index: '1'
- delay: 00:00:02
- service: rest_command.musiccast_setlist
data:
type: return
ip_address: 10.144.1.158
index: '1'
- delay: 00:00:02
- service: rest_command.musiccast_setlist
data:
type: select
ip_address: 10.144.1.158
index: '5'
- delay: 00:00:02
- service: rest_command.musiccast_setlist
data:
type: select
ip_address: 10.144.1.158
index: '2'
- delay: 00:00:02
- service: rest_command.musiccast_setlist
data:
type: select
ip_address: 10.144.1.158
index: '1'
- delay: 00:00:02
- service: rest_command.musiccast_setlist
data:
type: play
ip_address: 10.144.1.158
index: '4'
default: []
Errors I’m receiving in the log:
2021-04-20 16:37:40 ERROR (MainThread) [homeassistant.components.rest_command] Client error 'http://10.144.1.158/YamahaExtendedControl/v1/netusb/setListControl?list_id=main&type=return&zone=main'
2021-04-20 16:37:42 ERROR (MainThread) [homeassistant.components.rest_command] Client error 'http://10.144.1.158/YamahaExtendedControl/v1/netusb/setListControl?list_id=main&type=return&zone=main'
2021-04-20 16:37:44 ERROR (MainThread) [homeassistant.components.rest_command] Client error 'http://10.144.1.158/YamahaExtendedControl/v1/netusb/setListControl?list_id=main&type=return&zone=main'
2021-04-20 16:37:46 ERROR (MainThread) [homeassistant.components.rest_command] Client error 'http://10.144.1.158/YamahaExtendedControl/v1/netusb/setListControl?list_id=main&type=select&index=5&zone=main'
2021-04-20 16:37:48 ERROR (MainThread) [homeassistant.components.rest_command] Client error 'http://10.144.1.158/YamahaExtendedControl/v1/netusb/setListControl?list_id=main&type=select&index=2&zone=main'
2021-04-20 16:37:50 ERROR (MainThread) [homeassistant.components.rest_command] Client error 'http://10.144.1.158/YamahaExtendedControl/v1/netusb/setListControl?list_id=main&type=select&index=1&zone=main'
2021-04-20 16:37:52 ERROR (MainThread) [homeassistant.components.rest_command] Client error 'http://10.144.1.158/YamahaExtendedControl/v1/netusb/setListControl?list_id=main&type=play&index=4&zone=main'
My feeling is that somehow when calling it from browser or curl the client is establishing a session and remembers the context. It is needed as in the first command a source is selected (tidal in my case - that command executes successfully - no error in the log) and the following commands are browsing through the list of content on that source. But when calling it from HA the context is not retained.