Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telegram message notification support #8619

Closed
ademirci opened this issue Jun 4, 2020 · 83 comments
Closed

Telegram message notification support #8619

ademirci opened this issue Jun 4, 2020 · 83 comments
Assignees
Labels
Add to Docs Add info to Docs enhancement Type - Enhancement that will be worked on fixed Result - The work on the issue has ended

Comments

@ademirci
Copy link

ademirci commented Jun 4, 2020

Have you looked for this feature in other issues and in the docs?
Thank you for this great software. Yes, I searched in the repsitory and can not see related result.
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is.
No, it is not a problem
Describe the solution you'd like
A clear and concise description of what you want to happen.
I want to send a notification as Telegram message so that I can recieve to my phone anywhere.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
There are IOT MQTT alternatives for notification but they are not straightforward.
Additional context
Add any other context or screenshots about the feature request here.
I noticed following arduino library in the github and maybe it is easy to integrate it to Tasmota
https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot

(Please, remember to close the issue when the problem has been addressed)

@dzatoah
Copy link

dzatoah commented Jun 4, 2020

That would be Awesome!
I can imagine a command like notify "..." for rules or sensor values!!

@kugelkopf123
Copy link
Contributor

https://github.com/ArduinoHannover/Pushover
Another one that works.

@ascillato
Copy link
Contributor

Duplicated #1456

@ascillato2 ascillato2 added duplicated Result - Duplicated Issue feature request (devs?) Action - awaiting response from developers labels Jun 5, 2020
@arendst arendst self-assigned this Jun 6, 2020
@arendst
Copy link
Owner

arendst commented Jun 6, 2020

Been working on this yesterday but failed to get a https connection to api.telegram.org

All mentionend libraries fail in this case as is also reported by their different issues.

Tried a very basic approach using all SSL provided libraries but still fail to make a connection.

If anyone manages to make a https connection using the current core version I'll be interessted to dig in it again.

@arendst arendst added the Requires testing Action - Testing required from secondary user to confirm functionality label Jun 6, 2020
@s-hadinger
Copy link
Collaborator

Theo, I know very well the SSL part. I can try.

@arendst
Copy link
Owner

arendst commented Jun 6, 2020

This is the driver code currently not using any library other than the available BearSSL.

xdrv_50_telegram.zip

@arendst
Copy link
Owner

arendst commented Jun 6, 2020

You'll need this too

tasmota.zip

@arendst
Copy link
Owner

arendst commented Jun 6, 2020

And define USE_TELEGRAM in user_config_overrid.h

@ademirci
Copy link
Author

ademirci commented Jun 6, 2020

I am excited to see the result. Even we can send special format messages to Tasmota to enable or disable functions or rules over internet without the need for an IOT account. Also we can collect some sensor values periodically with another Telegram bot and setup our own IOT dashboard for free.

@eku
Copy link
Contributor

eku commented Jun 6, 2020

@ademirci well a plain XMPP/Jabber client would be enougth to reach public or private XMPP/Jabber chat server. And, furthermore, the desired function could be performed by the MQTT servers instead of overloading the client.
@arendst I would rather invest the time in support for an open federal platform than support a proprietary solution like Telegram.

@s-hadinger
Copy link
Collaborator

Telegram api is HTTP not XMPP which makes it far easier to integrate in Tasmota.

What do you mean by "open federal platform"?

@eku
Copy link
Contributor

eku commented Jun 6, 2020

@s-hadinger wrote:

What do you mean by "open federal platform"?

Anyone can run a server and you do not need to have an account on the same server where the chat partner has one. Classic examples are Email and XMPP/Jabber, but also Mastodon.

@s-hadinger
Copy link
Collaborator

At first glance, api.telegram.org uses a certificate signed by GoDaddy Daddy Secure Certificate Authority - G2. The server key is 2048 bits and the proposed cipher is ECDHE-RSA-AES128-GCM-SHA256 which is exactly the cipher used with AWS IoT.

This is all good news, apart from adding the CA in Flash, it should run smoothly. Stay tuned.

If you're curious about this, try openssl s_client -showcerts -connect api.telegram.org:443

@arendst
Copy link
Owner

arendst commented Jun 6, 2020

Just did. Nice find!

@s-hadinger
Copy link
Collaborator

And here is the CA ready to be munched by BearSSL (added at the end of tasmota_ca.ino:

#ifdef USE_TELEGRAM
// we add a separate CA for telegram

/*********************************************************************************************\
 * GoDaddy Daddy Secure Certificate Authority - G2, RSA 2048 bits SHA 256, valid until 20220523
 *
 * to convert do: "brssl ta GoDaddyCA.pem"
 * then copy and paste below, chain the generic names to the same as below
 * remove "static" and add "PROGMEM"
\*********************************************************************************************/

const unsigned char GoDaddyCAG2_DN[] PROGMEM = {
	0x30, 0x3E, 0x31, 0x21, 0x30, 0x1F, 0x06, 0x03, 0x55, 0x04, 0x0B, 0x13,
	0x18, 0x44, 0x6F, 0x6D, 0x61, 0x69, 0x6E, 0x20, 0x43, 0x6F, 0x6E, 0x74,
	0x72, 0x6F, 0x6C, 0x20, 0x56, 0x61, 0x6C, 0x69, 0x64, 0x61, 0x74, 0x65,
	0x64, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x10,
	0x61, 0x70, 0x69, 0x2E, 0x74, 0x65, 0x6C, 0x65, 0x67, 0x72, 0x61, 0x6D,
	0x2E, 0x6F, 0x72, 0x67
};

const unsigned char GoDaddyCAG2_RSA_N[] PROGMEM = {
	0xB4, 0xA3, 0x16, 0x9E, 0x5C, 0x57, 0xC9, 0x89, 0x65, 0xED, 0xEA, 0x78,
	0x0B, 0xAE, 0x8A, 0x58, 0x2F, 0xAE, 0x5A, 0xC8, 0x6E, 0x49, 0x8D, 0xFC,
	0x57, 0xA5, 0x98, 0x88, 0x78, 0x2E, 0x0B, 0x3C, 0x40, 0x3C, 0x21, 0x2E,
	0x9A, 0x94, 0x98, 0x33, 0xA7, 0xE3, 0x42, 0xA7, 0x85, 0xFA, 0xD0, 0x73,
	0x84, 0x01, 0x1C, 0x72, 0x39, 0x37, 0x23, 0xB5, 0x56, 0x1D, 0x43, 0xA5,
	0x71, 0x14, 0x08, 0x24, 0xA5, 0x39, 0xCC, 0xDE, 0x58, 0x53, 0x94, 0x8E,
	0x2A, 0x42, 0xA7, 0x4E, 0x2D, 0x07, 0x32, 0x9E, 0xBA, 0x8B, 0xD3, 0x2A,
	0xA9, 0x9E, 0xC0, 0xE3, 0xCE, 0x9A, 0x10, 0x96, 0x45, 0x58, 0x7A, 0xC7,
	0x1E, 0x45, 0x14, 0x23, 0x92, 0xBB, 0x54, 0x82, 0x88, 0x94, 0x49, 0xB6,
	0xBE, 0x81, 0x21, 0x00, 0x29, 0x6D, 0xC9, 0xCE, 0x8B, 0x39, 0x3A, 0xDC,
	0x35, 0x15, 0xD9, 0xEB, 0x47, 0x9C, 0xEF, 0xBA, 0x09, 0x0E, 0x16, 0xE4,
	0xD9, 0xEB, 0x72, 0x30, 0xFA, 0x49, 0xAB, 0x98, 0x31, 0x7C, 0xB3, 0xAC,
	0x2B, 0x29, 0x91, 0x87, 0x08, 0x41, 0x72, 0x5E, 0x35, 0xC7, 0x87, 0x04,
	0x22, 0xF5, 0x48, 0x76, 0x30, 0x6D, 0x88, 0xDF, 0xF2, 0xA5, 0x29, 0x13,
	0x70, 0xB3, 0x87, 0x02, 0xD5, 0x6B, 0x58, 0xB1, 0xE8, 0x73, 0xC7, 0xE4,
	0xEF, 0x79, 0x86, 0xA4, 0x07, 0x5F, 0x67, 0xB4, 0x79, 0x8D, 0xA4, 0x25,
	0x01, 0x82, 0x8C, 0xE0, 0x30, 0x17, 0xCB, 0x4B, 0x5C, 0xFB, 0xEB, 0x4C,
	0x12, 0x51, 0xB9, 0xC9, 0x04, 0x1F, 0x7E, 0xD2, 0xF8, 0xBA, 0xF5, 0x35,
	0x8D, 0x8A, 0x1C, 0x37, 0x82, 0xF0, 0x15, 0x73, 0x00, 0x6E, 0x3D, 0x1C,
	0x76, 0x8B, 0x01, 0x74, 0x81, 0x3D, 0xE4, 0x2C, 0xA7, 0xCC, 0x2F, 0x66,
	0xDC, 0x44, 0xA8, 0x27, 0x3F, 0xEA, 0xD0, 0xA7, 0xA8, 0xF1, 0xCB, 0xEA,
	0xDA, 0x07, 0x38, 0xBD
};

const unsigned char GoDaddyCAG2_RSA_E[] PROGMEM = {
	0x01, 0x00, 0x01
};

const br_x509_trust_anchor GoDaddyCAG2_TA[1] PROGMEM = {
	{
		{ (unsigned char *)TA0_DN, sizeof TA0_DN },
		0,
		{
			BR_KEYTYPE_RSA,
			{ .rsa = {
				(unsigned char *)GoDaddyCAG2_RSA_N, sizeof GoDaddyCAG2_RSA_N,
				(unsigned char *)GoDaddyCAG2_RSA_E, sizeof GoDaddyCAG2_RSA_E,
			} }
		}
	}
};

#endif // USE_TELEGRAM

The downside is that the certificate is valid until May 2022, so we will need to update regularly.

@s-hadinger
Copy link
Collaborator

s-hadinger commented Jun 6, 2020

I will not be available this afternoon to test the whole, but here is how it should work:

#include "WiFiClientSecureLightBearSSL.h"
BearSSL::WiFiClientSecure_light *tlsClient;

[...]
  tlsClient = new BearSSL::WiFiClientSecure_light(1024,1024);
  tlsClient->setTrustAnchor(&GoDaddyCAG2_TA);

Then pass tlsClient to the Telegram lib.

Edit: it would be interesting to print tlsClient->getMFLNStatus() after the connection to see if we risk dropping messages of more than 1024 bytes.

If connection failed, tlsClient->getLastError() will give the SSL error number.

@arendst
Copy link
Owner

arendst commented Jun 6, 2020

Thx I'll give it a try today

@s-hadinger
Copy link
Collaborator

Oh I forgot, you need to set #define USE_MQTT_TLS_FORCE_EC_CIPHER to force ECDHE-RSA-AES128-GCM-SHA256

@s-hadinger
Copy link
Collaborator

I'm trying now, actually here is the CA:

#ifdef USE_TELEGRAM
// we add a separate CA for telegram

/*********************************************************************************************\
 * GoDaddy Daddy Secure Certificate Authority - G2, RSA 2048 bits SHA 256, valid until 20220523
 *
 * to convert do: "brssl ta GoDaddyCA.pem"
 * then copy and paste below, chain the generic names to the same as below
 * remove "static" and add "PROGMEM"
\*********************************************************************************************/

const unsigned char GoDaddyCAG2_DN[] PROGMEM = {
	0x30, 0x3E, 0x31, 0x21, 0x30, 0x1F, 0x06, 0x03, 0x55, 0x04, 0x0B, 0x13,
	0x18, 0x44, 0x6F, 0x6D, 0x61, 0x69, 0x6E, 0x20, 0x43, 0x6F, 0x6E, 0x74,
	0x72, 0x6F, 0x6C, 0x20, 0x56, 0x61, 0x6C, 0x69, 0x64, 0x61, 0x74, 0x65,
	0x64, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x10,
	0x61, 0x70, 0x69, 0x2E, 0x74, 0x65, 0x6C, 0x65, 0x67, 0x72, 0x61, 0x6D,
	0x2E, 0x6F, 0x72, 0x67
};

const unsigned char GoDaddyCAG2_RSA_N[] PROGMEM = {
	0xB4, 0xA3, 0x16, 0x9E, 0x5C, 0x57, 0xC9, 0x89, 0x65, 0xED, 0xEA, 0x78,
	0x0B, 0xAE, 0x8A, 0x58, 0x2F, 0xAE, 0x5A, 0xC8, 0x6E, 0x49, 0x8D, 0xFC,
	0x57, 0xA5, 0x98, 0x88, 0x78, 0x2E, 0x0B, 0x3C, 0x40, 0x3C, 0x21, 0x2E,
	0x9A, 0x94, 0x98, 0x33, 0xA7, 0xE3, 0x42, 0xA7, 0x85, 0xFA, 0xD0, 0x73,
	0x84, 0x01, 0x1C, 0x72, 0x39, 0x37, 0x23, 0xB5, 0x56, 0x1D, 0x43, 0xA5,
	0x71, 0x14, 0x08, 0x24, 0xA5, 0x39, 0xCC, 0xDE, 0x58, 0x53, 0x94, 0x8E,
	0x2A, 0x42, 0xA7, 0x4E, 0x2D, 0x07, 0x32, 0x9E, 0xBA, 0x8B, 0xD3, 0x2A,
	0xA9, 0x9E, 0xC0, 0xE3, 0xCE, 0x9A, 0x10, 0x96, 0x45, 0x58, 0x7A, 0xC7,
	0x1E, 0x45, 0x14, 0x23, 0x92, 0xBB, 0x54, 0x82, 0x88, 0x94, 0x49, 0xB6,
	0xBE, 0x81, 0x21, 0x00, 0x29, 0x6D, 0xC9, 0xCE, 0x8B, 0x39, 0x3A, 0xDC,
	0x35, 0x15, 0xD9, 0xEB, 0x47, 0x9C, 0xEF, 0xBA, 0x09, 0x0E, 0x16, 0xE4,
	0xD9, 0xEB, 0x72, 0x30, 0xFA, 0x49, 0xAB, 0x98, 0x31, 0x7C, 0xB3, 0xAC,
	0x2B, 0x29, 0x91, 0x87, 0x08, 0x41, 0x72, 0x5E, 0x35, 0xC7, 0x87, 0x04,
	0x22, 0xF5, 0x48, 0x76, 0x30, 0x6D, 0x88, 0xDF, 0xF2, 0xA5, 0x29, 0x13,
	0x70, 0xB3, 0x87, 0x02, 0xD5, 0x6B, 0x58, 0xB1, 0xE8, 0x73, 0xC7, 0xE4,
	0xEF, 0x79, 0x86, 0xA4, 0x07, 0x5F, 0x67, 0xB4, 0x79, 0x8D, 0xA4, 0x25,
	0x01, 0x82, 0x8C, 0xE0, 0x30, 0x17, 0xCB, 0x4B, 0x5C, 0xFB, 0xEB, 0x4C,
	0x12, 0x51, 0xB9, 0xC9, 0x04, 0x1F, 0x7E, 0xD2, 0xF8, 0xBA, 0xF5, 0x35,
	0x8D, 0x8A, 0x1C, 0x37, 0x82, 0xF0, 0x15, 0x73, 0x00, 0x6E, 0x3D, 0x1C,
	0x76, 0x8B, 0x01, 0x74, 0x81, 0x3D, 0xE4, 0x2C, 0xA7, 0xCC, 0x2F, 0x66,
	0xDC, 0x44, 0xA8, 0x27, 0x3F, 0xEA, 0xD0, 0xA7, 0xA8, 0xF1, 0xCB, 0xEA,
	0xDA, 0x07, 0x38, 0xBD
};

const unsigned char GoDaddyCAG2_RSA_E[] PROGMEM = {
	0x01, 0x00, 0x01
};

const br_x509_trust_anchor GoDaddyCAG2_TA PROGMEM = {
	{ (unsigned char *)GoDaddyCAG2_DN, sizeof GoDaddyCAG2_DN },
	0,
	{
		BR_KEYTYPE_RSA,
		{ .rsa = {
			(unsigned char *)GoDaddyCAG2_RSA_N, sizeof GoDaddyCAG2_RSA_N,
			(unsigned char *)GoDaddyCAG2_RSA_E, sizeof GoDaddyCAG2_RSA_E,
		} }
	}
};

#endif // USE_TELEGRAM

@s-hadinger
Copy link
Collaborator

I'm progressing. Call is done, I'm now getting error 296 which is SSL3_ALERT_HANDSHAKE_FAILURE

I will continue tomorrow. The current code is here: https://github.com/s-hadinger/Tasmota/tree/telegram_dev

@s-hadinger
Copy link
Collaborator

I got a first version working by disabling CA validation, otherwise it seems to hang.

First good news is TLS was indeed connected, second good news is that Telegram supports MFLN so we can keep 1KB buffers. Bad news is it crashed in the destructor of HTTPClient, but I know why.

Fun fact: after doing lots of tests by IP address got black-listed. I needed to switch to mobile.

GET Update Messages
Client initialized
connect(api.telegram.org,443)
connect(149.154.167.220,443)
_connectSSL: start connection
Connected! MFLNStatus = 1
[HTTPS] GET... code: 404

Exception (28):
epc1=0x4023a0e7 epc2=0x00000000 epc3=0x40248b9d excvaddr=0x000002c0 depc=0x00000000

>>>stack>>>

ctx: cont
sp: 3ffffc40 end: 3fffffc0 offset: 0190
3ffffdd0:  00000001 3fff2fb8 3fff4b84 40208e70

@s-hadinger
Copy link
Collaborator

Crash fixed. It seems to connect correctly, since I get a 404 error because of a fake bot token.

Theo, the code shouldn't retry automatically when there is an error, because it ends up hammering the api endpoint and makes the ip address black-listed.

Log is very verbose for now. You need for now to #define USE_TELEGRAM and do not define any TLS option, especially don't enable USE_MQTT_TLS_CA_CERT (for now)

@s-hadinger
Copy link
Collaborator

Progressing. Connection works well and I need to clean up code.

However the current logic reconnects every second, which is problematic: the actual SSL connection takes around 1 second and freezes the entire Tasmota. Is long polling possible? Or should me relax the frequency?

Also send does not seem to work (yet).

connect(api.telegram.org,443)
connect(149.154.167.220,443)
_connectSSL: start connection
Connected! MFLNStatus = 1
[HTTPS] GET... code: 200
[HTTPS] Received payload telegram:
1BTC = {"ok":true,"result":[]}USD
Sent Update request messages up to : 0
no new messages

@s-hadinger
Copy link
Collaborator

s-hadinger commented Jun 7, 2020

Hi have a dilemma, for TLS server validation:

  1. validate the CA. Problem: the server certificate is bigger than 1024 bytes, so I need to increase the receive buffer from 1024 to 1536 bytes and eats up 512 more byte or RAM. Also, the certificate is only valid until 2022.
  2. is fingerprint validation of server public key. I have no clue about the stability of their public key, it may break tomorrow or stay stable for 10 years.
  3. don't check the server identity which is subject to man-in-the-middle attack.

I propose to implement both 1 and 2, it will depend on #define USE_MQTT_TLS_CA_CERT value.

@s-hadinger
Copy link
Collaborator

Done. The TLS is fully working, both with CA validation or Fingerprint validation. If the fingerprint is wrong, the new one is shown in logs.

@arendst You can now work on the fun part :)

All needed changes are in this branch: https://github.com/s-hadinger/Tasmota/tree/telegram_dev

@arendst
Copy link
Owner

arendst commented Jun 7, 2020

Thx for the basics. Will see tomorrow.

@JackNJack
Copy link

JackNJack commented Oct 17, 2020

You may check the status of your bot via typing the api commands (https://api.telegram.org/bot<token>/METHOD_NAME)
example: (to get all unread messages)
https://api.telegram.org/bot<token>/getUpdates?offset=<offset>
by this, you can see unread messages that is why you don't get what you expecting. If some message is unread, you cannot receive the current message you sent. Especially if your offset is higher than that of your current message's updateID
This is true if you send special bot commands that starts with "/" such as /start /getMe etc. Your bot will receive distinct message format when you use these special bot commands but will retain/follow the updateID trend.

You should receive this on your browser if you have no queued/unread messages:
{"ok":true,"result":[]}

For more details: https://core.telegram.org/bots/api

@Boris17210
Copy link

Hello, I have some questions.
It is posible to report the sensors value to Telegram upon change or using the periodic telemetry data with TelePeriod and PowerDelta like with MQTT?
For instance, for the Sonoff Pow R2 the message in Telegram: Power 234 W
and for the Sonoff TH in Telegram the message in Telegram: Temperature 25,6° C
And of course, how can I do that?
thanks

@j0ni2k
Copy link

j0ni2k commented Nov 21, 2020

Hello, I have some questions.
It is posible to report the sensors value to Telegram upon change or using the periodic telemetry data with TelePeriod and PowerDelta like with MQTT?
For instance, for the Sonoff Pow R2 the message in Telegram: Power 234 W
and for the Sonoff TH in Telegram the message in Telegram: Temperature 25,6° C
And of course, how can I do that?
thanks

First of all a big thank you to everyone contributing to this feature, I have been really looking forward to this and have been testing a lot with WEBSEND command before I found this thread.
I do have the same question as Boris17210. I managed to flash the latest Tasmota release with Telegram support following the description of #8619 (comment) and can now receive messages from my bot and see them in the web console as well as sending telegram messages.

The use case I have in mind is regarding my washing machine. I would like to monitor the power consumption and once it is done send a telegram message. Within the the message it would be great to include some status information such as required ,time consumed energy etc. Is it possible to achieve something like this using TmSend command?

@scheilch
Copy link

Big Thanks also from me for this nice feature. This helps to let Tasmota device run as standalone devices. There are so many use cases for this where you just need a state update instantly on your device when a rule is executed.

I've just tested it with a self compiled and a binary from ota page and both works perfectly. Thank you so much.

Great Work

@lipigab
Copy link

lipigab commented Dec 13, 2020

Is there a step by step guide on how to enable Telegram on a newly flashed Tasmota deive? That would be extremely helpful. Many thanks!

@scheilch
Copy link

scheilch commented Dec 14, 2020

Hello, there is no documentation at all but here are stepts to get telegram running on a Tasmota device.

Prerequisites:
Installed Git -> https://git-scm.com/downloads
Installed VSCode with Platform.io Plugin -> https://code.visualstudio.com/download and https://platformio.org/install/ide?install=vscode

Checkout the code with git somewhere on your disk with:

git checkout https://github.com/arendst/Tasmota.git

Then Open VsCode and click on File -> Open Folder (Choose the Folder where Tasmota was checked out)
Then open the File my_user_config.h under tasmota folder
Edit the file my_user_config.h -> Find // #define USE_TELEGRAM and remove the //
This enables the Telegram feature.

Then compile by choosing Platform.io (The little alien picture at the bottom of the left bar) and choose a project task for your needs (Best would be to choose env:tasmota-YOUR-LANGUAGE)
Click on it and choose General -> Build

After the task has completed you have a Telegram enabled binary and gzipped binary in your tasmota folder under build_output/firmware.

You can then use this to flash your Tasmota device manually. If your device don't have Tasmota, erase the flash and flash it with Tasmotizer.
If you already have Tasmota on it, you can do an OTA update but you have to update to the minimal firmware first and then to your built gzipped binary file.

To enable Telegram you have to chat to the Botfather and get an own Telegram Bot with a token and a chatId. How you can achieve this -> here: https://www.toptal.com/python/telegram-bot-tutorial-python
To get the ChatId type into your Bots chat the command: /getUpdates
This will give you a JSON String where you can find your chatId.

Then you have to navigate to your Tasmota device and type the following into your console:
tmtoken YOUR BOT TOKEN
tmchatid YOUR BOTS CHATID
tmstate 1 //to enable sending telegram message
tmstate 3 //to enable receiving telegram messages in your Tasmota device
tmstate 5 //to enable echo your telegram messages/commands

tmstate 0, tmstate 2 and tmstate 4 is for disabling the above features

if everything works right then you are able to use the command
tmsend WITH YOUR MESSAGE TEXT HERE

Example

tmtoken sofdih98we:099we000weß0we8ru09uew08zrehfjc
tmchatid 12343216453
tmstate 1
tmstate 3
tmstate 5
tmsend Hello out there. I'm using Telegram now!

I Hope this helps also others to get their devices into telgram.

Again Thanks Theo for this great feature - feel to take all or parts of this little tutorial for your documentation ;)

@lipigab
Copy link

lipigab commented Dec 14, 2020

Wow, thank you so much for the detailed information!

@scheilch
Copy link

I'v seen that my quoted variables were not visible to you - so I've updated the post. Please reread it and if you have any further questions -> just ask.

@ascillato2 ascillato2 added the Add to Docs Add info to Docs label Dec 14, 2020
@ciprocip
Copy link

Hello, I have some questions.
It is posible to report the sensors value to Telegram upon change or using the periodic telemetry data with TelePeriod and PowerDelta like with MQTT?
For instance, for the Sonoff Pow R2 the message in Telegram: Power 234 W
and for the Sonoff TH in Telegram the message in Telegram: Temperature 25,6° C
And of course, how can I do that?
thanks

First of all a big thank you to everyone contributing to this feature, I have been really looking forward to this and have been testing a lot with WEBSEND command before I found this thread.
I do have the same question as Boris17210. I managed to flash the latest Tasmota release with Telegram support following the description of #8619 (comment) and can now receive messages from my bot and see them in the web console as well as sending telegram messages.

The use case I have in mind is regarding my washing machine. I would like to monitor the power consumption and once it is done send a telegram message. Within the the message it would be great to include some status information such as required ,time consumed energy etc. Is it possible to achieve something like this using TmSend command?

Hi to All!
And a BiG Thanks for your work!!
Me too I'm interested how got sensors data from device to telegram chat!
I have to use a rule to got sensors data?
I know Tasmota rules but I don't how to start for this... Can someone help me please? Can someone address me to start?
Thank you so much for your help!

@fragolinux
Copy link

I'v seen that my quoted variables were not visible to you - so I've updated the post. Please reread it and if you have any further questions -> just ask.

hi, just tested again and the problem for me is always the same... i can "tmsend something" from tasmota to the bot, but getting something back is rare if not unique... i send from the bot "status 2" for example, wait for 30 seconds, and i never get back anything... if i continue to write "status 2" repeatdly and i get the correct timing when the console is doing "checking connection", i randomly succeed to get the answer... but it's RARE...

@scheilch
Copy link

I'v seen that my quoted variables were not visible to you - so I've updated the post. Please reread it and if you have any further questions -> just ask.

hi, just tested again and the problem for me is always the same... i can "tmsend something" from tasmota to the bot, but getting something back is rare if not unique... i send from the bot "status 2" for example, wait for 30 seconds, and i never get back anything... if i continue to write "status 2" repeatdly and i get the correct timing when the console is doing "checking connection", i randomly succeed to get the answer... but it's RARE...

Hi,

that could be an issue because the polling interval Tasmota polls the Telegram service defaults to 10 seconds and cannot be less than 10 secs. So I guess you have to wait for an answer almost 10 seconds.

But you can check if everything is configured the right way by typing the following commands:

tmtoken
you should get a JSON object with you token in it

tmchatid
you should get a JSON object with your chat id in it

tmstate
you should get this: {"TmState":{"Send":"ON","Receive":"ON","Echo":"ON"}}

@fragolinux
Copy link

@scheilch yup, all configured good, just checked your commands... if you scroll you'll see these are issues i had already, i know about that polling time, as said i waited even 30 seconds, but getting something back is rare... i'll go for nodered without using these, it's easier and VERY fast...

@Tigger2014
Copy link

Is it possible to completely disable the ssl checking for this and if so how, I need to be able to pass this through a MITM proxy and the cert changes often, I understand the risks of no validation?

@s-hadinger
Copy link
Collaborator

That's probably doable. But I'm reluctant to add it in the mainstream version. Can't you have a more stable proxy certificate?

@Tigger2014
Copy link

Tigger2014 commented Dec 28, 2020 via email

@Tigger2014
Copy link

Shall I open a new issue regarding the certificate check disable option as this one has been closed?

@s-hadinger
Copy link
Collaborator

Yes please. As a feature request. It will be easier to track

@fmarzocca
Copy link

fmarzocca commented Jan 23, 2021

Universal Arduino Telegram Bot library has been updated by including a certificate to connect to https://..telegram...

Repository owner deleted a comment from rj10rd Apr 21, 2022
Repository owner deleted a comment from scheilch Apr 21, 2022
Repository owner deleted a comment from scheilch Apr 21, 2022
Repository owner deleted a comment from barbudor Apr 21, 2022
@Kugeleis
Copy link

The issue is closed but what is the actual status of implementation? I can't find it in the docs.

@sfromis
Copy link
Contributor

sfromis commented Feb 26, 2023

Driver source code does have a bit of docs at the start
https://github.com/arendst/Tasmota/blob/development/tasmota/tasmota_xdrv_driver/xdrv_40_telegram.ino

@bam80
Copy link

bam80 commented Dec 11, 2023

The issue is closed but what is the actual status of implementation? I can't find it in the docs.

I created an issue to track the docs status:
#20206

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Add to Docs Add info to Docs enhancement Type - Enhancement that will be worked on fixed Result - The work on the issue has ended
Projects
None yet
Development

No branches or pull requests