Created
November 2, 2023 21:37
-
-
Save vladyspavlov/74d25856a58e252a1acee392286b7207 to your computer and use it in GitHub Desktop.
ESPHome Telegram bot send message example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| substitutions: | |
| TELEGRAM_BOT_TOKEN: !secret telegram_bot_token | |
| api_key: !secret api_key | |
| ota_password: !secret ota_password | |
| chat_id: xxxxxxxxx | |
| esphome: | |
| name: wemos | |
| friendly_name: wemos | |
| esp8266: | |
| board: d1_mini_pro | |
| # Enable logging | |
| logger: | |
| # Enable Home Assistant API | |
| api: | |
| encryption: | |
| key: ${api_key} | |
| ota: | |
| password: ${ota_password} | |
| wifi: | |
| ssid: !secret wifi_ssid | |
| password: !secret wifi_password | |
| captive_portal: | |
| status_led: | |
| pin: GPIO2 | |
| http_request: | |
| useragent: esphome/device | |
| timeout: 10s | |
| button: | |
| - platform: template | |
| name: Send Telegram message | |
| on_press: | |
| - http_request.post: | |
| url: "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" | |
| headers: | |
| Content-Type: application/json | |
| json: | |
| chat_id: ${chat_id} | |
| text: Message from ESPHome | |
| verify_ssl: false |
in case anyone is still using this post... here is how I got telegram working on ESPhome - thanks to original contributor for the excellent headstart...
substitutions:
TELEGRAM_BOT_TOKEN: !secret telegram_bot_token
mychat_id: "-1234567890" # replace with your numeric chat ID, keep the minus symbol if a group/channel. Note the need of quotes
esp32: # in case anything is board specific and you want to know what board this worked on
board: esp32-s3-devkitc-1
framework:
type: esp-idf
http_request:
# useragent: esphome/device # Keeping this line in just did not work for me. Commented out and voila it worked.
timeout: 10s
binary_sensor:
- platform: gpio
(YOUR CODE)
on_press:
- http_request.post:
url: "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage"
request_headers:
Content-Type: application/json
json:
chat_id: ${mychat_id}
text: "Message from ESPHome"
How to display information using the /help command?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
no i change the correct chat_id. is a group id but i test the conection to connect via web url and connect correctly