Shell command throws a URL error because of the square brackets. I tried using the --globoff command, but that doesn’t seem to send the correct command.
shell_command:
dahua_night: 'curl --globoff -X POST "http://user:[email protected]/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=1"'
I tried a restful command, but I’m getting a 401
dahua_night:
url: http://@192.168.1.108/cgi-bin/configManager.cgi
method: POST
verify_ssl: false
username: user
password: password
payload: "action=setConfig&VideoInMode[0].Config[0]=1"
A 401 Unauthorized response typically means that the device isn’t accepting your authentication. This could be for a couple of different reasons:
Your username or password is invalid, or isn’t being sent in the correct format (e.g. it expects Basic authentication but it’s being added somewhere else)
Your device is refusing to respond because Home Assistant’s origin/IP is different than your browser’s - check to see if there are any security/firewall whitelist settings on your camera.
I suspect that, under the hood, the REST component might use curl (or it may use the Python requests library, not sure), either way - it looks like it doesn’t support square brackets in the way your camera expects.
Curl’s -g flag prevents square brackets from being interpreted by curl itself, so they are passed as-is. That’s why it works.