External ESPHome component
device/device.yaml registers an external_components source pointing at this repository:
yaml
external_components:
- source:
type: git
url: https://github.com/jtenniswood/espcontrol
ref: main
path: components
components: [espcontrol]
refresh: 0s
espcontrol:Python layer
components/espcontrol/__init__.py currently defines an empty CONFIG_SCHEMA and to_code — the package is present so ESPHome accepts the espcontrol: key and can link C++ headers.
C++ / headers
components/espcontrol/sun_calc.h provides:
TzCoordtable — representative lat/lon for each IANA timezone option matchingClock: Timezoneinaddon/time.yamllookup_tz_coords— resolve coordinates for a timezone id stringcalc_sunrise_sunset— astronomical sunrise/sunset for a calendar date and position (used byaddon/backlight_schedule.yamllambdas)
This keeps sunrise/sunset and day/night brightness on-device without calling external APIs.
Related
- Backlight schedule — how computed times drive brightness