steps39 / dtgbot

Telegram Bot for Domoticz
19 stars 18 forks source link

dtgbot stops\crashes when in DTGMENU other when on\off buttons is sent #8

Closed Pjedr closed 6 years ago

Pjedr commented 6 years ago

dtgbot stops\crashes when in DTGMENU I send other then on\off buttons. but is still a nice bot :-)

2017-11-18 23:38:49 - ==< show options in submenu. 2017-11-18 23:38:49 - Message sent (1) 200 2017-11-18 23:38:49 - dtgbot: dtgmenu ended and text send ...return:200 2017-11-18 23:38:49 - Succesfully handled incoming request .2017-11-18 23:38:52 - WhiteList: 49529725 2017-11-18 23:38:52 - Handle command function started with Ferbrûk_AppLjocht_HobbyKeamer - 45.129 kWh and 49529725 2017-11-18 23:38:52 - dtgbot: Start DTGMENU ... (1) Ferbrûk_AppLjocht_HobbyKeamer - 45.129 kWh 2017-11-18 23:38:52 - ==> menu.lua process:Ferbrûk_AppLjocht_HobbyKeamer - 45.129 kWh

jvanderzande commented 6 years ago

Hi pjedr, What is stored the error you get in dtg.log.errors when the crash happens? it helps when you set the loglevel higher and share the dtg.log and errors with me so I can see what is happening.

Jos

Pjedr commented 6 years ago

First I hacked in my preferred roomlist in dtgbot.lua, i don't want all my 39 rooms (thematic, photo, SweetHome3D) in the menu. Hmm I see hidden devices starting with $ sign (could be filtered out) and scenes starting with * sign (ok by me).

Roomlist = {} --Roomlist = device_list_names_idxs("plans") -- Pjedr Roomlist['Keuken'] = 3 Roomlist['WenKeamer'] = 8 Roomlist['Keuken'] = 3 Roomlist['WenKeamer'] = 8 Roomlist['Hobbykeamer'] = 6 Roomlist['Badkeamer'] = 5 Roomlist['Yntree'] = 4 Roomlist['Solder'] = 15 Roomlist['Berging'] = 22 Roomlist['Berginghokje'] = 7 Roomlist['Sliepkeamer'] = 21 Roomlist['Bûtendoar'] = 2 Roomlist['Makkelik'] = 1 Roomlist['Ferljochting'] = 36 Roomlist['Binnenklimaat'] = 23 Roomlist['Bûtenklimaat'] = 10 for rname, rnumber in pairs(Roomlist) do print_to_log(rnumber..' RoomName = '..rname) end --Pjedr

Pjedr commented 6 years ago

Created Domotics User Variable TelegramBotLoglevel set to maximun 2. Then tested a non on/off item (in this case a powermeter) see log:

2017-11-20 01:23:58 - => Lastcmd submenu: (1) Badkeamer 2017-11-20 01:23:58 - => Lastcmd device : (1) Douche 2017-11-20 01:23:58 - ChkInTable: (1) Oan,Ut (2) Ferbrûk_AppLjocht_BadKeamer - 0.101 kWh 2017-11-20 01:23:58 - - ChkInTable not found: Ferbrûk_AppLjocht_BadKeamer - 0.101 kWh 2017-11-20 01:23:58 - ChkInTable: (1) AppLjocht_BadKeamer - Off|BadKeamerDoar - Open|BadKeamer_LoftÂfsûging - Off|BadKeamer_SpotFerljochting - Off|BadKeamer_TempFocht_Ch4 - 16.9°C - 64%|BadWetter_Temp - 16.8°C|Douche - On|Ferbrûk_AppLjocht_BadKeamer - 0.101 kWh|Ferbrûk_SpotLjocht_BadKeamer - 9.101 kWh|LeidingWetterBoiler_10_Liter - Off|LeidingWetterBoiler_10_Liter_Opwaarme - Off|LeidingWetterBoiler_10_Liter_Opwaarmje - Off|LeidingWetterBoiler_15_Liter - Off|LeidingWetterBoiler_15_Liter_Opwaarme - Off|LeidingWetterBoiler_15_Liter_Opwaarmje - Off|LoftFerfarsking - Off|LoftFochtichheid_BadKeamer_Heech - Off|Lûdsprekkers_Keuken - On|Rûte_BadKeamer_SliepKeamer - On|Tosken_Poetse - On| (2) Ferbrûk_AppLjocht_BadKeamer - 0.101 kWh 2017-11-20 01:23:58 - ChkInTable: (1) menu (2) Ferbrûk_AppLjocht_BadKeamer - 0.101 kWh 2017-11-20 01:23:58 - - ChkInTable not found: Ferbrûk_AppLjocht_BadKeamer - 0.101 kWh 2017-11-20 01:23:58 - => cmdisaction : (1) false 2017-11-20 01:23:58 - => cmdisbutton : (1) true 2017-11-20 01:23:58 - => cmdissubmenu: (1) false

And in dTGbot.log.errors: /usr/bin/lua5.2: /mnt/GrabnGo_2TB/peter/dTGbot/lua/dtgmenu.lua:705: attempt to index field '?' (a nil value) stack traceback: /mnt/GrabnGo_2TB/peter/dTGbot/lua/dtgmenu.lua:705: in function 'handler' /mnt/GrabnGo_2TB/peter/dTGbot/dtgbot.lua:275: in function 'HandleCommand' /mnt/GrabnGo_2TB/peter/dTGbot/dtgbot.lua:417: in function 'on_msg_receive' /mnt/GrabnGo_2TB/peter/dTGbot/dtgbot.lua:557: in main chunk [C]: in ?

Pjedr commented 6 years ago

I made a filter in dtgmenu.lua after line 426 to hide devices starting with a $ sign, and im my case with "Ferbr"

if type(DIPrecord) == "table" then if (string.match(DIPrecord.Name, "Ferbr") or string.match(DIPrecord.Name, "%$")) then --3 print_to_log(1," - Plan record skipping:",DIPrecord.Name,DIPrecord.devidx,DIPrecord.type) --Pjedr else local DeviceType="devices" local SwitchType ...... end ...... Now i have less devices and only working ones. And i added a space ": " to make it look nicer in dtgmenu.lua: response= submenu .. ": " .. dtgmenu_lang[menu_language].text["Select"]

jvanderzande commented 6 years ago

It is too hard for me to make sense out of the bits you posted here. It's a bit of a strange devicename i see is failing. Either way: I need the full logs to see what is happening at startup time, where the tables are filled and then see the process steps that lead to your error shown. You can Email them to me when you prefer that after have removed anything private like telegram botkey and personal id's. jvdzande "at" yahoo "dot" com.

jvanderzande commented 6 years ago

Close due to inactivity.