dtgbot - Domoticz TeleGram BOT

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

Moderator: leecollings

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 »

woody4165 wrote: Saturday 27 January 2018 8:52 Hi all
-snip-

This mean that everytime there is any kind of connection closing I have to restart the service?
Isn't that what I already said a few post up?
That is why I have added the extra log file to be able to check the age in monit and restart dtgbot when it is over 2 minutes old.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by woody4165 »

Hi Jos

Even if I have it in monitrc, it doesn't restart the service..
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
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 »

What does the monit webfrontend & log tell you for this item when this situation occurs?
Does it run the bash script to restart dtgbot?
I know for sure it does work for me when my internet has a glitch.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by woody4165 »

I'm sure too that there is some issue in my config.


This is my situation:

Code: Select all

linaro@cubietruck:~/dtgbot$ ls -l *.sh
-rwxr-xr-x 1 root   root    963 Jan 24 12:22 restartbot.sh
-rwxr-xr-x 1 root   root    442 Jan 24 12:22 stopbot.sh

Code: Select all

linaro@cubietruck:~/dtgbot$ ls /var/tmp -l
-rw-r--r-- 1 root root   5384 Jan 27 20:31 dtb.log
-rw-r--r-- 1 root root 738547 Jan 27 20:31 dtgloop.txt
when I run from terminal "/home/linaro/dtgbot/restartbot.sh"
I get

Code: Select all

linaro@cubietruck:~/dtgbot$ /home/linaro/dtgbot/restartbot.sh
/home/linaro/dtgbot/restartbot.sh: line 11: /var/tmp/dtgloop.txt: Permission denied
/home/linaro/dtgbot/restartbot.sh: line 13: /var/tmp/dtgloop.txt: Permission denied
/home/linaro/dtgbot/restartbot.sh: line 15: /var/tmp/dtgloop.txt: Permission denied
/home/linaro/dtgbot/restartbot.sh: line 19: /var/tmp/dtgloop.txt: Permission denied
/home/linaro/dtgbot/restartbot.sh: line 22: /var/tmp/dtgloop.txt: Permission denied
/home/linaro/dtgbot/restartbot.sh: line 23: /var/tmp/dtgloop.txt: Permission denied
So I have added "sudo" in monitrc to the calls to the .sh

Now I get in webfronted of monit

Image

Image
It seems that the monitoring service of dtgloop is not started.
After I click to Start Service I get an error

Image


Is it a owner issue?
I'm driving crazy.
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
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 »

Try to validate the config file as described in the manual to see if there are syntax errors:

Code: Select all

Before Monit is started the first time, you can test the control file for syntax errors:

 $ monit -t
 $ Control file syntax OK
EDIT: Scratch that... that status is looking good and looks the same as what I see.
Curious what it states when the DTGBOT locked status occurs.

It also looks like you don't have the access to the dtgloop.txt file so you could try running it with sudo or add sudo infront of the echo statements in the restartbot.sh script.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by woody4165 »

Thanks Jos for your support.
monit -t returns ok

I've added sudo into restartbot.sh in fromt of all echo command, but if I run restartbot.sh without sudo does not work anyway.
I've tried to add sudo into monitrc like

Code: Select all

  start program = "sudo /home/linaro/dtgbot/restartbot.sh" timeout 20 seconds
but it seems that monit does not work properly, I get errors

Code: Select all

Jan 27 21:56:28 cubietruck monit[741]: Starting daemon monitor: monit/etc/monit/monitrc:156: Program does...sudo'
Jan 27 21:56:28 cubietruck monit[741]: /etc/monit/monitrc:157: Program does not exist: 'sudo'
Jan 27 21:56:28 cubietruck monit[741]: /etc/monit/monitrc:163: Program does not exist: 'sudo'
and if I run monit -t I get

Code: Select all

linaro@cubietruck:~$ sudo monit -t
/etc/monit/monitrc:156: Program does not exist: 'sudo'
/etc/monit/monitrc:157: Program does not exist: 'sudo'
/etc/monit/monitrc:163: Program does not exist: 'sudo'
Control file syntax OK
What is the owner of you dtgloop.txt and of the restartbot.sh ? Maybe this can help...
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
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 »

woody4165 wrote: Saturday 27 January 2018 22:01What is the owner of you dtgloop.txt and of the restartbot.sh ? Maybe this can help...
Thanks
Looking at your outputs you are running on a Cubietruck (its helpful to include this in your forum signature) not a Raspberry Pi, and you don't appear to have sudo installed, which would explain why nothing happens when you add sudo into monitrc.

The owner of restartbot.sh shouldn't matter as long as it is executable by all users, you can find the owner of dtgloop.txt by ls -l on the temporary directory, mine is owned by root.

Code: Select all

pi@domoticz:~/dtgbot$ ls -l /var/tmp
-rw-r--r-- 1 root      root        2691 Jan 27 22:40 dtb.log
-rw-r--r-- 1 root      root           0 Jan 15 14:14 dtb.log.errors
-rw-r--r-- 1 root      root       97580 Jan 27 23:00 dtgloop.txt
-rw-r----- 1 root      root        2763 Jan 27 22:41 monit.log
I assume that monit is running as root on your system as it is on mine, so you don't need the sudo as the scripts will be run as root:

Code: Select all

pi@domoticz:~/dtgbot$ ps -ef | grep -i monit
root       617     1  0 Jan15 ?        00:09:14 /usr/bin/monit -c /etc/monit/monitrc
restartbot.sh and stopbot.sh are both designed to run as root by monit.

As you are trying to do it is good idea to check restartbot.sh and stopbot.sh work, it looks like you need to install the sudo package or log on as root to test on your system.

I have tested both restartbot.sh and stopbot.sh on my system and they work effectively:

Code: Select all

# dtgbot running normally
pi@domoticz:~/dtgbot$ ps -ef | grep -i bot
root      8884     1  0 Jan25 ?        00:00:00 /bin/sh /home/pi/dtgbot/dtgbot /var/run/dtgbot.pid
root      8885  8884  0 Jan25 ?        00:02:31 /usr/bin/lua5.2 /home/pi/dtgbot/dtgbot.lua
pi       21259 20106  0 22:38 pts/1    00:00:00 grep -i bot
# dtgbot stopped by stopbot
pi@domoticz:~/dtgbot$ sudo ./stopbot.sh 
pi@domoticz:~/dtgbot$ ps -ef | grep -i bot
pi       21477 20106  0 22:39 pts/1    00:00:00 grep -i bot
# monit launches restartbot.sh
pi@domoticz:~/dtgbot$ ps -ef | grep -i bot
root     21526   617  2 22:39 ?        00:00:00 /bin/bash /home/pi/dtgbot/restartbot.sh
pi       21570 20106  0 22:39 pts/1    00:00:00 grep -i bot
# restartbot.sh starts the dtgbot service
pi@domoticz:~/dtgbot$ ps -ef | grep -i bot
root     21526   617  0 22:39 ?        00:00:00 /bin/bash /home/pi/dtgbot/restartbot.sh
root     21592 21526  0 22:39 ?        00:00:00 sudo service dtgbot start
root     21596 21592  0 22:39 ?        00:00:00 /bin/sh /usr/sbin/service dtgbot start
pi       21603 20106  0 22:39 pts/1    00:00:00 grep -i bot
# monit has now restarted dtgbot successfully
pi@domoticz:~/dtgbot$ ps -ef | grep -i bot
root     21621     1  0 22:39 ?        00:00:00 /bin/sh /home/pi/dtgbot/dtgbot /var/run/dtgbot.pid
root     21623 21621 49 22:39 ?        00:00:02 /usr/bin/lua5.2 /home/pi/dtgbot/dtgbot.lua
pi       21631 20106  0 22:40 pts/1    00:00:00 grep -i bot
/var/tmp/monit.log shows the processes happening:

Code: Select all

[GMT Jan 27 22:39:41] error    : 'dtgbot' process is not running
[GMT Jan 27 22:39:41] info     : 'dtgbot' trying to restart
[GMT Jan 27 22:39:41] info     : 'dtgbot' start: /home/pi/dtgbot/restartbot.sh
[GMT Jan 27 22:41:55] info     : 'dtgbot' process is running with pid 21621
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
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by woody4165 »

simonrg wrote: Sunday 28 January 2018 0:05
Looking at your outputs you are running on a Cubietruck (its helpful to include this in your forum signature) not a Raspberry Pi, and you don't appear to have sudo installed, which would explain why nothing happens when you add sudo into monitrc.
Sudo is surely installed, it's workin, but it seems that adding just sudo to monit rc does not work.

So based on some search, I've added this to the monitrc config file:

Code: Select all

  start program = "/home/linaro/dtgbot/restartbot.sh" as uid root and gid root timeout 20 seconds
  stop  program = "/home/linaro/dtgbot/stopbot.sh" as uid root and gid root timeout 20 seconds
adding as uid root and gid root to the start and stop program

simonrg wrote: Sunday 28 January 2018 0:05 The owner of restartbot.sh shouldn't matter as long as it is executable by all users, you can find the owner of dtgloop.txt by ls -l on the temporary directory, mine is owned by root.

Code: Select all

pi@domoticz:~/dtgbot$ ls -l /var/tmp
-rw-r--r-- 1 root      root        2691 Jan 27 22:40 dtb.log
-rw-r--r-- 1 root      root           0 Jan 15 14:14 dtb.log.errors
-rw-r--r-- 1 root      root       97580 Jan 27 23:00 dtgloop.txt
-rw-r----- 1 root      root        2763 Jan 27 22:41 monit.log
All the files (logs) in the /var/tmp are owned by root:root too in my case.
simonrg wrote: Sunday 28 January 2018 0:05 I assume that monit is running as root on your system as it is on mine, so you don't need the sudo as the scripts will be run as root:

Code: Select all

pi@domoticz:~/dtgbot$ ps -ef | grep -i monit
root       617     1  0 Jan15 ?        00:09:14 /usr/bin/monit -c /etc/monit/monitrc
restartbot.sh and stopbot.sh are both designed to run as root by monit.
I get same result with ps command.

What I get in the monit.log when I close the xDSL connection is this:

Code: Select all

[CET Jan 28 08:03:47] info     : 'dtgloop' trying to restart
[CET Jan 28 08:03:47] info     : 'dtgloop' start: /home/linaro/dtgbot/restartbot.sh
[CET Jan 28 08:04:07] error    : 'dtgloop' failed to start (exit status -1) -- /home/linaro/dtgbot/restartbot.sh: Program timed out -- 01/28/2018 08:03:47 AM restartbot.sh started  (2)
So I tried to run an

Code: Select all

echo "test" >> /var/tmp/dtgloop.txt
and I get Permission denied, but also running it with sudo has same result. :shock:
Could it be still locked from don't know whom?

What the hell...
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
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 »

woody4165 wrote: Sunday 28 January 2018 8:25
simonrg wrote: Sunday 28 January 2018 0:05
Looking at your outputs you are running on a Cubietruck (its helpful to include this in your forum signature) not a Raspberry Pi, and you don't appear to have sudo installed, which would explain why nothing happens when you add sudo into monitrc.
Sudo is surely installed, it's workin, but it seems that adding just sudo to monit rc does not work.
Sorry I thought in one of the post away back I had seen "sudo" not a recognised command, sudo is a package so it needn't be loaded but normally it is, I like the detailed signature :D .

I suggest that you first need to check that stopbot.sh and restartbot.sh are working correctly, outside of monit. Also restartbot.sh as supplied assumes /var/tmp for temporary files and dtgbot/dtgbot.lua as the end of the path for the bot lua file.

So remove the dtgbot / dtgloop lines from monitrc, restart monit then:

Code: Select all

cd ~/dtgbot
sudo ./stopbot.sh
Assuming this works then:

Code: Select all

sudo ./restartbot.sh
If you get a timeout as happened with monit, then have a look inside restart.sh, and execute the individual commnads:

Code: Select all

sudo service dtgbot stop 
sudo pkill -f dtgbot/dtgbot.lua
sudo service dtgbot start
What output do you get from these?
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
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by woody4165 »

Hi Simon

Code: Select all

linaro@cubietruck:~/dtgbot$ sudo ./stopbot.sh
linaro@cubietruck:~/dtgbot$ sudo ./restartbot.sh
linaro@cubietruck:~/dtgbot$ 
Just did the stop and restart and everything is fine.

Removed first the check lines from monitrc and rebooted just to be sure.

Some strange message in dtgloop.txt ?

Code: Select all

2018-01-28 09:28:16
01/28/2018 09:29:00 AM  Stopping
2018-01-28 09:29:07
01/28/2018 09:29:12 AM  Stopped
01/28/2018 09:29:18 AM restartbot.sh started but is already running so stopping this one. (3)
linaro@cubietruck:/var/tmp$ 
Just run one time stopbot.sh and restartbot.sh
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
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by woody4165 »

It seems that the issue was the permission of the dtgloop.txt file .
previously was -rw-r--r-- now I changed in -rw-rw-rw- and it seems to work now, from cmd line as well as from monit

So now I have all "echo" commands in the .sh files without sudo and in monitrc changed back to original

Code: Select all

Monitor the DTGBOT Service
check process dtgbot with pidfile /var/run/dtgbot.pid
  start program = "/home/linaro/dtgbot/restartbot.sh" timeout 20 seconds
  stop  program = "/home/linaro/dtgbot/stopbot.sh" timeout 20 seconds
  if 5 restarts within 5 cycles then timeout

# Monitor the DTGBOT loop file which should be updated each minute.
# Restart DTGBOT when not updated in 2 minutes
 check file dtgloop with path /var/tmp/dtgloop.txt
  start program = "/home/linaro/dtgbot/restartbot.sh" timeout 20 seconds
  if timestamp > 2 minutes then restart
  if 5 restarts within 5 cycles then timeout
I'll keep an eye to it, but still don't understand why was working to all of you and not to me!!!
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
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by woody4165 »

I'm really sorry to say that I'm still having problems.
This time with the restartbot.sh that seems to be already running but "defunct".
This is what i find if I run a ps command

Code: Select all

30010 ?        Zs     0:00 [restartbot.sh] <defunct>
and if I try to manually kill with "kill 30010" nothing happens

In the script there is a check if the restartbot.sh is already running, but I don't understand what it does if it found it running.

Code: Select all

chk=`sudo ps x | grep "restartbot.sh" | grep -cv grep`
if  [ $chk -gt 2 ] ; then
        echo "`date +"%x %X"` restartbot.sh started but is already running so s$
        exit
fi
The message in dtgloop.txt is

Code: Select all

01/29/2018 07:02:18 AM restartbot.sh started but is already running so stopping this one. (3)
but it seems it doesn't stop....

The saga continues :shock: :oops:
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
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 am not a linux buff, but a quick google turned up this thread: https://askubuntu.com/questions/201303/ ... led#201308
It states you can't kill a defunc task and need to kill its parent.

I indeed build in a safeguard to avoid starting restartbot.sh multiple times, so any subsequent instance of restartbot.sh will stop after it detects an already running version. So in your case you have a defunct restartbot and no other one will be started.
A reboot should also clean things as a last resort measure.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by woody4165 »

Thanks Jos.
This sounds really weird to me, it seems that I have some issue on my system or some mis.configuration.

I will continue to keep an eye on it because I like very much dtgbot and its functionality...

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
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by woody4165 »

Hi Jos.

I found a workaround for me and seems to work.

In restartbot.sh I have added sudo service monit restart when it checks if restartbot.sh is found active (or defunct in my case)

Code: Select all

chk=`sudo ps x | grep "restartbot.sh" | grep -cv grep`
if  [ $chk -gt 2 ] ; then
        echo "`date +"%x %X"` restartbot.sh started but is already running so stopping this one. ($chk)" >> /var/tmp/dtgloop.txt
        sudo service monit restart
        exit
fi
It seems that just restarting the monit service, that is the "father" of restartbot.sh, will clear this situation.

Since this happens to me once a day, unless other xDSL disconnections happens for other reasons, it's ok for me.

Thanks all for your support.
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
User avatar
solidum90
Posts: 37
Joined: Tuesday 01 August 2017 20:59
Target OS: NAS (Synology & others)
Domoticz version: Debian
Location: Milan
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by solidum90 »

Great Work!!

Very very compliment!
satanasinc
Posts: 41
Joined: Monday 19 October 2015 12:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Spain
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by satanasinc »

Hi!

First of all excuse my bad english. I do my best.
Ive got a RPi working with the telegram bot and domoticz control but my instalation is very old running ver rapsbian wheezy. So i do a fresh install in a new SD with raspbian stretch and the domoticz telegram bot control dont works.
I cant find where is the problem because dont recive answer from domoticz but the notification works perfect.

The /var/tmp/dtb.log apears to be correct...
2018-03-13 14:52:01 - DomoticzIP: 127.0.0.1
2018-03-13 14:52:01 - DomoticzPort: 8080
2018-03-13 14:52:01 - BotHomePath: /home/pi/dtgbot/
2018-03-13 14:52:01 - TempFileDir: /var/tmp/
2018-03-13 14:52:01 - BotLuaScriptPath: /home/pi/dtgbot/lua/
2018-03-13 14:52:01 - BotBashScriptPath: /home/pi/dtgbot/bash/
2018-03-13 14:52:01 - TelegramBotToken: 524####64:AAFZUOtHs_tvJ_F6c06GYpkt6$$$$$$$$$$$$
2018-03-13 14:52:01 - TelegramBotOffset: TelegramBotOffset
2018-03-13 14:52:01 - -----------------------------------------
2018-03-13 14:52:01 - Starting Telegram api Bot message handler
2018-03-13 14:52:01 - -----------------------------------------

In /var/tmp/dtb.log.error i got this...
Illegal instruction

My /etc/profile.d/DomoticzData.sh#I can't get the next line to work during start-up so have gone to 127 instead
#export DomoticzIP=$(hostname -I|sed 's/[ ]*$//')
export DomoticzIP="127.0.0.1"
export DomoticzPort="8080"
export TempFileDir="/var/tmp/"
export BotHomePath="/home/pi/dtgbot/"
export BotBashScriptPath=$BotHomePath"bash/"
export BotLuaScriptPath=$BotHomePath"lua/"
export BotLuaLog=$TempFileDir"dtb.log"
export TelegramChatId='34####63#
export TelegramBotToken="524####64:AAFZUOtHs_tvJ_F6c06GYpkt6$$$$$$$$$$$$"
export TelegramBotOffset="TelegramBotOffset"
export EmailTo="alt$$$$$[email protected]"



I have started the installation a couple of times wthout luck following the domoticz wiki.

Any idea? What can i do to make it work?

Thanx in advance for your help.

Regards
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 issue seems to lie in these lines so guess the best bet will be an issue with the require files:

Code: Select all

-- Load necessary Lua libraries
http = require "socket.http";
socket = require "socket";
https = require "ssl.https";
JSON = require "JSON";

function file_exists(name)
   local f=io.open(name,"r")
   if f~=nil then io.close(f) return true else return false end
end

-- Load the configuration file this file contains the list of commands
-- used to define the external files with the command function to load.
local config=""
if (file_exists(BotHomePath.."dtgbot-user.cfg")) then
  config = assert(loadfile(BotHomePath.."dtgbot-user.cfg"))();
  print_to_log ("Using DTGBOT config file:"..BotHomePath.."dtgbot-user.cfg")
else
  config = assert(loadfile(BotHomePath.."dtgbot.cfg"))();
  print_to_log ("Using DTGBOT config file:"..BotHomePath.."dtgbot.cfg")
end
Could the issue be similar to issues reported like this one?: http://www.domoticz.com/forum/viewtopic ... on#p171940

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
satanasinc
Posts: 41
Joined: Monday 19 October 2015 12:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Spain
Contact:

Re: dtgbot - Domoticz TeleGram BOT

Post by satanasinc »

jvdz wrote: Tuesday 13 March 2018 18:36 The issue seems to lie in these lines so guess the best bet will be an issue with the require files:

Code: Select all

-- Load necessary Lua libraries
http = require "socket.http";
socket = require "socket";
https = require "ssl.https";
JSON = require "JSON";

function file_exists(name)
   local f=io.open(name,"r")
   if f~=nil then io.close(f) return true else return false end
end

-- Load the configuration file this file contains the list of commands
-- used to define the external files with the command function to load.
local config=""
if (file_exists(BotHomePath.."dtgbot-user.cfg")) then
  config = assert(loadfile(BotHomePath.."dtgbot-user.cfg"))();
  print_to_log ("Using DTGBOT config file:"..BotHomePath.."dtgbot-user.cfg")
else
  config = assert(loadfile(BotHomePath.."dtgbot.cfg"))();
  print_to_log ("Using DTGBOT config file:"..BotHomePath.."dtgbot.cfg")
end
Could the issue be similar to issues reported like this one?: http://www.domoticz.com/forum/viewtopic ... on#p171940

Jos
Hi!
That is the soution!!!
Working at first attempt.

Like i tell you in october of 2015 youre the Jedi Master.
Thank you very much Jos.

Regards an thanx again
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 »

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!
Domoticz stable | Intel NUC | VirtualBox | Ubuntu 16.04
RPI2B | RFLink
Yeelight | Sonoff Tasmota
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests