Push integration with motioneye

Hi All, relatively new to home assistant. I’m running 74.2 on raspbian, with motioneye installed.
I’ve been trying in vain to use push to copy the last image from a motion detection into the home assistant ui.

My push configuration. yaml for this is as follows: -

camera:

  • platform: push
    name: MotionEye Snug
    buffer: 3
    timeout: 5

And the motioneye config under File Storage / Run a Command is: -
curl -X POST -F “image=@%f” http://xx.xx.xx.xx:8123/api/camera_push/camera.push_camera -H “x-ha-access: xxxxxxxx”

This doesn’t work for me. If I try the command from the command line, I get the following error: -

{“message”: “Unknown camera.push_camera”}

Has anyone any ideas, the above is basically straight from the documentation page: -

Thank you.

Please note in my configuration. yaml file the above is indented correctly, the copy/paste didn’t keep the formatting.

in your curl command you must replace camera.push_camera with the name of your HA camera, I’m guessing camera.motioneye_snug.

1 Like

Thank you very much, that worked a treat! :slight_smile: So camera.push_camera is just a reference to the actual entity name I’m using. I now have my first pic in home assistant.

Apologies for the slight bump, but do you get a lot of broken images showing up on your frontend? I’m getting lots and checking the dev-panel, motion-eye is sending the mp4 file and not the jpg?

Not sure if my motioneye setup is wrong, or is there a way to get HomeAssistant to ignore any video files.

Hello,

Yes, video files are a problem (they are not supported by HA camera component)… you should ignore them in your upload command defined in motioneye.

E.g.: use an IF in the bash command

if [[ ${file: -4} == ".jpg" ]]; then curl .....; fi

Would either of you mind posting a screenshot of your MotionEye settings? I can’t seem to get MotionEye to send a photo over… not seeing anything in my logs in HA or MotionEye and I can’t figure out where the issue lies.

I’m currently Pull Requesting (PR) a change to Camera Push (https://github.com/home-assistant/home-assistant/pull/18346)

With the introduction of the new auth system, I first implemented a stop-gap solution with tokens in the URL, and since Paulus has introduced webhooks.

The current PR addresses this issue and will impact configuration of MotionEye. Let the PR get in and then we can post a final solution :slight_smile:

When I try and add a run command in the format shown on the Push page:

curl -X POST -F “image=@%f” http://my.hass.server.com:8123/api/webhook/my_custom_webhook_id

where I replace my.hass.server.com with the IP of my Hass.io and my_custom webook_id with motionEye_image_2 (which is the webhook_id I have in my camera configuration).

When I apply the changes, it moves the “Run a Command” to “Call A Web Hook”.

That is unfortunately a know bug in motioneye :frowning:

https://github.com/ccrisan/motioneye/issues/1062

Oh bummer… :frowning: Does that mean there is currently not a way to get this to work? Or is there another way to get the push camera to work with MotionEye?

What I ended up doing is adding a dummy webhook + the “run command” that actually does the job.

So the dummy webhook points to an existing webhook address and the “run command” is what you already have.

Please note that if you need to change something the configuration of run command will be empty… but it still works in between :slight_smile:

Wonder why I don’t get an answer in MotionEye to implement a proper fix :frowning:

Hi dgomes, how do you set-up the dummy webhook?

I just filled in the webhook field with a URL that is NOT the write one, but still returns something (any url on ha will do)

I don’t think I’m quite understanding what you’re saying.
I need a valid URL right, so how do I create one in HA?

You don’t need it to be 100% valid, you just need a quick answer from it (even if it’s a 404)

So if your REAL web hook is: http://my.hass.server.com:8123/api/webhook/my_custom_webhook_id

you can use as a dummy: http://my.hass.server.com:8123/api/webhook/my_custom_webhook_id_dummy

You will get warnings in your HA logs, which can be ignored. MotionEye will nonetheless work perfectly :slight_smile:

I thought the word webhook wasn’t working from the motioneye side?
Does that flip your image over to HA correctly then?

It works because since there is a “valid webhook” (from motioneye point of view) it will not mess with the “run command” entry.

Yes it does work :slight_smile: that’s how I have my system setup.

Sorry, I’m still confused, so this command above from Myztillx:-

curl -X POST -F “image=@%f” http://my.hass.server.com:8123/api/webhook/my_custom_webhook_id

doesn’t work because of the word webhook. So why would changing it to:-

curl -X POST -F “image=@%f” http://my.hass.server.com:8123/api/webhook/my_custom_webhook_id_dummy

make it work? It still contains the word webhook.

You need to fill 2 fields (“Call a Web Hook” AND “Run a Command”)

The “Call a Web Hook” will be the dummy, while “Run a Command” will be the correct webhook.