private@homelab: ~/latest
Home Assistant · Zigbee2MQTT · local control
private@homelab:~$ cat guides/article.md
· ·
7–10 minutes
read

Zigbee2MQTT last_seen Not Updating? What It Actually Tracks

Understand Zigbee2MQTT's last_seen timestamp, distinguish communication from fresh sensor reports, and build a Home Assistant communication-age alert.

A frozen last_seen value, an N/A label and a fresh timestamp beside an old temperature reading need different checks. Start by separating the time Zigbee2MQTT last heard from a device from the time it last received the measurement you care about.

A device can still exchange messages while one of its sensors has stopped reporting. A temperature can also remain unchanged because the room is stable. Neither a fresh timestamp nor an unchanged value proves that everything is working.

The checks below use Zigbee2MQTT’s settings, released source and original issue reports. The timestamp and Home Assistant examples run locally; a vendor cloud is not involved.

What last_seen actually is — and why it’s off by default

advanced.last_seen defaults to disable. Set it to ISO_8601, ISO_8601_local or epoch to include it in device state messages. The settings reference documents those choices. Check this first if the field is absent from MQTT; issue #9398 is an example of confusion around enabling it.

The description is the date and time of the last Zigbee message from the device. That is broader than a temperature, motion or power report. In the herdsman 10.10.0 code bundled with Zigbee2MQTT 2.14.2, the timestamp changes for network-address and IEEE-address reports, device announces, joins and received ZCL/raw payloads attributed to a known device. A ZCL response can count even when it produces no sensor-state update. This does not mean that every radio frame, acknowledgement or packet forwarded by a router updates every device’s timestamp.

Older behavior needs its own context. In the 2019 issue #1651, a maintainer added an update after a successful outbound command. Do not turn that historical fix into a promise about every command in current releases: the current controller’s update paths above, and any replies received from the device, are the relevant evidence. Merely publishing a command to MQTT does not prove delivery or a new measurement.

Why it can look current even when a device has gone quiet

Issue #23820 describes misleading timestamps and stale readings across a mixed network; #22551 contains a related complaint. These are reports of symptoms, rather than proof that powered-off devices generate traffic or that one bug explains every case.

A more useful distinction is that a device can be talking without sending the expected attribute. It might announce itself or reply to another request while temperature reporting has stalled. In #32152, a maintainer lists the timestamp’s update paths and recommends inspecting activity and debug logs. The feature request for a separate “Last Updated” field is now closed as not planned; it is not an announced upcoming feature.

Check the measurement

A recent timestamp is evidence of recent device-related communication, not proof that motion, temperature or energy reporting is healthy. This applies to battery sensors as well as powered devices. Conversely, an unchanged temperature is not evidence of a missed report: a fresh report may contain the same value.

Compare the device’s recent activity, received Zigbee messages and MQTT publications. Look for the specific cluster and attribute you expect. The Ember many-to-one route-error guide is relevant if failed deliveries accompany the missing reports, but a timestamp alone does not diagnose that routing problem.

last_seen vs. availability — two different features, often confused

last_seen records time. The separate availability feature publishes an online/offline state and adds checks for devices that can be pinged. Neither feature validates the physical measurement.

last_seen availability
Purpose Timestamp of device-related Zigbee activity Online/offline status based on check-ins and, for active devices, pings
Configuration advanced.last_seen; disabled by default Separate availability block; disabled by default
Default timing Records activity; no offline threshold of its own Active devices: 10 minutes before a check; passive devices: 25 hours without a check-in before offline
Limit Not a timestamp for each individual sensor report A responsive device can still have broken attribute reporting

The availability documentation defines a check-in as any Zigbee message from the device reaching Zigbee2MQTT, including internal updates. Active devices, typically powered devices, are pinged if they do not check in. Passive devices, typically sleeping battery devices, rely on the timeout because they cannot reliably answer a ping while asleep. Jitter, retries and backoff mean the active timeout is not an exact deadline for an offline notification.

Use availability when you want Home Assistant to mark unreachable devices unavailable. Add measurement-specific monitoring if a particular reading is important; availability uses the same broad idea of communication and cannot replace that check.

Known bugs worth knowing about before you trust either field

Old reports help identify which layer to inspect. They should not be treated as a list of confirmed defects in the latest version.

Symptom What the report established Version context
Internal last-seen time changes but MQTT remains old #7423 reported a publication gap for a TS0601 thermostat and Moes MS-104Z. Maintainer comments explicitly report fixes, including switching publication to internal last-seen events. Opened May 2021; closed as completed. Current code handles last-seen changes and messages without converted sensor payloads.
Frontend column initially shows N/A #20481 and #20513 reported that changing tabs restored the display while MQTT already contained timestamps. Zigbee2MQTT 1.35 / 1.35.0 reports; both closed as completed.
Fresh time beside a missing map link or stale reading #23820 and #22551 describe the mismatch. A missing map line alone is not an offline test. Read the original reports and compare with actual received messages on your version.
Compare each layer

Read a fresh device MQTT payload before changing Home Assistant. If MQTT has the correct time but the entity does not, check entity configuration and the consumer. If the frontend alone disagrees, investigate its display. If MQTT is stale too, inspect incoming Zigbee traffic and publication settings.

#7423, #20481 and #20513 retain that history. The current receive path also publishes for messages that produce no converted payload, with debounce/throttle behavior where configured. A stale value today needs current logs; the absence of a changelog entry would not establish that a 2021 bug survived.

Do not exclude MQTT delivery, subscriptions or permissions without checking them. The MQTT broker security checklist can help with access configuration. Historical Zigbee2MQTT bugs do not prove the broker or Home Assistant is healthy in a different installation.

Enabling it properly

ISO_8601 produces a UTC string. ISO_8601_local includes Zigbee2MQTT’s local-time offset. In the current implementation, epoch is milliseconds since the Unix epoch, not seconds; divide by 1,000 before passing it to an API expecting epoch seconds.

configuration.yaml (Zigbee2MQTT)
advanced:
  last_seen: ISO_8601_local

Merge this into your existing advanced block. Follow your version’s restart prompt, then wait for new device activity and inspect a new MQTT message. A retained message can still contain an older value. Enabling the field does not force a sleeping device to report.

Checking communication age in Home Assistant

An age check can warn when there has been no recorded communication for a chosen period. It cannot detect the opposite situation: a device whose last_seen is fresh but whose temperature reports have stopped. Keep that limitation visible when naming the alert.

Enable the diagnostic entity first

Zigbee2MQTT’s Home Assistant discovery creates a “Last seen” diagnostic sensor only when the option is enabled, and marks it disabled by default. Enable the entity on the device’s Home Assistant page and copy its actual entity ID. Confirm it contains an ISO timestamp before using this example.

configuration.yaml (Home Assistant)
template:
  - triggers:
      - trigger: homeassistant
        event: start
      - trigger: time_pattern
        minutes: "/15"
      - trigger: state
        entity_id: sensor.living_room_motion_last_seen
    binary_sensor:
      - name: "Living Room Motion Communication Stale"
        unique_id: living_room_motion_communication_stale
        device_class: problem
        state: >
          {% set seen = as_timestamp(states('sensor.living_room_motion_last_seen'), none) %}
          {{ seen is none or (as_timestamp(now()) - seen) > 6 * 3600 }}

Replace the entity ID in both places. Merge into your existing template list, rather than adding a duplicate top-level key. The example refreshes at startup, on timestamp changes and every 15 minutes. Home Assistant’s timestamp conversion returns the supplied none fallback for unknown, unavailable or malformed input, so those conditions raise the problem sensor instead of producing a date-parsing error. Valid ISO strings include timezone information and are compared as epoch seconds.

Six hours is an example, not a general sensor-health threshold. A contact sensor may legitimately stay quiet much longer; check the model’s heartbeat behavior. This template expects an ISO entity, not Zigbee2MQTT’s numeric millisecond epoch output. For missing measurement reports, inspect activity/debug logs or track receipt of the particular attribute in a separate automation; “value last changed” also misses repeated identical reports. If duplicate or orphaned entries are involved, see the ghost-device guide.

FAQ

Does last_seen mean the device is currently online? It records recent device-related communication. It is not a continuous connection test or a guarantee that every sensor function works.

Why is the timestamp fresh while a reading is old? Another message may have arrived without that attribute, the device may have reported the same value, or a downstream display may be stale. Check the specific received reports and MQTT payload before choosing a cause.

How is availability different? It applies timeouts and pings active devices. It helps detect communication loss, but does not certify the freshness of each measurement.

Why does every device show N/A? Check the disabled-by-default setting, then compare fresh MQTT data with the frontend. Enable the separate diagnostic entity if the missing display is in Home Assistant.

Can the template detect every failed sensor? No. It detects an old or unusable last-seen value. A sensor that keeps communicating while omitting its measurements needs monitoring of those measurements’ receipt.

Sources and version context

The implementation details above were checked against Zigbee2MQTT 2.14.2, its receive path, timestamp formatting and publication helpers, and the bundled herdsman controller. Home Assistant’s template documentation provides the example’s trigger structure. These are documentation and source checks, not measurements from a physical sensor test.

local-firstHome Assistantno-cloud