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
{client_id}/binary_sensor/{camera_identifier}_connected/state
Shows if Viseron is connected to a camera.
Payloads
- on
- off
{
"state": "on",
"attributes": {}
}
{
"state": "off",
"attributes": {}
}
{client_id}/binary_sensor/{camera_identifier}_recorder/state
Shows whether the recorder is recording or not.
Payloads
- on
- off
{
"state": "on",
"attributes": {
"last_recording_start": "2022-09-14T06:53:34.602066",
"last_recording_end": null,
"path": "/recordings/front_door/2022-09-14/06:53:34.mp4",
"thumbnail_path": "/recordings/front_door/2022-09-14/06:53:34.jpg"
}
}
{
"state": "off",
"attributes": {
"last_recording_start": "2022-09-14T06:53:34.602066",
"last_recording_end": "2022-09-14T06:54:11.596465",
"path": "/recordings/front_door/2022-09-14/06:53:34.mp4",
"thumbnail_path": "/recordings/front_door/2022-09-14/06:53:34.jpg"
}
}
{client_id}/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": {}
}
{client_id}/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
}
}
{client_id}/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": {}
}
{client_id}/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
}
}
{client_id}/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": {}
}
{client_id}/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": {}
}
Toggle topics
{client_id}/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
{client_id}/toggle/{camera_identifier}_connection/state
Camera connection state.
Payloads
- on
- off
{
"state": "on",
"attributes": {}
}
{
"state": "off",
"attributes": {}
}
Image topics
{client_id}/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.
{client_id}/image/{camera_identifier}_latest_thumbnail/attributes
A JSON formatted payload with attributes (currently empty)
Sensor topics
{client_id}/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
}
}
{client_id}/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": {}
}
{client_id}/sensor/{camera_identifier}_image_classification/state
Viseron state topic
{client_id}/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
{client_id}/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_thumbnail
is created.
Sensors
- A status sensor named
sensor.{camera_identifier}_operation_state
is created. The state is set toidle
,recording
,scanning_for_motion
,scanning_for_objects
orerror_scanning_frame
depending 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.