Yeah I gave up given my luck…
I would appreciate a detailed walkthrough.
Thanks for doing this!
Update
Authetication: Bearer YOUR TOKEN
to create token visit general settings in home assistant and scroll to bottom of page
Hassbian
First create camera in motioneyeos, once it is visible and motion is enabled copy and paste these commands into the area shown in image below:
commands:`
ON
curl -X POST -H “Authetication: Bearer YOUR TOKEN” \ -H “Content-Type: application/json” \ -d ‘{“state”: “on”, “attributes”: {“friendly_name”: “upstairscam”}}’ \ http://remoteiptohomeassistant:8123/api/states/binary_sensor.upstairscam
OFF
curl -X POST -H “Authetication: Bearer YOUR TOKEN” \ -H “Content-Type: application/json” \ -d ‘{“state”: “off”, “attributes”: {“friendly_name”: “upstairscam”}}’ \ http://remoteiptohomeassistant:8123/api/states/binary_sensor.upstairscam
NO SPECIAL CHARACTERS FOR PASSWORD ONLY UPPER AND LOWER CASE LETTERS ALONG WITH NUMBERS FOR EXAMPLE:
HAssBian101
create this in your hassbian homeassistant configuration.yaml
sudo su -s /bin/bash homeassistant
cd /home/homeassistant/.homeassistant
nano configuration.yaml
TO CREATE YOUR OWN JUST CHANGE THE NAME IN THE FRIENDLY NAME TO THE SAME NAME YOU USE AS YOUR BINARY SENSOR along with camera name in motioneyeos as state topic..
you should now see this after restarting homeassistant:
Now add automation
hopefully that helps
how did u configure the motion trigger? I detects like ghost motion all the time
i think you change the minimum motion frames.
Hey, @argykaraz
Thank you so much for the idea of using my favourite Home Automation platform and my least disliked CCTV Framework (liked would be an overstatement). I had never thought of using them together but here’s what I’ve done with your idea…
I have set the ‘command’ to:
mosquitto_pub -h 192.168.0.3 -t cameras/motion/pats -u john -P mypassword -m ON
and my ‘end command’ to:
mosquitto_pub -h 192.168.0.3 -t cameras/motion/pats -u john -P mypassword -m OFF
I am not a fan of putting my password in things ie putting my mosquitto password in motioneye but needs must (a program that stores it’s own admin passwords etc in plain text).
In Home Assistant I have some binary_sensors set up eg
platform: mqtt
name: "motion (drive)"
state_topic: "cameras/motion/drive"
payload_on: "ON"
payload_off: "OFF"
device_class: "motion"
That obviously controls the binary_sensor and sets it up as a motion detector.
After that was done I changed my image settings in Motioneye to make sure that it was creating an image when motion was detected.
I then turn to Node-RED to do some jiggery-pokery. In Node-RED I now have this…
which is:
[{"id":"a44c8cc5.3106c","type":"mqtt in","z":"839343ea.c64e3","name":"Drive Camera","topic":"cameras/motion/drive","qos":"2","broker":"2c553bf7.b54c64","x":100,"y":100,"wires":[["351a3f7.b860ec"]]},{"id":"351a3f7.b860ec","type":"switch","z":"839343ea.c64e3","name":"Motion ON or OFF","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"},{"t":"eq","v":"OFF","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":310,"y":100,"wires":[["963127ea.8d9638"],["cd591b63.543c88"]]},{"id":"cd591b63.543c88","type":"exec","z":"839343ea.c64e3","command":"find /CCTV/Drive -type f -iname '*.thumb' -printf \"%T@ %p\\n\" | sort -n | cut -d' ' -f 2- | tail -n 1","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Get the final video thumbnail","x":580,"y":140,"wires":[["48645b4c.3d1714"],[],[]]},{"id":"1410272c.30db59","type":"fs-ops-copy","z":"839343ea.c64e3","name":"Copy to the HA dir","sourcePath":"","sourcePathType":"str","sourceFilename":"payload","sourceFilenameType":"msg","destPath":"/home/john/.homeassistant/www/assets/images/cctv","destPathType":"str","destFilename":"drive.jpg","destFilenameType":"str","link":false,"overwrite":true,"x":1200,"y":80,"wires":[[]]},{"id":"963127ea.8d9638","type":"exec","z":"839343ea.c64e3","command":"find /CCTV/Drive -type f -iname '*.jpg' -printf \"%T@ %p\\n\" | sort -n | cut -d' ' -f 2- | tail -n 1","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Get the initial image","x":550,"y":60,"wires":[["48645b4c.3d1714"],[],[]]},{"id":"48645b4c.3d1714","type":"string","z":"839343ea.c64e3","name":"Get rid of the trailing newline","methods":[{"name":"trim","params":[]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":910,"y":80,"wires":[["1410272c.30db59"]]},{"id":"2c553bf7.b54c64","type":"mqtt-broker","z":"","name":"Main","broker":"192.168.0.3","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]
Let me know if need any help with the modules required etc.
So, that then copies the initial image to the www subdir of the HA filesystem and then the final thumbnail once the motion event has finished.
That means that I can then create a camera in HA with…
platform: local_file
name: "drive_motion"
file_path: "/home/homeassistant/.homeassistant/www/assets/images/cctv/drive.jpg"
What does that mean?
It basically means that I can delete the 5 or 6 cameras that I have on my HA overview and replace them with the up to date image. This should save on quite a few resources.
Watch out for a new video on this
Because of the advantages of this over having 5-6 cameras using the traditional method. I am pretty sure I will be doing a video on this on the HASSCASTS YouTube Channel tomorrow.
http://YouTube.com/hasscasts
OK: So if anybody has any questions about this then please don’t hesitate to give me a shout
John
i think you have your password posted on the off topic…
Thanks very much for pointing that out. What a moron! I can’t believe I changed it in the first one and not the second one :-/
I will now change my password but luckily I don’t have external access anyway; all my ports are closed etc
Thanks again for pointing it out, it is very much appreciated.
John
Wow! Very detailed and informative. I am glad I gave you that push you needed. Great job, but I am not using mqtt. It will sure be helpful for someone else!
Hi @HassCasts
I was working through your solution and when I open my motioneye notifications section I only have one field for “Run a command” and can’t figure out how to get the “Run an End command” field to show up. Is there a trick to getting the second field to show up? Thanks for any help you might be able to provide.
Nevermind @HassCasts I found my problem, I’m running Motioneye in Docker and must have pulled down an older version. I grabbed another version and it has both fields available. Now to get this all working
thank you very much for this guide. small question. Im running mosquitto in docker.
how do I run the command in docker as my base os doesnt have mosquitto.
Ok, so the Motioneye ccrisan/motioneye:dev-amd64 docker image does not have the mosquitto client. So this (straight mqtt) method wont work on docker yet.
@sycohexor method does work.
Thanks for your input on this. I have created both an input_boolean
and a script
to fire (and reset) the innput_boolean under hass.io 0.73.0 and I can test both successfullly using the following API calls using POSTMAN in Chrome without API passwords. I do have any internal calls whitelisted though under my HTTP configuration (trusted_networks:)
http://10.0.x.x:8123/api/services/input_boolean/turn_on?entity_id=input_boolean.motion_entrance
(works)
http://10.0.x.x:8123/api/services/script/trigger_ss_entrance_boolean
(works)
I’m trying to call mine from Synology Surveillance Station however and this is not working despite the forum chatter saying that the Synology action rule wizard defaults to sending POST requests. More head scratching required
Been a long time since I made this post. I am more into HA than ever and you guys contributed to that. Thank you very much.
I have one more question for you guys.
I changed my setup to use SSL, and the webhook is not working. I changed my webhook to use https but the script is not triggering. The obvious reason (i am just guessing here) is that motioneye cant accept the self singed certificate.
Any thoughts on this?
Are you using the motioneye addon? Can’t get mine to publish mqtt
MQTT is not supported by default…apparently he has custom setup with mqtt
Stupid question: how did u guys configure the motion in motioneyeos… For me it triggers motion even if no motion is detected … I also use the mask filter to reduce fails.
but still getting fails motion detections.
Go with a reeeeaaalllyyyy low frame change threshold I have it set at 0.1%.
Here is a screen from mine.
Hi, I’ve a problem with the add-on, when I click on web UI, it doesn’t load the page…
What can I get to do, please¿
Thank you so much!
check your ports are open on the router (8765)
Otherwise, when you click on “open web ui” replace your public hassio hostname with the local ip address of your hassio instance