dtgbot - Domoticz TeleGram BOT
Moderator: leecollings
-
- Posts: 329
- Joined: Tuesday 16 July 2013 22:54
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.8807
- Location: North East England
- Contact:
dtgbot - Domoticz TeleGram BOT
While telegram-cli is a very useful telegram client for Linux, Telegram have now released a new bot api, which makes it possible to send notifications without installing any Telegram software using https requests (http://www.domoticz.com/wiki/Telegram_Bot) and to connect Telgram to Domoticz more directly.
I have created a new handler dtgbot which builds on the previous bots (receive.lua for telegram-cli and the XMPP bot for Google Hangouts), providing the same functionality (http://www.domoticz.com/wiki/Telegram_B ... ctionality)
dtgbot requires installation of a number of Lua libraries which are attached in the two tar.gz files and installation of its own scripts which are attached in the tar file - I have detailed the installation in this Wiki page - http://www.domoticz.com/wiki/Remote_Con ... legram_Bot - however first you need to complete the actions described on the Telegram Bot page to create your own Telegram Bot for dtgbot to use - http://www.domoticz.com/wiki/Remote_Con ... legram_Bot.
If you have already installed telegram-cli then you do not need to remove or change anything (apart from DomoticzData.sh) in order to use dtgbot, in fact both can be used simultaneously.
Currently this is very much alpha software, however once it is stable then I suggest we depricate the exisiting Installing Telegram Notification System pages, in favour of this approach as it should be far more supportable (https://www.domoticz.com/wiki/Installin ... ion_System)
Comments / improvements / suggestions most welcome.
Edit: Updated dtgbot.tar - based on feedback and added extra log file to capture Lua errors - by default will be /var/tmp/dtb.log.errors
I have created a new handler dtgbot which builds on the previous bots (receive.lua for telegram-cli and the XMPP bot for Google Hangouts), providing the same functionality (http://www.domoticz.com/wiki/Telegram_B ... ctionality)
dtgbot requires installation of a number of Lua libraries which are attached in the two tar.gz files and installation of its own scripts which are attached in the tar file - I have detailed the installation in this Wiki page - http://www.domoticz.com/wiki/Remote_Con ... legram_Bot - however first you need to complete the actions described on the Telegram Bot page to create your own Telegram Bot for dtgbot to use - http://www.domoticz.com/wiki/Remote_Con ... legram_Bot.
If you have already installed telegram-cli then you do not need to remove or change anything (apart from DomoticzData.sh) in order to use dtgbot, in fact both can be used simultaneously.
Currently this is very much alpha software, however once it is stable then I suggest we depricate the exisiting Installing Telegram Notification System pages, in favour of this approach as it should be far more supportable (https://www.domoticz.com/wiki/Installin ... ion_System)
Comments / improvements / suggestions most welcome.
Edit: Updated dtgbot.tar - based on feedback and added extra log file to capture Lua errors - by default will be /var/tmp/dtb.log.errors
- Attachments
-
- 150714dtgbot.tar
- cd ~
tar -xvf 150714dtgbot.tar - (60 KiB) Downloaded 1455 times
-
- usrlocalsharelua52.tar.gz
- cd /usr/local/share/lua/5.2/
sudo tar -xvf ~/temp/usrlocalsharelua52.tar.gz - (128.81 KiB) Downloaded 3037 times
-
- usrlocalliblua52.tar.gz
- cd /usr/local/lib/lua/5.2/
sudo tar -xvf usrlocalliblua52.tar.gz - (142.82 KiB) Downloaded 2338 times
Last edited by simonrg on Tuesday 14 July 2015 23:26, edited 2 times in total.
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
- G3rard
- Posts: 669
- Joined: Wednesday 04 March 2015 22:15
- Target OS: -
- Domoticz version: No
- Location: The Netherlands
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
Great! Will certainly try this as I still have some issues with Telegram-CLI (only resolved after rebooting the Pi).
Not using Domoticz anymore
-
- 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
Thanks for the tutorial!
sadly im not able to get dtg bot to work.
When I do a status check I get: [FAIL] dtgbot is not running ... failed!
I don't have the following folder: cd /usr/local/share/lua/5.2/ and cd /usr/local/share/lua/5.2/
I created them myself.
sadly im not able to get dtg bot to work.
When I do a status check I get: [FAIL] dtgbot is not running ... failed!
I don't have the following folder: cd /usr/local/share/lua/5.2/ and cd /usr/local/share/lua/5.2/
Code: Select all
cd /usr/local/share/lua/5.2/
sudo tar -xvf ~/temp/usrlocalsharelua52.tar.gz
cd /usr/local/lib/lua/5.2/
sudo tar -xvf ~/temp/usrlocalliblua52.tar.gz
Last edited by fransiefrans on Tuesday 14 July 2015 8:36, edited 1 time in total.
-
- 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
Yes you need the directories, so I have changed the wiki to:fransiefrans wrote:Thanks for the tutorial!
sadly im not able to get dtg bot to work.
When I do a status check I get: [FAIL] dtgbot is not running ... failed!
I don't have the following folder: cd /usr/local/share/lua/5.2/
Do I need this one?Code: Select all
cd /usr/local/share/lua/5.2/ sudo tar -xvf ~/temp/usrlocalsharelua52.tar.gz cd /usr/local/lib/lua/5.2/ sudo tar -xvf ~/temp/usrlocalliblua52.tar.gz
Code: Select all
sudo mkdir /usr/local/share/lua/5.2/ #Only needed if this directory does not exist
cd /usr/local/share/lua/5.2/
sudo tar -xvf ~/temp/usrlocalsharelua52.tar.gz
sudo mkdir /usr/local/lib/lua/5.2/ #Only needed if this directory does not exist
cd /usr/local/lib/lua/5.2/
sudo tar -xvf ~/temp/usrlocalliblua52.tar.gz
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: 59
- Joined: Sunday 14 June 2015 13:22
- Target OS: Raspberry Pi / ODroid
- Domoticz version: stable
- Location: Netherlands
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
This is my log
Code: Select all
---------------------------------
Starting Telegram message handler
---------------------------------
DomoticzIP: 127.0.0.1
DomoticzPort: 8080
BotHomePath: /home/pi/dtgbot/
BotLuaScriptPath: /home/pi/dtgbot/lua/
BotBashScriptPath: /home/pi/dtgbot/bash/
TelegramBotToken: Correct token
TelegramBotOffset: TelegramBotOffset
Loading command modules...
Loading module <list>
found command <dump>
function: 0x1af9b50
found command <list>
function: 0x1af9b50
Loading module <devices>
found command <devices>
function: 0x1afd118
found command <scenes>
function: 0x1afd118
Loading module <flick>
found command <flick>
function: 0x1b0eef0
Loading module <nflick>
found command <nflick>
function: 0x1b0c5a8
Loading module <on>
found command <off>
function: 0x1afdd40
found command <on>
function: 0x1afdd40
Loading module <battery>
found command <battery>
function: 0x1b3c020
found command <batteries>
function: 0x1b3c020
Loading module <help>
found command <help>
function: 0x1b3cfa8
JSON request <http://127.0.0.1:8080/json.htm?type=command¶m=getuservariables>
Domoticz returned getuservariables after 1 attempts
-
- 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
It looks like you haven't created a user variable in Domoticz - TelegramBotOffset - http://www.domoticz.com/wiki/Remote_Con ... r_Variable.fransiefrans wrote:This is my logCode: Select all
Domoticz returned getuservariables after 1 attempts
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: 113
- Joined: Thursday 20 November 2014 22:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Norway
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
@fransiefrans, try to replace DomoticzIP: 127.0.0.1 with the internal IP of your server running Domoticz and dtgbot. i.e. DomoticzIP: 192.168.149.52...
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
-
- 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
Thanks for the great job getting this to work with Domoticz, @simonrg!
It worked great for me, until I issued the command "battery". This makes the dtgbot-service crash. See log below.
Have I done something wrong here? should I add more parameters to the command, or should I edit the battery.lua file somehow?
I try to issue sudo service dtgbot start, but it just crashes again immideately. How can I clear the command-queue so that the service don't crash again?
Thanks!
Log:
It worked great for me, until I issued the command "battery". This makes the dtgbot-service crash. See log below.
Have I done something wrong here? should I add more parameters to the command, or should I edit the battery.lua file somehow?
I try to issue sudo service dtgbot start, but it just crashes again immideately. How can I clear the command-queue so that the service don't crash again?
Thanks!
Log:
Code: Select all
---------------------------------
Starting Telegram message handler
---------------------------------
DomoticzIP: 10.10.10.127
DomoticzPort: 8080
BotHomePath: /home/pi/dtgbot/
BotLuaScriptPath: /home/pi/dtgbot/lua/
BotBashScriptPath: /home/pi/dtgbot/bash/
TelegramBotToken: keykeykyekye
TelegramBotOffset: TelegramBotOffset
Loading command modules...
Loading module <list>
found command <list>
function: 0x1e279a8
found command <dump>
function: 0x1e279a8
Loading module <devices>
found command <scenes>
function: 0x1e163c0
found command <devices>
function: 0x1e163c0
Loading module <flick>
found command <flick>
function: 0x1e5b4b0
Loading module <nflick>
found command <nflick>
function: 0x1e44638
Loading module <on>
found command <on>
function: 0x1e57f90
found command <off>
function: 0x1e57f90
Loading module <battery>
found command <battery>
function: 0x1e2fb80
found command <batteries>
function: 0x1e2fb80
Loading module <help>
found command <help>
function: 0x1e56c60
JSON request <http://10.10.10.127:8080/json.htm?type=command¶m=getuservariables>
Domoticz returned getuservariables after 1 attempts
1
TBOidx 1
JSON request <http://10.10.10.127:8080/json.htm?type=command¶m=getuservariable&idx=1>
Decoded 277849972
TBO 277849972
https://api.telegram.org/botkeykeykeykey/
.Message: 1
update_id 277849972
Battery
Handle command function started with Battery and IDIDIDIDI
JSON request <http://10.10.10.127:8080/json.htm?type=command¶m=getuservariables>
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
-
- 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
To get dtgbot to work again, you need to set TelegramBotOffset to 1 higher than the current update id, i.e. 277849973, this stops dtgbot from re-reading the message causing the error.thorbj wrote:Thanks for the great job getting this to work with Domoticz, @simonrg!
It worked great for me, until I issued the command "battery". This makes the dtgbot-service crash. See log below.
Have I done something wrong here? should I add more parameters to the command, or should I edit the battery.lua file somehow?
I try to issue sudo service dtgbot start, but it just crashes again immideately. How can I clear the command-queue so that the service don't crash again?
Thanks!
Log:Code: Select all
--------------------------------- Starting Telegram message handler --------------------------------- DomoticzIP: 10.10.10.127 DomoticzPort: 8080 BotHomePath: /home/pi/dtgbot/ BotLuaScriptPath: /home/pi/dtgbot/lua/ BotBashScriptPath: /home/pi/dtgbot/bash/ TelegramBotToken: keykeykyekye TelegramBotOffset: TelegramBotOffset Loading command modules... Loading module <list> found command <list> function: 0x1e279a8 found command <dump> function: 0x1e279a8 Loading module <devices> found command <scenes> function: 0x1e163c0 found command <devices> function: 0x1e163c0 Loading module <flick> found command <flick> function: 0x1e5b4b0 Loading module <nflick> found command <nflick> function: 0x1e44638 Loading module <on> found command <on> function: 0x1e57f90 found command <off> function: 0x1e57f90 Loading module <battery> found command <battery> function: 0x1e2fb80 found command <batteries> function: 0x1e2fb80 Loading module <help> found command <help> function: 0x1e56c60 JSON request <http://10.10.10.127:8080/json.htm?type=command¶m=getuservariables> Domoticz returned getuservariables after 1 attempts 1 TBOidx 1 JSON request <http://10.10.10.127:8080/json.htm?type=command¶m=getuservariable&idx=1> Decoded 277849972 TBO 277849972 https://api.telegram.org/botkeykeykeykey/ .Message: 1 update_id 277849972 Battery Handle command function started with Battery and IDIDIDIDI JSON request <http://10.10.10.127:8080/json.htm?type=command¶m=getuservariables>
The error is caused because I am expecting you to have a Domoticz variable called DevicesWithBatteries which should contain A Device|Another Device|Yet Another Device, this is one of the many bits that needs documenting and looking at the code tidying up as well.
As I capture errors I am updating the wiki pages and modifying the code.
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: 113
- Joined: Thursday 20 November 2014 22:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Norway
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
Thank you @simonrg!
So I should create a new user variable named "DevicesWithBatteries" and add devices in a string here? by idx or name?
So I should create a new user variable named "DevicesWithBatteries" and add devices in a string here? by idx or name?
Last edited by thorbj on Tuesday 14 July 2015 12:37, edited 1 time in total.
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
-
- 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
Names not idxs, the single user variable DevicesWithBatteries set in Domoticz with the name of each device seperated by a | i.e. stored as "name one|name 2|name 3|name Forty one" with correct case and spacing.thorbj wrote:Thank you @simonrg!
So I should create a new user variable named "DevicesWithBatteries" and add devices in a string here? by idx og name?
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: 59
- Joined: Sunday 14 June 2015 13:22
- Target OS: Raspberry Pi / ODroid
- Domoticz version: stable
- Location: Netherlands
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
still no luck after adding user variable.
Also tried changing ip to network ip
when I open the Json request in the logfile I do get the following:
{
"result" : [
{
"LastUpdate" : "2015-07-14 12:23:42",
"Name" : "TelegramBotOffset",
"Type" : "0",
"Value" : "1",
"idx" : "1"
}
],
"status" : "OK",
"title" : "GetUserVariables"
}
Also tried changing ip to network ip
when I open the Json request in the logfile I do get the following:
{
"result" : [
{
"LastUpdate" : "2015-07-14 12:23:42",
"Name" : "TelegramBotOffset",
"Type" : "0",
"Value" : "1",
"idx" : "1"
}
],
"status" : "OK",
"title" : "GetUserVariables"
}
-
- 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
Thank you, that worked!simonrg wrote:Names not idxs, the single user variable DevicesWithBatteries set in Domoticz with the name of each device seperated by a | i.e. stored as "name one|name 2|name 3|name Forty one" with correct case and spacing.thorbj wrote:Thank you @simonrg!
So I should create a new user variable named "DevicesWithBatteries" and add devices in a string here? by idx og name?

I noticed I can only have one instance of each device in the variable. Like if I have a device that has both a Motion Sensor, Lux sensor and a Temp sensor, I can not put "Motion Sensor | Lux sensor | Temp sensor" in the variable-string. Is this correct?
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
-
- 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
Hi,
in the following step of the instrucion:
As Lua functions run by Domoticz are run within Domoticz, the environment variables defined in DomoticzData.sh need to be available to Domoticz, add these two lines into /etc/init.d/domoticz.sh, just before #Exit
Do I have the added lines in the correct place?
#! /bin/sh
### BEGIN INIT INFO
# Provides: domoticz
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Home Automation System
# Description: This daemon will start the Domoticz Home Automation Sy$
### END INIT INFO
# Do NOT "set -e"
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
DESC="Domoticz Home Automation System"
NAME=domoticz
USERNAME=pi
DAEMON=/home/$USERNAME/domoticz/$NAME
#DAEMON_ARGS="-daemon -www 8080 -sslwww 443 -log /tmp/domoticz.txt"
#DAEMON_ARGS="-daemon -www 8080 -sslwww 443 -syslog"
DAEMON_ARGS="-daemon -www 8080 -sslwww 443"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
# Get the preset variables so that they are available for Lua functions wit$
. /etc/profile.d/DomoticzData.sh
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --chuid $USERNAME --start --quiet --pidfile $PIDF$
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON$
$DAEMON_ARGS \
|| return 2
}
in the following step of the instrucion:
As Lua functions run by Domoticz are run within Domoticz, the environment variables defined in DomoticzData.sh need to be available to Domoticz, add these two lines into /etc/init.d/domoticz.sh, just before #Exit
Do I have the added lines in the correct place?
#! /bin/sh
### BEGIN INIT INFO
# Provides: domoticz
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Home Automation System
# Description: This daemon will start the Domoticz Home Automation Sy$
### END INIT INFO
# Do NOT "set -e"
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
DESC="Domoticz Home Automation System"
NAME=domoticz
USERNAME=pi
DAEMON=/home/$USERNAME/domoticz/$NAME
#DAEMON_ARGS="-daemon -www 8080 -sslwww 443 -log /tmp/domoticz.txt"
#DAEMON_ARGS="-daemon -www 8080 -sslwww 443 -syslog"
DAEMON_ARGS="-daemon -www 8080 -sslwww 443"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
# Get the preset variables so that they are available for Lua functions wit$
. /etc/profile.d/DomoticzData.sh
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --chuid $USERNAME --start --quiet --pidfile $PIDF$
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON$
$DAEMON_ARGS \
|| return 2
}
-
- 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
Yes that is the right place.fransiefrans wrote:Do I have the added lines in the correct place?
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: 17
- Joined: Saturday 08 February 2014 13:57
- Target OS: Windows
- Domoticz version:
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
Hello,
I have to chance the curl to send the photo by lua. Can someone help me with this?
os.execute('curl -s -X POST "https://api.telegram.org/bot3333333:key ... /sendPhoto" -F chat_id=123456789 -F photo="@/home/pi/domoticz/camera/snapshot.jpg" ')
Something like this:
commandArray = {}
token = "0000000:KEYKEYKEYKEYKEYKEY"
chatid = 12345678
if (devicechanged['Test'] == 'On') then
os.execute('curl --data chat_id='..chatid..' --data-urlencode "text="'..message..'" "https://api.telegram.org/bot'..token..'/SendPhoto" ')
end
return commandArray
Thanks,
Regards,
Jan.
I have to chance the curl to send the photo by lua. Can someone help me with this?
os.execute('curl -s -X POST "https://api.telegram.org/bot3333333:key ... /sendPhoto" -F chat_id=123456789 -F photo="@/home/pi/domoticz/camera/snapshot.jpg" ')
Something like this:
commandArray = {}
token = "0000000:KEYKEYKEYKEYKEYKEY"
chatid = 12345678
if (devicechanged['Test'] == 'On') then
os.execute('curl --data chat_id='..chatid..' --data-urlencode "text="'..message..'" "https://api.telegram.org/bot'..token..'/SendPhoto" ')
end
return commandArray
Thanks,
Regards,
Jan.
-
- 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
I don't think it would mind if you had Motion Sensor|Lux Sensor|Temp Sensor as the contents of DevicesWithBatteries as long as they all return idx values, then the query for battery status should work, why not have a go.thorbj wrote: I noticed I can only have one instance of each device in the variable. Like if I have a device that has both a Motion Sensor, Lux sensor and a Temp sensor, I can not put "Motion Sensor | Lux sensor | Temp sensor" in the variable-string. Is this correct?
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: 59
- Joined: Sunday 14 June 2015 13:22
- Target OS: Raspberry Pi / ODroid
- Domoticz version: stable
- Location: Netherlands
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
Started with a new domoticz img, restored the backup. tried the tutorial again with no luck. I'm getting the following fault in the log.
Code: Select all
Starting Telegram message handler
---------------------------------
DomoticzIP: 192.168.2.7
DomoticzPort: 8080
BotHomePath: /home/pi/dtgbot/
BotLuaScriptPath: /home/pi/dtgbot/lua/
BotBashScriptPath: /home/pi/dtgbot/bash/
TelegramBotToken: key
TelegramBotOffset: TelegramBotOffset
-
- 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
If it is crashing there then not sure what is wrong.fransiefrans wrote:Started with a new domoticz img, restored the backup. tried the tutorial again with no luck. I'm getting the following fault in the log.
Code: Select all
Starting Telegram message handler --------------------------------- DomoticzIP: 192.168.2.7 DomoticzPort: 8080 BotHomePath: /home/pi/dtgbot/ BotLuaScriptPath: /home/pi/dtgbot/lua/ BotBashScriptPath: /home/pi/dtgbot/bash/ TelegramBotToken: key TelegramBotOffset: TelegramBotOffset
On the command line try:
Code: Select all
cd ~/dtgbot
lua dtgbot.lua
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: 1
- Joined: Tuesday 14 July 2015 22:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: dtgbot - Domoticz TeleGram BOT
Hi Frans,fransiefrans wrote:Started with a new domoticz img, restored the backup. tried the tutorial again with no luck. I'm getting the following fault in the log.
Code: Select all
Starting Telegram message handler --------------------------------- DomoticzIP: 192.168.2.7 DomoticzPort: 8080 BotHomePath: /home/pi/dtgbot/ BotLuaScriptPath: /home/pi/dtgbot/lua/ BotBashScriptPath: /home/pi/dtgbot/bash/ TelegramBotToken: key TelegramBotOffset: TelegramBotOffset
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
@simonrg, thanks for your work !! and maybe you can add the right packages in your - otherwise good - wiki
Greetz Erwin
Who is online
Users browsing this forum: Ahrefs [Bot] and 0 guests