Can't use Templated values with Telegram Notification


I’m trying to set up an automation that notifies me via Telegram when a MiFlora sensor’s temperature gets too high. Although the automation fires, there seems to be a problem with applying the templating in the notification. The following error is logged;

Error sending message: Can’t parse entities in message text: unsupported start tag “template” at byte offset 50. Args: (MYCHATID, ‘Propagator Temperature High\nCurrent Temperature: <template state sensor.propagator_temperature=25.6; unit_of_measurement=°C, friendly_name=Propagator Temperature @ 2018-02-11T13:15:14.519014+00:00>C’), kwargs: {‘parse_mode’: ‘HTML’, ‘disable_notification’: False, ‘disable_web_page_preview’: None, ‘reply_to_message_id’: None, ‘reply_markup’: None, ‘timeout’: None}

If I remove the {{ states.sensor.propagator_temperature }} template from the message, the notification works as intended - it’s only when i’m trying to use a value that it errors.

I came across a related thread, but that was solved by changing the parse_mode from the default markdown to html. Unfortunately, i’m already using the HTML parse mode. Indeed, if I change it to markdown, it does sort of work - sending the following message;

Propagator Temperature High
Current Temperature: <template state sensor.propagatortemperature=25.2; unitofmeasurement=°C, friendlyname=Propagator Temperature @ 2018-02-11T13:09:43.296712+00:00>C

Can anyone work out what’s going on here? My configurations are as follows;

  - platform: webhooks
    api_key: 'MYAPIKEY'
    parse_mode: html
      - MYCHATID
notify telegram:
  name: telegram
  platform: telegram
  chat_id: MYCHATID
- id: propagator-temperature-notify
  alias: 'Notify when Propagator Temperature out of Range'
    - platform: numeric_state
      entity_id: sensor.propagator_temperature
      above: 25
    - service: notify.telegram
        title: "Propagator Temperature High"
        message: "Current Temperature: {{ states.sensor.propagator_temperature }}C"

Try using this as your “message”:

message: "Current Temperature: {{ states.sensor.propagator_temperature.state }}C"
1 Like

That did the trick, thank you!

1 Like