New Telegram Binding - Tester and Feedback welcome

Pushover is a V1 binding and a V3 version is still in active development so the only way in openHAB V3 is to use telegram and it is working well for a few days here.

Regarding gif and telegram there is something weird under iOS as they are very clear if viewed with the desktop app, but on phone they are blurry, please post if anyone knows why.

I am using mp4 which is very smooth and has audio.

MP4 with audio, awesome. I’ve been considering changing the camera over my front door to one with a microphone and this might be what makes me finally do it. Does the binding work on 2.5?

No, the changes are for V3 only, however it is possible to do this via a script under 2.5

In Linux, this will work from the terminal and can be in a bash script.

curl -F video=@"/tmp/Doorbell/ipcamera.mp4" https://api.telegram.org/bot112233445566:AABBCCDDEEFFUUJSJIUDFF/sendVideo?chat_id=111222233344556566

There’s also another example here:

That’s really useful info, thanks.

Hi
After months of regular activity today I found my Telegram bot offline and in event.log this error

2020-11-12 10:04:14.064 [hingStatusInfoChangedEvent] - ‘telegram:telegramBot:xxxxxxx’ changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): java.net.SocketTimeoutException: timeout
2020-11-13 16:52:51.923 [hingStatusInfoChangedEvent] - ‘telegram:telegramBot:xxxxxxx’ changed from OFFLINE (COMMUNICATION_ERROR): java.net.SocketTimeoutException: timeout to UNKNOWN

what steps can I follow to understand the problem?
OH 2.5.10

Ale

Did you try to restart openHAB, or otherwise kill thing and reactivate to force telegram to restart without starting openHAB?

@JensH Tried first: kill things without success

2020-11-13 19:38:09.477 [hingStatusInfoChangedEvent] - ‘telegram:telegramBot:09202f90’ changed from UNKNOWN to REMOVING
2020-11-13 19:38:09.483 [hingStatusInfoChangedEvent] - ‘telegram:telegramBot:09202f90’ changed from REMOVING to REMOVED
2020-11-13 19:38:09.528 [hingStatusInfoChangedEvent] - ‘telegram:telegramBot:09202f90’ changed from REMOVED to UNINITIALIZED
2020-11-13 19:38:09.581 [hingStatusInfoChangedEvent] - ‘telegram:telegramBot:09202f90’ changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)
2020-11-13 19:43:00.409 [hingStatusInfoChangedEvent] - ‘telegram:telegramBot:493d00e4’ changed from UNINITIALIZED to INITIALIZING
2020-11-13 19:43:00.426 [hingStatusInfoChangedEvent] - ‘telegram:telegramBot:493d00e4’ changed from INITIALIZING to UNKNOWN

@JensH
the reboot was effective

thanks!
Ale

I have tried like the doc suggests, however with no luck.
How is the “telegramMessage” retrieved in the doc example?

rule "Reply handler for lights"
when
    Item telegramReplyId received update Reply_Lights
then
    val telegramAction = getActions("telegram","telegram:telegramBot:2b155b22")

    if (telegramMessage.state.toString == "Yes")
    {
        gLights.sendCommand(OFF)
        telegramAction.sendTelegramAnswer(telegramReplyId.state.toString, "Ok, lights are *off* now.") 
    }
    else
    {
        telegramAction.sendTelegramAnswer(telegramReplyId.state.toString, "Ok, I'll leave them *on*.")
    }
end

Here is my code: send query first

telegramAction.sendTelegramQuery("Porte de garage ouverte depuis: " + PorteGarage.lastUpdate + "\nVoulez-vous la fermer?", "PorteGarageActionAnswer", "Oui", "Non")

Then use rule to parse answer:

rule "PorteGarage notification si ouverture trop longue - parse answer"
when
    Item telegramReplyId received update PorteGarageActionAnswer
then
    val telegramAction = getActions("telegram","telegram:telegramBot:Telegram_Bot")
    logInfo("portegarage", "telegramReplyId.state.toString = " + telegramReplyId.state.toString)
    logInfo("portegarage", "telegramAction.toString = " + telegramAction.toString)
    logInfo("portegarage", "telegramAction = " + telegramAction)
    if (telegramMessage.state.toString == "Oui")
    {
        PorteGarage_Relay.sendCommand(ON)
        telegramAction.sendTelegramAnswer(telegramReplyId.state.toString, "Ok, je ferme")
    }
    else
    {
        telegramAction.sendTelegramAnswer(telegramReplyId.state.toString, "Ok, je laisse ouvert")
    }

Corresponding log when I press one of the buttons:

2021-01-28 16:29:10.065 [INFO ] [e.smarthome.model.script.portegarage] - telegramReplyId.state.toString = PorteGarageActionAnswer

2021-01-28 16:29:10.066 [INFO ] [e.smarthome.model.script.portegarage] - telegramAction.toString = org.openhab.binding.telegram.bot.TelegramActions@18fd409

2021-01-28 16:29:10.066 [INFO ] [e.smarthome.model.script.portegarage] - telegramAction = org.openhab.binding.telegram.bot.TelegramActions@18fd409

2021-01-28 16:29:10.066 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'PorteGarage notification si ouverture trop longue - parse answer': The name 'telegramMessage' cannot be resolved to an item or type; line 60, column 9, length 15

And you should check your telegram items. The log shows the item isn’t found

1 Like

stupid me :slight_smile: :slight_smile: :slight_smile:
sometimes other people find in 10 seconds what we fight for during hours
Was wondering how last message was retrieved.

Added this in an .items file and now working.

String telegramMessage "Telegram Message" { channel = "telegram:telegramBot:2b155b22:lastMessageText" }

Was a pleasure for me :slight_smile:

I put all Replies within one rule and a Switch case, so I have some easier to found the code :slight_smile: Maybe a useful hint.

Is there a latest example how to work with the telegram binding in Javascript and OH3? Could only find something with script helpers for 2.4/2.5

it works in 3.X just like it did it 2.X

Just stumpled across this topic and thought I post my way, maybe it helps:
Have this rule here

triggers:
  - id: "1"
    configuration:
      itemName: Telegram_PhiL
    type: core.ItemStateChangeTrigger
conditions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: Telegram_PhiL
      state: ""
      operator: "!="
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "3"
    configuration:
      type: application/javascript
      script: >
        var telegramAction =
        actions.get("telegram","telegram:telegramBot:*********");

        telegramAction.sendTelegram(itemRegistry.getItem( 'Telegram_PhiL' ).getState().toString());
    type: script.ScriptAction

so I can use the item Telegram_PhiL as a proxy, whatever I put this item to will be forwarded to my phone.

3 Likes

It seems that this is the “official” Telegram post, I’d like to mention a current open incident:

Sorry if this is against rules (double posting) but my hope is that maybe someone has a workaround in place or an idea what is happening.
Any feedback welcome…

1 Like

This would be great if this can be fixed. But I am not sure if it is related to the telegram binding or openhab3. Maybe some of the openhab developers can tell if it related to the binding or the system @J-N-K @ysc @David_Graeff

The same is in openhab 2.5.12

I used to receive the telegramaction like a global variable in the rule, at the top outside of every single rule.
But I think we need to move it within the rule just before the sendMessage:
var telegramAction = getActions(“telegram”,“telegram:telegramBot:FS6”) telegramAction.sendTelegram(“Test”)

@eric1905: if you place it before every sendMessage, does it work then?
But it still feels like a bug because leaving the var entry at the top and only reload the rule gets it working