I am setting up Scrypted NVR, which has a homeassistant plugin supporting sending notifications to Home Assistant. This works for Home Assistant Companion notifications. I receive the title, message and the image in the notification on my devices.
I have also setup a telegram bot, however when a notification is sent to the bot, I get the text and no image. It seems the bot doesn’t receive the “image:” data from the notification json.
For example, when I send a test, Home Assistant receives a notification, with an image payload
DEBUG (MainThread) [homeassistant.core] Bus:Handling
<Event call_service[L]:
domain=notify,
service=lazynooblet,
service_data=title=Scrypted Notification,
message=This is a message from Scrypted,
data=priority=high,
image=https://home.scrypted.app/_punch/web_hi_res_512.png>
But the image is stripped when sent to the telegram bot
DEBUG (MainThread) [homeassistant.components.telegram_bot]
New telegram message send_message: {
'target': [1######0],
'title': 'Scrypted Notification',
'message': 'This is a message from Scrypted'
}
That would grab the current snapshot, but the image from Scrypted NVR is a cropped photo of the object that triggered the notification. This is generated and sent as part of the notification.
Works fine on the companion app, but is literally lost in translation when sent to Telegram Bot.
Sorry maybe I misunderstood. So your Scrypted NVR HA plugin is sending the notification? If so can you change the code so that the notification sent to Telegram has a different format? Because the message format of those services is different and that is why the image does not appear in Telegram.
If you cannot change the plugin you could write a HA automation that is triggered by the HA notification and sends out the telegram notification from HA using code similar to the one I posted above.
If you really need it, it can be done. The companion app can trigger HA when it receives a certain notification. A HA automation can then send out the Telegram notification. It would be not too complicated but of course some yaml coding needs to be done.
I couldn’t find it yet. I believe its better for you to create a new topic and specifically ask for whether or not it is possible to extract the image name from a received notification that has an image attached. Maybe there is someone who did this and therefore knows how to do it.
What just came to my mind. You have the image url stored in the call_service event above,
So you should be able to create an automation that waits for that trigger and then pulls the url. I have not tried but something like this:
trigger:
platform: event
event_type: call_service
event_data:
domain: notify
service: lazynooblet
service_data:
title: Scrypted Notification
action:
- service: notify.lazynooblet
data:
message: 'Message'
data:
photo:
- url: '{{ trigger.event.data.image }}' # Note that is the key. I'm not sure if this works. You have to try.
caption: 'Caption'