GigiDuru
(Gigi Duru)
1
Hi, I created this sensor in configuration.yaml which is fine but how to move credentials from that line?
command_line:
- switch:
name: YouTube Samsung TV
command_on: >
curl -X POST -H "content-Type:application/json" -s -u ag_username:ag_password adguard.domain.name/control/clients/update -d '{"name":"Samsung TV","data":{"name":"Samsung TV","ids":["192.168.5.125"],"tags":["device_tv"],"upstreams":[],"use_global_blocked_services":true,"use_global_settings":true}}'
command_off: >
curl -X POST -H "content-Type:application/json" -s -u ag_username:ag_password adguard.domain.name/control/clients/update -d '{"name":"Samsung TV","data":{"name":"Samsung TV","ids":["192.168.5.125"],"tags":["device_tv"],"upstreams":[],"use_global_blocked_services":false,"use_global_settings":true,"blocked_services":["youtube"]}}'
I tried to use “!secret ag_credentials” instead of “ag_username:ag_password” but no avail.
amaximus
(Atticus Maximus)
2
You can set the whole curl command as a secret, the you’ll have:
command_on: !secret samsung_on
1 Like
GigiDuru
(Gigi Duru)
4
I tried with all line command in secrets but it’s not working.
I didn’t make it with rest, can someone help me?
Sir_Goodenough
((SG) WhatAreWeFixing.Today)
5
Hello GigiDuru,
If you add a secret, you may have to restart HA before it is pulled into core.
GigiDuru
(Gigi Duru)
6
I restarted HA, the switch is created but it’s not toggle and no error in log.
GigiDuru
(Gigi Duru)
7
Solved by adding “>” to secrets:
In configuration.yaml
command_line:
- switch:
name: YouTube Samsung TV
command_on:
!secret adguard_youtube_on
command_off:
!secret adguard_youtube_off
And in secrets.yaml
adguard_youtube_on: >
curl -X POST -H "content-Type:application/json" -s -u ag_username:ag_password adguard.domain.name/control/clients/update -d '{"name":"Samsung TV","data":{"name":"Samsung TV","ids":["192.168.5.125"],"tags":["device_tv"],"upstreams":[],"use_global_blocked_services":true,"use_global_settings":true}}'
adguard_youtube_off: >
curl -X POST -H "content-Type:application/json" -s -u ag_username:ag_password adguard.domain.name/control/clients/update -d '{"name":"Samsung TV","data":{"name":"Samsung TV","ids":["192.168.5.125"],"tags":["device_tv"],"upstreams":[],"use_global_blocked_services":false,"use_global_settings":true,"blocked_services":["youtube"]}}'