[RELEASE] Advanced Motion Lighting - The Ultimate Lighting Engine

Hey everyone,

I’m incredibly excited to share my latest release with the community: Advanced Motion Lighting.

This is a comprehensive, commercial-grade Parent/Child application designed to be the absolute last motion lighting app you will ever need. It takes standard motion lighting and injects it with predictive ROI telemetry, deep override logic, Zigbee/Z-Wave mesh protection, and highly granular mode controls.

Here is a deep dive into everything this engine can do.

Parent App Features (Global Control)

  • Global System Dashboard: The parent app features a live HTML dashboard that aggregates all of your child zones. At a glance, you can see the zone name, current light state (including live dim levels and color temperatures), active sensors, current action (Occupied, Counting Down, Motion Ignored), and exactly how much time is left on every active timer across your house.
  • Master System Control: A single virtual switch allows you to pause all motion lighting globally across your entire home.
  • Arrival Lighting Strategy: Trigger a staggered turn-on of your home's lights when you arrive. It intelligently ties into your window shades and a virtual "Overcast" switch, ensuring you aren't blinded by lights if the sun is already shining. Turn-on commands are delayed by a configurable stagger to protect your mesh network from data storms.
  • System Maintenance & Recovery (Global Sweep): If a missed mesh event leaves lights stuck ON, you can trigger a "Global Sweep" to force every inactive room to turn off. This applies a random stagger (500ms to 5000ms) to each zone to ensure the network isn't flooded with simultaneous commands.

Child App Features (Zone Rules)

  • Live Zone Dashboard & ROI Telemetry: Every child app has its own mini-dashboard displaying active overrides (Nap Locks, Manual Timeouts), live countdown timers, and current room Lux levels. Best of all, if you enter your bulb wattage and electricity rate, it calculates your Predictive ROI, showing you exactly how much money the automation has saved you today and over its lifetime!
  • Smart Bulb Relay Protection: If you use smart bulbs powered by a smart switch/relay, the app handles this natively. It will turn on the physical relay first, wait for a configurable boot delay (e.g., 1500ms) to let the bulbs connect to the mesh, and then send the level/color commands.
  • Triggers & Debounce: Supports standard motion sensors, Lux thresholds, and "Virtual Occupancy" trigger switches. You can also set a Debounce timer, requiring continuous motion for X seconds before the lights will even trigger.
  • Dynamic Hub Variables & Virtual Dimmers: Instead of static brightness or color temperatures, you can instruct a room to follow the level of a Virtual Dimmer, or track a global Hub Variable for Color Temperature. This is perfect for circadian rhythm setups!
  • Keep-Alives (Power & Switches): Keep the lights on without triggering them initially. You can use secondary motion sensors, switches (like a Virtual TV Switch), or Power Meters (e.g., "Keep lights on if the PC is pulling more than 10 Watts").
  • Advanced Restrictions: Set specific switches to disable the lights from turning ON, or disable them from turning OFF. Tie in a "Nap Lock" switch to completely freeze the room.
  • Contact Sensor Overrides: Use Contact Sensors to block lights from turning on if a window is open, unless your virtual "Overcast" switch overrides it.
  • Mesh Protection (Triple-Check Offs & Boot Recovery): To combat dropped commands on busy networks, the app verifies that the lights actually turned off. If they didn't, it retries the OFF command up to 3 times. Furthermore, if your hub reboots, the app staggers its initialization routines so your lights don't all trigger at once and crash your mesh.
  • Arrival Color Overrides: During an Arrival event, you can force Color/CT bulbs to a bright 6500K Daylight. When the arrival timer expires, they smoothly transition back to their standard mode-based color using a custom transition time.

Hubitat_Apps/Advanced_Motion_Lighting at main · ShaneAllen334/Hubitat_Apps

Open Source Disclaimer: This application is completely open-source and free to use. You are welcome to install it, edit it to fit your specific needs, or strip out any snippets of code to use in your own projects. Enjoy!

5 Likes

:rocket: Massive Update: Advanced Motion Lighting Engine (v2.0)

Just pushed a major architectural update to the Advanced Motion Lighting suite. The goal of this update was to eliminate the standard "smart home friction" (like waving your arms in a dark bathroom) and add true environmental context to the lighting logic.

Here is what’s new in the latest code:

:sparkles: New "Pro" Features Added

  • True Occupancy Lock (Door Logic): You can now assign a contact sensor (like a bathroom door) to a room. If the door is closed while the lights are on, the automation completely locks the lights in the ON state. They will not turn off, regardless of motion timeouts, until the door is opened again.
  • Active Lux Polling (Sunset Fade-In): Ever walk into a room at 4:00 PM when it's bright (so lights stay off), but stay in there reading until the sun goes down? If enabled, the app now actively polls the lux sensor while the room is occupied and will seamlessly fade the lights on when the room gets dark.
  • Warning Dim Phase: No more plunging into sudden darkness when a timer expires. You can now enable a "Warning Phase" that drops the lights to a set level (e.g., 10%) for a designated time (e.g., 30 seconds) before turning off. Moving during this phase instantly snaps them back to full brightness.
  • Lux Bypass for Open Contacts: If you use open window/shade sensors to block lights from turning on during the day, you can now assign a Lux threshold to bypass that block. If the shades are open but it's genuinely dark outside, the lights will turn on anyway.
  • Soft-Start Transition Ramping: Added configurable fade-in durations for dimmers and color bulbs so they ramp up smoothly instead of snapping to 100%.
  • Global Health & Battery Watchdog: The Parent App now features a master diagnostic table. It aggregates every motion, contact, and power sensor used across all your child zones, showing their current battery levels and last activity timestamps. It automatically flags dead or dying sensors (<25%) in red.
  • "Last Triggered By" Intelligence: The child dashboard now tells you exactly which sensor or switch was the last device to activate the zone. (An absolute lifesaver for tracking down "ghost" motion in rooms with multiple sensors).
  • Live Dashboard Refresh: Added a "Refresh Data" button straight to the child UI so you can watch zone states and timers update in real-time without having to back out and reload the page.

:hammer_and_wrench: Core Stability & Mesh Fixes

  • The "Midnight Wrap" Fix: Completely rewrote the Operational Time Window logic. The app now flawlessly handles time restrictions that span across midnight (like Sunset to Sunrise) without falsely blocking automations.
  • Mesh Race Condition Defenses: Built in a 1-second evaluation debounce for all off-commands. This allows the Zigbee/Z-Wave mesh to physically settle before the app decides if a room is empty, completely eliminating skipped timers caused by sensor latency.
  • Expanded Manual Override Protection: The physical switch debounce was expanded to 5 seconds to prevent network lag from falsely triggering a "Manual Override" state.

Hubitat_Apps/Advanced_Motion_Lighting at main · ShaneAllen334/Hubitat_Apps

What's New: Global Energy Savings & ROI Dashboard

  • Aggregated Telemetry: You no longer have to dig into each individual room's child app to see your predictive energy savings. The Parent app now automatically polls the ROI data from every single active lighting zone.
  • Live System Totals: The Parent dashboard now dynamically builds a clean table displaying "Today's Savings" and "Lifetime Savings" row-by-row for each zone. At the bottom, it tallies everything up into a live System Total. (The table also smartly hides itself if no child zones currently have telemetry enabled).
  • One-Click Global Reset: Under the "System Maintenance & Recovery" section in the Parent app, there is a new "Reset All ROI Telemetry" button. A single click broadcasts a command to wipe the slate clean across all child rules—perfect for starting fresh on a new billing cycle.

This makes tracking the actual money and power you are saving completely effortless.

Let me know what you guys think, and I'm happy to hear any feedback on expanding the telemetry capabilities even further!

Parent App:
raw.githubusercontent.com/ShaneAllen334/Hubitat_Apps/refs/heads/main/Advanced_Motion_Lighting/Advanced_Motion_Lighting _Parent.groovy

Child App:
raw.githubusercontent.com/ShaneAllen334/Hubitat_Apps/refs/heads/main/Advanced_Motion_Lighting/Advanced_Motion_Lighting_Child.groovy

1 Like

Update to the latest version. Bug fixes released.