Page 1 of 1
Telegram does not show devices
Posted: Sunday 03 July 2016 11:15
by Duan
Hello all,
I'm really enjoying the effort the guys put into telegram for Domoticz. I have followed these two wiki's:
-
https://www.domoticz.com/wiki/Installin ... ion_System
-
https://www.domoticz.com/wiki/Telegram_ ... ctionality
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
The log file seems alright and when I check the json api for devices I do get a valid output.
http://192.168.XXX.XXX:8080/json.htm?ty ... order=Name
I also saw the telegrambot wiki, does that mean the wiki's that I used were deprecated?
-
https://www.domoticz.com/wiki/Telegram_Bot
-
https://www.domoticz.com/wiki/Remote_Co ... legram_Bot
Additional info:
- Spoiler: show
- Domotics version 3.530
/etc/profile.d/DomoticzData.sh
Code: Select all
export DomoticzIP=$(hostname -I|sed 's/[ ]*$//')
export DomoticzPort="8080"
export TempFileDir="/var/tmp/"
export TelegramHomePath="/home/pi/tg/"
export TelegramScriptPath=$TelegramHomePath"scripts/user/"
export TelegramGenericPath=$TelegramHomePath"scripts/generic/"
export TelegramScript=$TelegramGenericPath"telegram.sh"
export TelegramCli=$TelegramHomePath"bin/telegram-cli"
export TelegramLog=$TempFileDir"tg.log"
export ReceiveLua=$TelegramGenericPath"receive.lua"
export TelegramTo="XXX"
export [email protected]"
Re: Telegram does not show devices
Posted: Sunday 03 July 2016 11:19
by jvdz
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.
Jos
Re: Telegram does not show devices
Posted: Sunday 03 July 2016 11:32
by woody4165
I've got same issue then I followed Jos post here
http://www.domoticz.com/forum/viewtopic ... bot#p87136
Don't know why, but this modification is not in the main files you download at post #1, for me it worked.
Re: Telegram does not show devices
Posted: Sunday 03 July 2016 11:36
by Derik
Still get a error:
Code: Select all
make: *** Er is geen regel om doel 'tgl/tl-parser/crc32.c' te maken, nodig voor 'objs/crc32.o'. Gestopt.
By the install of:
Code: Select all
./configure && make # Takes aprox. 30-45 minutes for a RPI-B
./configure && make -j4 # Takes aprox. 8-9 minutes for a RPI-2B
Re: Telegram does not show devices
Posted: Sunday 03 July 2016 12:02
by jvdz
@Derik, Are you not following the Telegram BOT install wiki as that doesn't require any local build of any commandline tool?
Jos
Re: Telegram does not show devices
Posted: Sunday 03 July 2016 12:05
by Derik
jvdz wrote:@Derik, Are you not following the Telegram BOT install wiki as that doesn't require any local build of any commandline tool?
Jos
Jos
The BOT version is hard to get for me.
And i was thinking that i need this option for the BOT to
Re: Telegram does not show devices
Posted: Sunday 03 July 2016 12:13
by jvdz
It really is pretty strait forward to setup when you follow first this wiki:
https://www.domoticz.com/wiki/Telegram_Bot
After that you need to follow this wiki to be able to send commands:
https://www.domoticz.com/wiki/Remote_Co ... legram_Bot
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.
So where are you getting stuck?
Jos
Re: Telegram does not show devices
Posted: Sunday 03 July 2016 15:48
by Derik
Got a Bot:
Got the update:
- ScreenShot069.jpg (18.31 KiB) Viewed 1706 times
Only i cannot find the chatid:
- ScreenShot070.jpg (73.31 KiB) Viewed 1705 times
Re: Telegram does not show devices
Posted: Sunday 03 July 2016 19:08
by Duan
Try to chat with your bot first and go the the link again. If you don't chat with your bot it can't give you results back which contains the chatId
Re: Telegram does not show devices
Posted: Sunday 03 July 2016 19:13
by Derik
i did chat and i have my id:-)
Only how can i send 1 message to multiple users [ group ]
I cannot set the bot as admin, like the wiki says
Re: Telegram does not show devices
Posted: Sunday 03 July 2016 20:16
by Duan
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.)
-
https://core.telegram.org/bots#privacy-mode
Workaround:
- Typ something in the group that starts with a slash like: "/hello"
- Get update:
https://api.telegram.org/bot784324329:E ... getUpdates
- Fetch ID, for example: -123456789
- Try it out:
https://api.telegram.org/bot784324329:E ... 9&text=123
Re: Telegram does not show devices
Posted: Sunday 03 July 2016 20:58
by Duan
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)
- Spoiler: show
- -- 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
- Spoiler: show
- -- 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