[RELEASE] Advanced Outdoor Security Lighting - Solar Geometry & Motion Controller

I’m excited to share a new application I've been working on: Advanced Outdoor Security Lighting. I built this to serve as an enterprise-grade exterior lighting controller that goes beyond basic sunset/sunrise rules.

If you've ever struggled with lights turning on too early on clear days, too late on overcast days, or wanted your security motion sensors to bypass your normal "Night" mode restrictions—this app is for you.

Key Features:

  • Live Environmental Dashboard: Check your system status, live solar elevation/azimuth, and exactly why a zone is currently active right from the app's main page.
  • Up to 10 Lighting Zones: Consolidate your outdoor lighting rules into one place.
  • Mathematical Solar Engine: Trigger your lights based on precise solar elevation drops (e.g., -4° for dusk) rather than just a flat offset. You can even set Azimuth filters to only trigger lights when the sun hits a certain side of your house.
  • Overcast/Weather Integration: Tie in a virtual switch (like from an overcast detector) to force lights on early when a storm rolls in.
  • Security Motion Overrides: Motion sensors can be configured to "punch through" your Mode Blacklists. For example, if your house is in "Good Night" mode and the lights are off, a motion event can still trigger the security lights to activate.
  • Mode Whitelists & Blacklists: Strict control over when zones are allowed to operate.
  • Hard OFF Scheduling: Set a specific time (like 11:00 PM) to force zones off and save energy.
  • Location Fallback: If your hub is missing its GPS coordinates, simply select your US State from the dropdown to automatically configure the solar geometry math.

raw.githubusercontent.com/ShaneAllen334/Hubitat_Apps/refs/heads/main/Advanced_Outdoor_Security_Lighting/Advanced_Outdoor_Security_Lighting.groovy

:handshake: Open Source & Free to Use

This project is completely free, open-source code. I know every smart home is unique, so please feel free to use it, tear it apart, edit the math, or adapt any part of the logic to perfectly fit your own setup. If you find a way to improve it, let me know!

Hey everyone,

I’ve been quietly overhauling my Advanced Outdoor Security Lighting app over the last few days, pushing it closer to a true Enterprise Building Management System (BMS) level. The goal was to make exterior lighting completely hands-off, ultra-reliable, and highly customizable.

We crushed some incredibly stubborn platform bugs and added a few major features that I think you’re all going to love.

:sparkles: New Features

  • Predictive "Exit" Lighting (Door Open Override): Instead of walking out the door into the dark and waiting for the outdoor sensor to catch you, the app now actively anticipates you leaving. It listens to a designated indoor motion sensor next to your door. If the door opens and it detects you were just walking inside (and no one is currently outside), it instantly fires up the exterior lights to illuminate your path. It then seamlessly hands control over to your outdoor motion sensors. If you were just peeking outside and close the door, the lights instantly shut down.
    • (Note: Includes a dedicated Mode Whitelist, so this only runs when you want it to, like in "Night" mode).
  • Live Financial ROI & Energy Savings Dashboard: Smart lighting is supposed to save us money, so I built an engine to prove it. You can now input your local electricity rate ($/kWh) and the total wattage of the bulbs in a zone. The app actively tracks the exact millisecond runtime of your lights vs. a standard 12-hour dusk-to-dawn "dumb" baseline, giving you a live dashboard showing exactly how much money the app has saved you since installation.

:hammer_and_wrench: Critical Bug Fixes & Architecture Overhauls

  • Replaced getSunriseAndSunset() with a Mathematical Solar Engine: We all know the native hub sunrise/sunset events can occasionally misfire or fail if geolocation hiccups. I completely ripped that out. The app now uses a pure mathematical solar geometry engine. If the sun's physical elevation is < 0°, it's night. Period. It is 100% bulletproof and locally calculated.
  • Mesh-Resilient "Logical State Tracking" (No more frozen Z-Wave states): If a Zooz or Inovelli switch dropped a status report packet, the hub would think a light was ON when it was physically OFF. This caused the app to politely skip sending motion-activation commands to save mesh traffic—leaving you in the dark. The app now tracks the Logical Reason for a lighting state. If the app decides a zone needs to change from "Mode Restriction" to "Motion Detected", it forces a fresh command through the mesh, completely bypassing the hub's potentially frozen hardware status.
  • Patched Hubitat Device ID Type-Casting Bug: Fixed an insidious bug where Hubitat was passing the event deviceId as a Long/Integer, but storing the configured devices as Strings. The strict it.id == evt.deviceId check was silently failing, causing the app to ignore motion events entirely. Everything is strictly cast to Strings now (it.id.toString() == evt.device.id.toString()) for flawless execution.
  • Resolved Motion Timeout Race Condition: Fixed an issue where a zone's motionActive flag wasn't explicitly clearing when a group of multiple sensors finally went quiet. This was causing lights to punch through restricted mode blacklists indefinitely. The timeout countdowns now trigger perfectly.

The code has been incredibly stable in my testing. Let me know if you run into any edge cases or have feature requests!

raw.githubusercontent.com/ShaneAllen334/Hubitat_Apps/refs/heads/main/Advanced_Outdoor_Security_Lighting/Advanced_Outdoor_Security_Lighting.groovy