Sending messages from Domotics works like a charm and I also get response when I for example send "checkdomoticzupdate".
But I can' get a list of devices also can't control them
They should still be valid and things are working fine for me. To debug simply set the Domoticz Uservariable TelegramBotLoglevel to 2 and look in the dtb.log for the result and errors. You can also PM it to me in case you want some help with sorting it out.
Simon and I have further developed this version of DTGBOT and also has the option to use the Buttons/Menu available in Telegram.
Just follow it step by step and it can function next to your existing setup while installing.
I had the same problem, I don't that it is possible to make the bot admin in an already existing group.
Bots are frequently added to groups in order to augment communication between human users, e.g. by providing news, notifications from external services or additional search functionality. This is especially true for work-related groups. Now, when you share a group with a bot, you tend to ask yourself “How can I be sure that the little rascal isn't selling my chat history to my competitors?” The answer is — privacy mode.
A bot running in privacy mode will not receive all messages that people send to the group. Instead, it will only receive:
Messages that start with a slash ‘/’ (see Commands above)
Replies to the bot's own messages
Service messages (people added or removed from the group, etc.)
Back to subject. I used the wiki's Jos recommended, but could not start the bot because of another device error:
/usr/bin/lua5.2: /home/pi/dtgbot//dtg_domoticz.lua:125: attempt to get length of global 'result' (a nil value)
stack traceback:
/home/pi/dtgbot//dtg_domoticz.lua:125: in function 'device_list_names_idxs'
/home/pi/dtgbot/dtgbot.lua:175: in function 'dtgbot_initialise'
/home/pi/dtgbot/dtgbot.lua:229: in main chunk
[C]: in ?
Quickfix:
- Sudo nano /home/pi/dtgbot/dtg_domoticz.lua
- Search for the function "device_list_names_idxs(DeviceType)" (around line 118)
-- returns a list of Domoticz items based on type i.e. devices or scenes
function device_list_names_idxs(DeviceType)
--returns a devcie idx based on its name
local idx, k, record, decoded_response
decoded_response = device_list(DeviceType)
result = decoded_response['result']
devices = {}
devicesproperties = {}
for i = 1, #result do
record = result
if type(record) == "table" then
if DeviceType == "plans" then
devices[record['Name']] = record['idx']
else
devices[string.lower(record['Name'])] = record['idx']
devices[record['idx']] = record['Name']
if DeviceType == 'scenes' then
devicesproperties[record['idx']] = {Type=record['Type'], SwitchType = record['Type']}
end
end
end
end
return devices, devicesproperties
end
- Add "if result ~= nil then" before the for loop and another "end" above te return.
Or you could replace the whole method with the code below
-- returns a list of Domoticz items based on type i.e. devices or scenes
function device_list_names_idxs(DeviceType)
--returns a devcie idx based on its name
local idx, k, record, decoded_response
decoded_response = device_list(DeviceType)
result = decoded_response['result']
devices = {}
devicesproperties = {}
if result ~= nil then
for i = 1, #result do
record = result
if type(record) == "table" then
if DeviceType == "plans" then
devices[record['Name']] = record['idx']
else
devices[string.lower(record['Name'])] = record['idx']
devices[record['idx']] = record['Name']
if DeviceType == 'scenes' then
devicesproperties[record['idx']] = {Type=record['Type'], SwitchType = record['Type']}
end
end
end
end
end
return devices, devicesproperties
end