Hi!
I’m looking for a way to change the telegram chat id from lovelace.
I’ve tried the following:
telegram_bot:
- platform: polling
api_key: '*************************'
allowed_chat_ids:
- '{{ states('input_number.telegram_user_1') }}'
notify:
- name: telegram_user_1
platform: telegram
chat_id: '{{ states('input_number.telegram_user_1') }}'
This returns the following error:
bad indentation of a sequence entry at line 41, column 21:
- '{{ states('input_number.telegram_user_1') }}'
^
Is there a way of accomplishing this
Edit: misspelling
Troon
(Troon)
June 29, 2020, 11:57am
2
You have nested single quotes. Use double quotes on the outside and see if that works:
- "{{ states('input_number.telegram_user_1') }}"
and
chat_id: "{{ states('input_number.telegram_user_1') }}"
1 Like
tom_l
June 29, 2020, 11:59am
3
No. That key is not templateable.
Don’t try to template the config. Instead configure two (or more) telegram notification services and choose which service to use with a service template in your automations.
e.g.
telegrram set up:
notify:
- platform: telegram
name: telegram_general
chat_id: !secret telegram_general_chat_group_id
- platform: telegram
name: telegram_system
chat_id: !secret telegram_system_chat_group_id
telegram_bot:
- platform: webhooks
api_key: !secret telegram_api_key
allowed_chat_ids:
- !secret telegram_general_chat_group_id
- !secret telegram_system_chat_group_id
- !secret telegram_tom_id
trusted_networks:
- 149.154.160.0/20
- 91.108.4.0/22
automation:
action:
- service_template: >
{% if is_state('input_number.telegram_user', '1') %}
notify.telegram_general
{% elif is_state('input_number.telegram_user', '2') %}
notify.telegram_system
{% endif %}
data:
title: '*ALERT*'
message: 'blah blah blah'
Edit: FYI here is how you can tell if a configuration option accepts a template:
2 Likes
I think I might have been a little unclear
My goal is to change the chat_id from the frontend.
The reason is that i’m selling my apartment with HA and want to make it easier for the new owners to get started.
tom_l
June 29, 2020, 12:33pm
5
Not possible. As I said, that part of the configuration is not templateable.
1 Like