Telegram BOT

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
bing69
Posts: 139
Joined: Thursday 05 June 2014 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: 's-Hertogenbosch, NL
Contact:

Telegram BOT

Post by bing69 »

Have been running the telegram bot for some time without any problems. Now also want to add my wife. Follow the wiki again and create a new bot. However, if I want to retrieve the ID by:

https://api.telegram.org/bot784324329:E ... getUpdates

(fill in her information ofcourse), I only get the result:

{"ok": true, "result": []} further Is not shown.

What do i wrong??
User avatar
jvdz
Posts: 2446
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Telegram BOT

Post by jvdz »

Why have you created a new bot? I am using a single BOT instances with multiple different persons/phones?
It is just a matter of getting them setup in the TelegramBotWhiteListedIDs variable seperated with a verticalbar character.

Jos
bing69
Posts: 139
Joined: Thursday 05 June 2014 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: 's-Hertogenbosch, NL
Contact:

Re: Telegram BOT

Post by bing69 »

Sorry but where van i find that??
User avatar
jvdz
Posts: 2446
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Telegram BOT

Post by jvdz »

From: https://www.domoticz.com/wiki/Remote_Co ... _Variables
Domoticz User Variables[edit]
Create the following user variables in Domoticz before starting dtgbot
TelegramBotOffset - integer: In order to stop dtgbot from processing the same message repeatedly it needs to keep track of the id of the next message. To do this create a user variable in Domoticz called TelegramBotOffset and set it to a value of 1. The first use of dtgbot will result in all unread messages being received and processed, at which point the offset will be correctly set and then only new messages will be processed from now on.
TelegramBotMenu - string: This will determine whether custom keyboards are displayed - set the value to On to use custom keyboard and Off to not use custom keyboards.
TelegramBotWhiteListedIDs string: Use this string to secure your dtgbot from being used by everybody. Put a list of userids that you want to allow to access your system separated by | here as userid1|userid2|userid3 , these are numbers so it will look like 12345678|2343249724|4534957 or use 1234342234 if you only want 1 person to access the system. If this variable does not exist then anybody can access your bot.
Jos
bing69
Posts: 139
Joined: Thursday 05 June 2014 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: 's-Hertogenbosch, NL
Contact:

Re: Telegram BOT

Post by bing69 »

jvdz wrote:From: https://www.domoticz.com/wiki/Remote_Co ... _Variables
Domoticz User Variables[edit]
Create the following user variables in Domoticz before starting dtgbot
TelegramBotOffset - integer: In order to stop dtgbot from processing the same message repeatedly it needs to keep track of the id of the next message. To do this create a user variable in Domoticz called TelegramBotOffset and set it to a value of 1. The first use of dtgbot will result in all unread messages being received and processed, at which point the offset will be correctly set and then only new messages will be processed from now on.
TelegramBotMenu - string: This will determine whether custom keyboards are displayed - set the value to On to use custom keyboard and Off to not use custom keyboards.
TelegramBotWhiteListedIDs string: Use this string to secure your dtgbot from being used by everybody. Put a list of userids that you want to allow to access your system separated by | here as userid1|userid2|userid3 , these are numbers so it will look like 12345678|2343249724|4534957 or use 1234342234 if you only want 1 person to access the system. If this variable does not exist then anybody can access your bot.
Jos
Jos,

Do we talk about the same? I have installed and work according to this page:
Https://www.domoticz.com/wiki/Telegram_Bot

Ad
User avatar
jvdz
Posts: 2446
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Telegram BOT

Post by jvdz »

You are correct when you only use the Telegram bot to send notifications.
I assume you also use the Bot to control Domoticz. :-)
Either way, you still are able to use the single bot to send messages to multiple users of Telegram, and control Domoticz from this BOT with the page I linked to.
I use LUA code to send notifications to the different telephones like described on the page you linked: https://www.domoticz.com/wiki/Telegram_ ... iple_users

Jos
bing69
Posts: 139
Joined: Thursday 05 June 2014 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: 's-Hertogenbosch, NL
Contact:

Re: Telegram BOT

Post by bing69 »

jvdz wrote:You are correct when you only use the Telegram bot to send notifications.
I assume you also use the Bot to control Domoticz. :-)
Either way, you still are able to use the single bot to send messages to multiple users of Telegram, and control Domoticz from this BOT with the page I linked to.
I use LUA code to send notifications to the different telephones like described on the page you linked: https://www.domoticz.com/wiki/Telegram_ ... iple_users

Jos
Jos,

Thanks. But then we're back with my problem again.
I do not get an id back from telegram. As in the example.

{"ok":true,"result":[{"update_id":939819607,
"message":{"message_id":81,"from":{"id":1234567,"first_name":"Joe","last_name":"Bloggs","username":"jbloggs"},"chat":
{"id":1234567,"first_name":"Joe","last_name":"Bloggs","username":"jbloggs"},"date":1436104501,"text":"\/devices Study"}},{"update_id":939819608,
"message":{"message_id":82,"from":{"id":1234567,"first_name":"Joe","last_name":"Bloggs","username":"jbloggs"},"chat":
{"id":1234567,"first_name":"Joe","last_name":"Bloggs","username":"jbloggs"},"date":1436104512,"text":"\/off 1"}}]}

i get only :

{"ok":true,"result":[{
zicht
Posts: 300
Joined: Sunday 11 May 2014 11:09
Target OS: Windows
Domoticz version: 2023.1+
Location: NL
Contact:

Re: Telegram BOT

Post by zicht »

Hi

Just an idea, "Thinking out loud" :

you should be able to send a message to your bot from you wifes phone.
Then you should be able to read the message with the getupdate from the telegram api.
Do this in you browser. In the returned update message containing the message you have send you should be able to read the ID of you wifes telegram.

like : https://api.telegram.org/bot:key/getUpdates

probably cause of you issue :
Just be shure to turn of any other receptors of the message (turn your script and phone off just to be sure), the getupdate is reset if message has status read, mening you would only get an empty ok message.

Also, if the api sees unread messages (EG no getupdates?offset=xxx where xxx is the message id) that is limted, you have to read received messages or thing will hangup *i assume queu full"....
I have ported the complete telegram thingy to lua as i am on windows and working fine. I can control any thing i want right now this way.
Sure willing to help you find you problem, as it took me quite a while to understand how to manage things :)

Hope this will get you on track...
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
bing69
Posts: 139
Joined: Thursday 05 June 2014 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: 's-Hertogenbosch, NL
Contact:

Re: Telegram BOT

Post by bing69 »

Thanks all for the answers. Tomorrow i go away for a holiday.
When i'm back i go further!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest