MotionEye config

Cool i also do basically the same thing with a pir sensor connected to a raspberry pi.
configuration.yaml:

 binary_sensor:
     - platform: mqtt
       name: "MotionSensor"
       state_topic: “movement/motionsensor/motion”

python script: REVISED

import RPi.GPIO as GPIO
import time
import requests


GPIO.setmode(GPIO.BCM)

GPIO.setup(pinnumber, GPIO.IN) #PIR
#GPIO.setup(24, GPIO.OUT) #BUzzer
url = 'http://ipaddress:8123/api/states/binary_sensor.motionsensor'
headers = {'x-ha-access': 'password', 'content-type': 'application/json'}
data = '{"state": "on", "attributes": {"friendly_name": "MotionSensor"}}'

url1 = 'http://ipaddress:8123/api/states/binary_sensor.motionsensor'
headers1 = {'x-ha-access': 'password', 'content-type': 'application/json'}
data1 = '{"state": "off", "attributes": {"friendly_name": "MotionSensor"}}'
def sensor():
  try:
    time.sleep(2) # to stabilize sensor
    while True:
        if GPIO.input(pinnumber):
            #GPIO.output(24, True)
            #time.sleep(0.5) #Buzzer turns on for 0.5 sec
            #GPIO.output(24, False)
            #print("Motion Detected...")
            #localtime = time.asctime( time.localtime(time.time()) )
            #print(localtime)
            response = requests.post(url, headers=headers, data=data)
            #print(response.text)
            time.sleep(5) #to avoid multiple detection
            response1 = requests.post(url1, headers=headers1, data=data1)
            #print(response1.text)

        time.sleep(0.1) #loop delay, should be less than detection delay

  except:
    GPIO.cleanup()
    sensor()
sensor()

chmod +x script.py
i do a an autostart using sudo nano ~/.config/lxsession/LXDE-pi/autostart
then add @sudo python script.py at the bottom of the file.

Also check this out:

I was actually thinking of creating a motioneye component as part of my youtube Home Assistant channel (only 1 video as only started a few days ago).

I too use MotionEye and am sure there can be better/more ways to integrate than just having the cameras display (like I normally do).

Are there many users of Motioneye on here or do most people seem to stick with ZoneMinder?

John

i myself havent used zoneminder, but adding other components to motioneye rather than only cameras would be fantastic. im still trying to work on my script for my pir sensor so that it has a schedule too.

I must admit, I’ve tried Zoneminder, and the only thing I can say that I like over Motioneye was the ability to create zoned areas so that motion detection wasn’t even applied to certain parts of the images (property that you don’t own etc). There were, however more disadvantages than advantages in my option and so I switched back to Motioneye but obviously I am stuck with the same restriction of viewing cameras the same as everyone else.

have you tried anything like opencv or simple cv? that would also be great to integrate into motioneyeos.

this is installed as a python virtual environment so any system running python3 or 2.7 would work. You can also use this to access cameras remotely(since it currently isnt implemented into motioneyeos, that i know, of). So with that said even just integrating it into hassbian would be GREAT!! i mean then we could almost bypass motioneyeos all together :stuck_out_tongue:

I use motioneyeos

1 Like

I have used ZoneMinder for the last 2 years and am happy with it for my purposes. I have not used MotionEye.

1 Like

Please help troubleshooting mosquitto problem, I’m using Hassio and MotionEye in Docker from here:

Binary sensor working if triggered manually from HA or from terminal, but when setting commands in “Motion Notification” nothing happenes, also tried with /usr/bin/mosquitto_pub

commands:

mosquitto_pub -h 10.0.0.10 -t cameras/1/motion -m ON
mosquitto_pub -h 10.0.0.10 -t cameras/1/motion -m OFF

configuration.yaml:

mqtt:
  broker: 10.0.0.10
  port: 1883

binary_sensor:
  - platform: mqtt
    name: "Motion"
    state_topic: "cameras/1/motion"
    payload_on: "ON"
    payload_off: "OFF"
    device_class: "motion"

Either command not sent because mosquitto_pub not found, or it’s sent but not received because network configuration, is there log I can check?

SOLVED: mosquitto-clients package was missing in docker

I tried all of you approaches, but nothing works… there’s nothing being published on the topic althought there’s motion and the camera is recording…
any help?

hey there, I have the same setup as you (hassio, motioneye in a seperate docker) and am also trying to get the MQTT notifications to work.

I already installed the client inside the motioneye docker container, but I cannot get it to publish messages.

mosquitto_pub -h 192.168.XXX.XXX -u XX -P XX  -t cameras/XIAOFANG/motion -m ON

I subscribed to the topic in one terminal window, publish to that topic in another one with the command from motioneye interface, works perfect. When I send the same command via motion activation or from the motion docker shell: nothing.

Am I missing something?

edit: I maybe should add: my binary sensor for that topic is working fine with the “manual” publishes

edit2: i did get it to work with the curl scripts, but i would rather go the MQTT way to be honest…

Hi , i want to try motionEye + MQTT. What camera I need?

mosquitto_pub -h 192.168.XXX.XXX -u XX -P XX -t cameras/XIAOFANG/motion -m ON

works like a charm HassOS

Run A Command works great on motion detection. But, like everyone else is saying, Run An End Command doesn’t work to return the sensor to the OFF state. Why is that?

I cannot confirm this. The end command is executed (I am using mosquitto and the motion state is set to ‘OFF’ then).

1 Like

How do I avoid false alarms with floodlights turning on and off?
I have the light switch detection on 100% and threshold at about 6.5%.

Everything else is working well. run/end commands to switch detection on/off etc. telegram and google drives uploads than
kfully.
Just the camera IDs were a pain as they didn’t match the ones in motioneye.

First thing I will do is reduce the sensivity of the floodlight motion sensor as our neighbours cat always passes through and sets it off!

Wouldn’t you need to reduce this to avoid it triggering from your light?

1 Like

Is there a way to get this working with a long life access token? instead of the API password?

@QSKONE, i’m working on the montioneye notification setup aswell. You seem to have it working. Can you help me out? I want to use 1 camera with motion detection. The motion detection should send a message to my phone. The phone notification is working, but i don’t yet understand how to setup the mqtt notification part.

@g0g0, i’m still a nooby on this topic, but try to figure out what i need to do to get motioneye to detect and notify on motion detection. I have 2 camera’s working in motioneye. i have mqtt installed. What steps do i need to take?

Anyone has an idea how to solve this?

I have this as config in configuration.yaml

binary_sensor:
  - platform: mqtt
    name: "Motion"
    state_topic: "home/motiondetection/camera"
    payload_on: "ON"
    payload_off: "OFF"
    device_class: "motion"

I have this in motioneye under Run A Command:
mosquitto_pub -h 192.168.1.201 -u user -P password -t home/motiondetection/camera -m ‘{“state”:“ON”}’

But the binary sensor never changes status. Should the mqtt ip be the same as the HA IP or does it have an internal ip?
What could be wrong?

it is solved.

mosquitto_pub -h 192.168.1.201 -p 1883 -u user -P password -t home/motiondetection/camera -m ‘“ON”