Page 2 of 30
Re: dtgbot - Domoticz TeleGram BOT
Posted: Tuesday 14 July 2015 23:13
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.
Re: dtgbot - Domoticz TeleGram BOT
Posted: Tuesday 14 July 2015 23:30
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.
Re: dtgbot - Domoticz TeleGram BOT
Posted: Wednesday 15 July 2015 7:43
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)
Re: dtgbot - Domoticz TeleGram BOT
Posted: Wednesday 15 July 2015 9:08
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.
Re: dtgbot - Domoticz TeleGram BOT
Posted: Wednesday 15 July 2015 13:40
by fransiefrans
Dear Simon,
My Domoticz is password protected!!
I added the username:password in the
/etc/profile.d/DomoticzData.sh file and started dtgbot.
Checked status and its running
Thank you for the great support!
Re: dtgbot - Domoticz TeleGram BOT
Posted: Wednesday 15 July 2015 15:03
by simonrg
fransiefrans wrote:Dear Simon,
My Domoticz is password protected!!
I added the username:password in the
/etc/profile.d/DomoticzData.sh file and started dtgbot.
Checked status and its running
Thank you for the great support!

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.

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.
Re: dtgbot - Domoticz TeleGram BOT
Posted: Wednesday 15 July 2015 23:47
by fransiefrans
I wouldn't know. I guess we will find out when someone else will try your methode.
Re: dtgbot - Domoticz TeleGram BOT
Posted: Sunday 19 July 2015 1:15
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.
Re: dtgbot - Domoticz TeleGram BOT
Posted: Tuesday 21 July 2015 8:16
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!"?
Re: dtgbot - Domoticz TeleGram BOT
Posted: Tuesday 21 July 2015 10:00
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?
Re: dtgbot - Domoticz TeleGram BOT
Posted: Tuesday 21 July 2015 10:33
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.
Re: dtgbot - Domoticz TeleGram BOT
Posted: Tuesday 21 July 2015 12:16
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.
dtgbot - Domoticz TeleGram BOT
Posted: Tuesday 21 July 2015 13:09
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

.
Re: dtgbot - Domoticz TeleGram BOT
Posted: Tuesday 21 July 2015 13:40
by Derik
great job....!!
Now a native support possible?
And perhaps in the option for all the messages.....?
Re: dtgbot - Domoticz TeleGram BOT
Posted: Tuesday 21 July 2015 22:04
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
Re: dtgbot - Domoticz TeleGram BOT
Posted: Wednesday 22 July 2015 8:25
by BigDog
In telegram it works but in console not..
Re: dtgbot - Domoticz TeleGram BOT
Posted: Wednesday 22 July 2015 20:15
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
Re: dtgbot - Domoticz TeleGram BOT
Posted: Wednesday 22 July 2015 21:16
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
Re: dtgbot - Domoticz TeleGram BOT
Posted: Thursday 23 July 2015 13:41
by pvm
Is there any specific reason for the dependency on lua 5.2? The standard domoticz image contains lua 5.1
Re: dtgbot - Domoticz TeleGram BOT
Posted: Thursday 23 July 2015 22:12
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?