The mqtt integration allows Viseron to connect to an MQTT broker and publish and subscribe to topics.
It is also used to integrate with Home Assistant.
Configuration
Configuration example
mqtt:
broker: mqtt_broker.lan
port: 1883
username: !secret mqtt_user
password: !secret mqtt_pass
Topics
Viseron internally manages entities, which in turn are published to MQTT topics. Available entity domains are:
binary_sensor: Binary sensors show on/off statesimage: Images are published as JPEGssensor: Sensors show any valuestoggle: Toggles are used to switch things on or off
You can observe the logs to find the entity ids.
Binary sensor topics
{base_topic}/binary_sensor/{camera_identifier}_connected/state
Shows if Viseron is connected to a camera.
Payloads
- on
- off
{
"state": "on",
"attributes": {}
}
{
"state": "off",
"attributes": {}
}
{base_topic}/binary_sensor/{camera_identifier}_recorder/state
Shows whether the recorder is recording or not.
Payloads
- on
- off
{
"state": "off",
"attributes": {
"name": "Porch Recorder",
"domain": "binary_sensor",
"id": 33406,
"start_time": "2025-03-12T10:14:10.887491+00:00",
"start_timestamp": 1741774450.887491,
"end_time": null,
"end_timestamp": null,
"date": "2025-03-12",
"thumbnail_path": "/thumbnails/porch/33406.jpg",
"objects": [
{
"label": "person",
"confidence": 0.93,
"rel_width": 0.092,
"rel_height": 0.391,
"rel_x1": 0.761,
"rel_y1": 0.081,
"rel_x2": 0.853,
"rel_y2": 0.472
}
]
}
}
{
"state": "off",
"attributes": {
"name": "Porch Recorder",
"domain": "binary_sensor",
"id": 33406,
"start_time": "2025-03-12T10:14:10.887491+00:00",
"start_timestamp": 1741774450.887491,
"end_time": "2025-03-12T10:15:36.798942+00:00",
"end_timestamp": 1741774536.798942,
"date": "2025-03-12",
"thumbnail_path": "/thumbnails/porch/33406.jpg",
"objects": [
{
"label": "person",
"confidence": 0.93,
"rel_width": 0.092,
"rel_height": 0.391,
"rel_x1": 0.761,
"rel_y1": 0.081,
"rel_x2": 0.853,
"rel_y2": 0.472
}
]
}
}
{base_topic}/binary_sensor/{camera_identifier}_object_detected/state
A JSON formatted payload is published to this topic when any configured label is in the field of view.
Payloads
- on
- off
{
"state": "on",
"attributes": {}
}
{
"state": "off",
"attributes": {}
}
{base_topic}/binary_sensor/{camera_identifier}_object_detected_{label}/state
A JSON formatted payload is published to this topic when a specific configured label is in the field of view.
Payloads
- on
- off
{
"state": "on",
"attributes": {
"count": 2
}
}
{
"state": "off",
"attributes": {
"count": 0
}
}
{base_topic}/binary_sensor/{camera_identifier}_zone_{zone}_object_detected/state
A JSON formatted payload is published to this topic when any configured label is in the specific zone.
Payloads
- on
- off
{
"state": "on",
"attributes": {}
}
{
"state": "off",
"attributes": {}
}
{base_topic}/binary_sensor/{camera_identifier}_zone_{zone}_object_detected_{label}/state
A JSON formatted payload is published to this topic when a specific configured label is in the specific zone.
Payloads
- on
- off
{
"state": "on",
"attributes": {
"count": 2
}
}
{
"state": "off",
"attributes": {
"count": 0
}
}
{base_topic}/binary_sensor/{camera_identifier}_motion_detected/state
A JSON formatted payload is published to this topic when motion is detected.
Payloads
- on
- off
{
"state": "on",
"attributes": {}
}
{
"state": "off",
"attributes": {}
}
{base_topic}/binary_sensor/{camera_identifier}_face_detected_{person name}/state
A JSON formatted payload is published to this topic when a tracked face is detected.
Payloads
- on
- off
{
"state": "on",
"attributes": {
"camera_identifier": "<camera_identifier>",
"camera_name": "<camera name>",
"name": "<person name>",
"confidence": "<detection confidence>",
"coordinates": "<detection coordinates>"
}
}
{
"state": "off",
"attributes": {}
}
{base_topic}/binary_sensor/{camera_identifier}_still_image_available/state
A JSON formatted payload is published to this topic when still image becomes available/unavailable.
Payloads
- on
- off
{
"state": "on",
"attributes": {}
}
{
"state": "off",
"attributes": {}
}
Toggle topics
{base_topic}/toggle/{camera_identifier}_connection/command
Used for turning on/off a camera. Payload should be ON or OFF.
Payloads
- Turn on
- Turn off
ON
OFF
{base_topic}/toggle/{camera_identifier}_connection/state
Camera connection state.
Payloads
- on
- off
{
"state": "on",
"attributes": {}
}
{
"state": "off",
"attributes": {}
}
{base_topic}/toggle/{camera_identifier}_manual_recording/command
Used for starting/stopping a manual recording. Payload should be a valid JSON, ON or OFF.
Payloads
- Start recording
- Stop recording
{
"action": "start",
"duration": 120
}
or
ON
{
"action": "stop"
}
or
OFF
{base_topic}/toggle/{camera_identifier}_manual_recording/state
Manual recording state.
Payloads
- on
- off
{
"state": "on",
"attributes": {}
}
{
"state": "off",
"attributes": {}
}
Image topics
{base_topic}/image/{camera_identifier}_latest_thumbnail/image
A JPEG encoded image is published to this topic when a new recording starts. The object that triggered the recorder will have its bounding box drawn.
{base_topic}/image/{camera_identifier}_latest_thumbnail/attributes
A JSON formatted payload with attributes (currently empty)
Sensor topics
{base_topic}/sensor/{camera_identifier}_object_detector_fps/state
A JSON formatted payload is periodically published to with an estimate of the current object detectors processing FPS.
Payloads
preprocessor_fps and inference_fps is used to calculate the state, which is the same as the theoretical_max_fps
{
"state": 34.2,
"attributes": {
"preprocessor_fps": 305.2,
"inference_fps": 34.3,
"theoretical_max_fps": 34.2
}
}
{base_topic}/sensor/{camera_identifier}_operation_state/state
A JSON formatted payload is published to this topic to indicate the current status of the camera
Payloads
- scanning_for_objects
- scanning_for_motion
- recording
- idle
- error_scanning_frame
{
"state": "scanning_for_objects",
"attributes": {}
}
{
"state": "scanning_for_motion",
"attributes": {}
}
{
"state": "recording",
"attributes": {}
}
idle means no frames are being processed. This is the state when the camera is turned off.
{
"state": "idle",
"attributes": {}
}
Sent to the MQTT broker when an error occurs while scanning a frame for motion or objects.
{
"state": "error_scanning_frame",
"attributes": {}
}
{base_topic}/sensor/{camera_identifier}_image_classification/state
Viseron state topic
{base_topic}/state
A JSON formatted payload is published to this topic to indicate the current status of Viseron.
Payloads
- online
- offline
online
offline
Last Will Topic
{base_topic}/lwt
MQTT Last will and Testament
Payloads
- online
- offline
online
offline
Home Assistant MQTT Discovery
Viseron integrates into Home Assistant using MQTT discovery.
Home Assistant integration is disabled by default. You enable it by adding home_assistant to your mqtt config.
Viseron will create a number of entities depending on your configuration.
The paragraphs below show a few of the most notable ones.
Cameras
- A camera entity named
camera.{camera_identifier}_latest_thumbnailis created.
Sensors
- A status sensor named
sensor.{camera_identifier}_operation_stateis created. The state is set toidle,recording,scanning_for_motion,scanning_for_objectsorerror_scanning_framedepending on the situation. - A sensor that shows current the object detector FPS.
Binary Sensors
A variable amount of binary sensors will be created based on your configuration.
- An entity showing if any tracked object is in view.
- An entity for each tracked object showing if the label is in view.
- An entity for each zone showing if any tracked object is in the zone.
- An entity for each tracked object in a zone showing if the label is in the zone.
- An entity showing if motion is detected.
- An entity showing if a face is detected.
- An entity showing camera connection.
Switch
- A switch used to arm/disarm a camera. When disarmed, no system resources are used for the camera.
Troubleshooting
mqtt, add the following to your config.yamllogger:
logs:
viseron.components.mqtt: debug