Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Home Assistant Blueprint - Xbox App to Harmony Activity Enhancer
blueprint:
name: Xbox App to Harmony Activity Enhancer
description:
<ha-icon icon="mdi:remote"></ha-icon><ha-icon icon="mdi:chevron-triple-left"></ha-icon><ha-icon icon="mdi:microsoft-xbox"></ha-icon>
Create an individual harmony activity for each Xbox activity you wish to
run, have a separate harmony activity for playing Xbox that you can use
so if you switch to another game or go to the Home screen on the Xbox it
doesn't attempt to re-run the app or game
domain: automation
input:
harmony_remote:
name: Harmony Remote Sensor
description: The Harmony remote that contains the activity to match to the Xbox
selector:
entity:
integration: harmony
domain: remote
default: remote.harmony
xbox_media_player:
name: Xbox Media Player
description: Xbox that you want to sync with the harmony activities
selector:
entity:
integration: xbox
domain: media_player
default: media_player.xbox
xbox_signedin_profile:
name: Signed in Xbox profile
description: Xbox Profile to watch and app activate from
selector:
entity:
integration: xbox
domain: sensor
name_mappings:
name: Activity Name Mappings
description: Where the name of the activity and Xbox App name (as seen in home assistant xbox media control) differs,
enter the mapping here as XboxAppName->HarmonyAcivity (no need to put in mappings that match e.g. YouTube to YouTube)
selector:
object:
default:
Amazon Instant Video: Prime Video
activesecs:
name: Amount seconds must be active for to attempt to change
description: 0 Seconds means activate immediately
selector:
number:
min: 0
max: 60
unit_of_measurement: seconds
default: 0
trigger:
platform: state
entity_id: !input xbox_signedin_profile
for:
seconds: !input activesecs
variables:
harmony_remote: !input harmony_remote
xbox_signedin_profile: !input xbox_signedin_profile
name_mappings: !input name_mappings
activesecs: !input activesecs
#replaces sensor.remote
Harmony_remote_activity: >
{% if is_state(harmony_remote, 'on') %}
{{ state_attr(harmony_remote,'current_activity').replace('PowerOff','Powered Off') }}
{% else %}
Powered Off
{% endif %}
xbox_runningapp: >
{% set NS = namespace(RunApp=states(xbox_signedin_profile)) %}
{% for searchfor, replacewith in name_mappings.items() %}
{% if NS.RunApp==searchfor -%}
{% set NS.RunApp=replacewith %}
{% endif %}
{% endfor %}
{{ NS.RunApp | default }}
condition: "{{ (xbox_runningapp != Harmony_remote_activity) and xbox_runningapp in state_attr(harmony_remote,'activity_list') }}"
action:
service: remote.turn_on
data:
entity_id: !input harmony_remote
activity: "{{ xbox_runningapp }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment