Telegram Binding

Hello
I’m running openhab 3.0.2 as a docker container. I installed Telegram Binding and configured a Telegram Bot Thing with my Token and ID and the Thing shows Online as status. I then created the following test DSL rule.

val telegramAction = getActions("telegram","telegram:telegramBot:TelegramBot")
   telegramAction.sendTelegram(" Pumpe 1 hat einen Alarm. Bitte überprüfen.")

If I fire the rule and click on Run now, the message appears within seconds in my Telegram Chat Bot on my personal smart phone. I then installed Telegram on a second smart phone and added my Chat Bot to Telegram. For some reason the message doesn’t appear on that smart phone at all. I really don’t know why. Did I miss something?

Thank you very much for your help.

Greetings Manuel

Are you using the same account to access telegram?

If its 2 people I think you may have created a new bot.

Hello James
Thank you for your answer. Yes my idea was to use the same chat bot for all three family members to send the alarm only to one chat bot and all three family members get the alarm if they add the Telegram chat bot to there Telegram app.

Yesterday I did some research on the net and found this post. It’s a kind of the other way round. I would like to have one Telegram chat bot and multiple consumers.

Maybe I don’t understand the idea of a chat bot. Is it necessary that every family member creates his own Telegram chat bot and then I can send the alarm to each of this individual chat bot? Can only Telegram chat bot creators receive messages in this chatbot?

Many thanks for your help. I’m really stucked.

Greetings Manuel

Hi, you have to add the chatbot in the family’s telegram.
Then you have to find out the chatID of the new members.
in the thing configuration you add the chatIDs.
Then the messages will be sent to all active chatIDs

I have one bot for me and my wife.
You are able to send messages only to one member if you add the chatID into the rule.
Greets

Hello Sebastian
Thank you very much for your answer. Ok, well I’m not very familiar with Telegram. Let me summarize your post.

  1. I need to create a group in telegram
  2. Add all family members and the chat bot to that family group
  3. Find chatID of the newly created family group somehow…
  4. Add chatID to things config and send message to chatID of family group instead to ID of chat bot
  5. Done

Thank you for your help! Long live openHAB!

Greetings Manuel

I glad you are learning and having fun.

As you are building your system have a think about what each family member wants as they probably don’t want all the same thing. You want the least amount of messages and only want the information you want.

You have successfully created one bot and have figured out how it works :+1:

Do the same for each family member so in the future you can address each one individually.

Then you can do things like

val telegramManuel = getActions("telegram","telegram:telegramBot:Manuel")
   telegramManuel.sendTelegram(" Pumpe 1 hat einen Alarm. Bitte überprüfen.")

Add another person could be

val message = " Pumpe 1 hat einen Alarm. Bitte überprüfen."
val telegramPerson = getActions("telegram","telegram:telegramBot:Person")
val telegramManuel = getActions("telegram","telegram:telegramBot:Manuel")
   telegramManuel.sendTelegram( message )
   telegramPerson.sendTelegram( message )
val message = " Happy Birthday you are " + secondCalc + " Seconds Old"
val telegramManuel = getActions("telegram","telegram:telegramBot:Manuel")
   telegramManuel.sendTelegram( message )

Person you have left your lights on in your bedroom do you want me to turn them off?

/ code not tested

Hello James
Thank you for your input.

I’m monitoring only a pump in the basement of a building. If there is an alarm on the pump controller, a message should be sent to only three people, me included. Not more. So all person should get the same message. There is no need at the moment to address these three people individually.

I supposed that one telegram chat bot should be enough for this but as I noticed I’m the only one which gets the message (I was creating the chat bot from my smartphone and I’m the only one having the token and ID).

Greetings Manuel

No no. You need just one bot, no group

Btw I’m on openhab 2.5 but I think it’s the same way.

I had linked the ‘chatID’ channel to an item.
then, I wrote to the bot with my wifes phone.
(you can search the bot and write a message)
Now, the chatID string changed.
This is the chatID from the wifes phone.

In the thing configuration (telegram bot) is a field where you add the chatIDs which the bot can interact.

Put here yours (is already) and the other chatID. (comma separated)

Then the bot should message to both phones.

I think I can explain better in German :grin:

Greets

Hello Sebastian
Thank you for your explanation. I’ll try this and give you some feedback. I really appreciate your help.

I’m using OH3 running as Docker Container and by the way I’m from Switzerland understanding German :wink:

Regards Manuel

Hello
As far I understand I need to have a individual chatID per chat bot consumer resp. per smartphone. So I did the following.

  1. Added my chatBot to the second smartphone in telegram
  2. Entered /start in the chatBot
  3. Typed some words in the chatBot to wake it up
  4. Pointed my browser to https://api.telegram.org/bot{token}/getUpdates
  5. I expected to receive an additional chatID which I can then add in my Telegram Thing. Unfortunately I only get the following answer from api.telegram.org.
ok	true
result	[]

What am I doining wrong?

Thank you for your patient :blush:

Greets Manuel

Link your thing - chatID to an item.
then you will see the chatID when you wrote a message to the bot.
That’s what I did…

Hello Sebastian
Thank you for your help. I’ve got the solution now. I’m very happy. Here is what I did.

  1. on the second smartphone opened telegram and added bot IDBot
  2. Wrote /getid into IDBot
  3. Got chatID of my second smartphone back
  4. added second chatID to my Telegram Things in Chat Id(s)

Telegram Thing

That’s it. Now both smartphones get the message!

Greetings Manuel

I’m glad that I could help you.