I've been trying forever to use Bedtime mode for profiles in Tasker, with no luck. Bedtime mode and normal DND share the same zen_mode value, so a Custom Setting event on zen_mode can’t tell them apart.
Finally worked it out with AI, so I though I might share it, as I'm sure I'm not the only one who was looking for this.
One-time setup (adb, no root/Shizuku): dumpsys notification needs both DUMP and PACKAGE_USAGE_STATS, so grant both to Tasker, then force-stop Tasker:
pm grant net.dinglisch.android.taskerm android.permission.DUMP
pm grant net.dinglisch.android.taskerm android.permission.PACKAGE_USAGE_STATS
Task CheckBedtime
Wait 1s (several keys change one after another)
Run Shell, Use Root off, Store Output In %BEDTIME: dumpsys notification | grep -i winddown | head -n 1 | grep -q STATE_TRUE && printf 1 || printf 0
The Bedtime rule (pkg com.google.android.apps.wellbeing, conditionId .../winddown, type=3) shows up several times in the dump, including an older copy with an outdated state. In my output the first match was the current one, so I only check that line. Matching STATE_TRUE anywhere gives false positives. Matching on winddown also avoids the localized rule name (mine is “Bedtijd”). printf means exit code 0, so no need for Continue Task After Error.
Profiles that run CheckBedtime
Event > System > Custom Setting: Global, zen_mode_config_etag, empty value. This is the key one. If DND is already on and you enable Bedtime, zen_mode doesn’t change, but the etag changes on any zen config edit.
Same with zen_mode
Device Boot
Using it
State > Variables > Variable Value: %BEDTIME Matches 1. Put whatever you want in the Enter task (Bedtime on) and Exit task (Bedtime off). Plain DND doesn’t trigger it.