Re: dtgbot - Domoticz TeleGram BOT
Posted: Friday 17 February 2017 20:48
thanks for the answers, I've lost my previous telegram setup and about to add back in
Open source Home Automation System
https://forum.domoticz.com/
I dont know if this is the logging from the time it didnt work, but the file contains the followingjvdz wrote:The dtgbot.log.errors file should contain the error encountered as described in the wiki: https://www.domoticz.com/wiki/Remote_Co ... log.errors
Have you checked that?
Jos
Code: Select all
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
^M 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0^M100 292 100 231 100 61 2714 716 --:--:-- --:--:-- --:--:-- 2750
jq: error: Cannot iterate over null
jq: error: Cannot iterate over null
jq: error: Cannot iterate over null
jq: error: Cannot iterate over null
/home/pi/dtgbot/bash//systemstatus.sh: line 48: [: : integer expression expected
/home/pi/dtgbot/bash//systemstatus.sh: line 52: [: : integer expression expected
/home/pi/dtgbot/bash//systemstatus.sh: line 56: [: : integer expression expected
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
^M 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0^M 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0^M100 566 100 345 100 221 3510 224$
/home/pi/dtgbot/bash//checkdomoticzupdate.sh: 21: [: -le: unexpected operator
/home/pi/dtgbot/bash//checkdomoticzupdate.sh: 26: [: -le: unexpected operator
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
^M 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0^M100 266 100 220 100 46 2214 463 --:--:-- --:--:-- --:--:-- 2222
Code: Select all
print_to_log(1,'update_id ',tt.update_id)
print_to_log(1,msg.text)
TelegramBotOffset = tt.update_id + 1
print_to_log(1,'TelegramBotOffset '..TelegramBotOffset)
set_variable_value(TBOidx,TBOName,0,TelegramBotOffset)
-- Offset updated before processing in case of crash allows clean restart
on_msg_receive(msg)
Code: Select all
print_to_log(1,'update_id ',tt.update_id)
-- print_to_log(1,msg.text)
TelegramBotOffset = tt.update_id + 1
print_to_log(1,'TelegramBotOffset '..TelegramBotOffset)
set_variable_value(TBOidx,TBOName,0,TelegramBotOffset)
-- Offset updated before processing in case of crash allows clean restart
if msg ~= nil and msg.text ~= nil then
print_to_log(1,msg.text)
on_msg_receive(msg)
end
Code: Select all
root@Domoticzmainz:/etc/init.d# sudo service dtgbot status
● dtgbot.service - LSB: A Telegram bot designed to control Domoticz
Loaded: loaded (/etc/init.d/dtgbot)
Active: active (running) since Fri 2017-04-14 20:12:17 CEST; 8min ago
Process: 7474 ExecStart=/etc/init.d/dtgbot start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/dtgbot.service
├─7481 /bin/sh /home/pi/dtgbot/dtgbot /var/run/dtgbot.pid
└─7482 /usr/bin/lua5.2 /home/pi/dtgbot/dtgbot.lua
Apr 14 20:12:17 Domoticzmainz dtgbot[7474]: Starting Telegram Bot for Domoti....
Apr 14 20:12:17 Domoticzmainz systemd[1]: Started LSB: A Telegram bot design....
Hint: Some lines were ellipsized, use -l to show in full.
root@Domoticzmainz:/etc/init.d#
Code: Select all
2017-04-14 20:12:17 - DomoticzIP: XXXXXXXX:[email protected]
2017-04-14 20:12:17 - DomoticzPort: 8080
2017-04-14 20:12:17 - BotHomePath: /home/pi/dtgbot/
2017-04-14 20:12:17 - BotLuaScriptPath: /home/pi/dtgbot/lua/
2017-04-14 20:12:17 - BotBashScriptPath: /home/pi/dtgbot/bash/
2017-04-14 20:12:17 - TelegramBotToken: XXXXXXXXXXXXXXXXXXXXXXXX
2017-04-14 20:12:17 - TelegramBotOffset: TelegramBotOffset
2017-04-14 20:12:17 - -----------------------------------------
2017-04-14 20:12:17 - Starting Telegram api Bot message handler
2017-04-14 20:12:17 - -----------------------------------------
2017-04-14 20:12:17 - Domoticz returned getuservariables after 1 attempts
2017-04-14 20:12:17 - dtgbotLogLevel set to: 0
2017-04-14 20:12:17 - Loading command modules...
2017-04-14 20:12:17 - Loading module <utility>
2017-04-14 20:12:17 - found command <refresh>
2017-04-14 20:12:17 - Loading module <dtgmenu>
2017-04-14 20:12:17 - define LastCommand
2017-04-14 20:12:17 - found command <dtgmenu>
2017-04-14 20:12:17 - Loading module <list>
2017-04-14 20:12:17 - found command <dump>
2017-04-14 20:12:17 - found command <list>
2017-04-14 20:12:17 - Loading module <devices>
2017-04-14 20:12:17 - found command <scenes>
2017-04-14 20:12:17 - found command <devices>
2017-04-14 20:12:17 - Loading module <flick>
2017-04-14 20:12:17 - found command <flick>
2017-04-14 20:12:17 - Loading module <nflick>
2017-04-14 20:12:17 - found command <nflick>
2017-04-14 20:12:17 - Loading module <on>
2017-04-14 20:12:17 - found command <off>
2017-04-14 20:12:17 - found command <on>
2017-04-14 20:12:17 - Loading module <battery>
2017-04-14 20:12:17 - found command <batteries>
2017-04-14 20:12:17 - found command <battery>
2017-04-14 20:12:17 - Loading module <help>
2017-04-14 20:12:17 - found command <start>
2017-04-14 20:12:17 - found command <help>
2017-04-14 20:12:17 - Loading module <temperature>
2017-04-14 20:12:17 - found command <temperatures>
2017-04-14 20:12:17 - found command <temperature>
2017-04-14 20:12:17 - found command <tempall>
2017-04-14 20:12:17 - Decoded On
2017-04-14 20:12:18 - WLidx 10
2017-04-14 20:12:18 - Decoded 34492***
2017-04-14 20:12:18 - WLString: 34492***
2017-04-14 20:12:18 - dtgbotLogLevel set to: 0
2017-04-14 20:12:18 - WLidx 10
2017-04-14 20:12:18 - Decoded 34492***
2017-04-14 20:12:18 - WLString: 34492***
2017-04-14 20:12:18 - Getting TelegramBotOffset the previous Telegram bot message offset from Domoticz
2017-04-14 20:12:18 - Decoded 1
Code: Select all
ubuntu@ubuntu:~/apps/dtgbot$ sudo lua dtgbot.lua
2017-05-10 20:23:30 - DomoticzIP not found check /etc/profile.d/DomoticzData.sh
2017-05-10 20:23:30 - DomoticzPort not found check /etc/profile.d/DomoticzData.sh
2017-05-10 20:23:30 - BotHomePath not found check /etc/profile.d/DomoticzData.sh
2017-05-10 20:23:30 - BotLuaScriptPath not found check /etc/profile.d/DomoticzData.sh
2017-05-10 20:23:30 - TempFileDir not found check /etc/profile.d/DomoticzData.sh
2017-05-10 20:23:30 - BotBashScriptPath not found check /etc/profile.d/DomoticzData.sh
2017-05-10 20:23:30 - TelegramBotToken not found check /etc/profile.d/DomoticzData.sh
2017-05-10 20:23:30 - TelegramBotOffset not found check /etc/profile.d/DomoticzData.sh
lua: dtgbot.lua:69: attempt to concatenate global 'DomoticzPort' (a nil value)
stack traceback:
dtgbot.lua:69: in main chunk
[C]: in ?
Code: Select all
● dtgbot.service - LSB: A Telegram bot designed to control Domoticz
Loaded: loaded (/etc/init.d/dtgbot; bad; vendor preset: enabled)
Active: active (exited) since Wed 2017-05-10 18:07:09 CEST; 2h 34min ago
Docs: man:systemd-sysv-generator(8)
Process: 18676 ExecStop=/etc/init.d/dtgbot stop (code=exited, status=0/SUCCESS)
Process: 18692 ExecStart=/etc/init.d/dtgbot start (code=exited, status=0/SUCCESS)
May 10 18:07:09 centraalpunt systemd[1]: Starting LSB: A Telegram bot designed to control Domoticz...
May 10 18:07:09 centraalpunt dtgbot[18692]: Starting Telegram Bot for Domoticz ... Done.
May 10 18:07:09 centraalpunt systemd[1]: Started LSB: A Telegram bot designed to control Domoticz.
Code: Select all
* dtgbot is running
Code: Select all
#!/bin/bash
# Variables to avoid having to set local system information in individual automation scripts
#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="192.168.88.2"
export DomoticzPort="8000"
export TempFileDir="/var/tmp/"
export BotHomePath="/home/user/apps/dtgbot/"
export BotBashScriptPath=$BotHomePath"bash/"
export BotLuaScriptPath=$BotHomePath"lua/"
export BotLuaLog=$TempFileDir"dtb.log"
export TelegramChatId="my_chat_id"
export TelegramBotToken="my_bot_ID:My_bot_token"
export TelegramBotOffset="TelegramBotOffset"
export EmailTo="[email protected]"
Code: Select all
/usr/bin/lua5.2: error loading module 'socket.core' from file '/usr/local/lib/lua/5.2/socket/core.so':
/usr/local/lib/lua/5.2/socket/core.so: wrong ELF class: ELFCLASS32
stack traceback:
[C]: in ?
[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'
/home/user/apps/dtgbot/dtgbot.lua:93: in main chunk
[C]: in ?
Code: Select all
dtg_domoticz.lua:178: attempt to index field 'result'( a nil value)
/dtg_domoticz.lua:178: in funtion 'devinfo_from_name'
/dtgmenu:433: in funtion 'MakeRoomMenus'
/dtgmenu:382: in funtion 'PopulateMenuTab'
/dtgbot.lua:211 in function 'dtg_initialise'
/dtgbot.lua:230 in main chunk
Code: Select all
/usr/bin/lua5.2: /home/pi/dtgbot//dtg_domoticz.lua:178: attempt to index field 'result' (a nil value)
stack traceback:
/home/pi/dtgbot//dtg_domoticz.lua:178: in function 'devinfo_from_name'
/home/pi/dtgbot/lua//dtgmenu.lua:433: in function 'MakeRoomMenus'
/home/pi/dtgbot/lua//dtgmenu.lua:382: in function 'PopulateMenuTab'
/home/pi/dtgbot/dtgbot.lua:211: in function 'dtgbot_initialise'
/home/pi/dtgbot/dtgbot.lua:230: in main chunk
[C]: in ?
Code: Select all
2017-05-11 23:44:12 - DomoticzIP: 192.168.1.27
2017-05-11 23:44:12 - DomoticzPort: 8080
2017-05-11 23:44:12 - BotHomePath: /home/pi/dtgbot/
2017-05-11 23:44:12 - BotLuaScriptPath: /home/pi/dtgbot/lua/
2017-05-11 23:44:12 - TempFileDir: /var/tmp/
2017-05-11 23:44:12 - BotBashScriptPath: /home/pi/dtgbot/bash/
2017-05-11 23:44:12 - TelegramBotToken: -
2017-05-11 23:44:12 - TelegramBotOffset: TelegramBotOffset
2017-05-11 23:44:12 - -----------------------------------------
2017-05-11 23:44:12 - Starting Telegram api Bot message handler
2017-05-11 23:44:12 - -----------------------------------------
2017-05-11 23:44:12 - JSON request <http://192.168.1.27:8080/json.htm?type=command¶m=getuservariables>
2017-05-11 23:44:12 - Domoticz returned getuservariables after 1 attempts
2017-05-11 23:44:12 - JSON request <http://192.168.1.27:8080/json.htm?type=devices&order=name&used=true>
2017-05-11 23:44:12 - JSON request <http://192.168.1.27:8080/json.htm?type=scenes&order=name&used=true>
2017-05-11 23:44:12 - JSON request <http://192.168.1.27:8080/json.htm?type=plans&order=name&used=true>
2017-05-11 23:44:12 - JSON request <http://192.168.1.27:8080/json.htm?type=command¶m=getlanguage>
2017-05-11 23:44:12 - dtgbotLogLevel set to: 2
2017-05-11 23:44:12 - Loading command modules...
2017-05-11 23:44:12 - Loading module <utility>
2017-05-11 23:44:12 - found command <refresh>
2017-05-11 23:44:12 - function: 0x793b60
2017-05-11 23:44:12 - Loading module <dtgmenu>
2017-05-11 23:44:12 - define LastCommand
2017-05-11 23:44:12 - found command <dtgmenu>
2017-05-11 23:44:12 - function: 0x7a3b80
2017-05-11 23:44:12 - Loading module <list>
2017-05-11 23:44:12 - found command <dump>
2017-05-11 23:44:12 - function: 0x7a01c8
2017-05-11 23:44:12 - found command <list>
2017-05-11 23:44:12 - function: 0x7a01c8
2017-05-11 23:44:12 - Loading module <devices>
2017-05-11 23:44:12 - found command <devices>
2017-05-11 23:44:12 - function: 0x7aa040
2017-05-11 23:44:12 - found command <scenes>
2017-05-11 23:44:12 - function: 0x7aa040
2017-05-11 23:44:12 - Loading module <flick>
2017-05-11 23:44:12 - found command <flick>
2017-05-11 23:44:12 - function: 0x7a9c50
2017-05-11 23:44:12 - Loading module <nflick>
2017-05-11 23:44:12 - found command <nflick>
2017-05-11 23:44:12 - function: 0x7acb98
2017-05-11 23:44:12 - Loading module <on>
2017-05-11 23:44:12 - found command <on>
2017-05-11 23:44:12 - function: 0x7aee50
2017-05-11 23:44:12 - found command <off>
2017-05-11 23:44:12 - function: 0x7aee50
2017-05-11 23:44:12 - Loading module <battery>
2017-05-11 23:44:12 - found command <batteries>
2017-05-11 23:44:12 - function: 0x7b69e0
2017-05-11 23:44:12 - found command <battery>
2017-05-11 23:44:12 - function: 0x7b69e0
2017-05-11 23:44:12 - Loading module <help>
2017-05-11 23:44:12 - found command <start>
2017-05-11 23:44:12 - function: 0x7b5b08
2017-05-11 23:44:12 - found command <help>
2017-05-11 23:44:12 - function: 0x7b5b08
2017-05-11 23:44:12 - Loading module <temperature>
2017-05-11 23:44:12 - found command <tempall>
2017-05-11 23:44:12 - function: 0x7b9980
2017-05-11 23:44:12 - found command <temperature>
2017-05-11 23:44:12 - function: 0x7b9980
2017-05-11 23:44:12 - found command <temperatures>
2017-05-11 23:44:12 - function: 0x7b9980
2017-05-11 23:44:12 - JSON request <http://192.168.1.27:8080/json.htm?type=command¶m=getuservariable&idx=139>
2017-05-11 23:44:12 - Decoded On
2017-05-11 23:44:12 - #### Start populating menuarray
2017-05-11 23:44:12 - Submenu table including buttons defined in menu.cfg: (1) 1 (2)
2017-05-11 23:44:12 - => (1) Misc (2) (3) n (4) 3
2017-05-11 23:44:12 - ==> start devinfo_from_name (2) refresh
2017-05-11 23:44:12 - !!!! found device (1) (2) 0
2017-05-11 23:44:12 - --< devinfo_from_name: (1) 0 (2) 9999 (3) (4) command (5) command (6) command (7)
2017-05-11 23:44:12 - static -> (1) Misc (2) refresh (3) (4) 9999 (5) command (6) command (7) command (8) 100 (9)
2017-05-11 23:44:12 - ==> start devinfo_from_name (2) tempall
2017-05-11 23:44:12 - !!!! found device (1) (2) 0
2017-05-11 23:44:12 - --< devinfo_from_name: (1) 0 (2) 9999 (3) (4) command (5) command (6) command (7)
2017-05-11 23:44:12 - static -> (1) Misc (2) tempall (3) (4) 9999 (5) command (6) command (7) command (8) 100 (9)
2017-05-11 23:44:12 - ==> start devinfo_from_name (2) battery
2017-05-11 23:44:12 - !!!! found device (1) (2) 0
2017-05-11 23:44:12 - --< devinfo_from_name: (1) 0 (2) 9999 (3) (4) command (5) command (6) command (7)
2017-05-11 23:44:12 - static -> (1) Misc (2) battery (3) (4) 9999 (5) command (6) command (7) command (8) 100 (9)
2017-05-11 23:44:12 - ==> start devinfo_from_name (2) batteries
2017-05-11 23:44:12 - !!!! found device (1) (2) 0
2017-05-11 23:44:12 - --< devinfo_from_name: (1) 0 (2) 9999 (3) (4) command (5) command (6) command (7)
2017-05-11 23:44:12 - static -> (1) Misc (2) batteries (3) (4) 9999 (5) command (6) command (7) command (8) 100 (9)
2017-05-11 23:44:12 - ==> start devinfo_from_name (2) systemstatus
2017-05-11 23:44:12 - !!!! found device (1) (2) 0
2017-05-11 23:44:12 - --< devinfo_from_name: (1) 0 (2) 9999 (3) (4) command (5) command (6) command (7)
2017-05-11 23:44:12 - static -> (1) Misc (2) systemstatus (3) (4) 9999 (5) command (6) command (7) command (8) 100 (9)
2017-05-11 23:44:12 - ==> start devinfo_from_name (2) dtgmenu
2017-05-11 23:44:12 - !!!! found device (1) (2) 0
2017-05-11 23:44:12 - --< devinfo_from_name: (1) 0 (2) 9999 (3) (4) command (5) command (6) command (7)
2017-05-11 23:44:12 - static -> (1) Misc (2) dtgmenu (3) (4) 9999 (5) command (6) command (7) command (8) 100 (9)
2017-05-11 23:44:12 - Creating Room Menus: (1) 1 (2)
2017-05-11 23:44:12 - JSON request <http://192.168.1.27:8080/json.htm?type=command¶m=getplandevices&idx=2&order=name&used=true>
2017-05-11 23:44:12 - For room woonkamer got some devices and/or scenes
2017-05-11 23:44:12 - - Plan record: (1) Verlichting woonkamer (2) 13 (3) 0
2017-05-11 23:44:12 - --> device record
2017-05-11 23:44:12 - ==> start devinfo_from_name (1) 13 (2)
2017-05-11 23:44:12 - JSON request <http://192.168.1.27:8080/json.htm?type=devices&rid=13>
2017-05-11 23:44:12 - device (1) (2) Verlichting woonkamer (3) 13 (4) 13
2017-05-11 23:44:12 - !!!! found device (1) Verlichting woonkamer (2) Verlichting woonkamer (3) 13 (4) 13
2017-05-11 23:44:12 - !!!! found device (1) Verlichting woonkamer (2) 13
2017-05-11 23:44:12 - --< devinfo_from_name: (1) 1 (2) 13 (3) Verlichting woonkamer (4) devices (5) Light/Switch (6) On/Off (7) Off
2017-05-11 23:44:12 - Dynamic -> (1) woonkamer (2) Verlichting_ (3) Verlichting woonkamer (4) 13 (5) devices (6) Light/Switch (7) On/Off (8) 100 (9) Off
2017-05-11 23:44:12 - - Plan record: (1) Energy meter (2) 72 (3) 0
2017-05-11 23:44:12 - --> device record
2017-05-11 23:44:12 - ==> start devinfo_from_name (1) 72 (2)
2017-05-11 23:44:12 - JSON request <http://192.168.1.27:8080/json.htm?type=devices&rid=72>
2017-05-11 23:44:12 - device (1) (2) Energy meter (3) 72 (4) 72
2017-05-11 23:44:12 - !!!! found device (1) Energy meter (2) Energy meter (3) 72 (4) 72
2017-05-11 23:44:12 - !!!! found device (1) Energy meter (2) 72
2017-05-11 23:44:12 -
2017-05-11 23:44:12 -
2017-05-11 23:44:12 - - Plan record: (1) Gas (2) 11 (3) 0
2017-05-11 23:44:12 - --> device record
2017-05-11 23:44:12 - ==> start devinfo_from_name (1) 11 (2)
2017-05-11 23:44:12 - JSON request <http://192.168.1.27:8080/json.htm?type=devices&rid=11>
2017-05-11 23:44:12 - device (1) (2) Gas (3) 11 (4) 11
2017-05-11 23:44:12 - !!!! found device (1) Gas (2) Gas (3) 11 (4) 11
2017-05-11 23:44:12 - !!!! found device (1) Gas (2) 11
2017-05-11 23:44:12 -
2017-05-11 23:44:12 -
2017-05-11 23:44:12 - - Plan record: (1) Keuken verlichting (2) 31 (3) 0
2017-05-11 23:44:12 - --> device record
2017-05-11 23:44:12 - ==> start devinfo_from_name (1) 31 (2)
2017-05-11 23:44:12 - JSON request <http://192.168.1.27:8080/json.htm?type=devices&rid=31>
2017-05-11 23:44:12 - device (1) (2) Keuken verlichting (3) 31 (4) 31
2017-05-11 23:44:12 - !!!! found device (1) Keuken verlichting (2) Keuken verlichting (3) 31 (4) 31
2017-05-11 23:44:12 - !!!! found device (1) Keuken verlichting (2) 31
2017-05-11 23:44:12 - --< devinfo_from_name: (1) 1 (2) 31 (3) Keuken verlichting (4) devices (5) Light/Switch (6) On/Off (7) Off
2017-05-11 23:44:12 - Dynamic -> (1) woonkamer (2) Keuken_verlichting (3) Keuken verlichting (4) 31 (5) devices (6) Light/Switch (7) On/Off (8) 100 (9) Off
2017-05-11 23:44:12 - - Plan record: (1) Tv huiskamer (2) 84 (3) 0
2017-05-11 23:44:12 - --> device record
2017-05-11 23:44:12 - ==> start devinfo_from_name (1) 84 (2)
2017-05-11 23:44:12 - JSON request <http://192.168.1.27:8080/json.htm?type=devices&rid=84>
2017-05-11 23:44:12 - device (1) (2) Tv huiskamer (3) 84 (4) 84
2017-05-11 23:44:12 - !!!! found device (1) Tv huiskamer (2) Tv huiskamer (3) 84 (4) 84
2017-05-11 23:44:12 - !!!! found device (1) Tv huiskamer (2) 84
2017-05-11 23:44:12 - --< devinfo_from_name: (1) 1 (2) 84 (3) Tv huiskamer (4) devices (5) Light/Switch (6) On/Off (7) On
2017-05-11 23:44:12 - Dynamic -> (1) woonkamer (2) Tv_huiskamer (3) Tv huiskamer (4) 84 (5) devices (6) Light/Switch (7) On/Off (8) 100 (9) On
2017-05-11 23:44:12 - - Plan record: (1) Kodi (2) 36 (3) 0
2017-05-11 23:44:12 - --> device record
2017-05-11 23:44:12 - ==> start devinfo_from_name (1) 36 (2)
2017-05-11 23:44:13 - JSON request <http://192.168.1.27:8080/json.htm?type=devices&rid=36>
but do you have a x86 or x64 ubuntu server?G3rard wrote:I have dtgbot working on my Ubuntu server. It took some extra steps which I think I have written down. Will have a look at it this weekend and share the steps here.
I am working with maomanna in PM on his issue, but it seems his PI issue is due to the fact that a JSON call doesn't return a RESULT section, hence causing the nil issue in lua.DennisD wrote:Seems like i have the same problem as maomanna described on my raspberry pi3, I think something broke after i updated the kernel of my pi because before that everything was working fine.
Code: Select all
http://192.168.1.27:8080/json.htm?type=devices&rid=36