Last active
December 7, 2022 19:34
-
-
Save a-nicholls/e3921b55654e140539270a348be2c8e7 to your computer and use it in GitHub Desktop.
Home Assistant Blueprint - Xbox App to Harmony Activity Enhancer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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->HarmonyActivity (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 | |
mode: restart | |
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('power_off','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 state_attr(harmony_remote,'activity_list') is iterable 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