Closed keiranharris closed 1 month ago
I don't know exactly how to help you. But if you are a python user, you could read the code of the mqtt cam in homeassistant/core Maybe this component uses the same approach.
Ok thanks i can try on the weekend. BTW - i have seen other people, on non sonoff cams, solve this by 1/ invoking the home assistant cam snapshot function 2/ writing that image to the local filesystem somewhere 3/ then picking up that latest image off the disk, to embed in a notification message..... but given you ALREADY put an image on the bus, this seems inefficient to me.
Out of curiosity, outside of home assistant (which sounds like you might not use?), do you do this? Use that image you put on the mqtt bus, and do something with it? I guess im looking to confirm that i actually can use that image.
You should be able to get the image from the MQTT message from the trigger.payload
variable in your automation. However telegram can only read images from a file or URL so you probably going to have to save it anyway.
If you are using the MQTT camera integration, then the following will probably work to get the image also: https://www.home-assistant.io/integrations/generic/#sharing-a-camera-feed-from-one-home-assistant-instance-to-another
@keiranharris here you have my automation just in case it helps you. When motion is detected it send me a telegram msg with the image 😃 :
alias: Send Sonoff camera snapshot to Telegram when motion is detected
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.yi_hack_s_93abe8_motion_detection
from: "off"
to: "on"
condition: []
action:
- service: camera.snapshot
data:
filename: /config/www/tmp/{{filename}}.jpg
target:
entity_id: camera.yi_hack_s_93abe8_cam
- service: notify.pixel
data:
message: Movimiento detectado
data:
message: Movimiento detectado
photo:
- file: /config/www/tmp/{{filename}}.jpg
caption: 🚨 Movimiento detectado en salón {{filename}}
variables:
filename: snapshot-{{now().strftime("%d%m-%H%M%S")}}
mode: single
It just use motion detection from MQTT, not the image, the image is pulled from the calm with home assistant snapshot service. I could reuse the one coming from MQTT but it must be because of what @darkxst says, I dont remember now because I did this some time ago, but it works :)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hi, i appreciate this is not a bug - but ive ran dry with my googling, and figure as you wrote the code there is a fair chance you will know the direction to point me in.
im running your hack and loving it. Today i ventured into MQTT world (first time ive needed it, although im a long term home assistant user). I went here, to get motion detect images from these sonoff cams, sent to my telegram.
My early automation is below - and it works just fine - as in when i walk past the cam, my telegram alerts me, with a simple message:
![image](https://user-images.githubusercontent.com/22670742/191717809-b85973d9-1dbf-43d7-ab05-5b1487546d3d.png)
but how do i get the motion_detection_image snapshot (that i can see is being published) off the MQTT message bus, and into my notifiy automation action above?![image](https://user-images.githubusercontent.com/22670742/191718075-71c8f721-c5c8-4ea4-a6ef-81c762eb85fb.png)
thanks in advance! great work BTW! Keiran.