Xbox on Lights On

Hi. I created an automation whereby when I turn on my Xbox, or more specifically when the Xbox logs into my account, the light turns on 3o minutes before sunset. I don’t know what’s going on, but it’s not working. The light itself works fine and is made with ESP32+LEDs – WLED. If you have a moment, could you take a look at my blueprint and see where the error is?

alias: Xbox On
description: ""
triggers:
  - type: turned_on
    device_id: 7d2de328eccbb2533a3f0239a1163ee3
    entity_id: bff9ac68eea494aaf0b4252aafeb40fd
    domain: binary_sensor
    trigger: device
conditions:
  - condition: sun
    after: sunset
    before: sunrise
    before_offset: "-00:30:00"
actions:
  - data:
      brightness_pct: 40
      rgb_color:
        - 120
        - 0
        - 255
      effect: Solid
    action: light.turn_on
    target:
      entity_id: light.wled
      device_id: 148e78961c7fa80531254e4e3e7ea383
mode: single
1 Like

Please post your code as preformatted text (</> in the toolbar). It’s very difficult to read otherwise.

You might also have a look at the docs on using sunrise/sunset as conditions - above/below horizon works much better.

You swapped your triggers & conditions. What you have right now only turns on the light if you switch on your xbox and it’s past 30 minutes before sunset.

Set the trigger to sun and the condition to xbox, and it will turn on your light 30 mins before sunset if your xbox is currently on.

1 Like

I made corrections, but still nothing came of it.

alias: Xbox On
description: ""
triggers:
  - trigger: sun
    event: sunset
    offset: "-00:30:00"
conditions:
  - type: is_on
    condition: device
    device_id: 7d2de328eccbb2533a3f0239a1163ee3
    entity_id: bff9ac68eea494aaf0b4252aafeb40fd
    domain: binary_sensor
actions:
  - data:
      brightness_pct: 50
      rgb_color:
        - 120
        - 0
        - 255
      effect: Solid
    action: light.turn_on
    target:
      entity_id: light.wled
      device_id: 148e78961c7fa80531254e4e3e7ea383
mode: single

The same story is with the Nvidia Shield

alias: Shield on patyk on
description: ""
triggers:
  - trigger: sun
    event: sunset
conditions:
  - condition: device
    device_id: 03df9754b33450dd742e9f57b0eb0cb8
    domain: media_player
    entity_id: 35ef07ee44363307decb3b6b001c7c01
    type: is_on
actions:
  - data:
      brightness_pct: 50
      effect: Solid
      rgb_color:
        - 255
        - 255
        - 255
    action: light.turn_on
    target:
      entity_id: light.wled
      device_id: 148e78961c7fa80531254e4e3e7ea383
mode: single

*patyk it is name my led lights

This isn’t helpful to people trying to help you from halfway across the world.

At the very least, show us your Xbox & shield binary sensor history for the hour before sunset.

Even better, show the traces of both automations, when they were triggered but didn’t behave like you expected.

I just wanted to say that the lights still aren’t working despite the changes that have been made. Below i put more info

That says at the exact time the sun met that condition it fired then checked whatever pixel warlord is - it checked for on. It was off so executions stopped.

PixelWarlord is my Xbox :slight_smile: Ok if its on light whont on 30 minuts before sun is down.

Ok well that’s fine but that’s what happened it detected it as off when that trigger hit so it did nothing…

Thanks for Reply but the same story is with Nvidia Shield also lights wont on when shield is On.

First please no more screenshots most of us are reading this on our phones. And screenies are Bad.

Please download the trace and look at it and post THAT in a code block as instructed earlier in the future.

Now all of these are the same thing.

Trigger fires conditions are checked… In that order. The condition is checked ONLY when the trigger fires.

So it will Only look (trigger) when the sun GOES down not because it IS down. When it goes down at that EXACT MOMENT it checks your Status in the condition block.

In your case it was off.

It did exactly what you told it to do.

If you’re trying to make it work just because it’s dark. That’s a different story

Thx for answers and patience. you mean tracer Like this ??

Xbox ligts on

1 Like

Both your pictures show that the state of the Xbox and the Shield was unavailable when the automation triggered. This means that either you are referencing an unreliable device, or else it means that the device was offline during the automation trigger.
How are these 2 devices integrated in HA, and can you check their history to see whether you see unavailable at any point during the automation trigger time?

@NathanCu I’m not sure where you saw that the state was off. Did I miss something in the trace pictures?

More coffee necessary Shadow. But that’s why I wanted the actual trace. Thanks for the catch.

1 Like

tomorrow after work I will configure everything again

Holidays, holidays.

Finaly problably i have solution

This my Xbox Wled ligt:

ON Light XBOX:

alias: Xbox On
description: ""
triggers:
  - trigger: sun
    event: sunset
conditions:
  - type: is_on
    condition: device
    device_id: 7d2de328eccbb2533a3f0239a1163ee3
    entity_id: bff9ac68eea494aaf0b4252aafeb40fd
    domain: binary_sensor
actions:
  - data:
      brightness_pct: 50
      rgb_color:
        - 120
        - 0
        - 255
      effect: Solid
    action: light.turn_on
    target:
      entity_id: light.wled
      device_id: 148e78961c7fa80531254e4e3e7ea383
mode: single

OFF Light XBOX:

alias: Xbox Off Patyk
description: ""
triggers:
  - type: turned_off
    device_id: 7d2de328eccbb2533a3f0239a1163ee3
    entity_id: bff9ac68eea494aaf0b4252aafeb40fd
    domain: binary_sensor
    trigger: device
conditions:
  - type: is_off
    condition: device
    device_id: 7d2de328eccbb2533a3f0239a1163ee3
    entity_id: bff9ac68eea494aaf0b4252aafeb40fd
    domain: binary_sensor
actions:
  - action: light.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: light.wled
mode: single

It turn ON according to the automation code but turn off doesn’t quite work the way I want it to because the light shuts off after an hour of running the XBOX. The reason may be the second automation which also activates the same light only that in a different color is operated by a motion sensor which activates the light when I sit at the computer.

PC On:

alias: Komputer Patyk ON
description: ""
triggers:
  - type: occupied
    device_id: ce59fee26432cbc31283255cefca7748
    entity_id: e4f279ec167a76d184ade9b35e1b2582
    domain: binary_sensor
    trigger: device
conditions:
  - condition: sun
    before: sunrise
    after: sunset
    before_offset: "-00:30:00"
actions:
  - action: light.turn_on
    metadata: {}
    data:
      rgb_color:
        - 207
        - 158
        - 89
      brightness_pct: 70
    target:
      entity_id: light.wled
mode: single

PC OFF:

alias: Komputer Patyk Off
description: ""
triggers:
  - type: not_occupied
    device_id: ce59fee26432cbc31283255cefca7748
    entity_id: e4f279ec167a76d184ade9b35e1b2582
    domain: binary_sensor
    trigger: device
conditions: []
actions:
  - action: light.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: light.wled
mode: single

How to reconcile these two automations because it seems to me that there is a conflict here and the presence sensor turns off the XBOX automation ??

Hello. Ok start from begining. I already have a working Xbox automation that controls my lights when the Xbox is turned on or off. It’s almost perfect. The thing is, my automation controls LEDs and turns them on when I play, lighting up the appropriate colour, and turns off the other lights, e.g. on the ceiling. At the same time, when I turn off the Xbox, the LEDs go out and the ceiling light comes on, which gradually goes out within three minutes so that I can leave the room calmly. I’ve been struggling with this for a long time and nothing helps. While playing, the LEDs go out from time to time and the ceiling light comes on when it detects that the Xbox has been turned off. I added various automations to this that were supposed to remove this problem and control whether it is on or off. I finally realised that the problem lies in the integration and the console itself. The console sends and loses micro-connections from time to time, which are detected in Home Assistant as switching off or on, which disrupts the entire automation and the lights go out for a moment or turn on. To the Integration authors, please fix this.

If anyone is interested, below is the automation controlling the Xbox, TV shield, ceiling lights and LED strip.

alias: :bulb: Inteligentne Światło Komputer Patyk
description: >-
Automatyczne światło z priorytetami: Xbox > Shield > Komputer. Jasność
dopasowana do pogody i pory dnia.
triggers:

  • trigger: state
    entity_id: binary_sensor.czujnik_obecnosci_patyk_occupancy
    to: “on”
    id: obecnosc
  • trigger: state
    entity_id: binary_sensor.czujnik_obecnosci_patyk_occupancy
    to: “off”
    for:
    minutes: 2
    id: brak_obecnosci
  • trigger: state
    entity_id: input_boolean.xbox_active
    id: device_change
  • trigger: state
    entity_id: input_boolean.shield_active
    id: device_change
    conditions:
    actions:
  • if:
    • condition: state
      entity_id: input_boolean.xbox_active
      state: “on”
      then:
    • action: light.turn_on
      target:
      entity_id: light.wled
      data:
      brightness_pct: 85
      rgb_color:
      - 255
      - 100
      - 0
      effect: Solid
      transition: 2
      else:
    • if:
      • condition: state
        entity_id: input_boolean.shield_active
        state: “on”
        then:
      • variables:
        cloud_coverage: >-
        {{ state_attr(‘weather.forecast_home_2’, ‘cloud_coverage’) |
        int(50) }}
        brightness_shield: |
        {% if cloud_coverage > 75 %}
        85
        {% elif cloud_coverage > 50 %}
        75
        {% elif cloud_coverage > 25 %}
        65
        {% else %}
        55
        {% endif %}
      • action: light.turn_on
        target:
        entity_id: light.wled
        data:
        brightness_pct: “{{ brightness_shield }}”
        rgb_color:
        - 150
        - 255
        - 0
        effect: Solid
        transition: 2
        else:
      • if:
        • condition: state
          entity_id: binary_sensor.czujnik_obecnosci_patyk_occupancy
          state: “off”
          then:
        • action: light.turn_off
          target:
          entity_id: light.wled
          data:
          transition: 3
          else:
        • if:
          • condition: template
            value_template: >-
            {{ states(‘sensor.jasnosc_wled_dynamiczna’) | int(0) > 0
            }}
            then:
          • action: light.turn_on
            target:
            entity_id: light.wled
            data:
            brightness_pct: “{{ states(‘sensor.jasnosc_wled_dynamiczna’) | int(80) }}”
            rgb_color:
            - 255
            - 255
            - 255
            effect: Solid
            transition: 3
            mode: single

you can prevent false triggering by adding not_from: unavailable to the triggers.