How bp974/xiao-nrf52840-zigbee-button works
This repository is firmware for a battery-powered, sleepy Zigbee button remote, with companion Zigbee2MQTT and Home Assistant integrations. The main workflow is physical button input → asynchronous gesture recognition → Zigbee command transmission → coordinator-side action conversion. A separate battery workflow samples voltage, updates Zigbee attributes, and exposes exact voltage in Zigbee2MQTT. The graph also preserves the documented single/three-button variants and automation blueprints. Source excerpts establish firmware calls; README statements support integration links where the companion runtime is external or unsampled.
Main entry points: main.c Application startup · zigbee_actions.c Zigbee actions · buttons.c Gesture detection · zb_button_remote.h Zigbee endpoints
Components 15
Button firmware
- Button GPIO
src/buttons.c - Gesture detection
src/buttons.c
Zigbee device
- Application startup
src/main.c - Zigbee actions
src/zigbee_actions.c - Zigbee endpoints
include/zb_button_remote.h - Zigbee stack
Battery reporting
- Voltage sampling
src/battery.c - Battery attributes
src/battery.c
Home integrations
- Zigbee2MQTT converter
zigbee2mqtt/broskie_zigbee_button.mjs - Single-button blueprint
home-assistant/blueprints/broskie-zigbee-button.yaml - Three-button blueprint
home-assistant/blueprints/broskie-zigbee-3button.yaml
Other components
- Button user
- Zigbee coordinator
- Zigbee2MQTT
- Home Assistant
Connections 18
- Button user → Button GPIO: presses
README.md - Button GPIO → Gesture detection: signals changes
src/buttons.c - Application startup → Gesture detection: initializes
src/main.c - Gesture detection → Zigbee actions: dispatches gestures
- Zigbee actions → Zigbee stack: schedules commands
src/zigbee_actions.c - Zigbee actions → Zigbee coordinator: sends cluster commands
src/zigbee_actions.c - Application startup → Zigbee endpoints: registers endpoints
src/main.c - Application startup → Zigbee stack: enables sleepy operation
src/main.c - Zigbee stack → Zigbee coordinator: joins network
README.md - Application startup → Voltage sampling: initializes and starts
src/main.c - Voltage sampling → Battery attributes: updates attributes
src/battery.c - Battery attributes → Zigbee endpoints: publishes voltage
src/battery.c - Zigbee endpoints → Zigbee2MQTT converter: reports Zigbee attributes
README.md - Zigbee coordinator → Zigbee2MQTT: delivers commands
README.md - Zigbee2MQTT → Zigbee2MQTT converter: loads converter
README.md - Zigbee2MQTT converter → Home Assistant: exposes actions and voltage
zigbee2mqtt/broskie_zigbee_button.mjs - Single-button blueprint → Home Assistant: configures automation
README.md - Three-button blueprint → Home Assistant: configures automation
README.md