IPC-T5442T-ZE CGI Profile Switching Not Working (Firmware V2.820.15OG001.0.R)

surly

n3wb
Dec 31, 2021
3
0
Canada
Hi all:

I'm working on finally getting my Home Assistant set up to control the switchover from day to night profiles on my IPC-T5442T-ZE via CGI. The camera is running firmware V2.820.15OG001.0.R (Build Date: 2021-07-06).

Digest authentication over HTTPS is working correctly (curl -k --digest), and I can query parameters like VideoInMode[0].Mode. However, attempts to switch profiles or force day/night behavior via CGI consistently return "Error! Bad Request!".

Here’s a summary of what I’ve tried:
  • VideoInMode[0].Mode=1 and =2 work (Night and Auto), but =0 fails with "Bad Request!"
  • DayNightMode[0]=Color, B/W, and Auto all return "Error"
  • switchProfile.cgi?profileName=day, night, general → "Error"
  • switchProfile.cgi?profileId=0, 1, 2 → "Error"
  • configManager.cgi?action=setConfig&Profile[0]=... → "Error"
  • getConfig&name=All confirms profiles exist: "day", "night", "general"
  • Profile management modes in UI include: General, Full Time, Schedule, Day/Night
My goal is to switch between profiles externally (e.g., "day" and "night") using automation. Is CGI-based profile switching supported on this firmware? If not, is there an alternative method (ONVIF, RPC2, etc.) that allows external control?

Thanks for any guidance you can provide. If this is working fine for you, please also let me know because then perhaps I've just made a silly mistake.
 
Just for a little extra clarity - some API elements I've found force the B&W/IR on and off. That's not what I'm looking for. I'm just looking to flip between "day", "night" and "general". Thus replacing the in-camera day/night schedule with API/CGI commands from an outside source. Within each day/night/general profile I have the manual or auto color/B&W settings that I wish to have in place for that profile. I don't wish to override the detailed settings within the profile, just set which profile is active.


2025-10-21 08_03_44-Clipboard.png


2025-10-21 08_03_59-Setting — Mozilla Firefox.png
 
Since thst is an older GUI camera, there is this utility and the commands also that some use in BI.

Thread 'Dahua day/night switch utility - DahuaSunriseSunset'
 
@wittaj 's linked thread did result in filling in the missing pieces to get this working. Thanks!

In configuration.yaml:

YAML:
shell_command:
  dahua_force_day: curl -k --digest -u "user:pass" "https://IP_ADDR/cgi-bin/configManager.cgi?action=setConfig&VideoInMode%5B0%5D.Config%5B0%5D=0"

  dahua_force_night: curl -k --digest -u "user:pass" "https://IP_ADDR/cgi-bin/configManager.cgi?action=setConfig&VideoInMode%5B0%5D.Config%5B0%5D=1"

In my case, I created a new user on camera with restricted permissions. Another good practice would be to use secrets.yaml to store the user/pass combo, but current Home Assistant revisions present some challenges there.

First you must set Profile Management to "Full Time" -> "Day". The CGI URLs above will then change which profile is selected for "Full Time", forcing it to Day or Night manually.
This presumes that you have already built profiles for DAY and NIGHT. In my NIGHT profile I have Color/BW set to automatically change, no WDR, different shutter, gain and noise settings compared to DAY.

To implement a simple "at sunset" and "at sunrise" pair of automations, which you can tweak for whatever triggers you like:

YAML:
alias: Sunset - Camera to NIGHT
description: ""
triggers:
  - trigger: sun
    event: sunset
    offset: 0
conditions: []
actions:
  - action: shell_command.dahua_force_night
mode: single


alias: Sunrise - Camera to DAY
description: ""
triggers:
  - trigger: sun
    event: sunrise
    offset: 0
conditions: []
actions:
  - action: shell_command.dahua_force_day
mode: single

As part of this exercise, I finally upgraded my firmware to the latest No SmartIR version I could find on EmpireTech's website:

Code:
System Version
V2.840.0000000.30.R, Build Date: 2025-02-27

WEB Version
V3.2.1.2192562

ONVIF Version
22.12(V3.1.0.1464287)

S/N
REDACTED

Algorithm Version
1.0.8

Security Baseline Version
V2.3

Copyright 2025, all rights reserved.



Hope this helps someone in the future.
 
I asked ChatGPT to modify bp2008's DahuaSunriseSunset utility to support new GUI cameras as well as legacy-API cameras, and I have the fix documented in this other thread.
  • It now queries
  • curl -g --digest -u '<user>:<password>' "http://<Camera-IP-Address>/cgi-bin/configManager.cgi?action=getConfig&name=VideoInMode""
and:
  • If getConfig&name=VideoInMode contains ConfigEx, use:
    • VideoInMode[...].ConfigEx=Day
    • VideoInMode[...].ConfigEx=Night
  • if it contains Config[0], use:
    • VideoInMode[...].Config[0]=0
    • VideoInMode[...].Config[0]=1
New files available in that other thread.