Xbox Live - Perform actions when an Xbox Achievement is unlocked

Xbox Achievement Unlocked

Detects when the user unlocks an achievement (gamer score increases) on Xbox Live, then you can run any desired action (flash lights, play mp3 files, activate scenes).

Since it’s based on Xbox Live cloud services it should support any platform (Xbox, PC, XCloud).

Requirements:
- Xbox Integration
- Xbox Gamer Score entity, by default the integration comes with this entity disabled and you’ll need to manually enable it.

Optional:
- Conditional sensor, the actions will only be performed if this entity status in ‘on’ or ‘home’.

Credits to /u/zjleblanc on Reddit for sharing his automation.

Blueprint Code

Click the badge to import this Blueprint: (needs Home Assistant Core 2021.3 or higher)

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Or import this Blueprint by using the forum topic / Gist URL:

blueprint:
  name: Xbox Achievement Unlocked 
  description: | 
  
    ## Xbox Achievement Unlocked 2022.01
    
    Detects when the user unlocks an achievement (gamer score increases) on Xbox Live, then you can run any desired action (flash lights, play mp3 files, activate scenes). 
    Since it's based on Xbox Live cloud services it should support any platform (Xbox, PC, XCloud).
    
    ### Requirements:
    - [Xbox Integration][1]
    - Xbox Gamer Score entity, by default the integration comes with this entity disabled and you'll need to manually enable it.
    
    ### Optional:
    - Conditional sensor, the actions will only be performed if this entity status in 'on' or 'home'.  
    
    
    
    Credits to [/u/zjleblanc][2] on Reddit for sharing his automation.
    
    [1]: https://www.home-assistant.io/integrations/xbox
    [2]: https://www.reddit.com/r/homeassistant/comments/rrgwqo/xbox_achievement_unlocked_automation/
  
  domain: automation
  source_url: https://gist.github.com/cvroque/27d2add657cbdf0651aee4394cc15ca2#file-xbox_achievement-yaml
  input:
    trigger_entity:
      name: User Game Score
      description: Choose entity named "YOURGAMERTAG Gamer Score"
      selector:
        entity:
          domain: sensor
          integration: xbox
    condition_entity:
      name: (Optional) Condition
      description: Only perform actions if selected entity is 'on' or 'home'.
      default: []
      selector:
        entity: {}
    actions:
      name: Actions
      description: Actions (e.g. flash lights, start scenes, play sounds...)
      default: []
      selector:
        action: {}
variables:
  condition_entity: !input 'condition_entity'
trigger:
  - platform: state
    entity_id: !input trigger_entity
condition:
  - condition: template
    value_template: '{{ trigger.to_state.state | float(0) > trigger.from_state.state | float(0) }}'
  - condition: template
    value_template: '{{ trigger.from_state.state | float(0) > 1 }}'
  - condition: template
    value_template:  '{{ states(condition_entity) in [''unknown'', ''on'', ''home'']}}'
action:
  - choose: []
    default: !input 'actions'
mode: queued
max_exceeded: silent
6 Likes

Is it possible to know which console a user is authenticated on in the integration? Rather than a conditional sensor, it might be better to tie the automation to the user being online on a specific xbox console?

Hello!

The integration does not show any entity linking a user to the console.

Since I don’t have any console I can’t be sure but according to the documentation your console should show up as a media player in HA and if it shows the game you’re playing you could match that with the user status (sensor.{gamertag}_status) through a template.

Interesting idea. Shame there’s not a straightforward way to tie user to console.