Hello, trying to set up a simple automation and I’m getting errors… Can you gurus please find the mistake? Tearing my hair out. It basically should turn on Sonos Kitchen speakers and set them to “Audio Component: Family Room” source once a specific activity happens with the Harmony remote.
alias: Turn on Kitchen Speakers
trigger:
platform: state
entity_id: remote.family_room_harmony
activity: ‘Family Room TV with Kitchen’
action:
service: media_player.select_source
data:
entity_id: media_player.kitchen
source: “Audio Component: Family Room”
The state trigger does not have an activity parameter. I would assume for this it should be to. Is that what the state of remote.family_room_harmony is? I don’t use the remote component. Maybe you should be using an event trigger instead???
According to the documentation, the entity’s activity is reported in an attribute called current_activity. Therefore the automation’s trigger should monitor that attribute and not the entity’s state. We can use a Template Trigger for this:
- alias: Turn on Kitchen Speakers
trigger:
platform: template
value_template: "{{ is_state_attr('remote.family_room_harmony', 'current_activity', 'Family Room TV with Kitchen') }}"
action:
- service: media_player.select_source
data:
entity_id: media_player.kitchen
source: "Audio Component: Family Room"
Thank you. So that made the trigger work perfectly, but now the issue is the action doesn’t really change the Sonos source. Leaving the way it is in the example, it does nothing. Changing it to Line-in changes to Kitchen line in, which I don’t want. I want the Kitchen Sonos to be set to Family Room Line-in. The Sonos app supports this. I also made the Family Room Line-in as the only Favorite Line-in source.
According to the the documentation for Media Player, the select_source service is platform dependent. I’ve searched the forum for ‘sonos select_source’ and found several examples (confirming you can use select_source with Sonos). Therefore all I can offer is that you ensure the value you’ve supplied for source is correct.
If I’ve understood this post correctly, your media_player.kitchen entity should have an attribute named source_list. Use the values in this attribute for setting source.
Sonos recently changed alot of the services and they are placed under ‘sonos.xxxx’. Check the services tab and see if select source was moved to that platform for sonos media players. I doubt it was, but it’s possible.