Terminal MQTT sink that publishes per-class object counts as Cumulocity SmartREST measurements. It takes [(String, UInt64)] class-name and count pairs, reports each count plus a total, and raises per-class and overall alarms when any count reaches the configured limit.
Typical backends
Crowd-size reporting from a camera feed to the broker.
Tracked safety-equipment counts published as measurements and alarms.
Caveats
- I/O contractThis is a terminal sink with no output; it publishes one measurement per class plus a total, and emits a per-class alarm and one overall violation whenever a class count reaches
count_limit.
- CompatibilityThe payloads are Cumulocity SmartREST measurements on a fixed device topic, so a generic MQTT broker will receive them but not decode them into measurements.
- Hard constraintEach class name from the input is used verbatim as the measurement type and series, so a comma or special character in a class name corrupts the SmartREST line.
- State lifetimeThe component subscribes to device control and runs a restart sequence when it receives a restart command on the shared topic, so co-locating it with other restart handlers on the same device can cause restart loops.
- FallbackA broker outage drops measurements; there is no durable queue beyond the MQTT client's own reconnection behaviour.
- State lifetimeThe broker connection and all configuration are captured once at startup; the device is registered on connect and changing any setting requires a redeploy.