DUDU-Meng thanks for responding! To your point: The logic also becomes wrong if I manually turn the lights on/off. In fact that's how I did it in the video (switched lights on/off constantly, dimming logic first correct then gets wrong). The problem with the automatic light is only that it switches more often (daytime when passing tunnels etc). As mentioned, the logic is correct after a reboot and only gets wrong after a time and various light switching events. So in practice you see it sooner with automatic lights because they switch more often than you would manually. But once the logic is wrong the dimming misbehaves irrespective of whether I switch lights manually or automatically. Looks a bit like something gets out of sync. Sometimes it cures the logic again but after more events it's wrong again.
On the improvement point: I know sunset exists for theme changes night/day. But I use always night (dark theme) and then the dimming is only based on headlights, I cannot select dimming depending on sunset - but I would like to get that option as an improvement because then I wouldn't care about headlight status detection.
Edit: Behaviour became worse today - dimming changed even though the lights were on all the time. So apparently system sees headlight status changes that don't actually happen. A reboot only helped to get the sync between headlights and dimming correct again but didn't prevent the error from returning. So eventually I used the reset pin. After resetting and rebooting, the behaviour seems fixed - at least it didn't occur again for a good hour of driving. So maybe something just needed a hard reset.
Nonetheless this was annoying and I would appreciate the improvement re sunset as dimming trigger.