How to Retrieve Secret Value in Automation Condition

I am attempting to replace a hard-coded value in an automation with a value from the secrets file, but I haven’t had a success getting the syntax correct. I have tried several solutions I have found in the forums, but I am obviously missing something since I keep getting some sort of ‘invalid’ / ‘not expected’ message.

condition:
  - condition: state
    entity_id: light.front_porch
    state: 'off'
  - condition: numeric_state
    entity_id: sensor.hue_outdoor_motion_sensor_1_light_level
    attribute: lightlevel
    below: '22000'    **<-trying to replace this with secret lightLevelMin**
  - condition: time
    after: '06:00:00'
    before: '23:00:00'
condition:
  - condition: state
    entity_id: light.front_porch
    state: 'off'
  - condition: numeric_state
    entity_id: sensor.hue_outdoor_motion_sensor_1_light_level
    attribute: lightlevel
    below: !secret light_level_min # do not use spaces, capital letters or other special characters.
  - condition: time
    after: '06:00:00'
    before: '23:00:00'

In secrets.yaml:

light_level_min: 22000

That is exactly what I currently have in both places, and when I attempt to save it in the YAML editor I get this:

**Message malformed: expected float for dictionary value @ data['condition'][1]['below']**

Which yaml editor?

The built-in one in HA.

So yaml mode in the automation editor?

Yes. That one.

I tried it using VSCode (I don’t use the automation editor) and it passed a configuration check.

I guess the automation editor does not support secrets. Looks like it used to but it may have been removed. See: Automation editor exposing !secret values · Issue #3065 · home-assistant/frontend · GitHub

Ok. Thanks. I will try editing it with VSCode and then testing if it actually returns the value at runtime.

Here’s what I use - BTW I noticed that you have the wrong attribute name (lightlevel vs light_level)

- alias: "Turn off lights"
  trigger:
    - platform: numeric_state
      entity_id: sensor.hue_outdoor_motion_sensor_1_light_level
      attribute: light_level
      above: input_number.daylight_threshold
      for: "00:20:00"

And in configuration.yaml

input_number:
  daylight_threshold:
    name: Daylight threshold
    initial: 22000
    min: 0
    max: 60000

I don’t use the UI to alter the value of “daylight_threshold”, but may in the future.