Curl script that doesn't work

Hi all,
i want to call a backend with a curl command (for my amcrest ad410 doorbell).
The following curl command works:

curl -u admin:XXXXXXX -X GET --digest 'http://192.168.1.XX/cgi-bin/configManager.cgi?action=setConfig&VSP_PaaS.Online=true'

in configuration.yaml

shell_command:
  doorbell_online_light: >
    curl -u !secret doorbell_username:!secret doorbell_password -X GET --digest 'http://!secret doorbell_ip/cgi-bin/configManager.cgi?action=setConfig&VSP_PaaS.Online=true'

Of course the secrets are correctly set.

How can I fix this ? Or help myself to fix this.
I think i’m missing somewhere quotes or double quotes or whatever.
I don’t blind right now :stuck_out_tongue:

Thank you.

You have to put the entire command in the secret.

Why ? It’s not clever to do such thing.

Because that’s how secrets work. They substitute for the entire value. Take this generic key value pair:

key: value

You can only do this:

key: !secret my_secret_key

You can not do this:

key: something !secret my_secret_key something

You’re right !
I can do this i think

shell_command:
  doorbell_online_light: >
    curl -u {{ secrets['doorbell_username'] }}:{{ secrets['doorbell_password'] }} -X GET --digest 'http://{{ secrets['doorbell_ip'] }}/cgi-bin/configManager.cgi?action=setConfig&VSP_PaaS.Online=true'

Nope. You can’t look up secrets that way.

What about this ?

shell_command:
  doorbell_online_command: !secret doorbell_online_light_command

and in secret file:

doorbell_online_light_command: >
  curl -u admin:XXXX -X GET --digest 'http://192.168.1.XX//cgi-bin/configManager.cgi?action=setConfig&VSP_PaaS.Online=true'
1 Like

What happened when you tested that?

I don’t know how to test this.
I need to wait like one month, until my doorbell is again in failure mode (blinking green), … and if it’s not bliking, that means my code is working.

Or may be i can add something into the automation to know right now, any suggestion ?

When I said

I was speaking of this…

Like I said, i don’t have any feedback on the doorbell because it’s already fixed.
And there is not return state from the script.
I hope it’s clearer now.