Re: dtgbot - Domoticz TeleGram BOT
Posted: Saturday 03 June 2023 22:50
dtgbot doesn't work with the latest domoticz update 15330
Open source Home Automation System
https://forum.domoticz.com/
I was not able to get it working untiljvdz wrote: Tuesday 06 June 2023 9:18 That Branch is a total overhaul of the scripts so does justify changing the version to 2 for sure.
I have made one other change to the code for the OLD and NEW formats support. The retrieval of the Domoticz version is now the first API done, and Domoticz could need some time to finish starting up the API support, so I added the logic currently in the Domo_Variable_List() function to retries max 20 times in case nothing was returned for the API call. This update is committed to github.
Code: Select all
export DomoticzIP="127.0.0.1"Code: Select all
export DomoticzIP="username:[email protected]"Code: Select all
sudo service dtgbot stop
cd ~
mv dtgbot olddtgbot
cd ~
git clone https://github.com/steps39/dtgbot.git
cd ~/dtgbot
git checkout Stability-and-new-install
sudo apt install lua5.2
sudo apt install lua-json
sudo apt install lua-socket
sudo apt install lua-sec
Code: Select all
["back"] = "Indietro",After you have done the last Setup step where you install the service, the IP of your domoticz should default to 127.0.0.1:8080 already:pesa1234 wrote: Thursday 15 February 2024 12:37 then:
Edit systemd-dtgbot.sh:
Fill the proper info in the different fields
copy /service/dtgbot.service to /etc/systemd/system/dtgbot.service
enable the service:sudo systemctl enable dtgbot
start the service: sudo systemctl start dtgbot
Code: Select all
#!/bin/bash
##### start script for dtgbot ##################
## Define some system wide env variables
export DomoticzIP="127.0.0.1"
export DomoticzPort="8080"
export TempFileDir="/tmp/"
export BotHomePath="/home/pi/dtgbot/"
export BotBashScriptPath=$BotHomePath"bash/"
export BotLuaScriptPath=$BotHomePath"lua/"
export BotLuaLog=$TempFileDir"dtb.log"
export TelegramChatId='012343553'
export TelegramBotToken="000000000:keykeykeykeykeykeykeykey"
export EmailTo="[email protected]"
# Force use of Lua 5.2 or else lua socks will fail with ltn12 error
/usr/bin/lua5.2 $BotHomePath"dtgbot.lua" >$BotLuaLog 2>>$BotLuaLog.errors
EDIT: I see that I have hardcoded that... will make a change for that and commit to github and let you know.pesa1234 wrote: Thursday 15 February 2024 12:37 One more question and sorry @jvdz how to translate back on menu... I've tried...but it don't work...Code: Select all
["back"] = "Indietro",
Yes, I change only port, but without change the IP it doesn't worksjvdz wrote: Thursday 15 February 2024 15:20After you have done the last Setup step where you install the service, the IP of your domoticz should default to 127.0.0.1:8080 already:pesa1234 wrote: Thursday 15 February 2024 12:37 then:
Edit systemd-dtgbot.sh:
Fill the proper info in the different fields
copy /service/dtgbot.service to /etc/systemd/system/dtgbot.service
enable the service:sudo systemctl enable dtgbot
start the service: sudo systemctl start dtgbotCode: Select all
#!/bin/bash ##### start script for dtgbot ################## ## Define some system wide env variables export DomoticzIP="127.0.0.1" export DomoticzPort="8080" export TempFileDir="/tmp/" export BotHomePath="/home/pi/dtgbot/" export BotBashScriptPath=$BotHomePath"bash/" export BotLuaScriptPath=$BotHomePath"lua/" export BotLuaLog=$TempFileDir"dtb.log" export TelegramChatId='012343553' export TelegramBotToken="000000000:keykeykeykeykeykeykeykey" export EmailTo="[email protected]" # Force use of Lua 5.2 or else lua socks will fail with ltn12 error /usr/bin/lua5.2 $BotHomePath"dtgbot.lua" >$BotLuaLog 2>>$BotLuaLog.errors
EDIT: I see that I have hardcoded that... will make a change for that and commit to github and let you know.pesa1234 wrote: Thursday 15 February 2024 12:37 One more question and sorry @jvdz how to translate back on menu... I've tried...but it don't work...Code: Select all
["back"] = "Indietro",
Code: Select all
Exit_MenuCode: Select all
dtgmenubottom.luaYes you're right!jvdz wrote: Thursday 15 February 2024 19:25 Guess you don't have 127.0.0.1 in the trusted networks then, but as long as it works its fine.![]()
I need to think about that for a little longer and do some testing as the "Exit_Menu" is indeed hardcoded as button but also tested for as action.
Code: Select all
showmenuOk ok, thanks a lot!jvdz wrote: Thursday 15 February 2024 21:34 There will be a limit to the freedom of commands and translation! I do not intent to change the way the menu is activated. I will look at the button text flexibility but even there it might be that some fixed texts will remain. I need to have a play with that idea and do some testing when time permits.
Code: Select all
-- English (Default) definition
["en"] = {
command = {
["back"] = "Back",
["menu"] = "Menu", -- define alternative for starting the menu
["exit_menu"] = "Exit_Menu" -- define alternative for exiting the menu.. also used as button text
},
switch_options = {
["On"] = "On,Close,Start",
["Off"] = "Off,Open"
},
devices_options = {
["Blinds"] = "Open,Close",
["Blinds Percentage"] = "Open,25%,50%,75%,Close",
["Scene"] = "Start",
["Group"] = "Off,On",
["On/Off"] = "Off,On",
["Push On Button"] = "On",
["Dimmer"] = "Off,On,25%,50%,75%,99%,?",
["Setpoint"] = "17,18,19,20,20.5,21,21.5,-,+,?",
["Thermostat"] = "17,18,19,20,20.5,21,21.5,-,+,?"
},
text = {
["start"] = "Hi, welcome to Domoticz.",
["main"] = "Select the submenu.",
["exit"] = "Exit Menu, type /menu to show it again",
["Select"] = "Select option.",
["SelectGroup"] = "Select the group option.",
["SelectScene"] = "Start scene?",
["SelectOptionwo"] = "Select new status.",
["SelectOption"] = "Select new status. Current status=",
["Specifyvalue"] = "Type value",
["Switched"] = "Change",
["UnknownChoice"] = "Unknown option:"
}
},
Code: Select all
Error:dtgmenuinline.lua:329: attempt to index field '?' (a nil value)jvdz wrote: Sunday 18 February 2024 18:46 Are you running the latest versions of the scripts as that line makes no sense looking at the current version of dtgmenuinline.lua?
Latest is : dtgmenuinline_version = '0.9 202402161814'
If you have the latest the please enable the debugging, trigger the error and Email me the logfile so I can have a look.
Code: Select all
dtgmenuinline_version = '0.9 202402161814'Code: Select all
2024-02-18 19:07:43 : Longpoll ended with status:200 response:nil
2024-02-18 19:07:43 : ### In contact with Telegram servers
2024-02-18 19:07:43 : Telegram response (1) {"ok":true,"result":[]}Thanks is ok, but why I get nil°C on the menu? please have a look at the attachment and many thanksjvdz wrote: Sunday 18 February 2024 19:20 I think I found the issue, but there is no relation to a thermostat, but there were wrong Language variable names on that line. Just committed an update. Please check that and let me know if that fixes it.![]()