Why can I not use secrets in the automation UI?

I like to use the UI for everything, but it seems you cannot use !secret so I end up having to have manual automations in a yaml file.

Never needed to reference a secret from an automation before. Can you elaborate on a specific use?

I like how secrets are accessible via UI in ESPHome.


I have my alarms arm and disarm automatically and the alarm control panel integration needs the code for this, eg:

- alias: Shed Alarm - auto arm night
  description: Arm shed alarm at midnight
  - platform: time
    at: '00:01'
  - service: alarm_control_panel.alarm_arm_away
      code: !secret shed_alarm_code
      entity_id: alarm_control_panel.shed_alarm
  mode: single

I could hard code the alarm code in the automations but then if I change the code I need to alter multiple automations, as opposed to storing the code once in the secrets file

Ah. My alarm stores the code with the user auth, using the total connect integration. Any way to do that with your panel so you don’t have to send code during each operation?

No, this isn’t a physical alarm system, its the virtual one provided by HA - Alarm Control Panel - Home Assistant

Fwiw if its just about having the code in one place and not having to change it in a bunch you can solve that with a script. Instead of directly calling the service alarm_control_panel.alarm_arm_away all over the place, make a script like this:

alias: Set my alarm
    name: Alarm control panel(s)
    description: Alarm control panel(s) to lock
    default: alarm_control_panel.shed_alarm
    example: alarm_control_panel.shed_alarm
        domain: alarm_control_panel
        multiple: true
  - service: alarm_control_panel.alarm_arm_away
      code: "1234"
      entity_id: "{{ entity_id }}"

And replace all calls to that service with a call to this script.

But I get it, using secrets would be nicer. This is just a workaround.

1 Like

What I ended up doing was to create an input_text as follows, then use the code_template attribute of the Alarm Control Panel. Then I can reference the input_text in my automation and in the code_template attribute of the Alarm Control Panel.

    name: Alarm Code
    mode: password
    min: 4
    max: 4
    pattern: "[0-9]*"
1 Like