dtgbot - Domoticz TeleGram BOT

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

Moderator: leecollings

simonrg
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

Post by simonrg »

Asa67 wrote:You problably (just like me) do not have lua installed:
From: https://www.domoticz.com/wiki/Installin ... ion_System

Code: Select all

sudo apt-get install libreadline-dev libconfig-dev libssl-dev lua5.2 liblua5.2-dev libevent-dev lua-lgi glib-2.0 make git-core libjansson-dev
Don't know if all the packages are needed but it did the trick for me.
@simonrg, thanks for your work !! and maybe you can add the right packages in your - otherwise good - wiki
Greetz Erwin
Erwin, thanks for your comments, if Frans has got this far he has Lua installed, the wiki is a work in progress, but I don't think you will need any packages beyond Lua itself, the rest of the libraries are installed as part of the wiki. So shouldn't need to install the whole lot, I would be interested to know which ones you actually need to install. libssl-dev may well be needed.
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
simonrg
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

Post by simonrg »

I have updated the scripts based on errors / improvements captured today and uploaded it to the initial post (150714dtgbot.tar - http://www.domoticz.com/forum/download/file.php?id=3689). If you have already installed dtgbot then the new scripts will overwrite the original scripts:

Code: Select all

sudo service dtgbot stop
cd ~
tar -xvf ~/temp/150714dtgbot.tar
cd ~/dtgbot/service
sudo mv dtgbot /etc/init.d
cd ..
rmdir service
sudo update-rc.d dtgbot remove
sudo update-rc.d dtgbot defaults
sudo service dtgbot start
There are now 2 log files /var/tmp/dtb.log and /var/tmp/dtb.log.errors - the .errors file will capture Lua crash type errors, so should be helpful in debugging new installations.
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
fransiefrans
Posts: 59
Joined: Sunday 14 June 2015 13:22
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by fransiefrans »

Again thanks for the effort.

I installed lua as Erwin said with no luck.

/var/tmp/dtb.log.errors:

Code: Select all

/usr/bin/lua: /home/pi/dtgbot/dtgbot.lua:183: attempt to index local 'decoded_response' (a nil value)
stack traceback:
	/home/pi/dtgbot/dtgbot.lua:183: in function 'idx_from_variable_name'
	/home/pi/dtgbot/dtgbot.lua:413: in main chunk
	[C]: in ?
I will get some sleep (worked last night) I will get a fresh domoticz again and try it all over again. (had some problems with creating folder :?. I had to use mkdir -p)
simonrg
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

Post by simonrg »

fransiefrans wrote:

Code: Select all

/usr/bin/lua: /home/pi/dtgbot/dtgbot.lua:183: attempt to index local 'decoded_response' (a nil value)
stack traceback:
	/home/pi/dtgbot/dtgbot.lua:183: in function 'idx_from_variable_name'
	/home/pi/dtgbot/dtgbot.lua:413: in main chunk
	[C]: in ?
Don't install a fresh Domoticz, lets do some troubleshoting first.

The simplest explanation for your error is that you haven't created any User Variables in Domoticz which I guess if this was a recent install might be the case, but unlikely.

I assume your Domoticz doesn't need a password to access, this would give the same error. If it is password protected then you would need include this in the ip address i.e. username:[email protected].

If you go to the command line and type lua it will display the version Lua 5.2.x, what does yours say? If you have tried the Google Hangouts you might have changed the default to 5.1 in which go into ~/dtgbot/dtgbot and change /usr/bin/lua for /usr/bin/lua5.2.

Also from your previous post your ip address was DomoticzIP: 192.168.2.7, but the Wiki instructions use 127.0.0.1.
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
fransiefrans
Posts: 59
Joined: Sunday 14 June 2015 13:22
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by fransiefrans »

Dear Simon,

My Domoticz is password protected!! :D
I added the username:password in the /etc/profile.d/DomoticzData.sh file and started dtgbot.
Checked status and its running :D :D

Thank you for the great support!
simonrg
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

Post by simonrg »

fransiefrans wrote:Dear Simon,
My Domoticz is password protected!! :D
I added the username:password in the /etc/profile.d/DomoticzData.sh file and started dtgbot.
Checked status and its running :D :D
Thank you for the great support!
:D Great, thanks for sticking with it, I am adding what we find out to the wiki, so will hopefully this will make it easier for other people who install dtgbot.

:oops: What I don't know is whether the long install list that Erwin suggested was needed or not? I was expecting you to only need Lua 5.2.
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
fransiefrans
Posts: 59
Joined: Sunday 14 June 2015 13:22
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by fransiefrans »

I wouldn't know. I guess we will find out when someone else will try your methode.
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by G3rard »

Thanks simonrg! It works great.

One question. I have changed the scripts in the bash folder so these send the message to TelegramChatId as defined in DomoticzData.sh. This way I can let the bot send the answers to a group in Telegram.

But I can't get this working for the scripts in the lua folder as these don't have a Send(Msg)To variable. I can send a message to the group for the commands in the lua folder, but the answer is sent back to the sender instead of being sent back to the group.
Any ideas how I can change that for these scripts? Should I make the changes in dtgbot.lua?

One small remark regarding the wiki on http://www.domoticz.com/wiki/Telegram_Bot.
On the bottom of the page at the LUA exampe is says:

Code: Select all

os.execute('curl --data chat_id='..chatid..' --data-urlencode "text="'..message..'"  "https://api.telegram.org/bot'..token..'/sendMessage" ')
but that should be:

Code: Select all

os.execute('curl --data chat_id='..chatid..' --data-urlencode "text='..message..'"  "https://api.telegram.org/bot'..token..'/sendMessage" ')
So the " after text= should be removed.
Not using Domoticz anymore
thorbj
Posts: 113
Joined: Thursday 20 November 2014 22:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Norway
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by thorbj »

Is it possible to set up dtgbot to send a small weatherstatus/forecast every weekday around 6am and weekends around 8am? Something like "It's 8c and raining today, better bring your umbrella!"?
2xRaspberry Pi Model 2 w/RaZberry z-wave chip (master/slave)|Fibaro Wall Plug|Fibaro Universal Dimmer 500W|Aeon Labs Multisensor|RFXtrx433E|Nexa WMR-1000|Nexa Pe-3|Nexa Remote|Nexa LGDR3500|Lightify Gateway|Lightify RGBW bulb
Heisenberg
Posts: 135
Joined: Monday 27 January 2014 14:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by Heisenberg »

In the 'old' Telegram setup it was possible to send photos and messages to multiple receipients by adding the Firstname_Lastname. Telegram Bot sends to chat_id. How to send to more than one contacts?
Raspberry Pi Type B
Raspberry Pi Type B2
RFXCOMtrx433e
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by G3rard »

Heisenberg wrote:In the 'old' Telegram setup it was possible to send photos and messages to multiple receipients by adding the Firstname_Lastname. Telegram Bot sends to chat_id. How to send to more than one contacts?
I am using a group for this.
Not using Domoticz anymore
Heisenberg
Posts: 135
Joined: Monday 27 January 2014 14:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by Heisenberg »

G3rard, could you please tell where to find the group option or how to set up? I may have missed the instructions but can't find how to do it.
Raspberry Pi Type B
Raspberry Pi Type B2
RFXCOMtrx433e
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

dtgbot - Domoticz TeleGram BOT

Post by G3rard »

Add the bot to the group and then send a message from the group, eg /temperature. Then you can find the id of the group, either with the explanation from the wiki or in the log file.

See also my earlier post, I have this working for the bash scripts, not yet for the lua scripts. I think simonrg can help us out with that :-).
Not using Domoticz anymore
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by Derik »

great job....!!

Now a native support possible?
And perhaps in the option for all the messages.....?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
BigDog
Posts: 82
Joined: Tuesday 17 September 2013 13:59
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.9269
Location: The Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by BigDog »

strange i get when i use doorbell
this in console


<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.6.2</center>
</body>
</html>

dont know what i did grong

greetz BigDog
1X Raspberry4B : Domoticz Version 2023.1 [Linux 5.10.63-v7l+ armv7l]
1X Conbee II : 2.25.3 - 26720700
1X RFXtrx433 USB Firmware:183
1X Mysensors Gateway 1.5 -3
6X ESP8266: Tosmota firmware
Zigbee : 6 Operators, 13 Sensors
BigDog
Posts: 82
Joined: Tuesday 17 September 2013 13:59
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.9269
Location: The Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by BigDog »

In telegram it works but in console not..
1X Raspberry4B : Domoticz Version 2023.1 [Linux 5.10.63-v7l+ armv7l]
1X Conbee II : 2.25.3 - 26720700
1X RFXtrx433 USB Firmware:183
1X Mysensors Gateway 1.5 -3
6X ESP8266: Tosmota firmware
Zigbee : 6 Operators, 13 Sensors
BigDog
Posts: 82
Joined: Tuesday 17 September 2013 13:59
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.9269
Location: The Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by BigDog »

i have tryed to use it stand alone that a scipt runs on the doorbel that sends a picture to me tro Telegram..
but it wount work :(

doorbell.sh dont work it gives a 403 command

can someone share me the script ?

OR the command to run the script in console or domoticz on command string in a switch
becose it wont work :(

Hope you guys can help :)

Greetz BigDog
1X Raspberry4B : Domoticz Version 2023.1 [Linux 5.10.63-v7l+ armv7l]
1X Conbee II : 2.25.3 - 26720700
1X RFXtrx433 USB Firmware:183
1X Mysensors Gateway 1.5 -3
6X ESP8266: Tosmota firmware
Zigbee : 6 Operators, 13 Sensors
BigDog
Posts: 82
Joined: Tuesday 17 September 2013 13:59
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.9269
Location: The Netherlands
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by BigDog »

Moderator edit: *snip*, please don't make multiple posts about your problem. Keep it at one topic: http://domoticz.com/forum/viewtopic.php?f=23&t=7371
Last edited by ThinkPad on Thursday 23 July 2015 9:29, edited 2 times in total.
Reason: Snipped post, please don't make multiple posts about your problem
1X Raspberry4B : Domoticz Version 2023.1 [Linux 5.10.63-v7l+ armv7l]
1X Conbee II : 2.25.3 - 26720700
1X RFXtrx433 USB Firmware:183
1X Mysensors Gateway 1.5 -3
6X ESP8266: Tosmota firmware
Zigbee : 6 Operators, 13 Sensors
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by pvm »

Is there any specific reason for the dependency on lua 5.2? The standard domoticz image contains lua 5.1
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
simonrg
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

Post by simonrg »

pvm wrote:Is there any specific reason for the dependency on lua 5.2? The standard domoticz image contains lua 5.1
The dependency is due to the way in which it is pulling in functions to make it compatible with the XPMM (Google Hangouts) bot.

I suppose there is no reason it shouldn't run in Domoticz with some modifications to the code. The bot would be a Lua time script which would issue a get updates every minute, but this would mean you the response would be very slow, i.e. only once every minute. Whereas as currently the code issues a long polling http request, it sends a request which either returns as soon as the next message is recieved, or times out after 60 seconds in which case the bot issues another long polling http request, so the processing load of the bot is very low and but it is still responsive.

How / what / why were you thinking of using the Lua inside Domoticz?
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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest