So, will this go away once I have successfully made all necessary changes?
Here is what I did: I created a script.
This was my notify.yaml file which was included in the configuration.yaml:
---
- name: admin_telegram
platform: telegram
chat_id: !secret telegram_chatid
- name: family_telegram
platform: telegram
chat_id: !secret telegram_family_chatid
- name: persistent
platform: rest
resource: 'https://localhost:8443/api/services/persistent_notification/create'
method: POST_JSON
headers:
Authorization: !secret persistent_api
Content-Type: 'application/json'
message_param_name: message
title_param_name: title
target_param_name: notification_id
- name: admin_notify
platform: group
services:
- service: admin_telegram
- service: persistent
- service: mobile_app_device
- name: family_notify
platform: group
services:
- service: family_telegram
I took out all but the persistent notify service.
Then I had this HA script created:
send_notification:
alias: Send notification
description: Unified notification with optional Telegram photo/video
fields:
target:
description: Who to notify (admin or family)
example: admin
title:
description: Notification title
example: "Something happened"
message:
description: Notification body
example: "The front door opened."
notification_id:
description: Optional ID for persistent notifications
example: "door_open"
photo_file:
description: Optional local path to photo to send via Telegram
example: "/config/www/snapshot.jpg"
photo_url:
description: Optional URL to photo to send via Telegram
example: "https://example.com/snapshot.jpg"
video_file:
description: Optional local path to video to send via Telegram
example: "/config/www/clip.mp4"
video_url:
description: Optional URL to video to send via Telegram
example: "https://example.com/clip.mp4"
sequence:
- choose:
# ADMIN: Telegram + persistent + mobile app
- conditions:
- condition: template
value_template: "{{ target == 'admin' }}"
sequence:
# Text message to admin via Telegram
- action: telegram_bot.send_message
data:
target: !secret telegram_chatid
message: "{{ message }}"
# optional: caption-like title prefix
# message: "{{ title ~ ': ' ~ message if title else message }}"
# Optional photo
- choose:
- conditions: "{{ photo_file is defined and photo_file != '' }}"
sequence:
- action: telegram_bot.send_photo
data:
target: !secret telegram_chatid
file: "{{ photo_file }}"
caption: "{{ title if title is defined else '' }}"
- conditions: "{{ photo_url is defined and photo_url != '' }}"
sequence:
- action: telegram_bot.send_photo
data:
target: !secret telegram_chatid
url: "{{ photo_url }}"
caption: "{{ title if title is defined else '' }}"
# Optional video
- choose:
- conditions: "{{ video_file is defined and video_file != '' }}"
sequence:
- action: telegram_bot.send_video
data:
target: !secret telegram_chatid
file: "{{ video_file }}"
caption: "{{ title if title is defined else '' }}"
- conditions: "{{ video_url is defined and video_url != '' }}"
sequence:
- action: telegram_bot.send_video
data:
target: !secret telegram_chatid
url: "{{ video_url }}"
caption: "{{ title if title is defined else '' }}"
# Existing REST persistent notification
- action: notify.persistent
data:
message: "{{ message }}"
title: "{{ title | default('') }}"
target: "{{ notification_id | default('ha_notification') }}"
# Existing mobile app notification
- action: notify.mobile_app_device
data:
message: "{{ message }}"
title: "{{ title | default('') }}"
# FAMILY: Telegram only (same media options)
- conditions:
- condition: template
value_template: "{{ target == 'family' }}"
sequence:
- action: telegram_bot.send_message
data:
target: !secret telegram_family_chatid
message: "{{ message }}"
- choose:
- conditions: "{{ photo_file is defined and photo_file != '' }}"
sequence:
- action: telegram_bot.send_photo
data:
target: !secret telegram_family_chatid
file: "{{ photo_file }}"
caption: "{{ title if title is defined else '' }}"
- conditions: "{{ photo_url is defined and photo_url != '' }}"
sequence:
- action: telegram_bot.send_photo
data:
target: !secret telegram_family_chatid
url: "{{ photo_url }}"
caption: "{{ title if title is defined else '' }}"
- choose:
- conditions: "{{ video_file is defined and video_file != '' }}"
sequence:
- action: telegram_bot.send_video
data:
target: !secret telegram_family_chatid
file: "{{ video_file }}"
caption: "{{ title if title is defined else '' }}"
- conditions: "{{ video_url is defined and video_url != '' }}"
sequence:
- action: telegram_bot.send_video
data:
target: !secret telegram_family_chatid
url: "{{ video_url }}"
caption: "{{ title if title is defined else '' }}"
And instead of using this code to send a notification:
- service: notify.family_notify
data:
message: Er is iemand bij de deur
data:
photo:
- file: '{{ snapshot_filename }}'
I now use this code:
- service: script.send_notification
data:
target: "family"
title: "Deurbel"
message: "Er is iemand bij de deur"
photo_file: '{{ snapshot_filename }}'
I hope this helps.
does this all affect my automation too?
if:
....
then:
- data:
message: ACHTUNG Badezimmerfenster ist noch offen!
action: notify.telegramsmarthome
enabled: true
It would be so easy, if the repair message would just tell would should be changed, but why shall it be made easy for users?
The latest advise says, do not change anything and just ignore this message, and that’s exactly what I will do for the next 5 or 6 months.
It is a good choice. The integration is very much not finished. It will change with future releases. i.e. the ability to use entities instead of numeric chat ids.
Hi, I need some help to migrate these telegram automation, any help would be appreciated. Thanks
this is part of an automation that sends me a video from my ip cam:
...
- service: notify.telegram
data_template:
target:
- 1234567890
- 1234567891
title: "cctv"
data:
video:
url: http://localhost:1984/api/stream.mp4?src=camera.cortile_sub&duration=7 # duration in seconds
caption: Video - *{{ states.sensor.last_cam_triggering_entity.state }}* at *{{now().strftime("%H:%M:%S")}}* of *{{now().strftime("%d.%m.%Y")}}*.
message: >
*{{ states.sensor.last_cam_triggering_entity.state }}* at *{{now().strftime("%H:%M:%S")}}* on *{{now().strftime("%d.%m.%Y")}}*.
tried to migrate with this but doesn’t work:
...
- action: notify.send_message
target:
entity_id:
- notify.telegram_bot_[REDACTED]_1234567890
- notify.telegram_bot_[REDACTED]_1234567891
data:
title: "cctv"
video:
url: http://localhost:1984/api/stream.mp4?src=camera.cortile_sub&duration=7 # duration in seconds
caption: Video - *{{ states.sensor.last_cam_triggering_entity.state }}* at *{{now().strftime("%H:%M:%S")}}* of *{{now().strftime("%d.%m.%Y")}}*.
message: >
*{{ states.sensor.last_cam_triggering_entity.state }}* at *{{now().strftime("%H:%M:%S")}}* on *{{now().strftime("%d.%m.%Y")}}*.
I have the same problem with this that is part of an automation that sends me a photo from my ip cam:
...
- service: camera.snapshot
data:
entity_id: camera.cortile_sub
filename: '/home/homeassistant/.homeassistant/_camshot/_triggered/_image/{{ states.sensor.rlc_outdoor_photo_filename.state }}.jpg'
- delay: 00:00:01
- service: notify.telegram
data_template:
target:
- 1234567890
- 1234567891
title: "cctv"
data:
photo:
file: '/home/homeassistant/.homeassistant/_camshot/_triggered/_image/{{ states.sensor.yi_outdoor_photo_filename.state }}.jpg'
caption: Foto - *{{ states.sensor.last_cam_triggering_entity.state }}* at *{{now().strftime("%H:%M:%S")}}* on *{{now().strftime("%d.%m.%Y")}}*.
message: >
*{{ states.sensor.last_cam_triggering_entity.state }}* at *{{now().strftime("%H:%M:%S")}}* on *{{now().strftime("%d.%m.%Y")}}*.
Did you read this thread?
Why are you trying to migrate now when the advice is to not migrate now?
My only question is, why do we get this repair message too early.
can you please point out where it was stated “Not to migrate”?
I have to admit I’m not at 100% as I just just finished to manually migrate 228 issue for the template integration, but really I lost the part in this thread with the advice from the integration maintainer not to migrate.
Thanks
The advice was not coming from the maintainer, it was coming from Tom.
The Integration is not finished yet and it’s better to wait till it’s finished.
The HA popup about this is 100% unclear. And there are many topics about this, without any concise / simple informations about what to do.
Fully agree, so the best is to just do nothing and wait, till it’s described in a better way.
For some reason the migration went pretty smooth. I already had telegram bot installed.
I removed
notify: !include notify.yaml
from my configuration.yaml
and adjusted (paint full amount of work) my automations to:
alias: Telegram - Alarm
description: Somebody Touched the Alarm!
triggers:
- entity_id:
- binary_sensor.alarm
from: null
trigger: state
conditions: []
actions:
- target:
entity_id: camera.ipc_hal
data:
filename: /config/www/snapshots/hal_snapshot.jpg
action: camera.snapshot
- action: telegram_bot.send_photo
data:
config_entry_id: 1234567
file: /config/www/snapshots/hal_snapshot.jpg
caption: |-
Someone touched the alarm. Here's a snapshot. Wijziging uitgevoerd
door: {{
state_attr('alarm_control_panel.panel_a',
'changed_by') }}.
target:
- "-GROUPID"
mode: single
and:
alias: _Sensor - Leakage Berging
description: Leakage bij Wasmachine / Droger
triggers:
- entity_id:
- binary_sensor.water_leak_sensor
from: "off"
trigger: state
to: "on"
for:
hours: 0
minutes: 0
seconds: 10
conditions: []
actions:
- action: notify.send_message
data:
title: Homeassistant Sensor
message: Lekkage in de berging bij de Wasmachine!
target:
entity_id: notify.telegram_bot_123456_5678906
mode: single
Luckily that seems to all work just fine again.
Please edit your post and use the preformatted text button </> not the quote button to format your config.
I updated all mine too. I had to use secrets to hide the chat ids but that can easily be replaced with entities when that becomes available later.
One other issue is that you can’t currently send more than one picture in a message. That too will be added later (using a different service, see: https://github.com/orgs/home-assistant/discussions/2356 ).
A few examples:
Old (send photo):
- action: notify.telegram_general
data:
message: ' '
data:
photo:
- url: http://10.1.1.241:11080/endpoint/@scrypted/webhook/public/<redacted>/takePicture
caption: >
{% if is_state('binary_sensor.shed_door_contact', 'on') %}
The shed door is open.
{% else %}
The shed door is closed.
{% endif %}
New:
- action: telegram_bot.send_photo
data:
target: !secret telegram_general_chat_group_id
url: 'http://10.1.1.241:11080/endpoint/@scrypted/webhook/public/<redacted>/takePicture'
caption: >
{% if is_state('binary_sensor.shed_door_contact', 'on') %}
The shed door is open.
{% else %}
The shed door is closed.
{% endif %}
Old (send message):
- action: notify.telegram_system_log
data:
title: "⏹️ <b>Lounge dehumidifier stopped</b>"
message: >
Peak electricity rate is active.
Relative humidity: {{ states('sensor.lounge_room_humidity')|round(0,even,'unknown') }}%
Condensation chance: {{ states('sensor.lounge_room_condensation_chance') }}%
New:
- action: telegram_bot.send_message
data:
target: !secret telegram_system_log_chat_group_id
title: '⏹️ <b>Workshop dehumidifier stopped</b>'
message: >
Peak electricity rate is active.
Humidity: {{ states('sensor.workshop_humidity')|round(0,even,'unknown') }}%
Condensation chance: {{ states('sensor.workshop_condensation_chance') }}%
Old (choose chat group to send to):
- action: >
{% if is_state_attr('event.backup_automatic_backup','event_type','failed') %}
notify.telegram_alert
{% else %}
notify.telegram_system_log
{% endif %}
data:
title: >
{% if is_state_attr('event.backup_automatic_backup','event_type','in_progress') %}
📅 <b>Automatic backup</b>
{% elif is_state_attr('event.backup_automatic_backup','event_type','completed') %}
✅ <b>Automatic backup</b>
{% elif is_state_attr('event.backup_automatic_backup','event_type','failed') %}
❌ <b>Automatic backup</b>
{% else %}
❓ <b>Automatic backup</b>
{% endif %}
message: >
Backup {{ state_attr('event.backup_automatic_backup','event_type')|replace('_',' ') }}.
{% if is_state_attr('event.backup_automatic_backup','event_type','failed') %}
Failed reason: {{ state_attr('event.backup_automatic_backup','failed_reason')|replace('_',' ')|title }}
{% else %}
{% endif %}
New:
- variables:
alert: !secret telegram_alert_chat_group_id
sys_log: !secret telegram_system_log_chat_group_id
- action: telegram_bot.send_message
data:
target: >
{% if is_state_attr('event.backup_automatic_backup','event_type','failed') %}
{{ alert }}
{% else %}
{{ sys_log }}
{% endif %}
title: >
{% if is_state_attr('event.backup_automatic_backup','event_type','in_progress') %}
📅 <b>Automatic backup</b>
{% elif is_state_attr('event.backup_automatic_backup','event_type','completed') %}
✅ <b>Automatic backup</b>
{% elif is_state_attr('event.backup_automatic_backup','event_type','failed') %}
❌ <b>Automatic backup</b>
{% else %}
❓ <b>Automatic backup</b>
{% endif %}
message: >
Backup {{ state_attr('event.backup_automatic_backup','event_type')|replace('_',' ') }}.
{% if is_state_attr('event.backup_automatic_backup','event_type','failed') %}
Failed reason: {{ state_attr('event.backup_automatic_backup','failed_reason')|replace('_',' ')|title }}
{% else %}
{% endif %}
Old (send multiple photos):
- action: notify.telegram_general
data:
message: ' '
data:
photo:
- url: http://10.1.1.241:11080/endpoint/@scrypted/webhook/public/<redacted>/takePicture
caption: Driveway
- url: http://10.1.1.241:11080/endpoint/@scrypted/webhook/public/<redacted>/takePicture
caption: Electronics Workshop
- url: http://10.1.1.241:11080/endpoint/@scrypted/webhook/public/<redacted>/takePicture
caption: Mechanical Workshop
- url: http://10.1.1.241:11080/endpoint/@scrypted/webhook/public/<redacted>/takePicture
caption: Patio
- url: http://10.1.1.241:11080/endpoint/@scrypted/webhook/public/<redacted>/takePicture
caption: Rear Deck
- url: http://10.1.1.241:10443/endpoint/@scrypted/webhook/public/<redacted>/takePicture
caption: Side Deck
- url: http://10.1.1.241:11080/endpoint/@scrypted/webhook/public/<redacted>/takePicture
caption: Washing Line
New (separate services for now):
- action: telegram_bot.send_photo
data:
target: !secret telegram_general_chat_group_id
url: http://10.1.1.241:11080/endpoint/@scrypted/webhook/public/<redacted>/takePicture
caption: Driveway
- action: telegram_bot.send_photo
data:
target: !secret telegram_general_chat_group_id
url: http://10.1.1.241:11080/endpoint/@scrypted/webhook/public/<redacted>/takePicture
caption: Electronics Workshop
- action: telegram_bot.send_photo
data:
target: !secret telegram_general_chat_group_id
url: http://10.1.1.241:11080/endpoint/@scrypted/webhook/public/<redacted>/takePicture
caption: Mechanical Workshop
- action: telegram_bot.send_photo
data:
target: !secret telegram_general_chat_group_id
url: http://10.1.1.241:11080/endpoint/@scrypted/webhook/public/<redacted>/takePicture
caption: Patio
- action: telegram_bot.send_photo
data:
target: !secret telegram_general_chat_group_id
url: http://10.1.1.241:11080/endpoint/@scrypted/webhook/public/<redacted>/takePicture
caption: Rear Deck
- action: telegram_bot.send_photo
data:
target: !secret telegram_general_chat_group_id
url: http://10.1.1.241:10443/endpoint/@scrypted/webhook/public/<redacted>/takePicture
caption: Side Deck
- action: telegram_bot.send_photo
data:
target: !secret telegram_general_chat_group_id
url: http://10.1.1.241:11080/endpoint/@scrypted/webhook/public/<redacted>/takePicture
caption: Washing Line
tnx @tom_l for pointing me into the right direction of using the forum.
Now it looks much better
indeed.
I currently also implemented multiple actions of telegram_bot.send_photo to get that sorted. I experience no issues so that is a good thing. The !secrets part is also a nice suggestion if I want to post more ‘examples’.
