Skip to main content

Crate dahua_camera_mqtt

Crate dahua_camera_mqtt 

Source
Expand description

MQTT publisher: events, health and capabilities.

§Topic layout

  dahua/{camera}/event/{kind}      detections, retained=false
  dahua/{camera}/health            latest verdict, retained=true
  dahua/{camera}/capability        what the device confirmed, retained=true
  dahua/{camera}/status            online/offline, retained=true + LWT

§Retain, and when not to

Health, capabilities and status are retained: a dashboard connecting ten minutes after the service started should immediately know the current state rather than waiting for the next change.

Events are not retained. A retained detection is a detection that stays true on the broker forever — a subscriber connecting tomorrow would be told about motion from yesterday as though it were happening now. That is the MQTT equivalent of the latched-alarm trap, and it is worse, because the broker keeps telling everyone.

§Last Will

The publisher registers a Last Will on status so that a subscriber can tell “the service says nothing is happening” from “the service is gone”. Without it those are indistinguishable, which — given the safety notice below — is exactly the confusion to avoid.

§⚠ Safety

Detections published here are an operator aid and are not safety-rated. Every event payload carries the notice inline. Absence of a message means nothing: no detection, a dead link, and a stopped service all look identical to a subscriber. Never drive machine motion from this feed. See SAFETY.md.

Structs§

Message
A message ready to publish.

Enums§

Qos
Delivery guarantee for a message.

Constants§

SAFETY_NOTICE
The notice carried inline in every detection payload.
TOPIC_ROOT
Root of every topic this crate publishes.

Traits§

MqttTransport
The transport under the publisher.

Functions§

capability_message
A capability message. Retained: it changes essentially never.
event_message
A detection message.
health_message
A health message. Retained: current state matters more than its history.
last_will
The Last Will message for a camera.
online
The message announcing that a camera’s publisher is live.
publish_event
Publish an event through a transport.
status_topic
The status topic for a camera, used for both liveness and the Last Will.