Adaptive Lightning Settings

Yes, just create a new automation, switch to “Edit in YAML” mode in the 3-dot menu in the top right, paste in the code and save. It’ll run every 5 minutes while it’s enabled.

I updated my own script to match the original author’s clean version, reintroduced my check for if adapt_color was on, and also added another filter to only select lights that accept color_temp commands (in addition to being off and controlled by AL). That updated code is here:

alias: Maintain Adaptive Lighting Color Temperature
description: >-
  Primes the color temperature of lights that are controlled by adaptive
  lighting and are currently off
triggers:
  - trigger: time_pattern
    minutes: /5
conditions: []
actions:
  - repeat:
      for_each: "{{enabled_adaptive_lighting_entities}}"
      sequence:
        - variables:
            adaptive_lighting_entity: "{{repeat.item}}"
            lights_currently_off_and_controlled_by_adaptive_lighting_entity: |-
              {{state_attr(adaptive_lighting_entity, "configuration").lights |
                expand |
                selectattr("state", "==", "off") |
                selectattr("attributes.supported_color_modes", "defined") |
                selectattr("attributes.supported_color_modes", "contains", "color_temp") |
                map(attribute="entity_id") |
                list}}
            color_temp_according_to_adaptive_lighting_entity: "{{state_attr(adaptive_lighting_entity, \"color_temp_mired\")}}"
        - if:
            - condition: template
              value_template: >-
                {{ 
                states(adaptive_lighting_entity|replace("adaptive_lighting","adaptive_lighting_adapt_color")) 
                == "on" }}
          then:
            - repeat:
                for_each: >-
                  {{lights_currently_off_and_controlled_by_adaptive_lighting_entity}}
                sequence:
                  - variables:
                      light_currently_off: "{{repeat.item}}"
                      mqtt_topic: >-
                        zigbee2mqtt/{{state_attr(light_currently_off,
                        "friendly_name")}}/set
                  - if:
                      - condition: template
                        value_template: >-
                          {{light_currently_off in
                          configured_light_entities_provided_by_mqtt}}
                    then:
                      - action: mqtt.publish
                        data_template:
                          topic: "{{mqtt_topic}}"
                          payload: |-
                            {
                              "color_options": {
                                "execute_if_off": "true"
                              }
                            }
                      - delay:
                          hours: 0
                          minutes: 0
                          seconds: 0
                          milliseconds: 100
                      - action: mqtt.publish
                        data_template:
                          topic: "{{mqtt_topic}}"
                          payload: |-
                            {
                              "color_temp": {{color_temp_according_to_adaptive_lighting_entity}},
                              "transition": 0
                            }
mode: single
variables:
  configured_light_entities_provided_by_mqtt: |-
    {{integration_entities("mqtt") |
      select("match", "^light\.") |
      expand |
      map(attribute='entity_id') |
      list}}
  enabled_adaptive_lighting_entities: |-
    {{integration_entities("adaptive_lighting") |
      select("match", "^switch\.adaptive_lighting_.*") |
      reject("match", "^switch\.adaptive_lighting_adapt_.*") |
      reject("match", "^switch\.adaptive_lighting_sleep_mode_.*") |
      expand |
      selectattr("state", "==", "on") |
      map(attribute="entity_id") |
      list}}