Select default audio device

Sorry to bump this, but this thread shows up as the first result when I google for this problem and I have something to add:

The problem:

Sometimes, your device will show up, but it won’t have the correct profile selected:

[core-ssh ~]$ ha audio info
audio:
  application: []
  card:
  - driver: module-alsa-card.c
    index: 0
    name: alsa_card.usb-0d8c_USB_Sound_Device-00
    profiles:
    - active: false
      description: Analog Stereo Input
      name: input:analog-stereo
    - active: false
      description: Digital Stereo (IEC958) Input
      name: input:iec958-stereo
    - active: false
      description: Analog Stereo Output
      name: output:analog-stereo
    - active: false
      description: Analog Stereo Duplex
      name: output:analog-stereo+input:analog-stereo
    - active: true <------------------------------------------- !! THIS IS THE WRONG PROFILE !!
      description: Analog Stereo Output + Digital Stereo (IEC958) Input
      name: output:analog-stereo+input:iec958-stereo
    - active: false
      description: Analog Surround 2.1 Output
      name: output:analog-surround-21
    - active: false
      description: Analog Surround 2.1 Output + Analog Stereo Input
      name: output:analog-surround-21+input:analog-stereo
    - active: false
      description: Analog Surround 2.1 Output + Digital Stereo (IEC958) Input
      name: output:analog-surround-21+input:iec958-stereo
    - active: false
      description: Analog Surround 4.0 Output
      name: output:analog-surround-40
    - active: false
      description: Analog Surround 4.0 Output + Analog Stereo Input
      name: output:analog-surround-40+input:analog-stereo
    - active: false
      description: Analog Surround 4.0 Output + Digital Stereo (IEC958) Input
      name: output:analog-surround-40+input:iec958-stereo
    - active: false
      description: Analog Surround 4.1 Output
      name: output:analog-surround-41
    - active: false
      description: Analog Surround 4.1 Output + Analog Stereo Input
      name: output:analog-surround-41+input:analog-stereo
    - active: false
      description: Analog Surround 4.1 Output + Digital Stereo (IEC958) Input
      name: output:analog-surround-41+input:iec958-stereo
    - active: false
      description: Analog Surround 5.0 Output
      name: output:analog-surround-50
    - active: false
      description: Analog Surround 5.0 Output + Analog Stereo Input
      name: output:analog-surround-50+input:analog-stereo
    - active: false
      description: Analog Surround 5.0 Output + Digital Stereo (IEC958) Input
      name: output:analog-surround-50+input:iec958-stereo
    - active: false
      description: Analog Surround 5.1 Output
      name: output:analog-surround-51
    - active: false
      description: Analog Surround 5.1 Output + Analog Stereo Input
      name: output:analog-surround-51+input:analog-stereo
    - active: false
      description: Analog Surround 5.1 Output + Digital Stereo (IEC958) Input
      name: output:analog-surround-51+input:iec958-stereo
    - active: false
      description: Analog Surround 7.1 Output
      name: output:analog-surround-71
    - active: false
      description: Analog Surround 7.1 Output + Analog Stereo Input
      name: output:analog-surround-71+input:analog-stereo
    - active: false
      description: Analog Surround 7.1 Output + Digital Stereo (IEC958) Input
      name: output:analog-surround-71+input:iec958-stereo
    - active: false
      description: Digital Stereo (IEC958) Output
      name: output:iec958-stereo
    - active: false
      description: Digital Stereo (IEC958) Output + Analog Stereo Input
      name: output:iec958-stereo+input:analog-stereo
    - active: true
      description: Digital Stereo Duplex (IEC958)
      name: output:iec958-stereo+input:iec958-stereo
    - active: false <------------------------------------------- !! I WANT THAT ONE !!
      description: "Off"
      name: "off"
  - driver: module-alsa-card.c
    index: 1
    name: alsa_card.platform-bcm2835_audio
    profiles:
    - active: true
      description: Stereo Output
      name: output:stereo-fallback
    - active: false
      description: Mono Output
      name: output:mono-fallback
    - active: false
      description: Multichannel Output
      name: output:multichannel-output
    - active: false
      description: "Off"
      name: "off"
  input:
  - applications: []
    card: 0
    default: true
    description: USB Sound Device         Digital Stereo (IEC958)
    index: 1
    mute: false
    name: alsa_input.usb-0d8c_USB_Sound_Device-00.iec958-stereo
    volume: 1
  output:
  - applications: []
    card: 0
    default: false
    description: USB Sound Device         Digital Stereo (IEC958)
    index: 0
    mute: false
    name: alsa_output.usb-0d8c_USB_Sound_Device-00.iec958-stereo
    volume: 1
  - applications: []
    card: 1
    default: true
    description: Built-in Audio Stereo
    index: 1
    mute: false
    name: alsa_output.platform-bcm2835_audio.stereo-fallback
    volume: 0.857696533203125
host: 172.30.32.4
update_available: false
version: 2022.07.0
version_latest: 2022.07.0

One would assume that

ha audio default output -- DEVICE_NAME.CORRECT_PROFILE
ha audio default input -- DEVICE_NAME.CORRECT_PROFILE

would fix this, but this will only give you an error saying that the device path was not found (or something), since we can only select a device path with an enabled profile.

Specific example for my case: I bought a USB sound card (based on a Cmedia CM6206-LX chip if anyone’s wondering) with optical in- and outputs which I want to use. HA automatically selects the analog duplex profile, though (due to a quirk of the card, any analog output still gets routed through the optical output as well, so I only had to set the input, but that’s beside the point).

How to change the profile of a sound device

Thanks to this page from the Arch wiki, I was able to change the profile using pactl. The syntax is as follows:
pactl set-card-profile <symbolic-name> <profilename>

In my case, I had to use this command:
pactl set-card-profile alsa_card.usb-0d8c_USB_Sound_Device-00 output:iec958-stereo+input:iec958-stereo

After that, you need to run ha audio reload for the changes to apply.
Checking with ha audio info again yields the following:

audio:
  application: []
  card:
  - driver: module-alsa-card.c
    index: 0
    name: alsa_card.usb-0d8c_USB_Sound_Device-00
    profiles:
    - active: false
      description: Analog Stereo Input
      name: input:analog-stereo
    - active: false
      description: Digital Stereo (IEC958) Input
      name: input:iec958-stereo
    - active: false
      description: Analog Stereo Output
      name: output:analog-stereo
    - active: false
      description: Analog Stereo Duplex
      name: output:analog-stereo+input:analog-stereo
    - active: false <------------------------------------------- !! THIS IS NOW SET TO FALSE !!
      description: Analog Stereo Output + Digital Stereo (IEC958) Input
      name: output:analog-stereo+input:iec958-stereo
    - active: false
      description: Analog Surround 2.1 Output
      name: output:analog-surround-21
    - active: false
      description: Analog Surround 2.1 Output + Analog Stereo Input
      name: output:analog-surround-21+input:analog-stereo
    - active: false
      description: Analog Surround 2.1 Output + Digital Stereo (IEC958) Input
      name: output:analog-surround-21+input:iec958-stereo
    - active: false
      description: Analog Surround 4.0 Output
      name: output:analog-surround-40
    - active: false
      description: Analog Surround 4.0 Output + Analog Stereo Input
      name: output:analog-surround-40+input:analog-stereo
    - active: false
      description: Analog Surround 4.0 Output + Digital Stereo (IEC958) Input
      name: output:analog-surround-40+input:iec958-stereo
    - active: false
      description: Analog Surround 4.1 Output
      name: output:analog-surround-41
    - active: false
      description: Analog Surround 4.1 Output + Analog Stereo Input
      name: output:analog-surround-41+input:analog-stereo
    - active: false
      description: Analog Surround 4.1 Output + Digital Stereo (IEC958) Input
      name: output:analog-surround-41+input:iec958-stereo
    - active: false
      description: Analog Surround 5.0 Output
      name: output:analog-surround-50
    - active: false
      description: Analog Surround 5.0 Output + Analog Stereo Input
      name: output:analog-surround-50+input:analog-stereo
    - active: false
      description: Analog Surround 5.0 Output + Digital Stereo (IEC958) Input
      name: output:analog-surround-50+input:iec958-stereo
    - active: false
      description: Analog Surround 5.1 Output
      name: output:analog-surround-51
    - active: false
      description: Analog Surround 5.1 Output + Analog Stereo Input
      name: output:analog-surround-51+input:analog-stereo
    - active: false
      description: Analog Surround 5.1 Output + Digital Stereo (IEC958) Input
      name: output:analog-surround-51+input:iec958-stereo
    - active: false
      description: Analog Surround 7.1 Output
      name: output:analog-surround-71
    - active: false
      description: Analog Surround 7.1 Output + Analog Stereo Input
      name: output:analog-surround-71+input:analog-stereo
    - active: false
      description: Analog Surround 7.1 Output + Digital Stereo (IEC958) Input
      name: output:analog-surround-71+input:iec958-stereo
    - active: false
      description: Digital Stereo (IEC958) Output
      name: output:iec958-stereo
    - active: false
      description: Digital Stereo (IEC958) Output + Analog Stereo Input
      name: output:iec958-stereo+input:analog-stereo
    - active: true <------------------------------------------- !! THIS IS NOW SET TO TRUE !!
      description: Digital Stereo Duplex (IEC958)
      name: output:iec958-stereo+input:iec958-stereo
    - active: false
      description: "Off"
      name: "off"
  - driver: module-alsa-card.c
    index: 1
    name: alsa_card.platform-bcm2835_audio
    profiles:
    - active: true
      description: Stereo Output
      name: output:stereo-fallback
    - active: false
      description: Mono Output
      name: output:mono-fallback
    - active: false
      description: Multichannel Output
      name: output:multichannel-output
    - active: false
      description: "Off"
      name: "off"
  input:
  - applications: []
    card: 0
    default: true
    description: USB Sound Device         Digital Stereo (IEC958)
    index: 1
    mute: false
    name: alsa_input.usb-0d8c_USB_Sound_Device-00.iec958-stereo
    volume: 1
  output:
  - applications: []
    card: 0
    default: false
    description: USB Sound Device         Digital Stereo (IEC958)
    index: 0
    mute: false
    name: alsa_output.usb-0d8c_USB_Sound_Device-00.iec958-stereo
    volume: 1
  - applications: []
    card: 1
    default: true
    description: Built-in Audio Stereo
    index: 1
    mute: false
    name: alsa_output.platform-bcm2835_audio.stereo-fallback
    volume: 0.857696533203125
host: 172.30.32.4
update_available: false
version: 2022.07.0
version_latest: 2022.07.0

An option to do this in the GUI would be greatly appreciated; a new user might find this a bit tricky.

6 Likes