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.
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
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
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…
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?
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!
@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?