Hue Lights Returning to previous brightness after automation

I have all Philips Hue lights connected to the Hue Bridge and the Hue integration in HA.

I have an issue and I can’t seem to figure out why this is happening or how to fix it. I didn’t previously have this issue but I recently upgraded from Hue white bulbs to Hue white and ambiance. I can’t pin it down to that but it feels like ever since then I’ve been having issues.

Basically I have a few automations to run to set the bulbs to certain brightnesses depending on what button I push on a Hue dimmer switch. The most basic one is that I turn on or off all bulbs when I click the power button on the dimmer switch.

The issue is that the bulbs are not following the brightness percentage i set with the light toggle service and instead will revert to their previous brightness after the automation runs. For example, I have a zone set up in the hue app for all of the lights for the Home Theater which contains a group of lights in the front of the room and a group in the back of the room. If the light group in the back of the room is set to 25% brightness, and I click the power button, all the lights turn off as I would expect.

When I click it again, I have the automation set to run the light toggle service and and set them all to 100% brightness. Instead the rear light group turns on to 100% and then return to the previous state of 25%. If I go in and change the brightness of the rear lights to 100% manually, and rerun, they turn on to 100% when I toggle them.

But if I have them at any other percentage when I toggle them on and off again they will return to the previous state instead of staying at 100% pertthe automation settings.

Here is the yaml

alias: Remote HT Dimmer Button 1
description: HT Hue dimmer switch button 1 press run script
trigger:
  - platform: state
    entity_id:
      - event.hue_dimmer_switch_1_button_1_2
    attribute: event_type
    to: short_release
    from: initial_press
condition: []
action:
  - service: light.toggle
    data:
      brightness_pct: 100
    target:
      entity_id:
        - light.home_theater_all
        - light.hue_ambiance_lamp_1_23
mode: single

I’m about at my wits end trying to figure out what is causing this. I don’t have any lights configured to the dimmer switch in the hue app so it’s shouldn’t be doing anything via the hue bridge. This issue is also occurring in other automations I run with lights. Anyone else see this before? I’m on 2023.09

Upon further testing I can add a delay of 3 seconds after the automation runs to then do another call service to turn the lights on to 100% brightness and it will adjust the lights to the correct brightness but this seems really janky and not sure why they are falling back to the previous brightness in the first place.

I modified the yaml to be a bit more granular than the toggle and here it is with the 3 second delay added in. Note that the 3 second delay only looks at the rear light group as the front lights are only ever on or off and the rears may be on at a dimmer state when watching something on the projector. So that’s why it only calls the light on for the rear group after the delay.

alias: Remote HT Dimmer Button 1
description: HT Hue dimmer switch button 1 press run script
trigger:
  - platform: state
    entity_id:
      - event.hue_dimmer_switch_1_button_1_2
    attribute: event_type
    to: short_release
    from: initial_press
condition: []
action:
  - if:
      - condition: and
        conditions:
          - condition: state
            entity_id: light.home_theater_rear
            state: "off"
          - condition: state
            entity_id: light.home_theater_front
            state: "off"
    then:
      - service: light.turn_on
        data:
          brightness_pct: 100
        target:
          entity_id:
            - light.hue_ambiance_lamp_1_23
            - light.home_theater_front
            - light.home_theater_rear
        enabled: true
      - delay:
          hours: 0
          minutes: 0
          seconds: 3
          milliseconds: 0
      - service: light.turn_on
        data:
          brightness_pct: 100
        target:
          entity_id: light.home_theater_rear
    else:
      - service: light.turn_off
        data: {}
        target:
          entity_id:
            - light.home_theater_rear
            - light.home_theater_front
            - light.hue_ambiance_lamp_1_23
    enabled: true
mode: single

I’m case anyone else comes across this, I believe that one of the integrations I had previously installed was causing the issue. I can’t remember the name now but it was an integration that intercepted the light on service call to change the bulb color temperature based on the time of day. I had disabled the integration and forgot about it but it seems like after completing removing it my lights seem to be behaving normally now.