Slow Scene Automation using Device change state

I created a automation that switches scenes when the Xbox turns on, but the automation is very slow to initiate.

I’m not sure if it’s the Xbox integration that has a delay in reporting it’s state back to HA, or that I have setup the automation wrong, but something is right and I’d appreciate any help on getting this resolved.

Here is my automation setup via the dashboard:

alias: "Gaming Mode: Xbox"
description: ""
trigger:
  - platform: device
    type: changed_states
    device_id: 00782ede8400b99380ca8e92f2d244e5
    entity_id: media_player.sam_xbox
    domain: media_player
condition: []
action:
  - if:
      - condition: device
        device_id: 00782ede8400b99380ca8e92f2d244e5
        domain: media_player
        entity_id: media_player.sam_xbox
        type: is_on
    then:
      - service: scene.turn_on
        target:
          entity_id: scene.gaming_mode
        metadata: {}
    else:
      - service: scene.turn_on
        target:
          entity_id: scene.relax_mode
        metadata: {}
mode: single

Thanks

You can check the automation trace:

But my money would be on the trigger. The Xbox integration uses cloud polling which is the worst possible IoT class. Not only do you have the latency between home assistant and the Xbox cloud servers but you also have to wait for the polling interval for state updates to be recognised.

1 Like

Yeh, I was thinking it’s something to do with that. Would the ‘local’ steps on the bottom of the Xbox integration page be a good workaround?

Here’s the automation trace, I don’t fully understand it however:

Thanks

Look at the time it triggers and compare that to the time you actually changed the media player state. If that is where the time difference is then the IoT class is to blame.

Do a search on the forum for Xbox local and see how well it works for others.