Feature request: Event when a ZHA device communicates

Open
#894 5 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
embedded-iot, python
Domain
embedded-iot

Research direction

No files or tests are named, so start by finding out whether zigpy already emits a signal for incoming device messages that ZHA could forward, and check the thread for a decision on the event's shape. The payload asks whether such a signal exists rather than specifying a change. Done means an agreed event name and payload, plus a way to emit it from received Zigbee packets.

Written by the indexing model from the issue text.

Description

Would it be possible for ZHA to expose an event whenever communication is received from a Zigbee device?

The use case is maintaining a reliable per-device last_seen timestamp and detecting devices that have stopped checking in.

Home Assistant entity timestamps are not ideal for this because a device may report the same value repeatedly without producing a meaningful entity state change. What would be useful is an event tied to actual Zigbee communication from the physical device.

For example, something conceptually like:

event_type: zha_device_activity
data:
  device_ieee: "00:11:22:33:44:55:66:77"
  device_id: "..."

The exact event name/data is not important. The main requirement would be that it fires whenever ZHA receives a valid packet/report/command from that device.

That would make it possible to build automations such as:

  • Maintain a true last_seen timestamp per ZHA device
  • Detect sleepy end devices that have stopped reporting
  • Mark devices as degraded/offline using user-defined timeouts
  • Build diagnostic dashboards without periodically polling all ZHA devices

Ideally this would represent device communication rather than only entity state changes or button-style zha_event actions.

Is there already an internal ZHA/zigpy signal that represents this which could reasonably be exposed to Home Assistant automations?

Dominant language
Python
Stars
96
Forks
84
Avg merge
2d 4h
Merged PRs (30d)
30

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from zigpy/zha

All issues in zigpy/zha

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.