Pass variables from automation to script for conditions

I think the location of the quotes are a problem… move entity outside the quotes so you can concatenate the value of the variable to ‘light.’ and ‘input_boolean.’ instead of the string ‘entity’. Also, float() needs a default, and do your future-self a favor and put in the data variable fields so it appears in the Services test tool.

fields:
  entity:
    description: Entity name (entity_id with domain removed)
    example: basement_overhead
  step_size:
    description: Number of percentage points each step will increase brightness
    example: 20
variables:
  current_brightness: >
    {{ (state_attr('light.'~entity, 'brightness') | float(0) / 2.55) }}
sequence:
  - choose:
      - conditions:
          - condition: template
            value_template: >-
              {{ current_brightness <= 95 and
              is_state('input_boolean.'~entity, 'on') }}
        sequence:
          - service: light.turn_on
            data:
              brightness_step_pct: '{{step_size}}'
            target:
              entity_id: light.{{entity}}
1 Like