Telegram Inline Keyboard template

I’m here to share a template to put in automations.yaml for Telegram inline Keyboard.

I hope it can help some people.

####################################################
#                                                  #
#                   Telegram                       #
#                   Keyboard                       #
####################################################

### Start Keyboard ###
- id: telegram-start
  alias: 'Telegram Start Command'
  initial_state: 'on'
  trigger:
    platform: event
    event_type: telegram_command
    event_data:
      command: '/start'
  action:
  - service: notify.notify
    data:
      message: >
       {{ [
       "Hi",
       "Hello",
       "Yes Sir!",
       "it's a pleasure to see you again"
       ] | random }}       
      data:
        keyboard:
          - '/start, /cp'


####################################################
#                                                  #
#                   Telegram                       #
#                Inline Keyboard                   #
####################################################
#############################
### Start Inline Keyboard ###
#############################
- id: telegram-control-pannel-start
  alias: 'Telegram Control Pannel Command'
  initial_state: 'on'
  trigger:
    platform: event
    event_type: telegram_command
    event_data:
      command: '/cp'
  action:
  - service: notify.notify
    data:
      message: >
       {{ [
       "Home Assistant Status",
       "Control Panel",
       "Yes Sir!",
       "Home Assistant Control Panel",
       "Pannello di controllo"
       ] | random }}       
      data:
        inline_keyboard:
          - 'Lights:/lights, Status:/status, Security:/security'
          - 'System:/system, Help:/help, Ping:/ping'
          - "Addons:/addons"
          - "Gimme Pizza:/gimmepizza, No thanks:/nopizza"


####################
### IK Ping Pong ###
####################
- id: telegram-ik-ping-pong
  alias: 'telegram ping pong'
  hide_entity: true
  trigger:
    - platform: event
      event_type: telegram_callback
      event_data:
        data: '/ping'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: >-
          Callback received from {{ trigger.event.data.from_first }}.
          Message id: {{ trigger.event.data.message.message_id }}.
          Data: {{ trigger.event.data.data }}
          {{now().strftime("%H:%M:%S %Y-%m-%d")}} Pong, Message from {{ trigger.event.data["user_id"] }}.
        show_alert: true

#########################
### IK Security Alarm ###
#########################
- id: telegram-ik-security-alarm
  alias: 'Telegram Alarm'
  hide_entity: true
  trigger:
    - platform: event
      event_type: telegram_callback
      event_data:
        data: '/security'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'Alarm control'
    - service: telegram_bot.edit_message
      data_template:
        message_id: 'last'
        chat_id: '{{ trigger.event.data.user_id }}'
        message: >
            {% if is_state("input_boolean.burglar_alarm_door", "off") %}Alarm is OFF. {% else %}Alarm is ON. {% endif %}
            {% if is_state("input_boolean.away_scene", "off") %}Presence simulation is OFF. {% else %}Presence simulation is ON. {% endif %}
        inline_keyboard:
          - 'Away ON:/away_on, Away OFF:/away_off'
          - 'Alarm ON:/alarm_on, Alarm OFF:/alarm_off, Cancel:/cancel'


#####################
### IK Pizza Time ###
#####################
- alias: 'Want pizza?'
  hide_entity: true
  trigger:
    platform: time
    at: '18:30:00'    
  condition:
    - condition: state
      entity_id: device_tracker.iphonemarie
      state: 'home'
    - condition: state
      entity_id: device_tracker.nico_nico
      state: 'not_home'
  action:
    - service: telegram_bot.send_message
      data_template:
        title: 'Want pizza?'
        target: telegram ID
        message: 'You look like you are home alone. Should I order you a pizza?'
        inline_keyboard:
          - "Gimme Pizza:/gimmepizza"
          - "No thanks:/nopizza"

- alias: 'No pizza'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/nopizza'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'Ok, no pizza then'

- alias: 'gimme pizza'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/gimmepizza'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'PIZZA TIME'
    - service: dominos.order
      data:
        order_entity_id: dominos.medium_pan


#################
### IK Lights ###
#################
- alias: 'Lights Actions'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/lights'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'What you want to do with Lights?'  
    - service: telegram_bot.send_message
      data_template:
        title: 'Lights ON or OFF?'
        target: telegram ID
        message: 'Look like you want to turn on or off your lights. What you want to do?'
        inline_keyboard:
          - "ALL ON:/lighton, Living ON:/Living_on, Bedroom ON:/bedroom_on"
          - "ALL OFF:/lightoff, Living OFF :/Living_off, Bedroom OFF:/bedroom_off"
          - "Kitchen ON:/kitchen_on, BathRoom ON:/bath_on"
          - "Kitchen OFF:/kitchen_off, BathRoom OFF:/bath_off"

### All ligths
- alias: 'IK - Telegram - Light On'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/lighton'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'Lights ON'
    - service: light.turn_on
      data:
        entity_id: group.all_lights
        brightness: 255

- alias: 'IK - Telegram - Light Off'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/lightoff'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'Lights OFF'
    - service: light.turn_off
      data:
        entity_id: group.all_lights
        brightness: 0

### Living ###
- alias: 'IK - Telegram - Living Light On'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/Living_on'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'Living Lights ON'
    - service: light.turn_on
      data:
        entity_id: group.living_lights
        brightness: 255

- alias: 'IK - Telegram - Living Light OFF'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/Living_off'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'Living Lights OFF'
    - service: light.turn_on
      data:
        entity_id: group.living_lights
        brightness: 0

### Kitchen
- alias: 'IK - Telegram - Kitchen Light On'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/kitchen_on'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'Kitchen Lights ON'
    - service: light.turn_on
      data:
        entity_id: group.kitchen_lights
        brightness: 255

- alias: 'IK - Telegram - Kitchen Light OFF'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/kitchen_off'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'Kitchen Lights OFF'
    - service: light.turn_on
      data:
        entity_id: group.kitchen_lights
        brightness: 0


### Bed Room
- alias: 'IK - Telegram - BedRoom Light On'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/bedroom_on'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'BedRoom Lights ON'
    - service: light.turn_on
      data:
        entity_id: group.bedroom_lights
        brightness: 255

- alias: 'IK - Telegram - BedRoom Light OFF'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/bedroom_off'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'BedRoom Lights OFF'
    - service: light.turn_on
      data:
        entity_id: group.bedroom_lights
        brightness: 0

### Bath Room
- alias: 'IK - Telegram - BathRoom Light On'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/bath_on'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'BathRoom Lights ON'
    - service: light.turn_on
      data:
        entity_id: group.bathroom_lights
        brightness: 255

- alias: 'IK - Telegram - BathRoom Light OFF'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/bath_off'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'BathRoom Lights OFF'
    - service: light.turn_on
      data:
        entity_id: group.bath_lights
        brightness: 0


#################
### IK System ###
#################
- alias: 'HA System Actions'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/system'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'What actions you want to do on HA?'  
    - service: telegram_bot.send_message
      data_template:
        title: 'HA System Actions'
        target: telegram ID
        message: 'Look like you want to do something about your Home Assistant istance.. What you want to do?'
        inline_keyboard:
          - "Check Config:/config, Automation Reload:/automreload"
          - "SSL certificate:/ssl, SSL Renew:/sslrenew"
          - "HA Restart:/harestart, Host Reboot:/hassioreboot"
          


### Automation reload
- alias: 'IK - Telegram - Automation reload'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/automreload'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'Automation Reload'
    - service: script.reload_automations
    - service: notify.notify
      data:
        message: 'Automation - Reload - Triggered'

### HA Restart
- alias: 'IK - Telegram - HA Restart'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/harestart'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'HA restart'
    - service: script.restart_ha
    - service: notify.notify
      data:
        message: 'HA - Restart - Triggered'

### SSL Renew
- alias: 'IK - Telegram - SSL Renew'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/sslrenew'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'SSL Renew'
    - service: script.letsencrypt_renew
    - service: notify.notify
      data:
        message: 'SSL - Renew - Triggered'


### Host Reboot
- alias: 'IK - Telegram - Host Reboot'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/hassioreboot'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'Host Reboot'
    - service: hassio.host_reboot
    - service: notify.notify
      data:
        message: 'Host - Reboot - Triggered'


#################
### IK Addons ###
#################
- alias: 'Addons Actions'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/addons'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'What you want to do with these addons?'  
    - service: telegram_bot.send_message
      data_template:
        title: 'Addons'
        target: telegram ID
        message: 'Look like you want to turn on or off your Addons. What you want to do?'
        inline_keyboard:
          - "Web SSH ON:/webssh_on, Pi-Hole ON:/pihole_on"
          - "Web SSH OFF:/webssh_off, Pi-Hole OFF:/pihole_off"
          - "IDE ON:/ide_on, LogViewer ON:/logview_on"
          - "IDE OFF:/ide_off, LogViewer OFF:/logview_off"


### Web SSH ###
### Addon SSH Web Start
- alias: 'IK - Telegram - Addon SSH Web Start'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/webssh_on'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'Addon SSH Web Start - Triggered'
    - service: hassio.addon_start
      data:
        addon: "aaaaaaaaa_ssh"
    - service: notify.notify
      data:
        message: 'SSH Enabled... Web SSH is available at Http://x.x.x.x:7681'

### Addon SSH Web Stop
- alias: 'IK - Telegram - Addon SSH Web Stop'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/webssh_off'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'Addon SSH Web Stop - Triggered'
    - service: hassio.addon_stop
      data:
        addon: "aaaaaaaaa_ssh"
    - service: notify.notify
      data:
        message: 'Addon SSH Web Stopped'

### Addon Log Viewer Start
- alias: 'IK - Telegram - Addon  Log Viewer Start'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/logview_on'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'Addon  Log Viewer Start - Triggered'
    - service: hassio.addon_start
      data:
        addon: "aaaaaaaaa_logviewer"
    - service: notify.notify
      data:
        message: ' Log Viewer... Log Viewer is available at Http://x.x.x.x:4277'

### Addon Log Viewer Stop
- alias: 'IK - Telegram - Addon  Log Viewer Stop'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/logview_off'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'Addon  Log Viewer Stop - Triggered'
    - service: hassio.addon_stop
      data:
        addon: "aaaaaaaaa_logviewer"
    - service: notify.notify
      data:
        message: 'Addon  Log ViewerStopped'

### Addon Pi-Hole Start
- alias: 'IK - Telegram - Addon  Pi-Hole Start'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/logview_on'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'Addon  Pi-Hole Start - Triggered'
    - service: hassio.addon_start
      data:
        addon: "aaaaaaaaa_pi-hole"
    - service: notify.notify
      data:
        message: 'Pi-Hole is available at Http://x.x.x.x:4277'

### Addon Pi-Hole Stop
- alias: 'IK - Telegram - Addon  Pi-Hole Stop'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/logview_off'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'Addon  Pi-Hole Stop - Triggered'
    - service: hassio.addon_stop
      data:
        addon: "aaaaaaaaa_pi-hole"
    - service: notify.notify
      data:
        message: 'Addon  Pi-Hole Stopped'

### Addon IDE Start
- alias: 'IK - Telegram - Addon  IDE Start'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/ide_on'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'Addon  IDE Start - Triggered'
    - service: hassio.addon_start
      data:
        addon: "aaaaaaaaa_ide"
    - service: notify.notify
      data:
        message: 'IDE is available at Http://x.x.x.x:4277'

### Addon IDE Stop
- alias: 'IK - Telegram - Addon  IDE Stop'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/ide_off'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'Addon  IDE Stop - Triggered'
    - service: hassio.addon_stop
      data:
        addon: "aaaaaaaaa_ide"
    - service: notify.notify
      data:
        message: 'Addon  IDE Stopped'

full automations.yaml can be found here

16 Likes

This is exactly what I was looking for, you really seem to get the most out of the telegram bot, great job :smiley:

1 Like

Okay, I can’t figure out what I am missing here, if I use a simple notify approach, the bot repeats itself over and over, and if I try to emulate your code - it does nothing, no response.

Maybe you could point me in the right direction? I’m sure it’s just me not grasping the logic behind the bot code. The example below gives me a very usefull “unknown error for call_service at pos 1” in the logs.

#################################
#### Alfred START ###############
################################
 - alias: 'Alfred Start'
trigger:
  - platform: event
    event_type: telegram_command
    event_data:
      command: '/start'
  - platform: event
    event_type: telegram_command
    event_data:
      command: '/back'
action:
  service: notify.alfred
  data:
    message: >
     {{ [
     "You require Sir?",
     "What can I do for you Sir?",
     "Yes Sir!",
     "Good-day sir",
     "Yes Mr. Pedersen?"
     ] | random }}
    data:
      inline_keyboard:
        - 'News:/news, Weather:/weather'
        - 'Music:/music, Radio:/radio'
        - 'System:/system, Status:/status'
        - "Timers:/timers, Security:/security"
#### News MENU ##################
  - alias: 'Alfred NEWS'
trigger:
  platform: event
  event_type: telegram_callback
  event_data:
    data: '/news'
action:
  - service: telegram_bot.answer_callback_query
    data_template:
      callback_query_id: '{{ trigger.event.data.id }}'
      message: 'Bla bla bla'
      inline_keyboard:
        - 'Weather:/weather, Start:/start'
        - 'Music:/music, Radio:/radio'
#### Weather MENU ###############
  - alias: 'Alfred Weather'
trigger:
  platform: event
  event_type: telegram_callback
  event_data:
    data: '/weather'
action:
  - service: telegram_bot.answer_callback_query
    data_template:
      callback_query_id: '{{ trigger.event.data.id }}'
      message: 'Todays weather; {{ states.sensor.dark_sky_hourly_summary.state }}, with a temperature of {{ states.sensor.dark_sky_temperature.state }} °C vindspeed of {{ states.sensor.dark_sky_wind_speed.state }} m/s'
      inline_keyboard:
        - 'News:/news, Start:/start'
        - 'Music:/music, Radio:/radio'

Sorry for the late answer but I’m transfering to another house and I’m a little bit busy :slight_smile:

from the copy an past on this post seems the formatting isn’t in the right order and some logic are not correct…

first you need a /start command

### Start Keyboard ###
- id: telegram-start
  alias: 'Telegram Start Command'
  initial_state: 'on'
  trigger:
    platform: event
    event_type: telegram_command
    event_data:
      command: '/start'
  action:
  - service: notify.notify
    data:
      message: >
       {{ [
       "Hi",
       "Hello",
       "Yes Sir!",
       "it's a pleasure to see you again"
       ] | random }}       
      data:
        keyboard:
          - '/start, /cp'

and then add another command for call the IK menu (Inline Keyboard menu) in my case /cp (it’s for control panel) but can be /news if you prefer

so add an action on the command /cp

- id: telegram-control-pannel-start
  alias: 'Telegram Control Pannel Command'
  initial_state: 'on'
  trigger:
    platform: event
    event_type: telegram_command
    event_data:
      command: '/cp'
  action:
  - service: notify.hassnico_bot
    data:
      message: >
       {{ [
       "Home Assistant Status",
       "Control Panel",
       "Yes Sir!",
       "Home Assistant Control Panel",
       "Pannello di controllo"
       ] | random }}
      data:
        inline_keyboard:
          - 'Lights:/lights, Status:/status, Security:/security'
          - 'System:/system, Help:/help, Ping:/ping'
          - "Addons:/addons"

after this you have added the inline keyboard command as Lights:/ligths… so you can make action on this telegram callback.

this is the telegram callback

- alias: 'Lights Actions'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/lights'

on this telegram call back you can add actions:

I have done this action for example:

  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'What you want to do with Lights?'  
    - service: telegram_bot.send_message
      data_template:
        title: 'Lights ON or OFF?'
        target: xxxxyxyyxyyx
        message: 'Look like you want to turn on or off your lights. What you want to do?'
        inline_keyboard:
          - "ALL ON:/lighton, Living ON:/Living_on, Bedroom ON:/bedroom_on"
          - "ALL OFF:/lightoff, Living OFF :/Living_off, Bedroom OFF:/bedroom_off"
          - "Kitchen ON:/kitchen_on, BathRoom ON:/bath_on"
          - "Kitchen OFF:/kitchen_off, BathRoom OFF:/bath_off"

here there is another inline keyboard ALL ON:/lighton for turn on all lights:

- alias: 'IK - Telegram - Light On'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/lighton'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'Lights ON'
    - service: light.turn_on
      data:
        entity_id: group.all_lights
        brightness: 255

Hello,

I started to use home assistant a few days ago and I want to integrate Telegram Bot as well.
I managed to use Telegram Bot to turn the lights on and off and now I’m trying to get the status of the lights / devices (on / off / unavailable) but I have no idea how to do it.

I would like to obtain something like here: ( Telegram send status when requested ), the part from /lights

Do you have any idea how to do it?

Thank you!

Yeah, I still use it I just don’t have it on GitHub anymore. I’ll drop the code in next time I’m home at the laptop if nobody beats me to it.

Or you can rummage around in the history of my github repo and find the telegram files if you’re in a hurry.

I think I found it:

  • id: telegram-lightsstatus
    alias: Telegram - LightsStatus
    trigger:
    platform: event
    event_type: telegram_command
    event_data:
    command: /lights
    action:
    service: telegram_bot.send_message
    data_template:
    target: “{{ trigger.event.data.user_id }}”
    message: “Lights are -
    {% for state in states.light %}
    {{- state.name }} - {{ state.state_with_unit }}
    {% endfor %}”

But still something is not working, my bot is not answering when I use /lights button.

Have you made sure that the automation is formatted correctly and reloaded automations?

Any errors in the log?

I rebooted my VM to be sure, only error is: Invalid config for [automation]: [action] is an invalid option for [automation]. Check: automation->trigger->0->action. (See /config/configuration.yaml, line 12), I checked and I don’t understand why I have this error.

group: !include groups.yaml
automation: !include_dir_merge_list automations/
script: !include scripts.yaml
scene: !include scenes.yaml
#automation: !include automations.yaml

I checked again, line by line and I found two extra spaces, now is working!

Thank you for your time!

1 Like

No worries, glad you’re sorted :+1:

1 Like

I share a keyboard option. This is the control of the intercom.

image

- alias: 'Телеграм: Домофон. Управление'
  description: Управление домофоном через телеграм
  trigger:
  - platform: event
    event_type: telegram_callback
    event_data: {}
  condition: []
  action:
  - choose:
    - conditions:
      - condition: template
        value_template: '{{ trigger.event.data.command == ''/domofon'' }}'
      sequence:
      - service: telegram_bot.send_message
        data:
          target: '{{ trigger.event.data.chat_id }}'
          message: &msg |
            {{'\U00002699'}} ДОМОФОН - настройки:
          inline_keyboard: &keyb
          - '{% if is_state(''switch.domofon_automatically_open_once'', ''off'')%}{{''🔴''}}{%
            else %}{{''🟢''}}{% endif %} Автооткрытие 1 раз:/domofon_open_once, {%
            if is_state(''switch.domofon_automatically_open'', ''off'') %}{{''🔴''}}{%
            else %}{{''🟢''}}{% endif %} Автооткрытие:/domofon_open_always'
          - '{% if is_state(''switch.domofon_mute_sound_once'', ''off'') %}{{''🔴''}}{%
            else %}{{''🟢''}}{% endif %} Звук 1 раз:/domofon_mute_sound_once, {% if
            is_state(''switch.domofon_mute_sound'', ''off'') %}{{''🔴''}}{% else %}{{''🟢''}}{%
            endif %} Звук:/domofon_mute_sound'
          - '{% if is_state(''switch.domofon_automatically_reject'', ''off'') %}{{''🔴''}}{%
            else %}{{''🟢''}}{% endif %} Игнор:/domofon_reject_always'
          - Назад:/backhome
      - service: telegram_bot.delete_message
        data:
          message_id: '{{ trigger.event.data.message.message_id }}'
          chat_id: '{{ trigger.event.data.chat_id }}'
    - conditions:
      - condition: template
        value_template: '{{ trigger.event.data.command == ''/domofon_open_once'' }}'
      sequence:
      - service: switch.toggle
        target:
          entity_id: switch.domofon_automatically_open_once
      - delay:
          milliseconds: 500
      - service: telegram_bot.edit_message
        data:
          message_id: '{{ trigger.event.data.message.message_id }}'
          chat_id: '{{ trigger.event.data.user_id }}'
          callback_query_id: '{{ trigger.event.data.id }}'
          message: *msg
          inline_keyboard: *keyb
    - conditions:
      - condition: template
        value_template: '{{ trigger.event.data.command == ''/domofon_open_always''
          }}'
      sequence:
      - service: switch.toggle
        target:
          entity_id: switch.domofon_automatically_open
      - delay:
          milliseconds: 500
      - service: telegram_bot.edit_message
        data:
          message_id: '{{ trigger.event.data.message.message_id }}'
          chat_id: '{{ trigger.event.data.user_id }}'
          callback_query_id: '{{ trigger.event.data.id }}'
          message: *msg
          inline_keyboard: *keyb
    - conditions:
      - condition: template
        value_template: '{{ trigger.event.data.command == ''/domofon_reject_always''
          }}'
      sequence:
      - service: switch.toggle
        target:
          entity_id: switch.domofon_automatically_reject
      - delay:
          milliseconds: 500
      - service: telegram_bot.edit_message
        data:
          message_id: '{{ trigger.event.data.message.message_id }}'
          chat_id: '{{ trigger.event.data.user_id }}'
          callback_query_id: '{{ trigger.event.data.id }}'
          message: *msg
          inline_keyboard: *keyb
    - conditions:
      - condition: template
        value_template: '{{ trigger.event.data.command == ''/domofon_mute_sound''
          }}'
      sequence:
      - service: switch.toggle
        target:
          entity_id: switch.domofon_mute_sound
      - delay:
          milliseconds: 500
      - service: telegram_bot.edit_message
        data:
          message_id: '{{ trigger.event.data.message.message_id }}'
          chat_id: '{{ trigger.event.data.user_id }}'
          callback_query_id: '{{ trigger.event.data.id }}'
          message: *msg
          inline_keyboard: *keyb
    - conditions:
      - condition: template
        value_template: '{{ trigger.event.data.command == ''/domofon_mute_sound_once''
          }}'
      sequence:
      - service: switch.toggle
        target:
          entity_id: switch.domofon_mute_sound_once
      - delay:
          milliseconds: 500
      - service: telegram_bot.edit_message
        data:
          message_id: '{{ trigger.event.data.message.message_id }}'
          chat_id: '{{ trigger.event.data.user_id }}'
          callback_query_id: '{{ trigger.event.data.id }}'
          message: *msg
          inline_keyboard: *keyb
    default: []
  mode: single
6 Likes

Hi,
Thanks for your tuto.
It’s possible to add a “back button” to come back to previous menu ?