I have a simple rule in rule machine that detects when a virtual switch is turned on (by alexa) that waits twenty minutes then sets the mode to night (that separately triggers loads of things to turn off)
It works perfectly, except if you trigger it just after midnight, when you don't get twenty minutes.
Is it to do with the time being measured not in absolute but using relative to the day time?
Is the switch used in any other rules? You can check this by looking at the In Use By section at the bottom of the Device page. I am wondering if anything else may be affecting the state of the switch around midnight. From the Device page you could also check the Events for the device, available from a button at the top of the Device page for the Virtual Switch.
For the rule switch on all logging (events, triggers, actions). Post a screenshot of the logs filtered to the rule when triggered after midnight (IE when it omits the 20 minute 'and stays' part of the rule)