Context aware Harmony remote setup

The top row, controls some harmony activities, that turn on whatever devices I need for each one. They are then configured in home-assistant as switches. If you’ve not got a harmony remote I’m sure other methods could be used. As a minimum, you could have a switch for each device and turn on the ones you want manually.

The main section of controls just call a service to do whatever, there’s no other config supporting this, the service parameters are all in the card config and the service itself is for the harmony remote. Again, as long as you can use a service call of some type for each button, you can replace that fairly easily. If you need to use different services for different devices then use conditional cards to swap things in and out.

The bottom section is dependant on the AndroidTV config, a sensor containing the currently running app and a script, called by the buttons, to swap apps.

All the elements this depends on are in the code below.

#################################################
# Hamrony Remote Setup
#################################################

remote:
  - platform: harmony
    host: 192.168.1.69
    name: lounge
    activity: TV

switch:
  - platform: template
    switches:
      lounge_tv:
        friendly_name: Lounge TV
        value_template: "{{ is_state_attr('remote.lounge', 'current_activity', 'SHIELD TV') }}"
        turn_on:
          service: remote.turn_on
          data:
            entity_id: remote.lounge
            activity: "SHIELD TV"
        turn_off:
          service: remote.turn_on
          data:
            entity_id: remote.lounge
            activity: "PowerOff"
        icon_template: >-
          {% if is_state_attr('remote.lounge', 'current_activity', 'SHIELD TV') %}
            mdi:television
          {% else %}
            mdi:television-off
          {% endif %}

      soundbar:
        friendly_name: Soundbar
        value_template: "{{ is_state_attr('remote.lounge', 'current_activity', 'Soundbar') }}"
        turn_on:
          service: remote.turn_on
          data:
            entity_id: remote.lounge
            activity: "Soundbar"
        turn_off:
          service: remote.turn_on
          data:
            entity_id: remote.lounge
            activity: "PowerOff"
        icon_template: >-
          {% if is_state_attr('remote.lounge', 'current_activity', 'Soundbar') %}
            mdi:music
          {% else %}
            mdi:music-off
          {% endif %}

      ps3:
        friendly_name: PS4
        value_template: "{{ is_state_attr('remote.lounge', 'current_activity', 'PS4') }}"
        turn_on:
          service: remote.turn_on
          data:
            entity_id: remote.lounge
            activity: "PS4"
        turn_off:
          service: remote.turn_on
          data:
            entity_id: remote.lounge
            activity: "PowerOff"
        icon_template: >-
          {% if is_state_attr('remote.lounge', 'current_activity', 'PS4') %}
            mdi:playstation
          {% else %}
            mdi:playstation
          {% endif %}

      usbc:
        friendly_name: USB-C
        value_template: "{{ is_state_attr('remote.lounge', 'current_activity', 'USB-C Cable') }}"
        turn_on:
          service: remote.turn_on
          data:
            entity_id: remote.lounge
            activity: "USB-C Cable"
        turn_off:
          service: remote.turn_on
          data:
            entity_id: remote.lounge
            activity: "PowerOff"
        icon_template: >-
          {% if is_state_attr('remote.lounge', 'current_activity', 'USB-C Cable') %}
            mdi:cellphone-play
          {% else %}
            mdi:cellphone
          {% endif %}

#################################################
# Shield TV Setup
#################################################
media_player:
  - platform: androidtv
    name: Shield
    host: 192.168.1.18
    # adbkey: "/config/adbkey/adbkey"
    device_class: androidtv
    apps:
      com.amazon.amazonvideo.livingroom: "PrimeVideo"
      com.google.android.tvlauncher: "Home"
      com.nvidia.bbciplayer: "iPlayer"
      com.channel5.my5: "My5"
      com.nousguide.android.rbtv: "RedBullTV"
      com.google.android.music: "GooglePlayMusic"
      air.ITVMobilePlayer: "ITVHub"

    state_detection_rules:
      "com.google.android.tvlauncher":
        - "standby"
      "com.amazon.amazonvideo.livingroom":
        - "paused":
            "wake_lock_size": 0
        - "playing":
            "wake_lock_size": 2
        - "standby"
      "com.nvidia.bbciplayer":
        - "paused":
            "wake_lock_size": 1
        - "playing":
            "wake_lock_size": 2
        - "standby"

script:
  launch_shield_app:
    sequence:
      - service: switch.turn_on
        entity_id: switch.lounge_tv

      - wait_template: "{{ is_state('switch.lounge_tv', 'on') }}"
        timeout: "00:01:00"
        continue_on_timeout: "false"

      - service: androidtv.adb_command
        data_template:
          command: "{{ adbcommand }}"
          entity_id: media_player.shield

sensor:
  - platform: template
    sensors:
      cur_shield_app:
        friendly_name: "Shield App"
        value_template: "{{ state_attr('media_player.shield', 'app_name') }}"
1 Like

@eggman Any chance you can share the new images you’re using? Thanks for your examples - I’ve learned so much from them!

Yes, the set up looks awesome. Great if we can get the shared package. Thanks so much

Apologies, it’s taken me a while to get round to uploading all the files they can be found in my home assistant configuration here:

I’ve been tweaking in the meantime and tweaked a few things, mostly moving to this theme

Off

On

1 Like

looks awesome
but i guess too much work to setup for me :confused:
stuff like this should be much faster been adopted to default :frowning:

1 Like

Thanks for sharing this but could I ask you to add the missing dpad.svg file to the repo.

This is what mine looks like:

And of course I can click each button on the “Virtual RC” just as if it was real. The card is a vertical stack with support for 8 mediaplayers of various types spread around my house. It only shows media player cards when a player is active.

3 Likes

Drew, did you get de dpad file, i’m in the need of that one to but kind find it.

Hi everyone - I have been following this thread and find this entire customization amazing. I am brand new to HA and YAML as well. Is there a place where I can find step by step instructions on how to create the harmony remote dashboard mentioned here? I have no clue how to create a custom dashboard using YAML and would appreciate any help. Thank you!

1 Like

You need to start easy if you have little or no previous experience. If you are persistent, it’ll take you a month or more to get to up to speed. Don’t jump right into advanced YAML structures from day one. It will only frustrate you. Sorry for that.