home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.7k stars 28.85k forks source link

telegram_bot will not parse html tags in message #115787

Open weswitt opened 2 months ago

weswitt commented 2 months ago

The problem

using the automation below i get an error saying unsupported tag. the automation clearly has the parse_mode set to html, yet it rejects valid html tags in the message.

What version of Home Assistant Core has the issue?

System Information version | core-2024.4.2 -- | -- installation_type | Home Assistant Supervised dev | false hassio | true docker | true user | root virtualenv | false python_version | 3.12.2 os_name | Linux os_version | 6.1.0-17-amd64 arch | x86_64 timezone | America/Los_Angeles config_dir | /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 5000 Installed Version | 1.34.0 Stage | running Available Repositories | 1400 Downloaded Repositories | 18
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Debian GNU/Linux 12 (bookworm) -- | -- update_channel | stable supervisor_version | supervisor-2024.04.0 agent_version | 1.6.0 docker_version | 24.0.7 disk_total | 37.6 GB disk_used | 35.8 GB healthy | true supported | true supervisor_api | ok version_api | ok installed_addons | Zigbee2MQTT (1.35.1-1), Studio Code Server (5.15.0), Terminal & SSH (9.13.0), File editor (5.8.0), go2rtc (1.8.5), Zigbee2MQTT (1.35.1-1)
Dashboards dashboards | 12 -- | -- resources | 17 views | 13 mode | storage
Recorder oldest_recorder_run | April 7, 2024 at 10:34 PM -- | -- current_recorder_run | April 12, 2024 at 10:45 AM estimated_db_size | 308.71 MiB database_engine | sqlite database_version | 3.44.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

alias: Waterflow Report
description: ""
trigger:
  - platform: mqtt
    topic: waterflow/report
condition: []
action:
  - service: telegram_bot.send_message
    data:
      authentication: digest
      title: Waterflow Report
      parse_mode: html
      message: >-
        North stall: {{trigger.payload_json['north']}}<br>South stall:
        {{trigger.payload_json['south']}}
mode: single

Anything in the logs that might be useful for us?

Logger: homeassistant.components.telegram_bot
Source: components/telegram_bot/__init__.py:692
integration: Telegram bot (documentation, issues)
First occurred: 3:32:20 PM (2 occurrences)
Last logged: 3:32:20 PM

Error sending message: Can't parse entities: unsupported start tag "br" at byte offset 38. Args: (-988501590, 'Waterflow Report\nNorth stall: 0.843435<br>South stall: 3.12291'), kwargs: {'parse_mode': <ParseMode.HTML>, 'disable_web_page_preview': None, 'disable_notification': False, 'reply_to_message_id': None, 'reply_markup': None, 'read_timeout': None}

Additional information

No response

home-assistant[bot] commented 2 months ago

telegram_bot documentation telegram_bot source

weswitt commented 2 months ago

thanks bot, i've already read all that but sadly it does not answer the problem

rapejim commented 2 days ago

This is not an issue in Home Assistant, you are using an HTML tag (the "br" tag, replace it for \n) not supported by Telegram bots. Take a look at the supported HTML tags in their official documentation: https://core.telegram.org/bots/api#html-style Here is a screenshot with the info.

image