Creating a Custom Automation Rule for Smart Lighting

I’ve been trying to set up a custom automation rule for my smart lighting system, and I’m running into a bit of trouble. Let me walk you through what I’m trying to achieve and where I’m getting stuck. Hopefully, someone can offer some guidance or tips!So, the goal is to have my living room lights automatically adjust based on the time of day and whether anyone is home. Specifically, I want the lights to dim to 30% brightness at sunset and turn off completely at midnight, but only if no one is in the house. If someone is still home at midnight, the lights should stay on until 2 AM, at which point they should turn off regardless.I’ve set up the basic structure of the rule using the SmartThings app, but it’s not working as expected. Here’s what I’ve done so far:1. Time Conditions: I’ve added conditions for sunset and midnight. The sunset part seems to work fine—the lights dim down at the right time. But the midnight condition isn’t triggering correctly.2. Presence Detection: I’ve linked the rule to my family’s presence sensors. The idea is that if any of our phones (which act as presence detectors) are still in the house at midnight, the lights should stay on. However, it seems like the rule isn’t recognizing the presence correctly. Sometimes the lights turn off even when someone is home, and other times they stay on indefinitely.3. Brightness Adjustment: I’ve set the brightness to 30% at sunset, which works, but I’d like to add a gradual transition instead of an abrupt change. I’m not sure how to implement that within the rule editor.4. Final Shutdown at 2 AM: This part is crucial because I don’t want the lights to stay on all night if someone is still up. But currently, the rule doesn’t account for this at all.I’ve tried troubleshooting by checking the presence sensors and ensuring they’re correctly paired with my devices. I’ve also reviewed the rule conditions multiple times, but I might be missing something. Maybe there’s a more efficient way to structure the rule or a feature I haven’t discovered yet.If anyone has experience with similar automation setups or knows how to refine this rule, I’d greatly appreciate your input! I’m excited to get this working smoothly—it would make a big difference in my daily routine and energy efficiency.