dtgbot - Domoticz TeleGram BOT
Moderator: leecollings
- jvdz
- Posts: 2276
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
The DTGBOT is running a loop requesting the "getUpdates?timeout=60&offset=xxxx" status. This will wait for about a minute for incoming messages after which the connection is ended by the server. In case there is no message the request is simply done again.
In case a Telegram message arrives for the BOT, the call returns right away and the message is processed.
This is the basic process used to retrieve the messages for the BOT.
The alternative could be to have Telegram deliver the messages, but that would mean you need to open up a port on your firewall and NAT to your PI, but this isn't implemented.
Jos
In case a Telegram message arrives for the BOT, the call returns right away and the message is processed.
This is the basic process used to retrieve the messages for the BOT.
The alternative could be to have Telegram deliver the messages, but that would mean you need to open up a port on your firewall and NAT to your PI, but this isn't implemented.
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 476
- Joined: Monday 14 March 2016 13:55
- Target OS: Linux
- Domoticz version: beta
- Location: Rome, Italy
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
Hi all
don't understand why, but dtgbot stopped working.
It worked well until some days ago, and now nothing...
I'm getting into the roomplan error, as explained in the last part of the wiki http://www.domoticz.com/wiki/Remote_Con ... legram_Bot
But I have four Roomplan defined, as I already did, and no change from when it was working.
I get exacting the same errors as descrobed in the Wiki.
I get also active(exited) when I check status
What can I check?
Thanks
don't understand why, but dtgbot stopped working.
It worked well until some days ago, and now nothing...
I'm getting into the roomplan error, as explained in the last part of the wiki http://www.domoticz.com/wiki/Remote_Con ... legram_Bot
But I have four Roomplan defined, as I already did, and no change from when it was working.
I get exacting the same errors as descrobed in the Wiki.
I get also active(exited) when I check status
Code: Select all
● dtgbot.service - LSB: A Telegram bot designed to control Domoticz
Loaded: loaded (/etc/init.d/dtgbot)
Active: active (exited) since mer 2016-05-25 22:45:14 CEST; 12s ago
Process: 3985 ExecStop=/etc/init.d/dtgbot stop (code=exited, status=0/SUCCESS)
Process: 4148 ExecStart=/etc/init.d/dtgbot start (code=exited, status=0/SUCCESS)
mag 25 22:45:14 raspberrypi dtgbot[4148]: Starting Telegram Bot for Domoticz ... Done.
mag 25 22:45:14 raspberrypi systemd[1]: Started LSB: A Telegram bot designed to control Do...cz.
Hint: Some lines were ellipsized, use -l to show in full.
What can I check?
Thanks
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
- jvdz
- Posts: 2276
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
Set the domoticz user variable TelegramBotLoglevel to 2, start dtgbot and show or PM the dtg.log and dtg.log.errors so I can see what is happening.
Jos
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 476
- Joined: Monday 14 March 2016 13:55
- Target OS: Linux
- Domoticz version: beta
- Location: Rome, Italy
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
Hi jvdz
I created the uservariable TelegramBotLogLevel, since I haven't got it.
I then reboot it and this is what I have in dtb.log
and the dtb.log.errors
I don't see any differences in the log with this uservariable set to 2 or without it.
I created the uservariable TelegramBotLogLevel, since I haven't got it.
Code: Select all
TelegramBotLogLevel Integer 2
Code: Select all
2016-05-26 10:47:48 - DomoticzIP: 192.168.1.xxx
2016-05-26 10:47:48 - DomoticzPort: 8080
2016-05-26 10:47:48 - BotHomePath: /home/pi/dtgbot/
2016-05-26 10:47:48 - BotLuaScriptPath: /home/pi/dtgbot/lua/
2016-05-26 10:47:48 - BotBashScriptPath: /home/pi/dtgbot/bash/
2016-05-26 10:47:48 - TelegramBotToken: xxxxxxxx
2016-05-26 10:47:48 - TelegramBotOffset: TelegramBotOffset
2016-05-26 10:47:48 - -----------------------------------------
2016-05-26 10:47:48 - Starting Telegram api Bot message handler
2016-05-26 10:47:48 - -----------------------------------------
2016-05-26 10:47:51 - Domoticz returned getuservariables after 3 attempts
and the dtb.log.errors
Code: Select all
/usr/bin/lua5.2: /home/pi/dtgbot//dtg_domoticz.lua:125: attempt to get length of global 'result' (a nil value)
stack traceback:
/home/pi/dtgbot//dtg_domoticz.lua:125: in function 'device_list_names_idxs'
/home/pi/dtgbot/dtgbot.lua:174: in function 'dtgbot_initialise'
/home/pi/dtgbot/dtgbot.lua:229: in main chunk
[C]: in ?
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
- jvdz
- Posts: 2276
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
ah, i see the debug logging is set later so that indeed doesn't give more information. guess that needs changing.
Could you provide the output for this URL:
Jos
Could you provide the output for this URL:
Code: Select all
http://xxx.xxx.xxx.xxx:8080/json.htm?type=plans&order=name&used=true
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 476
- Joined: Monday 14 March 2016 13:55
- Target OS: Linux
- Domoticz version: beta
- Location: Rome, Italy
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
This is what I get:
Thanks
Code: Select all
{
"result" : [
{
"Devices" : 12,
"Name" : "Meteo",
"Order" : "2",
"idx" : "x"
},
{
"Devices" : 0,
"Name" : "NAS",
"Order" : "3",
"idx" : "x"
},
{
"Devices" : 6,
"Name" : "Persiane",
"Order" : "4",
"idx" : "x"
},
{
"Devices" : 7,
"Name" : "Irrigation",
"Order" : "5",
"idx" : "x"
}
],
"status" : "OK",
"title" : "Plans"
}
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
-
- Posts: 476
- Joined: Monday 14 March 2016 13:55
- Target OS: Linux
- Domoticz version: beta
- Location: Rome, Italy
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
Now I removed the NAS roomplan which has no devices inside, but no changes
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
- jvdz
- Posts: 2276
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
Still doesn't make much sense as it seems the url does return what is expected, but the error indicates nothing is received.
I've proposed this update to the device_list_names_idxs function in dtg_domoticz.lua to avoid the error:
You could change it for yourself, but I expect the menu to be pretty empty.
Jos
I've proposed this update to the device_list_names_idxs function in dtg_domoticz.lua to avoid the error:
Code: Select all
function device_list_names_idxs(DeviceType)
--returns a devcie idx based on its name
local idx, k, record, decoded_response
decoded_response = device_list(DeviceType)
result = decoded_response['result']
devices = {}
devicesproperties = {}
if result ~= nil then
for i = 1, #result do
record = result[i]
if type(record) == "table" then
if DeviceType == "plans" then
devices[record['Name']] = record['idx']
else
devices[string.lower(record['Name'])] = record['idx']
devices[record['idx']] = record['Name']
if DeviceType == 'scenes' then
devicesproperties[record['idx']] = {Type=record['Type'], SwitchType = record['Type']}
end
end
end
end
end
return devices, devicesproperties
end
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 476
- Joined: Monday 14 March 2016 13:55
- Target OS: Linux
- Domoticz version: beta
- Location: Rome, Italy
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
The strange thing is that it was working until one week ago.
I probably have updated something (for sure the Domoticz bet to the last one) and some packages in Raspbian, but not in dgtbot.
I've tried reinstalling it, step by step, but nothing changes.
I will try this afternoon your update...
Thanks
I probably have updated something (for sure the Domoticz bet to the last one) and some packages in Raspbian, but not in dgtbot.
I've tried reinstalling it, step by step, but nothing changes.
I will try this afternoon your update...
Thanks
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
- jvdz
- Posts: 2276
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
We can take this offline (in PM) and simply start step by step the debugging until we found the the reason, but you will have to make regular updates to the LUA scripts for this.
Jos
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 476
- Joined: Monday 14 March 2016 13:55
- Target OS: Linux
- Domoticz version: beta
- Location: Rome, Italy
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
ok, thanks for your availability. 
I will do it most probably starting tomorrow.

I will do it most probably starting tomorrow.
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
-
- Posts: 476
- Joined: Monday 14 March 2016 13:55
- Target OS: Linux
- Domoticz version: beta
- Location: Rome, Italy
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
Hi Josjvdz wrote:Still doesn't make much sense as it seems the url does return what is expected, but the error indicates nothing is received.
I've proposed this update to the device_list_names_idxs function in dtg_domoticz.lua to avoid the error:
...
You could change it for yourself, but I expect the menu to be pretty empty.
Jos
I just tried the script update you propose and now it's working!!!!
Thanks!
What was the trick?
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
-
- Posts: 24
- Joined: Monday 27 April 2015 20:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.8258
- Location: Netherlands
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
Can you share the script update?
I have problems getting the DTGbot service up and running.
If I send "devices" I don't get any response or the services crashes
I have problems getting the DTGbot service up and running.
If I send "devices" I don't get any response or the services crashes
-
- Posts: 476
- Joined: Monday 14 March 2016 13:55
- Target OS: Linux
- Domoticz version: beta
- Location: Rome, Italy
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
Just go to post 168 of this 3d, it should be less than five post before your.
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
- jvdz
- Posts: 2276
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
The update to the original script is posted a few posts up, but in case you want to debug the setup, then simply change the Domoticz variable TelegramBotLoglevel to 2, restart the service and check both dtb.log and dtb.log.errors for any errors.
Jos
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 1
- Joined: Wednesday 24 February 2016 23:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.8061
- Location: France
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
Hi everybody,
After a lot of reading, and trail and error I managed to get the control by telegram working.
Great work!!! very nice function.
However I have one question (I'm not a programmer at all).
I would like to send a http post command ( for wife acceptence) to my bot with a switch command to open my gates. Now it works with "On xxxxx" but ultimatly i would like to create a shortcut on the telephone to do this. I would appreciate if someone could help me. I have looked around but can't find a solution
Thanks
After a lot of reading, and trail and error I managed to get the control by telegram working.
Great work!!! very nice function.
However I have one question (I'm not a programmer at all).
I would like to send a http post command ( for wife acceptence) to my bot with a switch command to open my gates. Now it works with "On xxxxx" but ultimatly i would like to create a shortcut on the telephone to do this. I would appreciate if someone could help me. I have looked around but can't find a solution
Thanks
-
- Posts: 10
- Joined: Monday 08 August 2016 23:22
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.4834
- Location: Netherlands
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
Hi,
I believe I have followed all installation instructions, however I cannot send any commands to the bot.
The service is running :
pi@raspberrypi3:~/dtgbot$ sudo service dtgbot status
â dtgbot.service - LSB: A Telegram bot designed to control Domoticz
Loaded: loaded (/etc/init.d/dtgbot)
Active: active (exited) since Mon 2016-08-08 23:30:20 CEST; 5min ago
Process: 14193 ExecStop=/etc/init.d/dtgbot stop (code=exited, status=0/SUCCESS)
Process: 15121 ExecStart=/etc/init.d/dtgbot start (code=exited, status=0/SUCCESS)
Aug 08 23:30:20 raspberrypi3 dtgbot[15121]: Starting Telegram Bot for Domoticz ... Done.
Aug 08 23:30:20 raspberrypi3 systemd[1]: Started LSB: A Telegram bot designed to control Domoticz.
Output of dtb.log :
pi@raspberrypi3:~$ tail -f /var/tmp/dtb.log
2016-08-08 23:30:21 - Decoded xxxxxx
2016-08-08 23:30:21 - WLString: xxxxxx
2016-08-08 23:30:21 - Decoded 0
2016-08-08 23:30:21 - dtgbotLogLevel set to: 0
2016-08-08 23:30:21 - WLidx 11
2016-08-08 23:30:21 - Decoded xxxxxx
2016-08-08 23:30:21 - WLString: xxxxxx
2016-08-08 23:30:21 - Getting TelegramBotOffset the previous Telegram bot message offset from Domoticz
2016-08-08 23:30:21 - Decoded 783075188
The output of dtb.log.errors :
pi@raspberrypi3:~$ tail -f /var/tmp/dtb.log.errors
/usr/bin/lua5.2: /home/pi/dtgbot/dtgbot.lua:549: attempt to index global 'msg' (a nil value)
stack traceback:
/home/pi/dtgbot/dtgbot.lua:549: in main chunk
[C]: in ?
tail: /var/tmp/dtb.log.errors: file truncated
/usr/bin/lua5.2: /home/pi/dtgbot/dtgbot.lua:549: attempt to index global 'msg' (a nil value)
stack traceback:
/home/pi/dtgbot/dtgbot.lua:549: in main chunk
[C]: in ?
Any ideas ?
I believe I have followed all installation instructions, however I cannot send any commands to the bot.
The service is running :
pi@raspberrypi3:~/dtgbot$ sudo service dtgbot status
â dtgbot.service - LSB: A Telegram bot designed to control Domoticz
Loaded: loaded (/etc/init.d/dtgbot)
Active: active (exited) since Mon 2016-08-08 23:30:20 CEST; 5min ago
Process: 14193 ExecStop=/etc/init.d/dtgbot stop (code=exited, status=0/SUCCESS)
Process: 15121 ExecStart=/etc/init.d/dtgbot start (code=exited, status=0/SUCCESS)
Aug 08 23:30:20 raspberrypi3 dtgbot[15121]: Starting Telegram Bot for Domoticz ... Done.
Aug 08 23:30:20 raspberrypi3 systemd[1]: Started LSB: A Telegram bot designed to control Domoticz.
Output of dtb.log :
pi@raspberrypi3:~$ tail -f /var/tmp/dtb.log
2016-08-08 23:30:21 - Decoded xxxxxx
2016-08-08 23:30:21 - WLString: xxxxxx
2016-08-08 23:30:21 - Decoded 0
2016-08-08 23:30:21 - dtgbotLogLevel set to: 0
2016-08-08 23:30:21 - WLidx 11
2016-08-08 23:30:21 - Decoded xxxxxx
2016-08-08 23:30:21 - WLString: xxxxxx
2016-08-08 23:30:21 - Getting TelegramBotOffset the previous Telegram bot message offset from Domoticz
2016-08-08 23:30:21 - Decoded 783075188
The output of dtb.log.errors :
pi@raspberrypi3:~$ tail -f /var/tmp/dtb.log.errors
/usr/bin/lua5.2: /home/pi/dtgbot/dtgbot.lua:549: attempt to index global 'msg' (a nil value)
stack traceback:
/home/pi/dtgbot/dtgbot.lua:549: in main chunk
[C]: in ?
tail: /var/tmp/dtb.log.errors: file truncated
/usr/bin/lua5.2: /home/pi/dtgbot/dtgbot.lua:549: attempt to index global 'msg' (a nil value)
stack traceback:
/home/pi/dtgbot/dtgbot.lua:549: in main chunk
[C]: in ?
Any ideas ?
-
- Posts: 329
- Joined: Tuesday 16 July 2013 22:54
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.8807
- Location: North East England
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
Sadly, I think you are right, I don't think it is possible to send a message as an http post command.cris77 wrote:I would like to send a http post command ( for wife acceptence) to my bot with a switch command to open my gates. Now it works with "On xxxxx" but ultimatly i would like to create a shortcut on the telephone to do this. I would appreciate if someone could help me. I have looked around but can't find a solution
Thanks
This is effectively a Telegram question and would not require any modification to allow dtgbot to do what you want to, if Telegram allowed it. It doesn't due to the security issues it would raise.
The bot sends a message effectively via an http post - so dtgbot sends an http post command to the Telegram api, which results in a message popping up in your Telegram client, but you can't send a http post command to the bot this way.
My only thought was whether you could have a bot that could send a message to another bot, but I don't think this is possible.
So rather than an http post command, you would need to code a Telegram client, which would be a single button on a phone.
jvdz is working on inline menus which while running in a Telegram client do present simple buttons to push.
Raspberry Pi 2 B - 2A@5V PSU - Raspbian + Domoticz + RFXtrx(89), LightwaveRF House(dimmers, sockets, wireless/mood switches), Owl CM113, 4 LaCross Temp / Humidity Sensors, 4 Siemens PIR, Smappee, Solaredge, ESP8266
-
- Posts: 329
- Joined: Tuesday 16 July 2013 22:54
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.8807
- Location: North East England
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
Only ideas -hannibal2206 wrote:.......
The output of dtb.log.errors :
pi@raspberrypi3:~$ tail -f /var/tmp/dtb.log.errors
/usr/bin/lua5.2: /home/pi/dtgbot/dtgbot.lua:549: attempt to index global 'msg' (a nil value)
stack traceback:
/home/pi/dtgbot/dtgbot.lua:549: in main chunk
[C]: in ?
tail: /var/tmp/dtb.log.errors: file truncated
/usr/bin/lua5.2: /home/pi/dtgbot/dtgbot.lua:549: attempt to index global 'msg' (a nil value)
stack traceback:
/home/pi/dtgbot/dtgbot.lua:549: in main chunk
[C]: in ?
Any ideas ?
You could have a command that is causing a problem, so try increase the bot offset - http://www.domoticz.com/wiki/Remote_Con ... use_Errors
Raspberry Pi 2 B - 2A@5V PSU - Raspbian + Domoticz + RFXtrx(89), LightwaveRF House(dimmers, sockets, wireless/mood switches), Owl CM113, 4 LaCross Temp / Humidity Sensors, 4 Siemens PIR, Smappee, Solaredge, ESP8266
-
- Posts: 10
- Joined: Monday 08 August 2016 23:22
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.4834
- Location: Netherlands
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
a bit further ..
Using the service won't work, but running interactively "lua dtgbot.lua" things start to work !
Need to find what the difference is ..
Using the service won't work, but running interactively "lua dtgbot.lua" things start to work !
Need to find what the difference is ..
Who is online
Users browsing this forum: No registered users and 1 guest