dtgbot - Domoticz TeleGram BOT

Client tools or tools that can connect with Domoticz. Tools for Windows, iOS, Android, Linux etc.

Moderator: leecollings

hansies
Posts: 4
Joined: Thursday 04 January 2018 15:25
Target OS: Linux
Domoticz version: stable
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by hansies »

Any change to got this working with channels?

Dtgbot is working perfect and love to use it. For now I want to go a step further so my 'TaskerBot' can talk to my 'DomoticzBot'. As bots can talk to eachother in private, the only way they can talk to eachother is in a channel.

So now I got a channel with me and my two bots. The thing is that dtgbot should understand the specific code from the channel.

If this will work than I can build my own geofence task working without having to open a port on my router of enable my VPN.


The reponse from a message and a channel is pretty the same, but I don't know anything about the dtgbot code.

Channel

Code: Select all

{
  "update_id":602971###,
  "channel_post":{
    "message_id":5,
    "author_signature":"#",
    "chat":{
      "id":-100##########,
      "title":"#",
      "username":"#",
      "type":"channel"
    },
    "date":1533288546,
    "text":"Test"
  }
}
Message

Code: Select all

{
  "update_id":684538###,
  "message":{
    "message_id":118,
    "from":{
      "id":#########,
      "is_bot":false,
      "first_name":"#",
      "username":"#",
      "language_code":"en-us"
    },
    "chat":{
      "id":#########,
      "first_name":"#",
      "username":"#",
      "type":"private"
    },
    "date":1533290530,
    "text":"Hi"
  }
)
Domoticz stable | Intel NUC | VirtualBox | Ubuntu 16.04
RPI2B | RFLink
Yeelight | Sonoff Tasmota
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by jvdz »

I will have a look at this as that shouldn't be too hard to add. (His famous last words :D )

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by jvdz »

hansies wrote: Friday 03 August 2018 13:06 Any change to got this working with channels?
I 've pushed an update to the github repository for both the "master" branch, using the keyboard menus as the "Menu_Inline" branch to support channel messages.
I've found out that channels do not support keyboard menus, so DTGMENU will be disabled in the "Master" branch version when messages are received from the channel. The inline version works fine as far as I can tell.

Let me know when there are questions or issues.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Slayer007
Posts: 29
Joined: Wednesday 18 June 2014 23:57
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by Slayer007 »

Hi there,

Maybe someone can help me out. I've been using Telegram Bot for the past 3 years or so. I'm still using it and it is working like a charm.
Now I have bought myself a new RPI, starting from scratch. The other RPI is still online and still working with Telegram.

Now I've tried to install Telegram, but I can't get dtgbot to start/work. (It is by the way the same bot as the other RPI.)
I don't get any log errors, so something must go right :D
I think the problem is in this:

Code: Select all

2018-10-27 23:57:23 - Getting TelegramBotOffset the previous Telegram bot message offset from Domoticz
2018-10-27 23:57:23 - TelegramBotOffset user variable does not exist in Domoticz so can not continue
This is from domoticz

Code: Select all

2 TelegramBotMenu String On
1 TelegramBotOffset Integer 1
I can send messages to my bot, but my bot is not responding. I also exited the dtgbot from my old RPI, maybe that conflicted.

I started the uservariable TBO with +1, that didn't work. I also started with the last update_id +1 from my old RPI, but this alos didn't work.
I used my old dtgbot.lua and I also used the new dtgbot.lua.

Does anyone has an idea what is going wrong?

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

Re: dtgbot - Domoticz TeleGram BOT

Post by jvdz »

You need to set the UserVariable TelegramBotOffset on the new System to the same value as the old system as that is the message sequencenumber for the received commands it is try to read. You probably can't use the both at the same time, but it should work when the old system's dtgbot is stopped.!

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Slayer007
Posts: 29
Joined: Wednesday 18 June 2014 23:57
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by Slayer007 »

jvdz wrote: Sunday 28 October 2018 10:27 You need to set the UserVariable TelegramBotOffset on the new System to the same value as the old system as that is the message sequencenumber for the received commands it is try to read. You probably can't use the both at the same time, but it should work when the old system's dtgbot is stopped.!

Jos
Hi Jos,

Sadly is doesn't work. I've stopped my dtgbot on my old RPI. Waited a couple of minutes. Then checked the TBO from the old one and filled it in by the new one. After that I started dtgbot on my new RPI and the log is still saying that the user variable doesn't exist... :cry:
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by jvdz »

So that would mean it can't connect to the domoticz server to retrieve the variable.
Are you sure the serversettings are done correctly?
Are you user Userid/Password for access to domoticz?
Could you show the whole dtgbot.log so I can have a look to see if that looks correct? ( you can also PM in case you don't want to post it in open forum)

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
EldigoR
Posts: 41
Joined: Monday 12 October 2015 19:57
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by EldigoR »

hansies wrote: Thursday 02 August 2018 20:51
G3rard wrote: Saturday 13 May 2017 10:49
maomanna wrote:How did you compile the lua libraries?
In the OP is a 32bit version supplied.
I did the following steps to make dtgbot working on my Ubuntu server 14.04 x64.
I can confirm this is working on Ubuntu 16.04 64bit on my NUC with VirtualBox!
I Also confirm it working on Ubuntu server LTS 18.04 .
Also attachted the needed files.
Attachments
Lua_Ubuntu_x64.tar
(383.5 KiB) Downloaded 69 times
nosehook
Posts: 49
Joined: Thursday 31 March 2016 20:49
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by nosehook »

Hi, I have some issues getting the bot working with Domoticz.

The error log states:

Code: Select all

2018-11-21 11:04:07 - DomoticzIP: 192.168.0.115
2018-11-21 11:04:07 - DomoticzPort: 8080
2018-11-21 11:04:07 - BotHomePath: /home/pi/dtgbot/
2018-11-21 11:04:07 - TempFileDir: /var/tmp/
2018-11-21 11:04:07 - BotLuaScriptPath: /home/pi/dtgbot/lua/
2018-11-21 11:04:07 - BotBashScriptPath: /home/pi/dtgbot/bash/
2018-11-21 11:04:07 - TelegramBotToken: correct token
2018-11-21 11:04:07 - TelegramBotOffset: TelegramBotOffset
2018-11-21 11:04:07 - -----------------------------------------
2018-11-21 11:04:07 - Starting Telegram api Bot message handler
2018-11-21 11:04:07 - -----------------------------------------
when I do

Code: Select all

cd ~/dtgbot
lua dtgbot.lua
I get:

Code: Select all

2018-11-21 11:27:49 - DomoticzIP: 192.168.0.115
2018-11-21 11:27:49 - DomoticzPort: 8080
2018-11-21 11:27:49 - BotHomePath: /home/pi/dtgbot/
2018-11-21 11:27:49 - TempFileDir: /var/tmp/
2018-11-21 11:27:49 - BotLuaScriptPath: /home/pi/dtgbot/lua/
2018-11-21 11:27:49 - BotBashScriptPath: /home/pi/dtgbot/bash/
2018-11-21 11:27:49 - TelegramBotToken: correct token
2018-11-21 11:27:49 - TelegramBotOffset: TelegramBotOffset
2018-11-21 11:27:49 - -----------------------------------------
2018-11-21 11:27:49 - Starting Telegram api Bot message handler
2018-11-21 11:27:49 - -----------------------------------------
lua: /usr/local/share/lua/5.2/socket.lua:12: module 'socket.core' not found:
        no field package.preload['socket.core']
        no file '/usr/local/share/lua/5.2/socket/core.lua'
        no file '/usr/local/share/lua/5.2/socket/core/init.lua'
        no file '/usr/local/lib/lua/5.2/socket/core.lua'
        no file '/usr/local/lib/lua/5.2/socket/core/init.lua'
        no file '/usr/share/lua/5.2/socket/core.lua'
        no file '/usr/share/lua/5.2/socket/core/init.lua'
        no file './socket/core.lua'
        no file '/usr/local/lib/lua/5.2/socket/core.so'
        no file '/usr/lib/arm-linux-gnueabihf/lua/5.2/socket/core.so'
        no file '/usr/lib/lua/5.2/socket/core.so'
        no file '/usr/local/lib/lua/5.2/loadall.so'
        no file './socket/core.so'
        no file '/usr/local/lib/lua/5.2/socket.so'
        no file '/usr/lib/arm-linux-gnueabihf/lua/5.2/socket.so'
        no file '/usr/lib/lua/5.2/socket.so'
        no file '/usr/local/lib/lua/5.2/loadall.so'
        no file './socket.so'
stack traceback:
        [C]: in function 'require'
        /usr/local/share/lua/5.2/socket.lua:12: in main chunk
        [C]: in function 'require'
        /usr/local/share/lua/5.2/socket/http.lua:10: in main chunk
        [C]: in function 'require'
        dtgbot.lua:114: in main chunk
        [C]: in ?
When I do

Code: Select all

sudo service dtgbot status
I get

Code: Select all

dtgbot.service - LSB: A Telegram bot designed to control Domoticz
   Loaded: loaded (/etc/init.d/dtgbot; generated; vendor preset: enabled)
   Active: active (exited) since Wed 2018-11-21 11:04:07 CET; 25min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 352 ExecStart=/etc/init.d/dtgbot start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/dtgbot.service

Nov 21 11:04:06 raspberrypi systemd[1]: Starting LSB: A Telegram bot designed to control Domoticz...
Nov 21 11:04:07 raspberrypi dtgbot[352]: Starting Telegram Bot for Domoticz ... Done.
Nov 21 11:04:07 raspberrypi systemd[1]: Started LSB: A Telegram bot designed to control Domoticz.
When I send messages via Telegram I get no response
Could someone please tell me how to fix things?

Kind regards,

Freek
Pi3 Domoticz | RFXcom 433E | KAKU/COCO |Harmony Hub | Samsung TV | HS100 | HS110| HUE | Tradfri | Tado| Xiaomi |sensors | scripts| Pi3 Node Red | Pi2 SDS_011 + MH-Z19B | PiAware (zero) | Pi2 breadboard with Node red and Domoticz
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by jvdz »

It looks like you missed the part to install the LUA libraries in the Wiki:
https://www.domoticz.com/wiki/Remote_Co ... _Libraries

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
nosehook
Posts: 49
Joined: Thursday 31 March 2016 20:49
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by nosehook »

jvdz wrote: Wednesday 21 November 2018 19:03 It looks like you missed the part to install the LUA libraries in the Wiki:
https://www.domoticz.com/wiki/Remote_Co ... _Libraries

Jos
Hi Jos,

Thanks for the tip.
I remember doing this, something must have gone wrong.

I have installed the Lua part. Now when I check I get this:

Code: Select all

2018-11-21 20:43:08 - DomoticzIP: 192.168.0.115
2018-11-21 20:43:08 - DomoticzPort: 8080
2018-11-21 20:43:08 - BotHomePath: /home/pi/dtgbot/
2018-11-21 20:43:08 - TempFileDir: /var/tmp/
2018-11-21 20:43:08 - BotLuaScriptPath: /home/pi/dtgbot/lua/
2018-11-21 20:43:08 - BotBashScriptPath: /home/pi/dtgbot/bash/
2018-11-21 20:43:08 - TelegramBotToken: Token
2018-11-21 20:43:08 - TelegramBotOffset: TelegramBotOffset
2018-11-21 20:43:08 - -----------------------------------------
2018-11-21 20:43:08 - Starting Telegram api Bot message handler
2018-11-21 20:43:08 - -----------------------------------------
lua: error loading module 'ssl.core' from file '/usr/local/lib/lua/5.2/ssl.so':
        libssl.so.1.0.0: cannot open shared object file: No such file or directo                                                                                                                                                             ry
stack traceback:
        [C]: in ?
        [C]: in function 'require'
        /usr/local/share/lua/5.2/ssl.lua:7: in main chunk
        [C]: in function 'require'
        /usr/local/share/lua/5.2/ssl/https.lua:10: in main chunk
        [C]: in function 'require'
        dtgbot.lua:116: in main chunk
        [C]: in ?
when I type help in telegram I get no response or anything.
any tips to help me out?

Kind regards,

Freek
Pi3 Domoticz | RFXcom 433E | KAKU/COCO |Harmony Hub | Samsung TV | HS100 | HS110| HUE | Tradfri | Tado| Xiaomi |sensors | scripts| Pi3 Node Red | Pi2 SDS_011 + MH-Z19B | PiAware (zero) | Pi2 breadboard with Node red and Domoticz
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by jvdz »

The second part of the linked topic should have extracted the files in that folder.
Did you check which files are present in /usr/local/lib/lua/5.2/ ?

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
nosehook
Posts: 49
Joined: Thursday 31 March 2016 20:49
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by nosehook »

Yes,

In /usr/local/lib/lua/5.2 There are present:
mime socket ssl.so


In cd /usr/local/share/lua/5.2/ there are present:
ansicolors.lua JSON.lua ltn12.lua luacolors.lua mime mime.lua mobdebug.lua socket socket.lua ssl ssl.lua ssl.so
Pi3 Domoticz | RFXcom 433E | KAKU/COCO |Harmony Hub | Samsung TV | HS100 | HS110| HUE | Tradfri | Tado| Xiaomi |sensors | scripts| Pi3 Node Red | Pi2 SDS_011 + MH-Z19B | PiAware (zero) | Pi2 breadboard with Node red and Domoticz
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by jvdz »

So the file seems to be there. Could you show me the result of these commands ran on the PI itself? :
ls -l /usr/local/lib/lua/5.2
ls -l /usr/local/share/lua/5.2/

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
nosehook
Posts: 49
Joined: Thursday 31 March 2016 20:49
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by nosehook »

Ofcourse!

First entry:
total 68
drwxr-sr-x 2 root staff 4096 Sep 25 2014 mime
drwxr-sr-x 2 root staff 4096 Sep 7 2014 socket
-rwxr-xr-x 1 root root 61293 Jul 5 2015 ssl.so


Second entry:
-rw-r--r-- 1 root staff 2184 Oct 25 2013 ansicolors.lua
-rw-r--r-- 1 root staff 34843 May 28 2015 JSON.lua
-rw-r--r-- 1 root staff 8331 Sep 25 2014 ltn12.lua
-rw-r--r-- 1 root staff 4812 Sep 25 2014 luacolors.lua
drwxr-sr-x 2 root staff 4096 Sep 25 2014 mime
-rw-r--r-- 1 root staff 2487 Sep 25 2014 mime.lua
-rw-r--r-- 1 root staff 62698 Sep 7 2014 mobdebug.lua
drwxr-sr-x 2 root staff 4096 Sep 25 2014 socket
-rw-r--r-- 1 root staff 5011 Sep 7 2014 socket.lua
drwxr-xr-x 2 root staff 4096 Jul 5 2015 ssl
-rw-r--r-- 1 root staff 4663 Jul 5 2015 ssl.lua
-rwxr-xr-x 1 root root 61293 Jul 5 2015 ssl.so


Thanks for helping out,

Freek
Pi3 Domoticz | RFXcom 433E | KAKU/COCO |Harmony Hub | Samsung TV | HS100 | HS110| HUE | Tradfri | Tado| Xiaomi |sensors | scripts| Pi3 Node Red | Pi2 SDS_011 + MH-Z19B | PiAware (zero) | Pi2 breadboard with Node red and Domoticz
nosehook
Posts: 49
Joined: Thursday 31 March 2016 20:49
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by nosehook »

I tried:

sudo wget http://ftp.nl.debian.org/debian/pool/main/o/openssl /libssl1.0.0_1.0.1t-1+deb8u8_armhf.deb

and

sudo dpkg -i libssl1.0.0_1.0.1t-1+deb8u8_armhf.deb

now I get:

2018-11-21 21:34:02 - DomoticzIP: 192.168.0.115
2018-11-21 21:34:02 - DomoticzPort: 8080
2018-11-21 21:34:02 - BotHomePath: /home/pi/dtgbot/
2018-11-21 21:34:02 - TempFileDir: /var/tmp/
2018-11-21 21:34:02 - BotLuaScriptPath: /home/pi/dtgbot/lua/
2018-11-21 21:34:02 - BotBashScriptPath: /home/pi/dtgbot/bash/
2018-11-21 21:34:02 - TelegramBotToken: token
2018-11-21 21:34:02 - TelegramBotOffset: TelegramBotOffset
2018-11-21 21:34:02 - -----------------------------------------
2018-11-21 21:34:02 - Starting Telegram api Bot message handler
2018-11-21 21:34:02 - -----------------------------------------
Illegal instruction
Pi3 Domoticz | RFXcom 433E | KAKU/COCO |Harmony Hub | Samsung TV | HS100 | HS110| HUE | Tradfri | Tado| Xiaomi |sensors | scripts| Pi3 Node Red | Pi2 SDS_011 + MH-Z19B | PiAware (zero) | Pi2 breadboard with Node red and Domoticz
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by jvdz »

I don't have this in /usr/local/share/lua/5.2/
rwxr-xr-x 1 root root 61293 Jul 5 2015 ssl.so
only in /usr/local/lib/lua/5.2
Could that be the issue?

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by jvdz »

No idea about that last one.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
nosehook
Posts: 49
Joined: Thursday 31 March 2016 20:49
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by nosehook »

Hi Jos,

I removed the file, now I get:

2018-11-21 21:34:02 - DomoticzIP: 192.168.0.115
2018-11-21 21:34:02 - DomoticzPort: 8080
2018-11-21 21:34:02 - BotHomePath: /home/pi/dtgbot/
2018-11-21 21:34:02 - TempFileDir: /var/tmp/
2018-11-21 21:34:02 - BotLuaScriptPath: /home/pi/dtgbot/lua/
2018-11-21 21:34:02 - BotBashScriptPath: /home/pi/dtgbot/bash/
2018-11-21 21:34:02 - TelegramBotToken: token
2018-11-21 21:34:02 - TelegramBotOffset: TelegramBotOffset
2018-11-21 21:34:02 - -----------------------------------------
2018-11-21 21:34:02 - Starting Telegram api Bot message handler
2018-11-21 21:34:02 - -----------------------------------------
Illegal instruction

Should I try a clean install and try again via the WIKI?
Regards,

Freek
Pi3 Domoticz | RFXcom 433E | KAKU/COCO |Harmony Hub | Samsung TV | HS100 | HS110| HUE | Tradfri | Tado| Xiaomi |sensors | scripts| Pi3 Node Red | Pi2 SDS_011 + MH-Z19B | PiAware (zero) | Pi2 breadboard with Node red and Domoticz
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by jvdz »

That is what you posted earlier and I responded to with:
No idea about that last one.
It seems you downloaded another version of libssl which I guess is causing this. Can't you reverse that action and test again?

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest