I have a script that I call in lieu of directly calling light.turn_on.
service: script.autocolor
data:
entity_id: light.couch_lamp
The purpose of the script is to attach a color_temp to the light.turn_on call, depending on sunset/time of day. The script also accepts other data like brightness_pct and transition, or passes along default values if none was received. My script works as the following:
sequence:
- if:
- condition: state
entity_id: sun.sun
state: above_horizon
then:
- service: light.turn_on
data:
entity_id: "{{entity_id}}"
color_temp: 153
brightness_pct: "{{brightness_pct}}"
transition: "{{transition}}"
# else code removed for simplicity
variables:
brightness_pct: "{{brightness_pct if brightness_pct is defined else 100}}"
transition: "{{transition if transition is defined else 3}}"
But I’d like to be able to utilize that same service call to occasionally pass along brightness_step_pct instead of brightness_pct, without nesting a bunch of if-else-then statements with their own service calls. I’m trying to do something like the following but it gives me an error “two or more values in the same group of exclusion”:
- service: light.turn_on
data:
entity_id: '{{entity_id}}'
color_temp: 153
brightness_pct: '{{brightness_pct if brightness_step_pct is not defined else 0}}'
brightness_step_pct: '{{brightness_step_pct if brightness_step_pct is defined else 0}}'
transition: '{{transition}}'
And it doesn’t seem like this type of thing works either-
- service: light.turn_on
data:
entity_id: '{{entity_id}}'
color_temp: 153
{%if brightness_step_pct is not defined then%} brightness_pct: '{{brightness_pct}}'
{%else%} brightness_step_pct: '{{brightness_step_pct}}' {%endif%}
transition: '{{transition}}'
So is there a way I could have a single service call to light.turn_on with all the data points, but it only passes along the ones that are defined?