Skip to content

Development Notes

djmattyb206 edited this page Feb 4, 2026 · 2 revisions

Project structure

TrimlightHomeAssistant/
  custom_components/trimlight/
    __init__.py
    api.py
    coordinator.py
    light.py
    select.py
    button.py
    config_flow.py
    const.py
    strings.json
    translations/en.json

API details

Base URL: https://trimlight.ledhue.com/trimlight

Authentication

Trimlight uses HMAC auth: authorization = base64(HMAC_SHA256("Trimlight|<client_id>|<timestamp_ms>", client_secret))

Headers: authorization: S-ClientId: <client_id> S-Timestamp: <timestamp_ms> Content-Type: application/json

Endpoints used

  • List devices

    • GET /v1/oauth/resources/devices?page=0
    • Fallback: POST with JSON body { "page": 0 }
  • Get device details

    • POST /v1/oauth/resources/device/get
    • Requires currentDate payload
  • Update switch state

    • POST /v1/oauth/resources/device/update
    • Payload: {"deviceId": "...", "payload": {"switchState": 1}}
  • Preview built‑in

    • POST /v1/oauth/resources/device/effect/preview
    • Payload includes category=0, mode, speed, brightness
  • Run preset

    • POST /v1/oauth/resources/device/effect/view
    • Payload includes id

Date payload format

{ "year": YY, // year - 2000 "month": M, "day": D, "weekday": 1..7, // Sunday=1 "hours": H, "minutes": M, "seconds": S }

Caching

  • Built‑in presets cached once.
  • Custom presets cached in HA storage.
  • Human‑readable cache stored in HA config folder.

Testing

Recommended:

  • HACS validation
  • hassfest