Fixed day/night profile control on dual illuminator cameras (IL series)#582
Open
Trexano99 wants to merge 3 commits into
Open
Fixed day/night profile control on dual illuminator cameras (IL series)#582Trexano99 wants to merge 3 commits into
Trexano99 wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✨ 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.