Lightwell / prototype / demo.py
| 1 | """No network or hardware access: two simulated lights on a local scene.""" |
| 2 | from datetime import datetime, time, timezone |
| 3 | from lightwell import Controller, LightState, Schedule, SimulatedLights |
| 4 | |
| 5 | lights = SimulatedLights("holiday", "accent") |
| 6 | controller = Controller(lights, {"holiday", "accent"}) |
| 7 | controller.add_scene("evening", { |
| 8 | "holiday": LightState(True, 55, (255, 174, 95)), |
| 9 | "accent": LightState(True, 30, (245, 209, 164)), |
| 10 | }) |
| 11 | controller.add_schedule(Schedule("after-dusk", time(18, 0), "evening")) |
| 12 | now = datetime(2026, 11, 29, 18, 0, tzinfo=timezone.utc) |
| 13 | print("Scheduled local scene:", controller.run_due(now)) |
| 14 | print("Repeated tick:", controller.run_due(now)) |
| 15 | lights.offline_devices.add("accent") |
| 16 | print("Manual request with one device unavailable:", controller.apply("evening")) |