Motioneye snapshot trigger on doorbell ( byron )

Good day erveryone,

Migrated from Pimatic to HA. Happy i did that, cause when you get the HA in your head, it works great! Thanks to all contributors and developers.

I have the motioneye up and running on the camera. Also the snapshot function in motioneye up and running. It works good.
Now i want to make the snapshot when doorbell is pressed. Now the doorbell is linked only to the notification and pushbullet. I also want the snapshot to created. Anyone has an idea?
Thanks for the replies.

No one has an idea?

this works to create the snapshot (put it in your automation action)

  - service: camera.snapshot
    data:
      entity_id: camera.front_door #(replace this camera entity with your own)
      filename: /config/www/camera_snapshots/front_door_snapshot_{{ now ().year }}_{{ now ().month }}_{{ now ().day }}_{{ now ().hour }}_{{ now ().minute }}.jpg   

then just send it using Pushbullet. I don’t have the code for sending files via Pushbullet but you should be able to find that easy enough

1 Like

Do i need to install something? Or does camera.snapshot work with only motioneye installed?

This snapshot does not use motioneye, you have to define the camera in HA and the snapshot is a new one, if you’re already taking one in motioneye.

Unfortunately, MotionEye lacks on communication with the rest of the world (i.e MQTT) and it’s not easy to have some interaction.

I’m fighting to do something similar and get also a Telegram notification with the snapshot or also a video.

thanks for the replies guys. I will dig into it and try to configure it in HA

@woody4165 if you’re using docker this image has mqtt
image: ccrisan/motioneye:dev-amd64

@countjuh here is how i did it.

- id: notify_doorbell_chime
  alias: Notify doorbell chime
  initial_state: true
  trigger:
  - platform: state
    entity_id: binary_sensor.doorbell_chime, binary_sensor.cs4_doorbell
    from: 'off'
    to: 'on'
  action:
  - service: camera.snapshot
    data:
      entity_id: camera.front_door
      filename: "/config/www/doorbell/tmp/front_door_{{now().strftime('%Y%m%d_%H%M')}}.jpg"
  - delay: 00:00:02
  - service_template: notify.magda_juan_group
    data_template:
      title: Home Assistant    
      message: "Doorbell Rung"
      data:
        tag: alert
        image: "https://yourdomain/local/doorbell/tmp/front_door_{{now().strftime('%Y%m%d_%H%M')}}.jpg"
        ttl: 86400
        priority: high

Thanks @juan11perez!

I was just going to write that I found the way to manage what I wanted to do.

My needs were to save the jpg and mp4 when motion is detected notified via Telegram with the image and video (still thinking if video is useful on Telegram).

I succeded this way.

On the File Storage section, I run a command with mosquitto_pub sending the filename just saved by MotionEye.

mosquitto_pub -h IP -u username -P password -t topic/Vialetto/filename -m “%f”

From Node Red, but I think you can use also automation in HA, I subscribe to that topic and get the filename with full path.

Then I analyze if the last three chars are jpg or mp4 to determine if I have to send a video or a photo using Telegram and that’s it.

With the standalone version of MotionEye in docker, you need to install mosquitto_pub (even if you shouldn’t touch the docker image), but I saw that the MotionEye version, strangely, is lower than the addon one and it seems there is an issue with the filename full path.

1 Like

I had suggested to the developer they added the mosquitto client about 6 months ago. So they added it to the dev branch.
I dont know if it’s already in the stable, as the dev version is working fine and havent replaced it.

I’m interested in doing the same thing. I’ve configured MotionEye to publish to MQTT the filename, when a JPG or MP4 is created.

Can you share your code for extracting determining the filetype?

I plan to send the JPG to my devices and let MotionEye keep a copy of the MP4, just in case.

I’ve done it with Node Red.

This is the flow

I have subscribed to the topic, then with the “String” node I test if endsWith and check if it’s true (the ms.motioneye_photo_vialetto, in this case, I have tried without checking and sometimes I get a false-positive) and the send it to Telegram

Let me know if this is ok for you…

Very helpful. I’ve not had chance to test it properly in an automation, but this code would work in an automation to trim determine the filetype based on the last message posted to a specific MQTT topic.

{% if value_json[-3:] == "jpg" %}true{% endif %}

may you share your nodered flow?

This is my flow

[{"id":"9bbc99e3.a78108","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"141cd03e.e3269","type":"string","z":"9bbc99e3.a78108","name":"photo","methods":[{"name":"endsWith","params":[{"type":"str","value":"jpg"}]}],"prop":"payload","propout":"motioneye_photo_cam_name","object":"msg","objectout":"msg","x":250,"y":360,"wires":[["b0131bd5.250b68"]]},{"id":"4e656984.3c69a8","type":"mqtt in","z":"9bbc99e3.a78108","name":"Filename cam_name","topic":"cameras/cam_name/filename","qos":"0","datatype":"utf8","broker":"","x":90,"y":380,"wires":[["141cd03e.e3269","8e41d6e0.e17568"]]},{"id":"b0131bd5.250b68","type":"switch","z":"9bbc99e3.a78108","name":"true","property":"motioneye_photo_cam_name","propertyType":"msg","rules":[{"t":"eq","v":"true","vt":"jsonata"}],"checkall":"true","repair":false,"outputs":1,"x":370,"y":360,"wires":[["f5e97397.8159e"]]},{"id":"8e41d6e0.e17568","type":"string","z":"9bbc99e3.a78108","name":"video","methods":[{"name":"endsWith","params":[{"type":"str","value":"mp4"}]}],"prop":"payload","propout":"motioneye_video_cam_name","object":"msg","objectout":"msg","x":250,"y":400,"wires":[["cc972b6e.b2d0b8"]]},{"id":"f5e97397.8159e","type":"change","z":"9bbc99e3.a78108","name":"photo_cam_name","rules":[{"t":"set","p":"photo_cam_name","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"camera_cam_name","pt":"msg","to":"cam_name","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":360,"wires":[["38566e03.17fe72"]]},{"id":"cc972b6e.b2d0b8","type":"switch","z":"9bbc99e3.a78108","name":"true","property":"motioneye_video_cam_name","propertyType":"msg","rules":[{"t":"eq","v":"true","vt":"jsonata"}],"checkall":"true","repair":false,"outputs":1,"x":370,"y":400,"wires":[["294abed.a895242"]]},{"id":"38566e03.17fe72","type":"function","z":"9bbc99e3.a78108","name":"Send jpg to Telegram","func":"msg.payload = {chatId :111111, type : 'photo', content : msg.photo_cam_name, caption: \"Motion snapshot \"+msg.camera_cam_name+\"! \"}\nreturn msg;\n\n","outputs":1,"noerr":0,"x":720,"y":360,"wires":[[]]},{"id":"294abed.a895242","type":"change","z":"9bbc99e3.a78108","name":"video_cam_name","rules":[{"t":"set","p":"video_cam_name","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"camera_cam_name","pt":"msg","to":"cam_name","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":400,"wires":[["4a0bb081.5f1e6"]]},{"id":"4a0bb081.5f1e6","type":"delay","z":"9bbc99e3.a78108","name":"5s","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":670,"y":400,"wires":[["fbdf0552.fc5958"]]},{"id":"fbdf0552.fc5958","type":"function","z":"9bbc99e3.a78108","name":"Send mp4 to Telegram","func":"msg.payload = {chatId :11111111, type : 'video', content : msg.video_cam_name, caption: \"Motion video \"+msg.camera_cam_name+\"! \"}\nreturn msg;\n\n","outputs":1,"noerr":0,"x":840,"y":400,"wires":[[]]},{"id":"3a271cc0.84b7b4","type":"comment","z":"9bbc99e3.a78108","name":"Telegram node ","info":"","x":920,"y":360,"wires":[]},{"id":"e4f2f0c6.add43","type":"comment","z":"9bbc99e3.a78108","name":"Telegram node ","info":"","x":1040,"y":400,"wires":[]}]

I’ve done one of this for each camera

1 Like

Another option which I use, setup ftp service in HassIO, then push images/videos to dir in hassio config.

I then use node red and monitor the dir in config for new files and send a notification with images/vid.