[solved] Turn on lights with different brightness with template & 2 input booleans?

I would like to use a different brightness percentage in an automation to turn on lights, depending on the state of an input boolean.

This is the action part of my automation:

type: turn_on
device_id: 7e3a28e57afb9276188914b2f8d57888
entity_id: light.kl
domain: light
data:
  brightness_pct: "{{ 5 if is_state ''input_boolean.bedtime'' = ''on'' else 90}}"

This template works (gives me a true or false result)

{{ is_state("input_boolean.bedtime", "off") }}

Device actions do not support templates use the light.turn_on service action.

service: light.turn_on
target:
  entity_id: light.kl
data:
  brightness_pct: "{{ 5 if is_state('input_boolean.bedtime', 'on') else 90 }}"
1 Like

use scenes and an automation that’s triggered by the booleans (or even better input_select) to apply the logic

1 Like

Thanks a lot guys for jumping in!

@tom_l: this works perfectly, thank you.
I have a third state/input boolean which I would like to use in this same automation/action.
The brightness percentage is the same (5/90), depending if this boolean is on or off.
How can I combine these 2 because if the first is off and the second on, this will not work.

@avd706: out of curiosity, could you elaborate a little on your solution please?

Like this:

brightness_pct: "{{ 5 if is_state('input_boolean.bedtime', 'on') or is_state('input_boolean.other', 'on') else 90 }}"
1 Like

Thanks A LOT again @tom_l !
It’s so easy when you see the solution… :blush:

1 Like

See the example here:

1 Like

Thank you! :+1:
I’m always interested if things in HA can be done differently, better, easier, …

What a coincidence to land on a topic twice a day where the same person provides the answer :wink:
@tom_l, would you also be able to explain how a template would work where I have two booleans? If the first is true, it would be 1%, if the second is true it would be 20% and in all other situations it would be 50%.