Ok, I see.
Yes, you could change _ELEV_RND
to 0.1
instead of 0.5
, but I think that would be overkill.
I would do it a different way. First I’d define two binary sensors:
binary_sensor:
- platform: sun2
monitored_conditions:
- elevation: -5
- elevation: 5
Now create an automation that is triggered when binary_sensor.above_5_0
goes off
. Have the action be a repeat
loop that increases the brightness on each loop. Include in the loop a delay that uses a template to calculate the delay based on how much time will elapse until binary_sensor.above_minus_5_0
changes to off
by using its next_change
attribute.
So basically when binary_sensor.above_5_0
changes to off
(and triggers the automation), binary_sensor.above_minus_5_0
will still be on
, and its next_change
attribute will indicate when it will change to off
. So the difference between that time and now()
is how much time will elapse between the sun being +5 and -5 degrees. You can then, say, divide that time by 10, where the automation increases the bulb’s brightness each time (by 10%.)
Let me know if you can’t work out the automation and I can give it a shot.
EDIT:
Here’s what I was thinking regarding the automation:
automation:
- trigger:
- platform: state
entity_id: binary_sensor.above_5_0
to: 'off'
action:
- variables:
steps: 10
light: light.LIGHT
time: >
{{ (state_attr('binary_sensor.above_minus_5_0', 'next_change') - now())
.total_seconds() }}
- repeat:
count: "{{ steps - 1 }}"
sequence:
- service: light.turn_on
data:
entity_id: "{{ light }}"
brightness_step_pct: "{{ 100 / steps }}"
- delay: "{{ time / (steps - 1) }}"
- service: light.turn_on
data:
entity_id: "{{ light }}"
brightness_pct: 100