MotionEye, home assistant, camera motion, automation

For those using docker, the developers have added the mosquitto-client to the dev-amd64 image and will work with the HassCasts mqtt command

No need for webhook/token etc

1 Like

I’m running Hassio 0.85.0 and finally I was able to get it to work by using the command below:

curl -X POST https://youraddress/api/services/script/turn_on -H 'Authorization: Bearer TOKEN' -H "Content-Type: application/json" -d '{"entity_id": "script.yourscript"}'

5 Likes

Thank you. Sold. I’ve just subscribed!

Did you ever do that video? I couldn’t immediately spot it.

1 Like

Mr HassCast, shooting way back into the past here, but is this still working for you? I tried but HA isnt making any changes on a motion mqtt command.

i still have no issues with my setup, curl is the way to go. As for ghost motion i’ve noticed a lot of it depended on my camera quality, meaning resolution and fps, also wireless vs wired. here is a picture of my motion settings.

51%20PM

with this setting i dont get a lot of ghost motion, its a crappy camera 3 db antenna

2 Likes

can u send a pic of ur setup to use curl command

I guess ill just have to figure out curl then. Its just not very familiar or readable to me. MQTT I have had more success as I’m all in on Sonoff light switches with Tasmota.

4

Just turn this on and add this from an earlier post:

Replace the script.yourscript with a script name of your choice. You will have to create a script to do something when motion is detected.

1 Like

this is my old post on here, also my setup uses a mqtt to http bridge thats why the binary sensor is mqtt, the curl command is issued to the mqtt service and passed to http or https. In my opinion dont use a script, use the mqtt binary sensor, works great, that way in the future if you figure out mqtt all you have to change is the command in motioneye. Also i believe you should definitely use the run end command so it turns off the sensor once motion has stopped being detected.

Why use curl when you can use mosquitto_pub and just use MQTT? Way easier.

Because MQTT isnt working (well not for me)

I managed to get it working via MQTT. Using this command.

Motion On
curl -X POST \ -H “Authorization: Bearer YOURTOKEN” -H “Content-Type: application/json” \ -d ‘{“payload”: “{“status” :“MOTION”}”, “topic”: “cameras/motion/picam”, “retain”: “True”}’ \ http://192.168..**:8123/api/services/mqtt/publish

Motion On
curl -X POST \ -H “Authorization: Bearer YOURTOKEN” -H “Content-Type: application/json” \ -d ‘{“payload”: “{“status” :“NO MOTION”}”, “topic”: “cameras/motion/picam”, “retain”: “True”}’ \ http://192.168..**:8123/api/services/mqtt/publish

Sensor YAML:

  • platform: mqtt
    name: “PiCam Motion”
    state_topic: “cameras/motion/picam”
    payload_on: “MOTION”
    payload_off: “NO MOTION”

HA is complaining about the payload on/off but ill sort that out later, its still working.

Anyone that has mosquitto_pub can use these:

mosquitto_pub -h <MQTT IP> -p <port> -t cameras/motion/frontdoor -u <username> -P <password> -m ON

mosquitto_pub -h <MQTT IP> -p <port> -t cameras/motion/frontdoor -u <username> -P <password> -m OFF

1 Like

Hi all

actually I have motionEye installed outside Hassio on another VM on my Intel NUC.

I’ve created a python script like this to run on motion detection.

curl -s -X POST https://api.telegram.org/botxxxxxx/sendPhoto -F chat_id=xxxxxx -F photo=@/var/lib/motioneye/Camera1/Alarm.jpg -F caption="Motion Vialetto!"
mosquitto_pub -h 192.168.x.x -u user -P password -t topic/Vialetto/motion -m "ON"

that I activate here

58

and this is how is defined the Still Images section

57

then in Nodered after receiving the ON payload on that topic after 15secs I send the OFF payload to manage a binary_sensor in HA

In this way I receive in a Telegram BOT a picture with the motion.

What I would like to receive (or to save locally, is a small video of the motion.
Is there a way to do it?

Thanks

2 Likes

I just found the solution, but this imply to have both MonionEye and NodeRed as Hassio Addon.

1 Like

I just wanted to add something here:
Ive started using MotionEye addon JUST to capture motion events in HA.
I have an NVR recording already, which is doing stuff on motion events, but my NVR doesnt have the ability to hit a webhook or run a command on these events. MotionEye does.

Hello HassCasts,

Thanks for the great description, have set up MotionEye and HA as described by you and it works, yeah …:+1::checkered_flag:

Ive had no luck with MotionEye. It keeps losing the connection to the camera.

1 Like

Are you able to share you config?

In MotionEye, under motion events, theres an option to send a webook.

I have rpi doing a number of things, one of hwich is a webserver. I wrote a simple handler for the HA api to make it easier to integrate with.
The webhook in MotionEye is just http://blah/ha?action=event&entity=camera_motion

then my handler grabs this, adds the auth header, and sends the relevant API request to HA.
You could, in theory, also turn on the legacy API for HA and do the same thing directly, but i decided for security reasons i didnt want to turn that on.