Nastavení přepíání výstupů Libreelec z HA, pomocí skriptů a shell command příkazů.
Zjištění právě zvoleného výstupu spustit:
curl -v -H "Content-type: application/json" -d '{"jsonrpc":"2.0","id": 1, "method":"Settings.GetSettingValue", "params": {"setting": "audiooutput.audiodevice"} }' http://localhost:8080/jsonrpc -u user:password
Výstup:
* Trying 192.168.1.66:8080...
* Connected to 192.168.1.66 (192.168.1.66) port 8080 (#0)
* Server auth using Basic with user 'user'
> POST /jsonrpc HTTP/1.1
> Host: 192.168.1.66:8080
> Authorization: Basic cGV0cnAyYjpkdHBhMjAzMw==
> User-Agent: curl/7.85.0
> Accept: */*
> Content-type: application/json
> Content-Length: 113
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Connection: Keep-Alive
< Content-Length: 59
< Content-Type: application/json
< Cache-Control: private, max-age=0, no-cache
< Accept-Ranges: none
< Date: Wed, 08 Mar 2023 22:37:48 GMT
<
* Connection #0 to host 192.168.1.66 left intact
{"id":1,"jsonrpc":"2.0","result":{"value":"PULSE:Default"}}
* Connected to 192.168.1.66 (192.168.1.66) port 8080 (#0)
* Server auth using Basic with user 'user'
> POST /jsonrpc HTTP/1.1
> Host: 192.168.1.66:8080
> Authorization: Basic cGV0cnAyYjpkdHBhMjAzMw==
> User-Agent: curl/7.85.0
> Accept: */*
> Content-type: application/json
> Content-Length: 113
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Connection: Keep-Alive
< Content-Length: 59
< Content-Type: application/json
< Cache-Control: private, max-age=0, no-cache
< Accept-Ranges: none
< Date: Wed, 08 Mar 2023 22:37:48 GMT
<
* Connection #0 to host 192.168.1.66 left intact
{"id":1,"jsonrpc":"2.0","result":{"value":"PULSE:Default"}}
Přepnutí zvoleného výstupu z shellu:
curl -v -H "Content-type: application/json" -d '{"jsonrpc":"2.0","method":"Settings.SetSettingValue","params":{"setting":"audiooutput.audiodevice","value":"PULSE:Default"},"id":1}' http://localhost:8080/jsonrpc -u user:password
Následně v HA configuration.yaml nastavit (escapované uvozovky):
shell_command:
libreelec_audio_analog: 'curl -v -H "Content-type: application/json" -X POST -d "{\"jsonrpc\":\"2.0\",\"method\":\"Settings.SetSettingValue\", \"params\":{\"setting\":\"audiooutput.audiodevice\",\"value\":\"ALSA:sysdefault:CARD=Headphones\"},\"id\":1}" http://192.168.1.66:8080/jsonrpc -u user:password'
libreelec_audio_bluetooth: 'curl -v -H "Content-type: application/json" -X POST -d "{\"jsonrpc\":\"2.0\",\"method\":\"Settings.SetSettingValue\", \"params\":{\"setting\":\"audiooutput.audiodevice\",\"value\":\"PULSE:Default\"},\"id\":1}" http://192.168.1.66:8080/jsonrpc -u user:password'
libreelec_audio_bluetooth: 'curl -v -H "Content-type: application/json" -X POST -d "{\"jsonrpc\":\"2.0\",\"method\":\"Settings.SetSettingValue\", \"params\":{\"setting\":\"audiooutput.audiodevice\",\"value\":\"PULSE:Default\"},\"id\":1}" http://192.168.1.66:8080/jsonrpc -u user:password'