šŸ“ø Send camera snapshot notification on motion

Hey, did you ever get yours to work? Iā€™m quite new to this HA and MQTT stuff and Iā€™m not sure what Iā€™m suppose to do with your config and command.

EDIT: I figured it out. I had dig through your profile to find your post. Hereā€™s my setup if anyoneā€™s curiousā€¦

For configuration.yaml, I have something like:

binary_sensor:
  - platform: mqtt
    name: "Front Porch Cam" # i.e. Name of camera
    state_topic: "motion/FrontPorch" # i.e. Name of topic
    payload_on: "ON"
    payload_off: "OFF"
    device_class: "motion"

In my motionEye camera settings, I have a Run a Command like:

mosquitto_pub -h *MQTT HOST* -p *MQTT PORT* -u *MQTT USERNAME* -P *MQTT PASSWORD* -t *state_topic* -m ON

and a Run An End Command like (this is optional, but I put this in because the ON topic will continue running for a couple of minutes):

mosquitto_pub -h *MQTT HOST* -p *MQTT PORT* -u *MQTT USERNAME* -P *MQTT PASSWORD* -t *state_topic* -m OFF

So each command should basically look like:

mosquitto_pub -h 192.168.1.202 -p 1883 -u mqtt-user -P password -t motion/FrontPorch -m ON
mosquitto_pub -h 192.168.1.202 -p 1883 -u mqtt-user -P password -t motion/FrontPorch -m OFF

Then, I checked my config in Server Controls and did a server restart just for kicks. Afterward, I went back to this blueprint and created an automation like so:


And it seems like everythingā€™s functioning as expected. So nice work, fschade!

1 Like

Can we have something similar setup for Android phone too? The current blueprints does send the notification with snapshot for Android phone but it was silent and in the background. I know we can send HA notifications to Android with ttl:0 and priority: high settings to trigger the sound, but Iā€™m not sure how to do it in this blueprint.

This really applies to any Home Assistant notification, but when I click on the notification, it will open Home Assistant and delete the notification (iOS).

Is there anyway to change this behavior so that I donā€™t loose the notification?

Do you have any other app notifications that behave like this? AFAIK, the actual behaviour you describe is controlled by iOS. What would be the point of a notification that doesnā€™t clear when reacted to (honestly curious)?

True, but what is the purpose of a notification which disappears before seeing the content. Curious whether there any notification type which requires you to explicitly remove the notification.

Maybe we are talking about slightly different things. Are you talking about notification banners? Those can be set as temporary or persistent (but still clears when tapped). Otherwise, it ends up in your notification centre. Regardless, one can tap and hold a notification to see it in full before just tapping it. Still, this has to do with iOS and Iā€™m pretty sure thereā€™s nothing HA can do about it. The only alternatives I can think of is to adjust this blueprint to also set an HA internal persistent notification, send an IM or email.

Yes, you are correct, I am talking about the notification banners and even though they can be set as temporary or persitant, as you rightfully notice, they clear when tapped.

I do understand this has to do with iOS and I assume that iOS makes the assumption, that the notification is available in Home Assistant. When you tap the notification, it opens Home Assistant, but Home Assistant just opens its current page. It might be nice if Home Assistant would open the Notification page (you could send a persitent notification at the same time), or if the notification passes anything to Home Assistant, for Home Assistant to take an action based that information.

1 Like

Since moving my nodered to a container I cannot seem to pick up the jpg snapshots from /config/www/ā€¦

I added it to allowlist_external_dirs also but still nothing.
The telegram sendPhoto just does not work unless I use the nodered addon within HA.

{"photo": "/config/www/camshots/rear.jpg"}

Do you have any other tips please? Thanks

image

Use the full url?
{ā€œphoto": http://my.some.ip.address/config/www/camshots/rear.jpg"}

Unfortunately, that does not work even with the ingress token with filename=/config/www/camshots/rear.jpg

In the meantime Iā€™ve added pushbullet which sends the snapshots to my phone without issues.

At first I wasnā€™t seeing the image in the notification on my iPhone. After I upgraded to IOS 15, all is well. Thanks for the blueprint!

It would be nice if a condition was added (optional of course) that if someone is home or not :slight_smile:

1 Like

Great job. Blueprint works flawlessly.

Now I just have to find out, how to send the snapshot to two or more iPhones? Can I simple group them (like group.parentsphone) and select group.parentsphone as the device?

Great blueprint!

The only ā€œproblemā€ is that I get the snapshot but when I click the notification (Android) it closes and the app is shown (not the actual snapshot). Are the snapshots saved somewhere? Would disk usage be an issue?

TIA

1 Like

Hi
I ask for help

HA is installed on a raspberry p4 with hassio 2021.12.7
i am inexperienced with MQTT so i dont know if i am wrong something

I was following your guide to send motion alert from motioneye but not function motioneye side, this is my last command : ā€œmosquitto_pub -h 127.0.0.1 -p 8883 -u user -P pw -t motion / gate -m ONā€

I did a manual test
If I give command from MQTT

immagine

I see that the entity changes my state

immagine

maybe what i am wrong is the address i give to MQTT.
I tried to give the address:
del raspberry -h 192.x.x.x -p 1883
of the brocker -h 127.0.0.1 -p 1883
of the brocker -h 127.0.0.1 -p 8883
but it doesnā€™t answer me when it detects movement.

Hmmā€¦
@Subia75, @TwoPuncakes I think it is a lot easier to use a webhook from MotionEye :wink:
image
I use this POST address: https://192.168.1.2:8123/api/webhook/doormotion from MotionEye
and then I catch it with an automation
In my config, Iā€™m setting an input helper boolean to true for 30 secs (but only between 22:00 and 07:00):
My automation yaml:

alias: Front Doorcam motion detected
description: Notify when motion is detected between 22:00 and 07:00
trigger:
  - platform: webhook
    webhook_id: doormotion
condition:
  - condition: time
    after: '22:00'
    before: '07:00'
action:
  - service: input_boolean.turn_on
    target:
      entity_id: input_boolean.doormotion
  - delay:
      hours: 0
      minutes: 0
      seconds: 30
      milliseconds: 0
  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.doormotion
mode: single
initial_state: true

And with the input_boolean.doormotion I make other things happenā€¦, but if you only require one trigger, just use your own action :wink:

2 Likes

Thanks for the reply.
Iā€™ll do this automation test to see if it responds to motion.
I need that when I have an HA movement I warn me that there is an event to watch.
But what I donā€™t understand is where I am wrong to give the address to me seems right.
It occurs to me that it is motioneye addon that he is unable to send messages to HA

I donā€™t think there is anything wrong with the used urlā€™s.
You could test with mqtt-explorer and monitor what is going on :wink:

But I suspect youā€™re running Mosquito and MotionEye with HA addons (dockers)?
And that makes me doubt whether ā€˜mosquitto_pubā€™ is available within the MotionEye docker :face_with_raised_eyebrow:
Maybe someone can confirm my suspicion?

Nevertheless, I think using a web-hook is easier (and skips the usage of MQTT ;))

Hi guys, could use a little help here.

Iā€™m running HA Core, modified the snapshot_create_file_path so the picture is created with movement.
I do get notifications with movement, so that part is OK as well.
But, I donā€™t get to see the picture in the companion app (android).

I can open the snapshot in the browser on my desktop as well on mobile - restarted HA and the app.

What am I missing?

EDIT: this is all on LAN, not using https