Raspberry pi 3 Home Assistant Camera as Motion Sensor Mqtt

  • 7 years ago
Raspberry pi 3 Home-assistant Camera as Motion Sensor

Usb Camera as a Motion sensor on Raspberry pi 3 Hassbian

Using "motion" the images and Videos from the Usb webcam are recorded and streamed on the (same)Rpi3 running Hassbian
but i have edited the motion.conf file to run commands when motion is detected and when the motion event ends so that it publishes Mqtt messages to the Mosquitto broker and in the Homeassistant configuration.yaml file i have made an mqtt sensor that shows motion detected TRUE or FALSE .

It works and using Automations it can be used to send mqtt messages to some other mqtt switches connected to the Hassbian to turn lights on or off or do something else ill post the results soon

in motion.conf file edited the following lines

# Command to be executed when an event starts. (default: none)

on_event_start mosquitto_pub -u newuser -P 12345 -t /house/system/motion -m "TRUE"

# Command to be executed when an event ends after a period of no motion

on_event_end mosquitto_pub -u newuser -P 12345 -t /house/system/motion -m "FALSE"

# Command to be executed when a motion frame is detected

on_motion_detected mosquitto_pub -u newuser -P 12345 -t /house/system/motion -m "TRUE"

in Configuration.YAML file

sensor 1:
- platform: mqtt
name: "Motion Detect"
state_topic: "/house/system/motion"
payload_on: "TRUE"
payload_off: "FALSE"
qos: 0