i like to set the Brightness of my LED-Stripes when its on or off. I do not like to change the power-state. I have serval LEDs for my stairs and like to dimm the brightness based on the sun elevation.
- id: brightness_led_front_entry
alias: Change Brightness of LED on Door Front Entry depending on Sun Elevation
trigger:
- platform: time_pattern
minutes: "/1"
condition:
- condition: template
value_template: "{{ state_attr('sun.sun', 'elevation') <= 2.5
and state_attr('sun.sun', 'elevation') >= -4.5 }}"
action:
- service: light.turn_on
data:
entity_id: light.wled_eingangstuer
brightness: '{{ ((230 / (--4.5 + 2.5 + 0.05)) * (states.sun.sun.attributes.elevation + (--4.5 + 0.05))) | int }}'
The only way i know to accomplish this is to use the light.turn_on service.
Do you want to avoid to turn on the leds if they are off? Then you have to add some logic to your automation with a condition. For me, building this is easier in node-red since it gives an easier to understand visual representation.
Most lights can’t change brightness without turning on the light, that’s a hardware limitation.
The ones that are able to do it, have a separate service for this, e.g. LIFX has the service lifx.set_state
Every light that is related to the outdoor light (ambient-sensor) i have created a “fake light object” that warps the turn off / turn on commands to the correct light. When forwarding “turn on” i also send the correct brightness value to the correct light.