I’m trying to have a script turn off/on a lamp based on a lux sensor, but the script below is returning extra keys to light.turn_off while I only want it to return the keys to light.turn_on.
The error: Invalid service data for light.turn_off: extra keys not allowed @ data['brightness_pct']. Got ''
How do I make the script only return “brightness_pct: 80” when calling the turn_on service?
merelys:
alias: Mere lys naar der bliver moerkt
sequence:
- service_template: >-
{% if states.sensor.stue_lys.state | float < 16000 %}
light.turn_on
{% else %}
light.turn_off
{% endif %}
data:
entity_id: light.ph5
transition: 10
data_template:
brightness_pct: >-
{% if states.sensor.stue_lys.state | float < 16000 %}
80
{%- endif %}