Ecosystem-agnostic smart home lighting automation using Matter protocol
Project description
Home Lighting Programmer
Ecosystem-agnostic smart home lighting automation using the Matter protocol. Replaces physical switches with sensor-driven control and supports circadian rhythm alignment through dynamic color temperature and brightness scheduling.
Note: For domestic use only. Not hardened for production/commercial deployment.
How It Works
The system runs a 1Hz loop that:
- Reads real-time sensor data (motion/presence) via Server-Sent Events
- Interpolates the configured schedule to determine target brightness and color temperature
- Sends commands only when the target state changes
Three lighting modes are supported:
- Decoration - Static color and intensity
- Utility - Sensor-triggered, low-latency response
- Ambient - Time-based color temperature and brightness that follows natural daylight
Requirements
- Python 3
- A running
matter-web-controllerinstance - Matter-compatible lights and sensors
Installation
pip install light-programmer
Quick Start
# Step 1: Auto-generate config from your hardware
light-genconfig --ip 192.168.1.220 --port 8080 --out config.json
# Step 2: Edit config.json to customize schedules and sensor logic
# Step 3: Run
light-programmer --server 192.168.1.220:8080 --config config.json
Configuration
Each device entry in the config JSON has:
{
"id": "dev_kitchen_sink", // Matter node ID
"note": "Sink area light", // Human-readable description
"schedule": [ // Time-based control points
{ "time": "06:30", "level": 50, "kelvin": 4000 },
{ "time": "12:00", "level": 100, "kelvin": 4000 },
{ "time": "21:30", "level": 100, "kelvin": 2700 }
],
"sensor": [ // Simple sensor trigger
{ "id": "kitchen_motion", "timeout": 5 }
]
}
level: Brightness 0-100%kelvin: Color temperature 2700-6500K (omit for non-color lights)timeout: Seconds to keep light on after sensor clears- Values between schedule points are linearly interpolated
See sample.json for a full working example.
Advanced Sensor Logic
For complex scenarios, use sensor_condition instead of sensor. It supports a tree of boolean operators:
| Node Type | Description |
|---|---|
sensor |
true if occupied or within timeout |
time_window |
true if current time is between start and end (cross-midnight supported) |
AND |
All operands must be true |
OR |
At least one operand must be true |
NOT |
Inverts its operand |
Example: Light on only when at desk AND not in bed
{
"sensor_condition": {
"operator": "AND",
"operands": [
{ "type": "sensor", "id": "desk_presence", "timeout": 15 },
{
"operator": "NOT",
"operands": [
{ "type": "sensor", "id": "bed_presence", "timeout": 5 }
]
}
]
}
}
Example: Follow schedule during day, sensor-only at night
{
"sensor_condition": {
"operator": "OR",
"operands": [
{ "type": "time_window", "start": "06:00", "end": "22:00" },
{ "type": "sensor", "id": "room_motion", "timeout": 5 }
]
}
}
During 06:00-22:00 the light follows its schedule regardless of sensors. Outside that window, it only turns on when the sensor detects motion.
Project Structure
| File | Purpose |
|---|---|
light_programmer/programmer.py |
Main automation controller - runs the 1Hz loop |
light_programmer/matter_lib.py |
Device abstraction layer (lights, sensors, controller) |
light_programmer/genconfig.py |
Generates config JSON from hardware discovery |
sample.json |
Example configuration with 11 devices |
pyproject.toml |
Package configuration and CLI entry points |
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file light_programmer-0.1.0.tar.gz.
File metadata
- Download URL: light_programmer-0.1.0.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae3f48c4d7c86b3ee2202bbaf0f549efa17253cce5b032d623f431b16de41abc
|
|
| MD5 |
7d6fa08f48628885d7d4fb21acec7ec3
|
|
| BLAKE2b-256 |
52676967da226dcdc049bb2ac817c397e6d2565cf36fcc509b9aa0f7458a7247
|
Provenance
The following attestation bundles were made for light_programmer-0.1.0.tar.gz:
Publisher:
python-publish.yml on dongnh/light_programmer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
light_programmer-0.1.0.tar.gz -
Subject digest:
ae3f48c4d7c86b3ee2202bbaf0f549efa17253cce5b032d623f431b16de41abc - Sigstore transparency entry: 1155032007
- Sigstore integration time:
-
Permalink:
dongnh/light_programmer@202fb096f0192aefade4fd54605db744babe6744 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/dongnh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@202fb096f0192aefade4fd54605db744babe6744 -
Trigger Event:
release
-
Statement type:
File details
Details for the file light_programmer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: light_programmer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5e0659f3a01de07335cf3780b3703ee1e2e85b8a2099ef85a37037108f7d962
|
|
| MD5 |
aa118a4c0eb3e0fa003b35f6c56e1c10
|
|
| BLAKE2b-256 |
c702d67a51e2a442b429d0a37a6cac2de7634a8402acab38094ce515984a536a
|
Provenance
The following attestation bundles were made for light_programmer-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on dongnh/light_programmer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
light_programmer-0.1.0-py3-none-any.whl -
Subject digest:
d5e0659f3a01de07335cf3780b3703ee1e2e85b8a2099ef85a37037108f7d962 - Sigstore transparency entry: 1155032009
- Sigstore integration time:
-
Permalink:
dongnh/light_programmer@202fb096f0192aefade4fd54605db744babe6744 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/dongnh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@202fb096f0192aefade4fd54605db744babe6744 -
Trigger Event:
release
-
Statement type: