Commit Graph
20 Commits
Author SHA1 Message Date
Matt Spencer 9e7d0d7d1f Merge branch 'main' into ab_update 2026-11-29 00:38:36 +00:00
Matt SpencerandCopilot c92adaed01 docs: license the project under the MIT License
Add the LICENSE file, declare the license in Cargo.toml, and say so in the
README. The Zigbee stack in vendor/zigbee-rs is a separate project and keeps
its own licenses (MIT or Apache-2.0).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-29 00:38:36 +00:00
Matt SpencerandCopilot 9ea25c3aab feat: add A/B firmware slots
Split the single app partition into two slots, ota_0 and ota_1, with an
otadata partition that tells the bootloader which to run, so an update can
be written to the idle slot while the other keeps running. The Zigbee
storage partition is unchanged, so the light keeps its network. Moving from
the old table needs one USB flash.

* src/ota.rs logs the running slot and the state of its image at boot,
  marks an image valid after it has stayed up for 20 seconds, and can
  switch to the other slot and restart. The slot in use is read from the
  flash mapping, not from otadata.
* src/flash.rs shares the one flash handle: esp-storage allows only one, and
  both the Zigbee stack and the update code need it.
* The runner clears otadata on every USB flash. A USB flash always writes
  slot 0, so without this a board that had switched to slot 1 would keep
  booting the old image.
* Two development features, ota-test and ota-test-crash, exercise slot
  switching and an unconfirmed image without an update source. FW_LABEL tells
  builds apart in the log.

Tested on the hardware: switching between two images across six reboots, each
booting the slot it had just selected, resuming its Zigbee network, and
confirming itself. Rollback is not available: the bootloader espflash installs
is not built with it, so a newly selected image reports "New" rather than
"PendingVerify", and an image that resets without confirming itself is booted
again indefinitely. Needs a rollback-enabled bootloader. Nothing delivers
updates yet. Both are recorded in TODO.md.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-29 00:32:40 +00:00
Matt SpencerandCopilot 2f5f457ffc docs: add a TODO of the known open work
Record what is known to be open but not being worked on: the Zigbee stack
forgetting its network after a short coordinator outage, the hardcoded
network ID and channel, state not kept across reboots, the upstream zigbee-rs
PRs and the spec questions to raise in them, what has not been tried on the
hardware, and some housekeeping.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-29 00:32:10 +00:00
Matt SpencerandCopilot 575cd8896f feat: add a button gesture to return to pairing mode
A light that has a network only ever rejoins that one, so there was no way
to re-pair it or move it to another coordinator without reflashing.

Holding the encoder button for 10 seconds now makes the light flash green
twice, forget its Zigbee network (saved to flash) and restart, after which
it looks for a network with an open pairing window, in ZHA with Add device.
The coordinator is not told, so Home Assistant keeps the device and
recognises it by its IEEE address when it joins again.

While the light is looking for a network the on-board LED blinks fast
instead of once a second, so a waiting pairing window can be seen to be
picked up, and the change between joined and searching is logged.

The README documents the gesture and how pairing works, and notes that the
extended PAN ID is broadcast by the network and is not a secret.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-28 23:26:29 +00:00
Matt SpencerandCopilot 90af6197c6 docs: add a README
Describe what the project is, the hardware and controls, how to build and
flash it from source, how to join a Zigbee network, and how to install the
ZHA quirk for the effects cluster.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-28 22:33:38 +00:00
Matt SpencerandCopilot 115f245484 feat: add light effects driven over Zigbee
Add animated effects to the light, controlled from Home Assistant.

* Identify Trigger Effect (ZCL 3.5.2.3.3): the light plays Blink, Breathe,
  Okay and Channel change as overlays on its current state, and returns to
  exactly what it was showing (src/effect.rs). Home Assistant's flash
  option uses this.
* Scenes: Rainbow, Pulse and Comet run continuously and use the light's own
  colour and brightness, so on/off, level and colour keep working while one
  plays (src/scene.rs). The strip is redrawn every 20 ms while anything
  animates.
* A manufacturer-specific effects cluster (0xfd00) selects the scene and
  tunes its speed and intensity (src/effects_cluster.rs). It uses 0xc0de as
  a development manufacturer code, which is also what the node descriptor
  now reports instead of the NXP code it had borrowed.
* A ZHA quirk exposes the cluster as a select and two number entities
  (ha/zha_quirks/smart_light.py). Copy it to a folder set as ZHA's
  custom_quirks_path.
* Ignore Python bytecode.

vendor/zigbee-rs is not vendored here: it stays a submodule, now tracking
feature/lighting-effects-integration on the fork. That branch adds the
manufacturer-specific cluster support and Identify Trigger Effect on top of
the RGB colour control work, each of which is also on its own branch for
upstream.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-28 22:22:08 +00:00
Matt SpencerandCopilot cb4b38fc01 chore: rebase zigbee-rs integration onto upstream main
The level and color temperature work was merged upstream, so the RGB
integration branch now sits directly on main. Track that branch.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-23 15:48:04 +00:00
Matt Spencer e8e7d78714 chore: update zigbee-rs RGB integration 2026-11-17 23:47:57 +00:00
Matt Spencer 3e5ef7570f feat: add RGB color picker support 2026-11-17 23:26:50 +00:00
Matt Spencer f7f97e8685 chore: track lighting integration branch 2026-11-16 00:45:33 +00:00
Matt Spencer 65f951b890 feat: add Zigbee brightness and color temperature 2026-11-16 00:33:54 +00:00
Matt Spencer 1aa6ba3c5f feat: add Zigbee-controlled smart light 2026-11-15 23:22:20 +00:00
Matt Spencer 9793bc62af feat(encoder): trigger on B and sample A
Waiting on both phases via select drops the pending future each time the
other fires, so B's edges were being lost and a later sample of B always
read it back at rest. Triggering on B's falling edge and sampling A there
is stable on this encoder.

Also moves the encoder to D10/D9/D8 next to the power pads, drops the
strip to a single LED for bring-up, and makes saturation an adjustable
axis so the light defaults to white.
2026-10-17 18:22:09 +01:00
Matt Spencer b0e3b6f4a0 fix(flash): give zigbee persistence its own partition
The default espflash layout hands the whole 0x10000..0x400000 span to the
app partition, so the storage range sat inside it. Shrink the app and
reserve a dedicated storage partition above it.
2026-10-17 16:13:47 +01:00
Matt Spencer 74b3a4a06b feat(status): blink the on-board LED as a heartbeat
Also moves the encoder and button onto XIAO ESP32C6 pads: GPIO4/5/6 are
JTAG pins and are not broken out on this board.
2026-10-17 16:08:30 +01:00
Matt Spencer ebc2f3be7a feat(led): use the published esp-hal-smartled driver
Moves the whole esp stack to esp-hal 1.2 (see the zigbee-rs submodule),
which lets esp-hal-smartled 0.18 be used unmodified from crates.io
instead of a hand-rolled RMT driver.
2026-10-17 15:58:22 +01:00
Matt Spencer 1ec7408f8e checkpoint: vendored esp-hal-smartled with widened esp-hal bound 2026-10-17 15:49:50 +01:00
Matt Spencer e021ab751a refactor(led): drive the strip through the smart-leds traits
Replaces the hand-rolled Rgb type, HSV conversion and brightness scaling
with RGB8, hsv2rgb, gamma and brightness from smart-leds, and exposes the
driver as SmartLedsWriteAsync. The RMT symbol encoding stays in-tree: no
upstream RMT driver currently targets esp-hal 1.1.
2026-10-17 15:42:13 +01:00
Matt Spencer bb81182daa feat: bootstrap esp32-c6 embassy lighting controller 2026-10-17 15:21:58 +01:00