Page 21 of 30

Re: dtgbot - Domoticz TeleGram BOT

Posted: Tuesday 25 August 2020 11:24
by hoeby
jvdz wrote: Tuesday 25 August 2020 10:08 I have tested the whole process by sending the posted inline keyboard to my DTGBOT, click one of the buttons and check the DTGBOT.LOG & my_dtgbotcommands.log and they both contain the expected result, so have no idea what you are doing wrong.

You do mean with this statement "same command to dtgbot" to say that you fire the URL using the BOTTOKEN of DTGBOT so the selected button command is send to it... right?

Jos
I don't exactly know what you mean with "BOTTOKEN of DTGBOT"

I made a telegram bot. Do you mean that token?

Re: dtgbot - Domoticz TeleGram BOT

Posted: Tuesday 25 August 2020 11:35
by jvdz
The DTGBOT process running on your PI has it's own BOTTOKEN defined, so you need to use that BOTTOKEN in the dzevent script which sends the inline keyboard message so the answer to this is send to the DTGBOT for processing.

Jos

Re: dtgbot - Domoticz TeleGram BOT

Posted: Tuesday 25 August 2020 16:25
by hoeby
Is the token to be found in a file on the pi?
If not, how can i find this token?

Re: dtgbot - Domoticz TeleGram BOT

Posted: Tuesday 25 August 2020 16:58
by jvdz
When you followed the wiki https://www.domoticz.com/wiki/Installin ... _-_Stage_1, it should be:
First create your customisation file:
sudo nano /etc/profile.d/DomoticzData.sh

Re: dtgbot - Domoticz TeleGram BOT

Posted: Tuesday 25 August 2020 17:33
by hoeby
I followed this wiki:
Https://www.domoticz.com/wiki/Remote_Co ... legram_Bot

I find the setup a little confusing.
There a mutli telegram wiki's. I followed the one i posted.
Is the one you posted necessary for the dtgbot token?
And do i have to follow that wiki, or was following the wiki i posted enough and should the token be found there?

When i look in the file /etc/profile.d/DomoticzData.sh
Then i find the token, but that is the token i made with BotFather on my phone.
Not a token that is made by dtgbot

Re: dtgbot - Domoticz TeleGram BOT

Posted: Tuesday 25 August 2020 17:59
by jvdz
Seems you're somewhat confused about how BOTs work in telegram. All BOTs are created with the BOTFATHER and DTGBOT requires its own BOTtoken.
Now when you want the the answers from your inline keyboard to be processed by DTGBOT, you will have to use its BOTToken to send it and it is irrelevant whether it is send by DTGBOT itself or you use a DZevents script to send the message for it, as long as the answer can be read by DTGBOT.

Hope it clears it up (a little) :)

... or are you intending to have the message flow differently in Telegram via a group or something?
Guess I need to understand your basic setup now first before we both get totally confused. You have DTGBOT with its own token and a ESP with its own token.... so what communicates to what and which Token is the DZevent script using , yet another one?

Re: dtgbot - Domoticz TeleGram BOT

Posted: Tuesday 25 August 2020 18:04
by hoeby
It doesn't clear what to do now to get it working.

Must i follow your wiki?
Or is the token i setup in the /etc/profile.d/DomoticzData.sh enough

Now i have 1 token that i made with botfather on my phone. That token i use for all situations (dzvents, dtgbot, esp)

Re: dtgbot - Domoticz TeleGram BOT

Posted: Tuesday 25 August 2020 18:07
by jvdz
see edit in previous post .... I first need to understand your setup and configuration.

Re: dtgbot - Domoticz TeleGram BOT

Posted: Tuesday 25 August 2020 18:08
by hoeby
Now i have 1 token that i made with botfather on my phone. That token i use for all situations (dzvents, dtgbot, esp)

I have a group where i want the inline-keyboard to work

Re: dtgbot - Domoticz TeleGram BOT

Posted: Tuesday 25 August 2020 18:19
by jvdz
I am trying to understand how that would ever properly work assuming the ESP also needs to receive commands to perform an action?
To me it would be logic to have an separate BOTname&token defined for each entity you want to perform actions with.
So that would mean the you need one bot for the ESP, one for DTGBOT and one for DOMOTICZ in case you want to send out messages that indicate they are coming from Domoticz. I actually combine the last 2 so use the DTGBOT token for both DTGBOT running on the pi as well as sending other notifications for Domoticz.
Obviously you can have script that uses the DTGBOTname&Token to send a message to your phone to start the flow and then the subsequent messages with be read by DTGBOT.
Making sense?

ps. we can also take this discussion offline (in Dutch) if that makes things easier.

Re: dtgbot - Domoticz TeleGram BOT

Posted: Wednesday 26 August 2020 19:22
by jvdz
@hoeby and I have had an offline discussion about his issue and I remembered that the MASTER DTGBOT didn't have support for "callback_query" messages which was the issue we had here, so I've made a few changes to the MASTER dtgbot.lua to add support for "callback_query". This now allows for sending an telegram message to your phone with a inline keyboard selection and have Telegram send the command back to DTGBOT when any of the shown buttons is pressed. Update is available in GITHUB.

Example: When you send this message with the TOKEN used bu DTGBOT:

Code: Select all

https://api.telegram.org/bot123456789:AA...ww/sendMessage?chat_id=123456789&text=Keukenlamp&reply_markup={"inline_keyboard":[[{"text":"Aan","callback_data":"on keukenlamp"},{"text":"Uit","callback_data":"off keukenlamp"}]]}
the following will be shown in Telegram on the phone:
ilk.jpg
ilk.jpg (9.47 KiB) Viewed 1962 times
Then when you press "Aan", the command "on keukenlamp" will be send to DTGBOT, switching the device On.
Then when you press "Uit", the command "off keukenlamp" will be send to DTGBOT, switching the device Off.
You could also use a custom Bash or Lua script in DTGBOT to do any none-standard action.

Jos

Re: dtgbot - Domoticz TeleGram BOT

Posted: Saturday 29 August 2020 10:38
by hoeby
I worked on the inline-keyboard, to make a menu in telegram.
All works with a bash file. Only when you give a command to modify the status of a device, then a command is send to domoticz.
Easy to use when we are away from home.

When i give the command "thuis" (means home) this will show up
Image

Here i choose "rolluik" (blinds)
Image

Here is choose "ouders" (parents)
The percentage is also read live out of the domoticz system
Image

Here is choose the "gordijnen" (curtains) menu
Image

The same for "jaloezie" (venetian blinds)
Image

When pushed "klaar" (finished) the menu will disapeer

Re: dtgbot - Domoticz TeleGram BOT

Posted: Monday 09 November 2020 9:02
by Tommie
Hi all,

I'm trying to get dtgbot to work on my Ubuntu Ubuntu 20.x LTS VM (on Intel NUC).

I've created the bot, token, channel ID etc. I'm able to send messages to a channel via the bot by API-requests.

Now I'm following the steps from the wiki and i'm stuck somewhere with the LUA library's.

dtb.log.errors gives me the following error:

Code: Select all

        
        /usr/local/lib/lua/5.2/ssl.so: wrong ELF class: ELFCLASS32
stack traceback:
        [C]: in ?
        [C]: in function 'require'
        /usr/local/share/lua/5.2/ssl.lua:7: in main chunk
        [C]: in function 'require'
        /usr/local/share/lua/5.2/ssl/https.lua:10: in main chunk
        [C]: in function 'require'
        /home/nuc/dtgbot/dtgbot.lua:132: in main chunk
        [C]: in ?
After some extensive searching i've found some downloads of alternative libssl library's. But mostly they are for different Linux versions or are throwing the same error.

Does anyone has a pointer for me?

Thanks in advance.

Re: dtgbot - Domoticz TeleGram BOT

Posted: Monday 09 November 2020 9:55
by jvdz
You could try using the standard available lua-sec these days, which Simon pointed me too a while ago, but haven't tested this myself yet:
sudo apt-get install lua-sec 

Re: dtgbot - Domoticz TeleGram BOT

Posted: Monday 09 November 2020 16:24
by Tommie
jvdz wrote: Monday 09 November 2020 9:55 You could try using the standard available lua-sec these days, which Simon pointed me too a while ago, but haven't tested this myself yet:
sudo apt-get install lua-sec 
Hi jvdz, thnx for the reaction. Do you know how to configure the script(s) or Lua to use the standard available lua-sec? I can image the script is hard coded you use /usr/local/share/lua/5.2/ and / usr/local/lib/lua/5.2/ ?

Re: dtgbot - Domoticz TeleGram BOT

Posted: Monday 09 November 2020 17:18
by jvdz
There is no hardcoding in the scripts and the system defaults are used when it comes to the search path for the libraries.

Jos

Re: dtgbot - Domoticz TeleGram BOT

Posted: Friday 01 January 2021 17:27
by Mrblomme
I've followed everything and my bot is running. When I send a message from Telegram nothing happens...
Does anybody know what to do?

When I do
sudo service dtgbot status
my bot is active but only since a couple of minutes every time. It seems like it's rebooting.. .

All my variables are added in Domoticz..

Re: dtgbot - Domoticz TeleGram BOT

Posted: Friday 01 January 2021 17:48
by jvdz
Have you checked the log files as indicated in the wiki?

Jos

Re: dtgbot - Domoticz TeleGram BOT

Posted: Saturday 02 January 2021 11:20
by Mrblomme
This is what's in the log files... not much...

dtb.log
2021-01-02 11:14:47 - DomoticzIP: *********
2021-01-02 11:14:47 - DomoticzPort: 8080
2021-01-02 11:14:47 - BotHomePath: /home/pi/dtgbot/
2021-01-02 11:14:47 - TempFileDir: /var/tmp/
2021-01-02 11:14:47 - BotLuaScriptPath: /home/pi/dtgbot/lua/
2021-01-02 11:14:47 - BotBashScriptPath: /home/pi/dtgbot/bash/
2021-01-02 11:14:47 - TelegramBotToken: ***************
2021-01-02 11:14:47 - TelegramBotOffset: TelegramBotOffset
2021-01-02 11:14:47 - -----------------------------------------
2021-01-02 11:14:47 - Starting Telegram api Bot message handler
2021-01-02 11:14:47 - -----------------------------------------
dtgbot.pid
10273

Re: dtgbot - Domoticz TeleGram BOT

Posted: Saturday 02 January 2021 11:30
by jvdz
Did you also check the contents of dtg.log.errors as I expect the lua script has errors?