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>
This commit is contained in:
Matt SpencerandCopilot committed 2026-11-28 22:22:08 +00:00
1 parent cb4b38fc01
commit 115f245484
10 files changed
+665 -13

No files matched your search

+27 -4
View File
@@ -28,6 +28,7 @@ use zigbee::zdo::descriptor::PowerDescriptorConfig;
use zigbee_cluster_library::clusters::general::basic;
use zigbee_cluster_library::clusters::general::basic::BasicServer;
use zigbee_cluster_library::clusters::general::identify;
use zigbee_cluster_library::clusters::general::identify::Effect;
use zigbee_cluster_library::clusters::general::identify::IdentifyServer;
use zigbee_cluster_library::clusters::general::on_off;
use zigbee_cluster_library::clusters::general::on_off::OnOffServer;
@@ -53,6 +54,8 @@ use zigbee_mac::esp::EspMlme;
use zigbee_types::IeeeAddress;
use zigbee_types::ShortAddress;
use crate::effects_cluster;
use crate::effects_cluster::EffectsServer;
use crate::light;
/// Flash region reserved for Zigbee persistence.
@@ -78,12 +81,13 @@ const LIGHT_ENDPOINT: u8 = 1;
/// (bit 2), and rx-on-when-idle (bit 3); bit 1 stays clear for an end device.
const CAPABILITY: u8 = 0x8c;
static INPUT_CLUSTERS: [u16; 5] = [
static INPUT_CLUSTERS: [u16; 6] = [
basic::CLUSTER_ID,
identify::CLUSTER_ID,
on_off::CLUSTER_ID,
level_control::CLUSTER_ID,
color_control::CLUSTER_ID,
effects_cluster::CLUSTER_ID,
];
static OUTPUT_CLUSTERS: [u16; 0] = [];
@@ -117,6 +121,7 @@ static LEVEL_CONTROL: LevelControlServer<'static> =
LevelControlServer::new(128).with_reporting(&REPORTING);
static COLOR_CONTROL: ColorControlServer<'static> =
ColorControlServer::new(370).with_reporting(&REPORTING);
static EFFECTS: EffectsServer = EffectsServer;
type ZigbeeFlash = zigbee::storage::FlashStorage<BlockingAsync<FlashStorage<'static>>>;
@@ -131,7 +136,10 @@ type Handler = (
&'static OnOffServer<'static>,
(
&'static LevelControlServer<'static>,
(&'static ColorControlServer<'static>, UnsupportedClusterResponder<'static>),
(
&'static ColorControlServer<'static>,
(&'static EffectsServer, UnsupportedClusterResponder<'static>),
),
),
),
),
@@ -150,7 +158,10 @@ pub fn handler() -> Handler {
&LEVEL_CONTROL,
(
&COLOR_CONTROL,
UnsupportedClusterResponder::new(&INPUT_CLUSTERS),
(
&EFFECTS,
UnsupportedClusterResponder::new(&INPUT_CLUSTERS),
),
),
),
),
@@ -176,7 +187,7 @@ pub fn config() -> StackConfig<'static> {
node: NodeDescriptorConfig {
// bit 3: 2400 MHz band
frequency_band: 0x08,
manufacturer_code: 0x1037,
manufacturer_code: effects_cluster::MANUFACTURER_CODE,
maximum_buffer_size: 80,
maximum_incoming_transfer_size: 128,
server_mask: 0,
@@ -275,6 +286,18 @@ pub async fn lighting_task(stack: &'static Stack) {
loop {
Timer::after(Duration::from_millis(50)).await;
if let Some(effect) = IDENTIFY.take_effect() {
log::info!("Zigbee Trigger Effect: {effect:?}");
match effect {
Effect::Blink => light::play_effect(light::Effect::Blink),
Effect::Breathe => light::play_effect(light::Effect::Breathe),
Effect::Okay => light::play_effect(light::Effect::Okay),
Effect::ChannelChange => light::play_effect(light::Effect::ChannelChange),
Effect::FinishEffect => light::finish_effect(),
Effect::StopEffect => light::stop_effect(),
}
}
if let Some(on) = LEVEL_CONTROL.take_on_off_change() {
ON_OFF.set_on_off(on);
}