Then you’re probably running an add-on?
Perfect write up BUT I always faced and still face the issue that it triggers motion all the time… my sensitvity is very high … i mean needs a lot of changes in the picture to detect motion. WOuld you mind sharing your MotionEye config? My problem is that i have some moving plants in the picture and this apparently triggers motion all the time:
Enable both auto features and see if that helps.
Hi @Tinkerer unfortunatly this does not solve my issue that motion will be triggered all the time even without significant movements in front of the cam. I tried all kind of combinations but I cannot figure this out somehow. My Camera is a Foscam. What are your settings?
Can I just say that you may get more tips on a forum dedicated to motion or motioneye. Not that this conversation is (IMHO) unwelcome here, you just may get more motion experts on a dedicated forum
His point was that this is a forum for Home Assistant and there are some people using Motion(Eye). Motion itself has an active community where you can find people that really know it.
There was no need to get rude about it
However, I see you have show frame changes on… what kind of change numbers are you seeing when it triggers?
I’m using a different command for this, is there any advantage using a rest command as opposed to a shell command?
shell_command:
cam01_motion_on: 'wget -O- "http://motioneye:7999/1/detection/start" >/dev/null'
cam01_motion_off: 'wget -O- "http://motioneye:7999/1/detection/pause" >/dev/null'
I’ve noticed that pausing motion doesn’t turn off the motion detection section in the motioneye gui. I’m guessing that’s more of a question for the motioneye forum though.
Also, has anyone figured out how to view motioneye recordings or “movies” in lovelace yet? I can embed the motioneye gui locally but externally is a bit more troublesome, I’m guessing I would have to allow remote access to motioneye which I’m not really comfortable with.
@alexandresalome This is perfect. I will definitely try this out soon, just what I was looking for, thank you!
Sorry if this is the wrong place to ask… I wish to run HA and MotionEye on the same Rasberry Pi 4B 8GB (w/128GB SD). The purpose it to have 4 POE cameras run through MotionEye. In response to motion detection, record video onto the 128GB SD and turn on lights controlled by HA. Can this be done? How do you set up the Pi so that both HA and MotionEye coexist?
Thanks,
Jerry
Welcome to the HA forum.
The answer is yes.
If you use home assistant OS or a supervised install, then there is a motioneye addon which is simple to add.
If you run a venv or HA container, then you will have to install motioneye yourself.
The way to get them to work together is surely dealt with in the first post in this thread isn’t it?
Great implementation! I did mine and with a few tweaks it’s working great!!! The only parts I missed were steps 6 and 7… and replace those ones with a condition in the automation step; so, cameras keep tracking movement but HA only triggers it when ON. I didn’t have to change MotionEye…
Great tutorial, thanks!
I did eventually run into a weird issue, and I need your help.
Everything worked great for about two weeks, and since the last Home Assistant update (Core + 108.2)
I noticed that for some reason, the motion detection switches itself from “pause” to “active” in Motion Eye after about 2 mins of it being paused in HA…
I check the detection statut here http://192.168.1.21:7999/1/detection/status
It goes back to active on its own, while on Home Assistant it stays off…
Again, everything worked perfectly fine for two weeks, so I don’t think I have made a mistake.
I feel like the update broke something, but I don’t know what.
Any idea? :-/
Hi!
I think it was a great tutorial also.
And i face the exact same problem, goes back to “ACTIVE” after a while.
Noone has Any idea? :-/
Hi @alexandresalome,
First I want to say thank you. You took simple steps and made it look and operate like a big and expensive system.
I added something nice, an automation and input boolean to control it that sends a screenshot if motion is detected.
This is what I added:
- Create a camera based on streams from MotionEye
- Create and folder for the snapshots to be saved
- Create an input_boolean to start and stop the snapshot service
- Create an automation without trigger, it will be triggered manually when needed
In configuration.yaml:
camera:
- platform: mjpeg
mjpeg_url: http://192.168.129.244:8083
name: cam1
input_boolean:
cam1_notify:
name: Camera1 Notify
and in automations I added one and modified the original.
This one create and send the snapshot:
- id: 'motionincam1'
alias: Notify me if there is movement in my camera1
description: ''
trigger: []
condition: []
action:
- service: camera.snapshot
data:
entity_id: camera.cam1
filename: /share/snapshots/cam1/snapshot.jpg
- delay: 00:00:02
- service: notify.ha_notify
data:
message: Movement in Cam1!
data:
photo:
file: /share/snapshots/cam1/snapshot.jpg
caption: 'Cam1 Motion Detected'
and modify the automation for that create the motion trigger in include the new settings:
- id: 'motionincam1-on'
alias: Turn on motion in camera1
description: ''
mode: queued
max: 3
trigger:
- platform: webhook
webhook_id: ha-whook-cam1-movement
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: input_boolean.cam1_notify
state: "on"
sequence:
- service: input_boolean.turn_on
entity_id: input_boolean.cam1_motion
- service: automation.trigger
entity_id: automation.notify_me_if_there_is_movement_in_my_camera1
- conditions:
- condition: state
entity_id: input_boolean.cam1_notify
state: "off"
sequence:
- service: input_boolean.turn_on
entity_id: input_boolean.cam1_motion
All the rest stays the same… now if wish to get a snapshot from you front door camera as well as change the sensor to “detected”, you can…
I also wish to wrap the entire configs as a package so I won’t look around every time I want to make a change…
You rock! thank you very much!
@alexandresalome
Hello there @alexandresalome, awesome write-up!! Thanks a million for putting this all together in the first place.
I’ve been carefully following it step by step and started troubleshooting the different steps when I tried it end-to-end and wouldn’t work. So far I managed to “unit test” steps 1 up to 7 but I got stuck in number 7. I would swear that the rest API call isn’t successful:
Marcs-Air:~ marc$ curl -XPOST http://192.168.1.5:7999/1/detection/start
curl: (52) Empty reply from server
Marcs-Air:~ marc$ curl -XPOST http://192.168.1.5:7999/1/detection/stop
curl: (52) Empty reply from server
I think it is important to state that I’m running the duckdns add-on. I’m saying this because in step #4 I had to fine tune the commands like this
from:
curl -XPOST http://home-assistant:8123/api/webhook/motioneye-camera1-started
to
curl -XPOST https://MYDUCKDNSADDRESS.ORG:8123/api/webhook/motioneye-camera1-started
(note that I have a local definition in my router in /etc/hosts to redirect the lookup of MYDUCKDNSADDRESS.ORG to the local IP
Marcs-Air:~ marc$ nslookup MYDUCKDNSADDRESS.ORG
Server: 192.168.1.1
Address: 192.168.1.1#53
Name: MYDUCKDNSADDRESS.ORG
Address: 192.168.1.5
I’ve now tested both over http
Marcs-Air:~ marc$ curl -XPOST http://192.168.1.5:7999/1/detection/start
curl: (52) Empty reply from server
Marcs-Air:~ marc$ curl -XPOST http://192.168.1.5:7999/1/detection/stop
curl: (52) Empty reply from server
and over https
Marcs-Air:~ marc$ curl -XPOST https://192.168.1.5:7999/1/detection/start
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to 192.168.1.5:7999
and it won’t work. Motioneye won’t display any change in the toggle for motion detection and I don’t get any notification email either.
If I do a telnet into the port, I do see that a service is listening. And if I check the add-on log, I see I’m warned about the lack of authentication and the lack of encryption, so I’m ruling out the add on being not properly configured.
Marcs-Air:~ marc$ telnet 192.168.1.5 7999
Trying 192.168.1.5...
Connected to MYDUCKDNSADDRESS.ORG.
Escape character is '^]'.
^C
Anybody running motioneye as an add-on and duckdns add-on could help me finish this up? Should the REST calls above change this section in all my defined cameras at once or is there any global setting hidden somewhere?
thanks!!
OK! I’m going to answer to my own points above.
No, there is not a global command.
The menu itself won’t change when the REST API is used. The only way to check if the commands sent are successfully enabling Motion Detection is by activating the option “Show Frame Changes”. When you run the automation go and check whether you see frames highlighting movement.
I followed the above steps and got to a point where the UI displays the camera stream and motionEye detects motion (pink squares, images are saved once motion is detected).
However, I’m running out of ideas to get the motion notification to work. I’m running motionEye as an addon to Home Assistant. I can’t get anything inside motionEye’s Run a command
box to work. Are there any logs or loglevels that I could use? I reckon it has something todo with the containers but I’m not too familiar with containers.
I finally managed to get the webhooks runnings (verified on a shell command), i.e. the commands themselves. The last bit now is the trigger from motionEye to run a command.
Ok, solved it myself. My previous setup was
- Router fritz.box with open external ports 443 and 8123 to the raspi 4 (no DynDNS on fritz.box)
- Home Assistant running on raspi 4
- DuckDNS as add-on
- motionEye as add-on
- an old iPhone serving as a guinea pig camera
I had had to install NGINX as an add-on. I just added my domain in the config
domain: xxxx.duckdns.org
certfile: fullchain.pem
keyfile: privkey.pem
hsts: max-age=31536000; includeSubDomains
cloudflare: false
customize:
active: false
default: nginx_proxy_default*.conf
servers: nginx_proxy/*.conf
but contrary to the documentation
In the
configuration.yaml
file, some options in thehttp:
section are no longer necessary for this scenario, and should be commented out or removed:
ssl_certificate
ssl_key
server_port
my configuration.yaml
still contains
ssl_certificate: /ssl/fullchain.pem
ssl_key: /ssl/privkey.pem
The two commands for motionEye are now …
/usr/bin/curl -X POST https://xxxx.duckdns.org:443/api/webhook/motioneye-camera1-started
/usr/bin/curl -X POST https://xxxx.duckdns.org:443/api/webhook/motioneye-camera1-ended
Just the curl didn’t do the job, we need the absolute path of curl in that particular docker container. Also note the different ports.
Sortings things out took me all afternoon ;-/
-Stefan.
I’ve noticed not only does the motioneye GUI not reflect the changes to motion detection when using the webcontrol command, the actual config files (camera-1.conf) remain unchanged. The only way to tell if it’s enabled from the GUI is to have “Show Frame Changes” and the number in the top right corner will then change to a “-” when it’s disabled. If it’s enabled and no motion is detected it will be a “0”.
I was also having an issue with high CPU usage causing intermittent results with this making it hard to know what is going on so I disabled two cameras which made me stumble upon this “quirk”:
When you disable a camera from the motioneye gui by switching “video device” to off it changes the numbering of the cameras. So for example I have 6 cameras and I disable camera’s 4 and 5, camera 6 becomes camera 4. I was hoping to disable cameras when not in use but this makes controlling them very problematic.
I’ve figured out the numbering is determined by the order in motion.conf not the name of the file. So if you’re having problems with turning motion detection on with webcontrol it’s worth checking that file to make sure the order is the same as the numbering!
EDIT: I’ve also just noticed that making changes in the GUI and then applying them will also change motion detection to whatever it’s set to in the GUI. So if you had disabled it with webcontrol and then apply the settings in the GUI and it’s set to on there, it will come back on.