Syntax help: Automation to stop automation via telegram

Hi all,

trying to get an automation that sends me a telegram message if specific states of the PV is reached and I want to press a button in telegram how long I want that automation to stop.

This is what I got so far: (XXX is where I shortened for this post, am aware of that)

alias: test
description: "ein test"
trigger:
  - platform: numeric_state
    entity_id: XXX
    above: 2000
    for:
      hours: 0
      minutes: 10
      seconds: 0
condition:
  - type: is_battery_level
    condition: device
    device_id: XXX
    entity_id: sensor.battery_state_of_charge
    domain: sensor
    above: 95
action:
  - service: notify.telegram_XXX
    data:
      message: "Gute Zeit zum Wäsche waschen. Nachrichten pausieren? Wie lange?"
      reply_markup:
        inline_keyboard:
          - [ {text: "1 Stunde", callback_data: "1_hour_pause"} ]
          - [ {text: "2 Stunden", callback_data: "2_hour_pause"} ]
          - [ {text: "Stop", callback_data: "stop_automation"} ]
      parse_mode: "Markdown"
  - wait_for_trigger:
      - platform: event
        event_type: telegram_callback
    timeout: "00:00:30"
    continue_on_timeout: true
    variables:
      pause_duration: "{{ {'1_hour_pause': '01:00:00', '2_hour_pause': '02:00:00'}[trigger.event.data] }}"
      stop_automation: "{{ trigger.event.data == 'stop_automation' }}"
    data:
      pause_duration: "{{ pause_duration }}"
      stop_automation: "{{ stop_automation }}"
  - choose:
      - conditions:
          - "{{ stop_automation }}"
        sequence:
          - wait_template: "{{ states('sensor.time') == '09:00' }}"
          - service: automation.turn_on
            entity_id: automation.test
          - service: notify.telegramXXX
            data:
              message: "Die Automation ist jetzt wieder aktiv."
              parse_mode: "Markdown"
      - conditions: []
        sequence:
          - service: automation.turn_off
            entity_id: automation.test
          - delay: "{{ pause_duration }}"
          - service: automation.turn_on
            entity_id: automation.test
          - service: notify.telegramXXX
            data:
              message: "Die Automation ist jetzt wieder aktiv."
              parse_mode: "Markdown"

Getting Error: Message malformed: extra keys not allowed @ data[‘action’][1][‘variables’]

I can’t find the error, what am I doing wrong?

Error message says extra keys ‘variables’ is not allowed under action 1.

Action 0 is the first action in your case send telegram, action 1 is therefore the 2nd action, in your case is wait for trigger.

So error message quite rightly states that you can’t have variables nested within a wait for trigger action, it’s not an option of wait for trigger.

anyone any suggestions on how I could make that work than?