How to get command line switch working?

for whatever reason, my Amcrest ad410 keeps switching from h265 to h264 every 15 hours. the good news is that i can set it via HTTP GET. with this…http://192.168.1.112/cgi-bin/configManager.cgi?action=setConfig&Encode[1].MainFormat[0].Video.Compression=h.264

now, how to automate that every 15 hours via HA?
with some googling, i tried this but it’s not working:


switch:
  - platform: command_line
    switches:
      doorbell_encoder:
        friendly_name: doorbell encode
        command_on: switch_command on 264
        command_off: switch_command off 264
        command_state: "/usr/bin/curl --digest -u admin:pass123 -X GET http://192.168.1.112/cgi-bin/configManager.cgi?action=setConfig&Encode[1].MainFormat[0].Video.Compression=h.264"	

I would think you should use the Shell Command integration instead of the Command line Switch integration. It’s designed to register a service that can be called from a script or automation. Then you can create an automation that runs every 15 hours (or maybe every 12, which would probably be simpler) that calls that service.

EDIT:

In theory you should be able to also use the RESTful Command integration, but it doesn’t support digest authentication. :slightly_frowning_face:

how would it be set up in config file to run this command?
"http://admin:[email protected]/cgi-bin/configManager.cgi?action=setConfig&Encode[0].MainFormat[0].Video.Compression=H.264
"

i also tried this but it failed.

shell_command:
  change_h264: curl http://admin:[email protected]/cgi-bin/configManager.cgi?action=setConfig&Encode[0].MainFormat[0].Video.Compression=H.264

if i open a browswer and paste the url in, it works fine though off course.

I do not remember why or where I got it from but all of my Amcrest curl commands start like this:

'curl -s --digest -u username:password "http://192.168.1.108/cgi-bin/etc…”'
command_name: 'curl -s --digest -u username:password "http://192.168.1.108/cgi-bin/split.cgi?action=setMode&channel=0&mode=split4&group=0"'

i just tried using your syntax with my credentials into the config file:

shell_command:
  cam264: 'curl -s --digest -u admin:pass123 "http://192.168.1.112/cgi-bin/configManager.cgi?action=setConfig&Encode[0].MainFormat[0].Video.Compression=H.264"'

upon calling the service,


i got this error in Core log:
2022-07-16 21:35:31 ERROR (MainThread) [homeassistant.components.shell_command] Error running command: curl -s --digest -u admin:pass123 "http://192.168.1.112/cgi-bin/configManager.cgi?action=setConfig&Encode[0].MainFormat[0].Video.Compression=H.264", return code: 3
NoneType: None

Can you get into your HA command line as HA user and test manually? That will usually give you a better idea what is going on.

Also that whole command part needs to be wrapped in single quotes. And it doesn’t look like it is

Should be:


command: 'curl -s --digest -u admin:pass123 "http://192.168.1.112/cgi-bin/configManager.cgi?action=setConfig&Encode[0].MainFormat[0].Video.Compression=H.264"'

i tried your code via HA’s terminal and it did not work. also tried Developer’s tab and same issue.
i think it has something to do with the beginning part of “curl -s --digest -u”
i really appreciate your time and help in figuring this out. thank you!

What did it say when you did in HA terminal? That should have gave you more info

i combed through all of the amcrest digest posts and played with all the possible combinations.
happy to say this works in order to set the amcrest doorbell 410 to encode in h264

command264: 'curl -g --digest -u admin:pass123 "http://192.168.1.112/cgi-bin/configManager.cgi?action=setConfig&Encode[0].MainFormat[0].Video.Compression=H.264"'

now, onto figuring out how to get HA to execute it every 15 hours. lol

‘’’
Hi,
I have the same problem, I just can not understand how to get the symbol to change and stay in the state on/off.
Using the tool in “Developer Tool” and set state to on/off works fine, but how can I do this from within the command_line action.
As I understand the command_line->command_on/off “takes” the event that should do the actual state shift on the entity. Normally it would be easy just to drop a new event or just call a default facility but here it seems just not work. Would be most thankful if anyone could help me out.
Regards,
Eric
‘’’