Hi all.
I’m working on updating the soundtouch component to support input selection. I’ve successfully created a custom component based on the original soundtouch code which uses the later version of libsoundtouch (0.8.0) which provides input selection support.
I’ve added a support for SELECT_SOURCE and added a very simple function to switch to aux no matter which source you ask to switch to (just to simplify the debugging). It seems to be working properly, and if calling the select_source service on my soundtouch entity, all goes as planned.
I’ve then added media_players to my google assistant integration scope, and can successfully turn on and off the device or change volume level using assistant. However, switching inputs does not work and google assistant keep showing search results. I do understand support is limited and done through the Modes traits, but understood select_source should be supported.
Any idea would be appreciated.
Yaron
Just adding the code changes:
the manifest was changed to require the latest library version
{
"domain": "soundtouch",
"name": "Soundtouch",
"documentation": "https://www.home-assistant.io/integrations/soundtouch",
"requirements": [
"libsoundtouch==0.8.0"
],
"dependencies": [],
"codeowners": []
}
and the media_player.py changed to support SELECT_SOURCE:
from homeassistant.components.media_player.const import (
DOMAIN,
SUPPORT_NEXT_TRACK,
SUPPORT_PAUSE,
SUPPORT_PLAY,
SUPPORT_PLAY_MEDIA,
SUPPORT_PREVIOUS_TRACK,
SUPPORT_SELECT_SOURCE,
SUPPORT_TURN_OFF,
SUPPORT_TURN_ON,
SUPPORT_VOLUME_MUTE,
SUPPORT_VOLUME_SET,
SUPPORT_VOLUME_STEP,
)
from homeassistant.const import (
CONF_HOST,
CONF_NAME,
CONF_PORT,
STATE_OFF,
STATE_PAUSED,
STATE_PLAYING,
STATE_UNAVAILABLE,
)
SUPPORT_SOUNDTOUCH = (
SUPPORT_PAUSE
| SUPPORT_VOLUME_STEP
| SUPPORT_VOLUME_MUTE
| SUPPORT_PREVIOUS_TRACK
| SUPPORT_NEXT_TRACK
| SUPPORT_TURN_OFF
| SUPPORT_VOLUME_SET
| SUPPORT_TURN_ON
| SUPPORT_SELECT_SOURCE
| SUPPORT_PLAY
| SUPPORT_PLAY_MEDIA
)
and the function:
def select_source(self, source):
"""Select input source."""
self._device.select_source_aux()