Hey, I am building a multi-room audio system controlled by Home Assistant.
As a part of this I need to control Kodi audio output and have experimented with scripts using the player.kodi_call_method:
script:
audio_tv:
sequence:
- service: media_player.kodi_call_method
data:
entity_id: media_player.kodi_stue
method: Settings.SetSettingValue
setting: "audiooutput.audiodevice"
value: "PI:HDMI"
But, it’s all hardcoded and no state feedback.
The Settings.GetSettingValue Kodi api can read out the audiooutput.audiodevice, but how to get it to display to the user?
For simular integration with Snapcast using switches to control a zone input stream I get the state like:
script:
stream_spotify:
sequence:
- service: media_player.select_source
data:
entity_id: media_player.snapcast_group_b66dd6c63c3b8de95237d287b1b8adaa
source: "Spotify"
binary_sensor:
- platform: template
sensors:
stream_spotify_on:
friendly_name: "Stream Spotify"
entity_id: media_player.snapcast_group_b66dd6c63c3b8de95237d287b1b8adaa
value_template: >
{{ is_state_attr('media_player.snapcast_group_b66dd6c63c3b8de95237d287b1b8adaa', 'source', 'Spotify') }}
switch:
- platform: template
switches:
switch_stream_spotify:
friendly_name: "Stream Spotify"
entity_id: binary_sensor.stream_spotify_on
value_template: >
{{ states('binary_sensor.stream_spotify_on') }}
turn_on:
service: script.stream_spotify
turn_off:
This works nicely with multiple switches, each press turns off the others due to the binary_sensor feedback.
But, how to get state for Kodi? My initial thought was to make a kodi_audio_status script and call from the value_template of binary_sensor but ehh…can’t figure out if a script actually can return a result and how to get it from the template… I really suspect I’m barking up the wrong tree.
So, any1 input on how to get some kind of selection of the configured Kodi audio output including status feedback?