Rules + HttpToSend + Telegram ?
Posted: 05 Mar 2020, 14:31
Hello, I need your help :]. I'm trying to make some notifications from espeasy to mobile phone and send messages (notifications) to Telegram.
I have userID and API token, sending messages from browser to Telegram client is without any problem, URL is simple:
FYI, here are two articles how to do that, it's simple (but to get userID instead of nickname is a little bit tricky): https://cutt.ly/jtrhbIt & https://cutt.ly/mtrhvan
But now I'm trying to send any message from espeasy. Configuration is as simple as possible, here is Rule#1 code, every 5 seconds it should send message to TG:
(I only replaced APItoken & userID with xxxxxx here)
I know that there is difference between HTTP and HTTPS, but URL for posting message is working also on port 80, I tried that in browsers, without any problem.
Here is log from esp:
So it seems that rules and SendToHTTP command works well. But no messages are received.
I tried a lot of combinations, also with URL shorteners (to avoid case sensitive and URL lenght possible problems), with IP instead of domain name, with spaces and without them, put URL in apostrofs (as it is mentioned in wiki) .. all the same, no message sent to TG.
There are probably no problems with ESP communication outside (I'm using also Thingspeak.com etc.). I'm using NTP, I also set IP/mask/gw/dns manually, I suppose that communication to internet is working. If I changed port to 443 for test, I got error message (HTTP : Command_HTTP_SendToHTTP Error: HTTP/1.1 400 Bad Request^), so internet connection is working.
SendToHTTP commnad is also probably working, I tried a simple rule to flash LED (GPIO13) on second ESP8266, it works:
LED is flashing, but messages to TG are not working.
hw: LOLIN D1 mini,
fw: mega-20200222
i tried also old and new rules engine, Tolerant last parameter, SendToHTTP wait for ack .. all the same.
I suppose that there is some simple mistake from my side, can you help me to solve this?
IMHO using Telegram as instant ('push') notifications via URL could be great, there are many clients for different platforms for free. But it must be functional :].
Thanks! :]
I have userID and API token, sending messages from browser to Telegram client is without any problem, URL is simple:
Code: Select all
http://api.telegram.org/bot<token>/sendMessage?chat_id=<userID>&text=<text_I_want_to_send>
But now I'm trying to send any message from espeasy. Configuration is as simple as possible, here is Rule#1 code, every 5 seconds it should send message to TG:
Code: Select all
on System#Boot do
TimerSet,1,5
endon
On Rules#Timer=1 do
SendToHTTP,api.telegram.org,80,/botxxxxxx/sendMessage?chat_id=xxxxxx&text=testmessage
TimerSet,1,5
endon
I know that there is difference between HTTP and HTTPS, but URL for posting message is working also on port 80, I tried that in browsers, without any problem.
Here is log from esp:
Code: Select all
10698834: : Rebooting...
6390: Subscribed to: ESP008/#
6401: EVENT: WiFi#Connected
6443: EVENT: Rules#Timer=1
6452: ACT : SendToHTTP,api.telegram.org,80,/botxxxxxx/sendMessage?chat_id=xxxxxx&text=testmessage
6455: Command: SendToHTTP
6456: SendToHTTP: Host: api.telegram.org port: 80
6730: ACT : TimerSet,1,5
6732: Command: TimerSet
I tried a lot of combinations, also with URL shorteners (to avoid case sensitive and URL lenght possible problems), with IP instead of domain name, with spaces and without them, put URL in apostrofs (as it is mentioned in wiki) .. all the same, no message sent to TG.
There are probably no problems with ESP communication outside (I'm using also Thingspeak.com etc.). I'm using NTP, I also set IP/mask/gw/dns manually, I suppose that communication to internet is working. If I changed port to 443 for test, I got error message (HTTP : Command_HTTP_SendToHTTP Error: HTTP/1.1 400 Bad Request^), so internet connection is working.
SendToHTTP commnad is also probably working, I tried a simple rule to flash LED (GPIO13) on second ESP8266, it works:
Code: Select all
on System#Boot do
TimerSet,1,10
endon
On Rules#Timer=1 do
SendToHTTP,<ip>,80,'/control?cmd=GPIO,13,1'
TimerSet,2,2
endon
On Rules#Timer=2 do
SendToHTTP,<ip>,80,'/control?cmd=GPIO,13,0'
TimerSet,3,2
endon
On Rules#Timer=3 do
SendToHTTP,api.telegram.org,80,/botxxxxxx/sendMessage?chat_id=xxxxxx&text=testmessage
TimerSet,1,2
endon
Code: Select all
912433: Command: TimerSet
915237: EVENT: Rules#Timer=1
915246: ACT : SendToHTTP,<ip>,80,'/control?cmd=GPIO,13,1'
915248: Command: SendToHTTP
915250: SendToHTTP: Host: <ip> port: 80
915286: HTTP : Command_HTTP_SendToHTTP Success! HTTP/1.1 200 OK^
915290: ACT : TimerSet,2,2
915292: Command: TimerSet
918236: EVENT: Rules#Timer=2
918246: ACT : SendToHTTP,<ip>,80,'/control?cmd=GPIO,13,0'
918248: Command: SendToHTTP
918250: SendToHTTP: Host: <ip> port: 80
918282: HTTP : Command_HTTP_SendToHTTP Success! HTTP/1.1 200 OK^
918285: ACT : TimerSet,3,2
918287: Command: TimerSet
921236: EVENT: Rules#Timer=3
921249: ACT : SendToHTTP,api.telegram.org,80,'/botxxxxxxxxx/sendMessage?chat_id=xxxxxxxx&text=te
921252: Command: SendToHTTP
921254: SendToHTTP: Host: api.telegram.org port: 80
921581: ACT : TimerSet,1,2
921583: Command: TimerSet
fw: mega-20200222
i tried also old and new rules engine, Tolerant last parameter, SendToHTTP wait for ack .. all the same.
I suppose that there is some simple mistake from my side, can you help me to solve this?
IMHO using Telegram as instant ('push') notifications via URL could be great, there are many clients for different platforms for free. But it must be functional :].
Thanks! :]