Secrets in data Field of automation

Hi,

I’m trying to pass a username and password to a REST command in an automation using the data field. However, this only works if I enter the username and password in plain text, which I obviously don’t want. Calling it via a secret file fails.

My configuration:

secrets.yaml:

controme_user: "[email protected]"
controme_password: "PASSWORD"

rest_command.yaml:

controme_set_temperaturszene:
url: "http://IP/set/json/v1/1/temperaturszenen/{{ scene_id }}/"
method: POST
content_type: "application/x-www-form-urlencoded"
payload: "user={{ username }}&password={{ password }}&room_id={{ room_id }}"

Automation (working):

action: rest_command.controme_set_temperaturszene
metadata: {}
data:
  room_id: 2
  scene_id: 1
  username: [email protected]
  password: PASSWORD

Automation (desired, but failing; calling the secrets file):

action: rest_command.controme_set_temperaturszene
metadata: {}
data:
  room_id: 2
  scene_id: 1
  username: "!secret controme_user"
  password: "!secret controme_password"

Does anyone have any idea where the error lies here, or how I could achieve the desired result in another way, without specifying the username and password anywhere other than in the secrets.yaml file? I would be very grateful for any tips!

Best regards,

Jan

remove the quotes

action: rest_command.controme_set_temperaturszene
metadata: {}
data:
  room_id: 2
  scene_id: 1
  username: !secret controme_user
  password: !secret controme_password

yaml only, can’t use the UI. And when I say “Can’t use the UI”, I mean cannot use the UI at all even yaml mode in the UI.

Secrets don’t work in the UI.

5 Likes

Wow, great, I couldn’t image the GUI could be a problem! Thanks a lot! :grinning: