[SOLVED] Send Image Item with Telegram

rules
telegram
items
Tags: #<Tag:0x00007f0153e2c380> #<Tag:0x00007f0153e37cf8> #<Tag:0x00007f0153e37578>

(Bastiaan van Haastrecht) #1

Hello,

I have a Synology with Surveillancestation installed. It’s great and has an API. I would like to send the latest snapshot image when the doorbell is pressed thru Telegram.

I got my Item & Rule setup so it gets the image in string from the Synology. Its saved in base64 (jpeg) in the Image Item. This works perfect. I can display the image in HABpanel.

Now I want to send this image thru telegram. From what I’ve researched is that you can send an image from URL and from File, but I doesn’t seem to have support from Image Item. (nice feature enhancement)

Is my findings correct? Is there some way to ‘convert’ my Image Item so the Telegram Action can use it?

Regards,
Bastiaan


(Bastiaan van Haastrecht) #2

I have forked the telegram action, and added the image via item myself. It’s working in my lab, will push the code asap.


(Jörg Mahmens) #3

Hi, I use in my OH2.2 the new telegram action from Snapshot (org.openhab.action.telegram-1.12.0-SNAPSHOT.jar)

With this code I send an Image from wunderground weather via Telegram in a rule

    // Images
    var String base64Image0 = weatherunderground_weather_XXX_current_icon.state.toFullString
    sendTelegramPhoto("bot1", base64Image0, "Caption")

Using of …_icon.state.toString doesn’t work but …_icon.state.toFullString


(Bastiaan van Haastrecht) #4

Hi @JMahmens, I take this is not a question but an example?


(E. Gerland) #5

How did you do this?
I can send local files:

sendTelegramPhoto(“OH_Bot”, “http://192.168.178.50:8080/static/motion_d.jpg”, "Bewegung detektiert!\n Zeitpunkt: " + Dome_Motion.state)

But would prefer to use somthing like:

sendTelegramPhoto("OH_TeleBot", Syn_Tele_Snap.state.toString, "Zeitpunkt: " + Abus_Motion.state)

Where Syn_Tele_Snap is the snapshot (image item).


Pushover image support
(Bastiaan van Haastrecht) #6

You need to use ‘.toFullString’ to get the image formatted as base64 string.

sendTelegramPhoto("OH_TeleBot", Syn_Tele_Snap.state.toFullString, "Text")

(E. Gerland) #7

Thanks a lot - I will give it a try!

EDIT: Works, thanks