Skip to content

Fixed day/night profile control on dual illuminator cameras (IL series)#582

Open
Trexano99 wants to merge 3 commits into
rroller:mainfrom
Trexano99:Fix-set-profile-mode
Open

Fixed day/night profile control on dual illuminator cameras (IL series)#582
Trexano99 wants to merge 3 commits into
rroller:mainfrom
Trexano99:Fix-set-profile-mode

Conversation

@Trexano99

Copy link
Copy Markdown

✨ Fix: Reliable day/night profile switching for Dahua dual smart light cameras (IL Series)

🚨 The Problem
On modern Dahua dual smart light cameras (IL series), dahua.set_video_profile_mode didn't hold. Forcing Day (or Night) appeared to work for a moment, then the camera would flip back on its own and keep oscillating between day and night indefinitely.

There were two root causes:

The service wrote VideoInMode[0].Config[0], which these cameras ignore, they select the active profile through the ConfigEx string, not the Config index list (which stays a static [0,1]).
Even once the profile was set, the camera was left on its automatic switch mode (Mode=2, by brightness), which reverts any forced profile within seconds.
As a side effect, the integration read the active profile from Config[0] (always 0 on these cams), so the illuminator entity always tracked the day profile.

🛠️ The Solution
Introduced async_set_video_profile_config_ex: forces the profile exactly the way the camera's own web UI does: VideoInMode.Mode=4 (manual) + VideoInMode.ConfigEx=Day/Night, so the requested profile actually sticks.
Added ConfigEx auto-detection (supports_config_ex): cameras that report ConfigEx use the new path; everything else cleanly preserves the legacy Config[0] behavior.
Fixed the read side: _profile_mode is now derived from ConfigEx on these cameras, so the illuminator state/brightness follow the correct active profile.

✅ Impact
💡 set_video_profile_mode now reliably forces Day/Night on IL series cameras with no oscillation.
🛡️ Strict backward compatibility for cameras that use the legacy Config[0] path.
🔬 Verified against a live device: Mode=2 + forced Night reverts to Day in ~8s, while Mode=4 + forced Night holds indefinitely.

📝 Documentation & Usage Note
Because the fix writes a persistent config, after calling set_video_profile_mode the camera stays in manual switch mode (Mode=4), automatic day/night switching remains off until you re-enable it from the camera's web UI. This is intended for forcing a profile from HA (e.g. to drive the illuminator) and mirrors what the camera UI's own manual toggle does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant