Hi all ![]()
I've been building MoLight, a HACS custom integration that lets you get occupancy-, daylight-, and schedule-aware lighting without writing a single automation. Instead of YAML, you wrap your real sensors and lights in virtual building blocks and wire them together entirely from the UI.
The problem it solves
Hand-writing "turn the lights off a while after the room empties" automations starts simple and gets ugly fast once you deal with the real world:
- motion sensors with different hold timeouts
- sensors that are great at triggering occupancy but bad at maintaining it (mmWave, I'm looking at you), or vice-versa
- schedules that mix fixed times and sun events
- Home Assistant restarts landing in the middle of a countdown
- a sensor dropping to
unavailableat the worst possible moment
MoLight folds all of that into a small set of reusable, composable entities.
The building blocks
Each is its own config entry β create as many as you like:
| Entity | What it does |
|---|---|
| Virtual Occupancy Sensor | Wraps one motion/presence sensor; estimates when the person actually left |
| Virtual Combined Occupancy Sensor | Merges several occupancy sensors with trigger/maintain roles |
| Virtual Illuminance Sensor | Turns a lux reading into a steady bright/dark signal (with hysteresis) |
| Virtual Schedule Sensor | On inside time windows defined by fixed times and/or sun events |
| Virtual Light | Controls N real lights with an occupancy/illuminance/schedule-aware state machine |
Sensors are reusable β one occupancy or illuminance sensor can feed many lights. You use the virtual light in your dashboards and voice assistants instead of the real ones.
Some things it handles that I'm happy with
- Countdowns anchor to when the person actually left, not the moment a sensor happens to clear β each sensor's own hold time is respected.
- False-detection filtering β a fly or a heat blip is classified and won't cut short lights you turned on by hand, but it can let auto-lit lights turn off quickly.
- Manual control is never gated. You can always turn a light on, even when it's bright or outside a schedule window.
- Follow-mode schedules give porch-light behavior (on at window start, off at window end) while respecting manual overrides mid-window.
- Optional blink/dim warning before an automatic turn-off, plus a grace period to re-trigger β instead of a room suddenly going dark.
- Keep-on holds β every virtual light gets a companion Auto-off switch, and any on/off entity (e.g.
input_boolean.guest_mode) can suspend automatic turn-offs for guest mode / movie night. - Restarts and unavailable sources are handled everywhere β missed schedule boundaries are applied exactly once, sensor blips are never misread as state changes, and a dead motion sensor can't hold the lights on forever.
Everything is local_push, no cloud, no polling β schedule transitions fire on the exact boundary. And all of the behavior above is covered by an automated test suite.
Bulk setup
If you've got a lot of rooms, there are Discover⦠actions that scan your existing entities and bulk-create virtual wrappers, plus an Assign a sensor to several lights flow that wires one shared sensor into many lights in a single pass.
Install
It's a HACS custom repository:
- HACS β add
https://github.com/jharris4/molightas a custom repository (type: Integration) - Install MoLight, restart HA
- Settings β Devices & Services β Add Integration β MoLight
Everything after that is configured from the UI β no YAML.
Repo / full docs: GitHub - jharris4/molight: Smart Virtual Light Control Entities for Home Assistant Β· GitHub
This is a fairly new project (currently v1.3.0), so I'd really value feedback, bug reports, and ideas β especially edge cases around weird sensors and restart timing. Happy to answer questions in this thread. ![]()