Help with Chromecast + Harmony Pro 2400 automation set up

I’m just getting started with Home Assistant and looking for some pointers. My setup:

  1. Chromecast devices that are connected to Sony Receivers for casting audio to various rooms in the house.
  2. Logitech Harmony Pro 2400 with IR blasters connected to each Sony Receiver.

I want to set up an automation that will power on a Sony Receiver when a Chromecast activity is started, and power off the receiver when the Chromecast activity stops. How do I go about setting that up? The Harmony Pro is able to control the Sony Receivers, powering them on/off etc.

1 Like

Basic outline:

  • Use a state trigger.
  • Use choose for the action.

Thanks @KTibow - could you please point me to some examples? I’m not sure how to get the right device IDs from the Harmony

  • Basically, go to the automations tab of config. Then create a new one.
  • For the trigger, change it to “State”. Select the chromecast media player. Then for the action, choose “Call service”. Save it.
  • Go to File Editor, and choose automations.yaml. Copy the automation, and paste it on the forum.
  • By the way, what is the entity ID of your Sony Reciever?

@KTIbow what state do I set the Chromecast to trigger on, is it playing?

Here is the automation, I had to pick a service to save it so I just picked harmony.sync

- id: '1596492625365'
  alias: Turn on Office Receiver when Casting to Office Speakers
  description: ''
  trigger:
  - entity_id: media_player.office_speakers
    platform: state
  condition: []
  action:
  - data: {}
    service: harmony.sync
  mode: single

In the config directory is a config generated by the Harmony Hub integration /config/harmony_16562131.conf and the receiver I’m targeting for this automation is Office Receiver (there are other receivers too but I’ve removed them to keep the post short):

{
    "Activities": {
        "-1": "PowerOff",
        "45303800": "Watch TV"
    },
    "Devices": {
        "Office Receiver": {
            "commands": [
                "PowerToggle",
                "Mute",
                "VolumeDown",
                "VolumeUp",
                "DirectionDown",
                "DirectionLeft",
                "DirectionRight",
                "DirectionUp",
                "Select",
                "Stop",
                "Play",
                "Rewind",
                "Pause",
                "FastForward",
                "SkipBack",
                "SkipForward",
                "Return",
                "Back",
                "PresetPrev",
                "TuneDown",
                "TuneUp",
                "PresetNext",
                "Sleep",
                "Display",
                "AmpMenu",
                "BassDown",
                "BassUp",
                "BTPairing",
                "Dimmer",
                "Input1",
                "Input2",
                "Input3",
                "Input4",
                "InputBluetooth",
                "InputFm",
                "InputPhono",
                "InputPortableIn",
                "Memory",
                "PureDirect",
                "SpeakersAB",
                "TrebleDown",
                "TrebleUp",
                "TunerPreset1",
                "TunerPreset2",
                "TunerPreset3"
            ],
            "id": "70709580"
        }
    }
}

This should work:
CHANGE THE REMOTE ENTITY ID

- id: turn_on_reciever
  alias: Turn on Office Receiver when Casting to Office Speakers
  description: ''
  trigger:
  - entity_id: media_player.office_speakers
    platform: state
  condition: []
  action:
  - data:
      entity_id: remote.ChAnGe_tHiS_PlEaSe
      device: 70709580
      command: PowerToggle
    service: remote.send_command
  mode: single
- id: turn_off_reciever
  alias: Turn off Office Receiver when Casting to Office Speakers
  description: ''
  trigger:
  - entity_id: media_player.office_speakers
    platform: state
  condition: []
  action:
  - data:
      entity_id: remote.ChAnGe_tHiS_PlEaSe
      device: 70709580
      command: PowerToggle
    service: remote.send_command
  mode: single
1 Like

@KTibow awesome got it working! Thanks so much for your help, here is the final config

- id: '1596492625365'
  alias: Turn on Office Receiver when start casting to Office Speakers
  description: ''
  trigger:
  - entity_id: media_player.office_speakers
    from: idle
    platform: state
    to: playing
  - entity_id: media_player.office_speakers
    from: 'off'
    platform: state
    to: playing
  condition: []
  action:
  - data:
      command: PowerToggle
      device: 70709580
    entity_id: remote.harmony_hub
    service: remote.send_command
  mode: single
- id: '1596493779241'
  alias: Turn off Office Receiver when stop casting to Office Speakers
  description: ''
  trigger:
  - entity_id: media_player.office_speakers
    from: playing
    platform: state
    to: idle
  - entity_id: media_player.office_speakers
    from: playing
    platform: state
    to: 'off'
  condition: []
  action:
  - data:
      command: PowerToggle
      device: 70709580
    entity_id: remote.harmony_hub
    service: remote.send_command
  mode: single

This would be even better:

- id: handle_reciever_power
  alias: Turn on and off Office Receiver when Office Speakers state changes
  description: ''
  trigger:
  - entity_id: media_player.office_speakers
    platform: state
  condition:
    - condition: template
      value_template: '{{states(''media_player.office_speakers'')}} in [''idle'', ''off'', ''playing'']}}'
  action:
    - data:
        command: PowerToggle
        device: 70709580
      entity_id: remote.harmony_hub
      service: remote.send_command
  mode: single

@KTibow thanks, I tried the script but I was running into issues where it would trigger on/off when switching between songs. I found this set up to work the best, detecting when the Chromecast goes from off->idle to turn on receiver, and from playing->off to turn off receiver. I also added a TTS action to announce what is happening on the Google Home:

- id: turn_on_office_receiver
  alias: Turn on Office Receiver when Office Speakers Playing
  description: ''
  trigger:
  - entity_id: media_player.office_speakers
    from: 'off'
    platform: state
    to: idle
  condition: []
  action:
  - data:
      command: PowerToggle
      device: 70709580
    entity_id: remote.harmony_hub
    service: remote.send_command
  - data:
      message: Turning on Office Speakers
    entity_id: media_player.office_home
    service: tts.google_translate_say
  mode: single
- id:  turn_off_office_receiver
  alias: Turn off Office Receiver when Office Speakers idle
  description: ''
  trigger:
  - entity_id: media_player.office_speakers
    from: playing
    platform: state
    to: 'off'
  condition: []
  action:
  - data:
      command: PowerToggle
      device: 70709580
    entity_id: remote.harmony_hub
    service: remote.send_command
  - data:
      message: Turning off Office Speakers
    entity_id: media_player.office_home
    service: tts.google_translate_say
  mode: single