Hmm, i think i might be hitting a telegram issue now.
This is my automation:
- id: '1591182611573'
alias: exp
description: ''
trigger:
- device_id: 2e055d5b22014d82aa014dc1100f10ba
domain: binary_sensor
entity_id: binary_sensor.0x00158d0003ce34ab_contact
platform: device
type: opened
condition: []
action:
- data_template:
message: "{{ trigger.to_state.attributes.friendly_name }} blabla"
service: telegram_bot.send_message
It doesn’t work, but i am getting this error in the logs:
“Error sending message: Can’t parse entities: can’t find end of the entity starting at byte offset 15. Args: (1008895627, ‘Dishwasher Door_contact blabla’), kwargs: {‘parse_mode’: ‘Markdown’, ‘disable_notification’: False, ‘disable_web_page_preview’: None, ‘reply_to_message_id’: None, ‘reply_markup’: None, ‘timeout’: None}”
Edit: Looks like changing the service to send a notification to my phone app works fine. So it’s the telegram addon that doesn’t like the message format now… any ideas why?
Btw, @lolouk44, for this working automation:
- id: '1577478983895'
alias: Notify Door or Window has been Opened
description: ''
trigger:
- entity_id: binary_sensor.0x00158d00034d6d2d_contact
from: 'off'
platform: state
to: 'on'
- entity_id: binary_sensor.0x00158d00040c4f0b_contact
from: 'off'
platform: state
to: 'on'
- entity_id: binary_sensor.0x00158d00040c2704_contact
from: 'off'
platform: state
to: 'on'
- entity_id: binary_sensor.0x00158d00040c271b_contact
from: 'off'
platform: state
to: 'on'
- entity_id: binary_sensor.0x00158d00040c27b6_contact
from: 'off'
platform: state
to: 'on'
condition: []
action:
- data:
message: 'A window or door has been Opened! Bedroom Balcony- {{state_attr(''binary_sensor.0x00158d00034d6d2d_contact'',
''contact'')}} ---------- Bedroom Windows - {{state_attr(''binary_sensor.0x00158d00040c4f0b_contact'',
''contact'')}} ---------- Bathroom - {{state_attr(''binary_sensor.0x00158d00040c2704_contact'',
''contact'')}} --------------- LivingRoom - {{state_attr(''binary_sensor.0x00158d00040c271b_contact'',
''contact'')}} ------------- Kitchen - {{state_attr(''binary_sensor.0x00158d00040c27b6_contact'',
''contact'')}} '
service: telegram_bot.send_message
you mentioned " as long as you have data_template as part of your main service, you’ll be fine". What do you mean by ‘main service’? Not sure why this automation works without ‘>-’ or without ‘data_template’… Trying to understand templating a bit better
PPS: Yes, it was a telegram issue. It doesn’t like “_” characters by default. As a quick fix replacing the string for now like this:
data_template:
message: blablabla '{{ trigger.to_state.attributes.friendly_name.replace("_", "\\_") }}' blabla
service: telegram_bot.send_message
Thanks for the help!