Automation for lights off whe sun is above horizon and rising

I have a simple automation to turn off a light when the sun is above the horizon. It works fine but the automation to turn it on used the same number of degrees above the horizon and was conflicting with it. I added a condition based on if the time of day was morning or evening to each of the automatons. This fixed the issue, but seem clunky. So… not leaving well enough alone I added the following condition which seems like it should work but doesn’t. What is wrong with it?

The code that results from it is:

condition: state
entity_id: sun.sun
state: 'true'
attribute: rising


Thanks in advance!

You just described ‘sunrise’.

trigger:
   platform: sun
   event: sunrise

sunrise is defined as “sun crosses the horizon and is rising”

sunset is “sun crosses the horizon and is not rising”

Agree. But what I’m trying to do is turn the lights off after the sun has risen above 4 degrees. That works. It’s when I add the condition that the automation doesn’t seem to work. Here’s all of the code.

alias: Turn Lights Off When Sun Comes Up a Bit
description: ''
trigger:
  - platform: numeric_state
    entity_id: sun.sun
    value_template: '{{state.attributes.elevation}}'
    above: '4'
    below: '6'
condition:
  - condition: state
    entity_id: sun.sun
    state: 'true'
    attribute: rising
action:
  - type: turn_off
    device_id: deviceIDxxxxxxxxxxxxxxxxx
    entity_id: light.centralite_4257050_rzhac_7ea52d0b_on_off
    domain: light
  - type: turn_off
    device_id: deviceidxxxxxxxxxxxxxxxxxx
    entity_id: light.hallway_main_lights
    domain: light
  - scene: scene.living_room_all_off
mode: single

Oh, I see.

True/False are kind of special. True != ‘true’; True != ‘True’, etc.

i’m not sure what that state condition will do. You can try using state: True instead of state: 'true'.

If that doesn’t work, this will

- condition: template
  value_template: "{{ is_state_attr('sun.sun', 'rising', True) }}"