Posts: 400
Threads: 88
Joined: Jul 2016
Reputation:
3
Dear all,
I would like to improve in HomeLynk telegram boat API. Have you any experience about it?
Thanks.
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
Hi,
I know homeLYnk very well, but i don't understand what you mean with bot or boat..
Can you explain what you want to achieve?
BR,
Erwin van der Zwart
Posts: 400
Threads: 88
Joined: Jul 2016
Reputation:
3
Ciao Erwin,
I mean telegram. Telegram is an instant messages program like pushover but stronger and flexible.
And it is free. I mean telegram bot api https://core.telegram.org/bots/api/.
Thanks.
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
19.10.2016, 08:36
(This post was last modified: 19.10.2016, 08:37 by Erwin van der Zwart.)
Hi,
I just checked the Telegram API and it works exactly like the Pushover API, including HTTPS and API Key, the only difference are the used fields.
If you take my Pushover script as sample and rebuild the URL with the correct fields it should work ..
See: http://openrb.com/send-instant-messages-...s-with-lm/ for the Pushover Script
Pushover is also free, and real strong ..
BR,
Erwin van der Zwart
Posts: 400
Threads: 88
Joined: Jul 2016
Reputation:
3
Thank you Erwin. Free Pushover? It's free for 7 days only. Then there's a fee to pay. Have you different information?
Thanks.
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
19.10.2016, 09:33
(This post was last modified: 19.10.2016, 09:34 by Erwin van der Zwart.)
Hi,
Yes i see now, it always was a € 4.99 once payment for the app, the app was free last year, now i see they ask again a € 4.99 on time payment after 7 days.
I don't see that as a issue, there are no such things as free services (; and the amount they charge once is almost for free and really acceptable ..
I purchached the app a few years ago, and still working, so good money spend ..
BR,
Erwin van der Zwart
Posts: 400
Threads: 88
Joined: Jul 2016
Reputation:
3
Hi,
I link to a event_based script the following command in order to test the telegram API. I test strin on a url and it works fine hence now I have to replicate on homelynk.
What is wrong?
local res, status = 'https://api.telegram.org/token/sendMessage?chat_id=215120747&text=ciao'
Thanks.
Posts: 7769
Threads: 42
Joined: Jun 2015
Reputation:
447
Code: require('ssl.https')
body, status, headers, response = ssl.https.request('https://api.telegram.org/token/sendMessage?chat_id=215120747&text=ciao')
Posts: 400
Threads: 88
Joined: Jul 2016
Reputation:
3
Thank you Erwin.
I did it.
Regards.
Posts: 400
Threads: 88
Joined: Jul 2016
Reputation:
3
(27.10.2016, 21:23)Domoticatorino Wrote: Thank you Erwin.
I did it.
Regards.
Hi there,
let me give you the instruction to use Telegram ( https://telegram.org/) as instant message service. Follow these steps:
- install telegram in your phone
- searching on app the BotFather and this easy telegram program can allow you to create your own bot. Here you will find your bot "TOKEN number".
- Share your bot to your user and send a simple message to it.
- After that you can find your CHAT_ID which you can read with a URL request https://api.telegram.org/bot<token>/getUpdates.
Add user script as follow (user.telegram)
require 'ssl.https'
local telegram_url = 'https://api.telegram.org/bot<token_bot>/sendMessage?'
local chat_id = '<chat_id>'
function telegram(message)
local data_str = 'chat_id=' .. chat_id .. '&text=' .. message..''
local res, code, headers, status = ssl.https.request(telegram_url, data_str)
end
Add a event-script as follow example:
require("user.telegram")
message = ('<your own message>')
telegram (message)
end
Have fun!
Posts: 237
Threads: 31
Joined: May 2018
Reputation:
2
Hi,
Im trying to send an image located in the Logic Machine by telegram but it doesn´t work.
Using an url image from internet work perfectly
My code is:
local telegram_url_sendphototo = "https://api.telegram.org/bot<token>/sendPhoto?"
function SendPhotoTo (photo)
local chat_id ='353575234245'
local data_str = 'chat_id='..chat_id..'&photo='..photo..""
local res, code, headers, status = ssl.https.request(telegram_url_sendphototo,data_str)
log (res,code,headers,status)
end
--This code works perfectly
SendPhotoTo("http://www.imagen.com.mx/assets/img/imagen_share.png")
--But this code donesn´t work. I can open in browser but it is not sended by telegram
SendPhotoTo("http://<LogicMachineIP:port>/scada/resources/img/imagen_share.png")
Also I´m trying to send the image that I get from the IPCamera, please see the following link https://forum.logicmachine.net/showthrea...64#pid9364
SendPhotoTo(image)
But it doesnt work
Can anyone help me please?
Thanks
Posts: 184
Threads: 39
Joined: Sep 2015
Reputation:
4
09.02.2020, 22:52
(This post was last modified: 10.02.2020, 06:21 by baggins.)
I have used Domoticatorino's Telegram script for a couple of years without problem, but recently it started to fail.
When I call the function I have the following result:
Code: test_telegram 09.02.2020 23:41:30
* string: status: nil
test_telegram 09.02.2020 23:41:30
* string: headers: nil
test_telegram 09.02.2020 23:41:30
* string: code: revcd alert fatal error
test_telegram 09.02.2020 23:41:30
* string: res: nil
I can run the same script on my desktop machine and there it runs without errors...
Any idea what may be going on?
Update: I have tested this on another LM4 where the function is also in use and there the script does not work anymore either.
I also moved the code of the function to the test script, so I don't need a library call, with the same result.
Firmware: 20160714
Posts: 7769
Threads: 42
Joined: Jun 2015
Reputation:
447
You are using outdated firmware where SSLv3 is used by default. It is disabled on most servers and you have to use TLSv1.2 or newer. Try using this function to make HTTPS GET request:
Code: function request(url)
local resp = {}
local stat, code, hdrs = require('ssl.https').request({
method = 'GET',
url = url,
protocol = 'tlsv12',
sink = ltn12.sink.table(resp),
})
if stat then
stat = table.concat(resp)
end
return stat, code, hdrs
end
Posts: 184
Threads: 39
Joined: Sep 2015
Reputation:
4
(10.02.2020, 06:40)admin Wrote: You are using outdated firmware where SSLv3 is used by default. It is disabled on most servers and you have to use TLSv1.2 or newer. Try using this function to make HTTPS GET request:
Code: function request(url)
local resp = {}
local stat, code, hdrs = require('ssl.https').request({
method = 'GET',
url = url,
protocol = 'tlsv12',
sink = ltn12.sink.table(resp),
})
if stat then
stat = table.concat(resp)
end
return stat, code, hdrs
end
At the moment I cannot upgrade because of a third party library...
I tried the following, but got the same error:
Code: function request(url)
local resp = {}
local stat, code, hdrs = require('ssl.https').request({
method = 'GET',
url = url,
protocol = 'tlsv12',
sink = ltn12.sink.table(resp),
})
if stat then
stat = table.concat(resp)
end
return stat, code, hdrs
end
local telegram_url = 'https://api.telegram.org/mybot/sendMessage?'
local chat_id = '123456789'
message = "test"
data_str = 'chat_id=' .. chat_id .. '&text=' .. message..''
stat, code, hdrs = request(telegram_url, data_str)
log("code: " ..tostring(code))
log("headers: " ..tostring(hdrs))
log("status: " ..tostring(stat))
Posts: 7769
Threads: 42
Joined: Jun 2015
Reputation:
447
You are trying to do a POST request, try GET like this:
Code: stat, code, hdrs = request(telegram_url .. data_str)
If this still does not work then the only solution is to do firmware upgrade to 2019 RC1.
Posts: 184
Threads: 39
Joined: Sep 2015
Reputation:
4
(10.02.2020, 08:22)admin Wrote: You are trying to do a POST request, try GET like this:
Code: stat, code, hdrs = request(telegram_url .. data_str)
If this still does not work then the only solution is to do firmware upgrade to 2019 RC1.
It doesn't work
I will have to figure out how to upgrade...
Thanks for your help.
Posts: 25
Threads: 7
Joined: May 2019
Reputation:
0
19.03.2020, 18:43
(This post was last modified: 19.03.2020, 18:45 by Dario.)
(10.02.2020, 08:22)admin Wrote: You are trying to do a POST request, try GET like this:
Code: stat, code, hdrs = request(telegram_url .. data_str)
If this still does not work then the only solution is to do firmware upgrade to 2019 RC1.
Hi!
I used in my message "\n" to go new line.
Now I receive only first line:
Code: if grp.getvalue('9/2/7')== true then txtstate='On' else txtstate='Off' end
txtmessage = txtmessage .. ('Primario: ' .. txtstate .. '\n')
if grp.getvalue('9/2/1')== true then txtstate='On' else txtstate='Off' end
txtmessage = txtmessage .. ('Caldaia: ' .. txtstate .. '\n')
local stat, code, hdrs = request(telegram_url .. txtmessage)
Message on log is ok, message on telegram is:
"Primario: On" not else.
Posts: 7769
Threads: 42
Joined: Jun 2015
Reputation:
447
You need to escape your text sequence:
Code: txtmessage = require('socket.url').escape(txtmessage)
local stat, code, hdrs = request(telegram_url .. txtmessage)
Posts: 25
Threads: 7
Joined: May 2019
Reputation:
0
Posts: 126
Threads: 16
Joined: May 2020
Reputation:
0
Hello
I am interested in using this telegram script but among the solutions from the beginning, the new ones and the corrections I am not clear.
It would be possible to compile a complete script that currently works and with the appropriate steps.
Thank you.
a greeting
P.S. I have a Wiser for knx with the latest firmware and latest hardware.
|