Hello everyone,
I find it quite difficult as I struggled a few hours a week ago, and also today I tried again for about 30 minutes, and I always encountered some errors.
I have led strips in all my plinths but in the night time the light is too bright if it’s turned on at 100%. In other areas like above the kitchen countertop or under the bar where the light is NOT directly visible, it’s ok to be at 100%, but in the plinths, is not ok.
For now I only have radar sensors in 3 rooms, but all the rooms will in the end have radar sensors so the lights will turn on automatically.
I also made a dashboard with a small button for every light strip, I tried today again to make an adjustable brightness based on sun position, the code evolved like this:
#v.1
- type: vertical-stack
cards:
- type: custom:mushroom-chips-card
alignment: center
chips:
- type: light
entity: light.esp32_mos_x3_d_led_strip_d3_office
content_info: none
icon: mdi:laptop
#v2 than I added an tooltip like description for the button
- type: light
entity: light.esp32_mos_x3_d_led_strip_d3_office
content_info: none
icon: mdi:laptop
card_mod:
style: |
ha-card:hover::after {
content: "Office";
position: absolute;
bottom: 110%; /* Apare deasupra butonului */
left: 50%;
transform: translateX(-50%);
background-color: rgba(0, 0, 0, 0.8);
color: white;
padding: 4px 8px;
border-radius: 4px;
font-size: 10px;
white-space: nowrap;
z-index: 100;
pointer-events: none;
}
#v3 than tried to turn it on at a certain level, and it worked
- type: light
entity: light.esp32_mos_x4_a_led_strip_a1_livingroom
content_info: none
icon: mdi:sofa
hold_action:
action: more-info
tap_action:
action: call-service
service: light.toggle
target:
entity_id: light.esp32_mos_x4_a_led_strip_a1_livingroom
data:
transition: 5
brightness_pct: 50
#v4 AND THE PROBLEM STARTED WHERN I TRIED TO USE AN HELPER NUMBER INSTEAD OF 50 as the brightness
tap_action:
action: call-service
service: light.toggle
target:
entity_id: light.esp32_mos_x4_a_led_strip_a1_livingroom
data:
transition: 5
brightness_pct: >-
{{ states('input_number.leds_adaptive_brightness') | int
}}
# or
brightness_pct: "{{ states('input_number.leds_adaptive_brightness') | int }}"
# AND THIS ERROR SHOWED UP
Failed to perform the action light/toggle. expected float for dictionary value @ data['brightness_pct']
This is my YAML automation to update the helper number every 15 minutes
alias: LEDs Adaptive Brightness Helper
description: Actualizează valoarea luminozității în funcție de soare
triggers:
- minutes: /15
trigger: time_pattern
- event: sunrise
trigger: sun
- event: sunset
trigger: sun
- event: start
trigger: homeassistant
actions:
- target:
entity_id: input_number.leds_adaptive_brightness
data:
value: |
{% if is_state('sun.sun', 'above_horizon') %}
100
{% elif state_attr('sun.sun', 'elevation') > -18 %}
50
{% else %}
30
{% endif %}
action: input_number.set_value
mode: single
The error is also displayed in the video bellow, for the first light button only, as I only tried to modify that one
So what is everyone using in this case, when we want the lights to turn on at a certain level based on day/night conditions?
I hoped there is a simple attribute I can attach to any automation (the one that turns on my lights when motion sensor detects motion) or to any button when I turn the light manually, but it seems I haven’t found the way to do it.
How to use HELPERS in the code of an light.toggle button ?
PS. I also tried to use the script inside the brightness_pct option inside the data, as in this topic , but it failed with the exact same error