Optional bool conition

I have a blueprint for turning on lights (switches) at sunset.
It includes settings for sun elevation and between two times.
Currently I also have a hard coded condition for my alarm to be deactivated.

Now for the problem. Some of my lights should only turn on if alarm is deactivated but some lights should not care if alarm is on or off.

So, I would like to include a boolean varable to decide if this condition should be used or not.
Something like “Only turn on if alarm is deactivated”.
When used as automation, if boolean variable is set, this condition should be used:

condition: state
entity_id: switch.alarm_active
state: 'off'

And if boolean variable is not set, the condition should not be used at all.

Here is my current blueprint:

blueprint:
  name: Pluggar - Tänd - Kväll
  description: Slå på pluggar vid solnedgång
  domain: automation
  input:
    # Variable for identifying the switches to act upon
    target_switch:
      name: Pluggar
      description: Plugg eller pluggar som ska slås på vid solnedgång
      # Use a selector, to pick the switches
      selector:
        target:
          entity:
            domain: switch
    # Variable for sun elevation offset
    elevation_shift:
      name: Solvinkel
      description: Solens vinkel ovanför horisonten. Ett positivt värde tänder tidigare medans ett negativt värde tänder senare.
      default: 0.0
      # Use a selector, to set the time shift or offset
      selector:
        number:
          min: -3.0
          max: 3.0
          mode: slider
          step: 0.5
    # Variable for time window
    time_after:
      name: Efter klockan
      selector:
        time:
    # Variable for time window
    time_before:
      name: Före klockan
      selector:
        time:
        
# Prevent the automation from running concurrently
mode: single

# Define the variables used in the action section
variables:
  target_switch: !input target_switch

# Define the trigger for the automation
trigger:
  # Using the state of the sun to act as the trigger
  platform: numeric_state
  entity_id: sun.sun
  attribute: elevation
  # Can be a positive or negative number
  below: !input elevation_shift
  
# Add a condition to ensure that this only triggers near sunset, in the evening
condition:
  # Check that it is after sunrise
  - condition: sun
    after: sunrise
    # Add a buffer to be sure
    after_offset: "01:00:00"  
  - condition: time
    after: !input time_after
    before: !input time_before
  - condition: state
    entity_id: switch.alarm_active
    state: 'off'
    
# This section will take action on the switches, and turn them on
action:
  # A very simple structure of turning on the selected switches
  - service: switch.turn_on
    target: !input target_switch

Unclear what your actual question is.

You can add boolean selectors:

I know I can add boolean selectors, but in my case I dont want to use the value of the selector directly as condition.
If selector is true, I want this condition to be used:

  • condition: state
    entity_id: switch.alarm_active
    state: ‘off’

If the selector is false the condition should not be used at all.
Could I use an OR condition something like this (pseudo code):
state: ‘off’ OR <boolean_selector> false

use a template to write out that condition, that’s what templates are for. It’s the only way to conditionally add a condition.