Skip to content

Home-Assistant addon for motion with support for /dev/video0

License

Notifications You must be signed in to change notification settings

dcmartin/addon-motion-video0

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎬 - motion Classic add-on

This Home Assistant add-on utilizes the motion project, YOLO, and other AI's to detect and classify entity(s) in images. The motion project software provides an extensive set of capabilities to capture video feeds from a variety of sources, including RSTP,HTTP, and MJPEG network cameras. Locally attached video sources are also supported (e.g. /dev/video0).

Related

This add-on interacts with additional components and services:

  1. motion-ai - Automated Home Assistant configurator for use with motion addon (see below).
  2. MQTT Messaging service; use mosquitto or HiveMQ add-on
  3. FTP (optional) FTP daemon to receive webcam videos; use addon-ftp add-on

In addition, there are three Open Horizon AI services specified in the in motion-ai repository; they may be used to identify entities, faces, and license plates.

  1. yolo4motion - using the script sh/yolo4motion.sh
  2. face4motion - using the script sh/face4motion.sh
  3. alpr4motion - using the script sh/alpr4motion.sh

Containers

This addon is built for the following architectures and available in Docker Hub, e.g. amd64 version.

Configuration

The configuration instructions provide information on all options; however, for brevity there are three components that need to be defined for successful operation:

  • mqtt - the IP address (FQDN), username, password, and port of the MQTT broker
  • group - identifier for a subset of cameras; default: motion
  • device - unique identifier for each device in the group; shall not use reserved MQTT characters (e.g. -,+,#,/)
  • client - identifier for device to listen; may be + to indicate all devices; default: +
  • cameras - array of individual camera specifications (see below)

cameras

There are three attributes required to integrate a camera into HA:

  • name - identifier for the camera as defined by the addon (n.b. MQTT topic reserved characters)
  • type - camera source type; may be local, netcam, ftpd, mqtt
  • netcam_url - address of live stream for source, e.g. rtsp://192.168.1.223/live
  • netcam_userpass - authentication credentials for source, e.g. username:password

In addition, there are two additional attributes which are optional:

[
  {
    "name": "sheshed",
    "type": "netcam",
    "netcam_url": "rtsp://192.168.1.223/live",
    "netcam_userpass": "!secret netcam-userpass",
    "icon": "cctv",
    "w3w": ["varieties","usage","racks"]
  }
]

All MQTT messages sent use topics beginning with the group specified, for example:

  • <group>/{name}/{camera} -- JSON payload of motion detected
  • <group>/{name}/{camera}/lost -- JSON payload of motion detected
  • <group>/{name}/{camera}/event/start -- JSON payload of motion detected
  • <group>/{name}/{camera}/event/end -- JSON payload of motion detected
  • <group>/{name}/{camera}/image -- JPEG payload of image (see post_pictures)
  • <group>/{name}/{camera}/image-average -- JPEG payload of average event
  • <group>/{name}/{camera}/image-blend -- JPEG payload of blended event (50%)
  • <group>/{name}/{camera}/image-composite -- JPEG payload of composite event
  • <group>/{name}/{camera}/image-animated -- GIF payload of event
  • <group>/{name}/{camera}/image-animated-mask -- GIF payload of event (as B/W mask)

Sample output

motion sample

MQTT

A MQTT broker is required; the default Mosquitto add-on is sufficient, but must be configured with appropriate authentication, for example:

logins:
  - username: username
    password: password
anonymous: false
customize:
  active: false
  folder: mosquitto
certfile: fullchain.pem
keyfile: privkey.pem
require_certificate: false

Additional information

The Motion package has extensive documentation on available parameters. Almost all parameters are avsailable. The JSON configuration options are provided using the same name as in the Motion documentation.

Changelog & Releases

Releases are based on Semantic Versioning, and use the format of MAJOR.MINOR.PATCH. In a nutshell, the version will be incremented based on the following:

  • MAJOR: Incompatible or major changes.
  • MINOR: Backwards-compatible new features and enhancements.
  • PATCH: Backwards-compatible bugfixes and package updates.

Authors & contributors

David C Martin ([email protected])