I am trying to assure a Sony Bravia TV is using its speakers rather than audio system prior to starting an automation action. The REST example came from: https://github.com/home-assistant/core/issues/88532 which was used to create a shell command that was added to configuration.yaml as:
#Exposes shell_command,sonytv_speakers shell_command: sonytv_speakers: curl -X POST \ http://xxx.xx.xx.xxx/sony/audio \ -H 'cache-control:no-cache' \ -H 'x-auth-psk:xxxx' \ -d '{"method":"setSoundSettings", "id":5, "params":[{"settings":[{"value":"speaker", "target":"outputTerminal"}]}], "version":"1.1"}'
The command works when entered directly in the terminal and there are no errors in the configuration.yaml file. (“xxxxxxxx” used in lieu of actual IP and PSK.)
However when envoked as a service call in an automation, for example:
action: shell_command.sonytv_speakers data: {}
nothing happens and the log error is:
``Logger: homeassistant.components.shell_command
Source: /usr/src/homeassistant/homeassistant/components/shell_command/init.py:129
integration: Shell Command (documentation, issues)
First occurred: 5:30:04 PM (1 occurrences)
Last logged: 5:30:04 PM
Error running command: curl -X POST \ http://xxx.xx.xx.xxx/sony/audio \ -H 'cache-control:no-cache' \ -H 'x-auth-psk:xxxx' \ -d '{"method":"setSoundSettings", "id":5, "params":[{"settings":[{"value":"speaker", "target":"outputTerminal"}]}], "version":"1.1"}'
, return code: 3
NoneType: None``
I would appreciate suggestions to make the automation work as planned.