Weird Actionable Notification Bug

Hi,

Below you will find my actionable notification automation code and scripts. As a summary; I have an automation to trigger 4 different scripts. These scripts send actionable notification to 2 people (Cenk and Derya)
If Cenk confirms the action a message sent to Derya saying “Cenk confirmed” or If Cenk dismiss the action a message is sent to Derya saying “Cenk dismissed” This logic is also valid for Derya. Here the bug is start.

IF I run the “Scripts” MANUALLY and Cenk confirmed the action a message is sent to Derya saying “Cenk confirmed”. This is ok. BUT If automation is TRIGGERED to call the scripts and Cenk confirmed then a message is sent to Derya saying “Cenk Confirmed” and ANOTHER message sent TO CENK!! saying “Derya Confirmed” :slight_smile:

Anyone have thoughts? What can be diffetence between manual triggering a script and automation call. result should be the same at the end of the day. Thank you.

Script:

alias: Confirmable Notification - (Watering Flowers to Cenk)
mode: restart
icon: mdi:flower-poppy
sequence:
  - alias: Set up variables for the actions
    variables:
      action_confirm: "{{ 'CONFIRM_' ~ context.id }}"
      action_dismiss: "{{ 'DISMISS_' ~ context.id }}"
  - alias: Ask to water flowers
    service: notify.mobile_app_cenk
    data:
      message: Time to give some water to our lovely flowers!
      data:
        actions:
          - action: "{{ action_confirm }}"
            title: ✅ Yes, I will
          - action: "{{ action_dismiss }}"
            title: ❌ No, I can't
  - alias: Wait for a response
    wait_for_trigger:
      - platform: event
        event_type: mobile_app_notification_action
        event_data:
          action: "{{ action_confirm }}"
      - platform: event
        event_type: mobile_app_notification_action
        event_data:
          action: "{{ action_dismiss }}"
  - alias: Perform the action
    choose:
      - conditions:
          - condition: template
            value_template: "{{ wait.trigger.event.data.action == action_confirm }}"
        sequence:
          - service: notify.mobile_app_derya
            data:
              message: Yes, I will
              title: ✅ Cenk Confirmed!
      - conditions:
          - condition: template
            value_template: "{{ wait.trigger.event.data.action == action_dismiss }}"
        sequence:
          - service: notify.mobile_app_derya
            data:
              message: No, I can't
              title: ❌ Cenk Dismissed!

Automation

alias: Reminder (Watering the Plants)
description: ""
trigger:
  - platform: time
    at: "22:47:00"
condition: []
action:
  - if:
      - condition: time
        weekday:
          - mon
          - wed
          - sun
    then:
      - parallel:
          - service: script.watering_tree_to_derya
            data: {}
          - service: script.watering_tree_to_cenk
            data: {}
    else:
      - if:
          - condition: time
            weekday:
              - fri
              - sat
        then:
          - parallel:
              - service: script.watering_flowers_to_derya
                data: {}
              - service: script.watering_flowers_to_cenk
                data: {}
        else:
          - delay:
              hours: 0
              minutes: 0
              seconds: 0
              milliseconds: 250
mode: single
1 Like

Did you listen on the event between a manual and a triggered run?? I would guess the context.IDs are making the issue.

You can also check that in the script debugging under the changed variables.

Thanks for your time. I am coding as a hobby I am not a developer so I am so sorry if I tell something stupid. Here is the changed variables. I would be happy if you can check them

If I run script manually

this:
  entity_id: script.watering_flowers_to_cenk
  state: 'off'
  attributes:
    last_triggered: '2022-08-27T20:18:17.379351+00:00'
    mode: restart
    current: 0
    icon: mdi:flower-poppy
    friendly_name: Confirmable Notification - (Watering Flowers to Cenk)
  last_changed: '2022-08-27T20:37:43.272858+00:00'
  last_updated: '2022-08-27T20:37:43.272858+00:00'
  context:
    id: 01GBGGCXXXXXX53563Y
    parent_id: null
    user_id: null
context:
  id: 01GBGGGNXXXXXXA7DRTF4031
  parent_id: null
  user_id: 	97fc53f8xxxxxxxxxxxxxxxaea17b8b

If automation is triggered

this:
  entity_id: script.watering_flowers_to_cenk
  state: 'off'
  attributes:
    last_triggered: '2022-08-27T20:39:56.250295+00:00'
    mode: restart
    current: 0
    icon: mdi:flower-poppy
    friendly_name: Confirmable Notification - (Watering Flowers to Cenk)
  last_changed: '2022-08-27T20:40:04.726193+00:00'
  last_updated: '2022-08-27T20:40:04.726193+00:00'
  context:
    id: 01GBGGGXXXXXXX7BFAG0
    parent_id: null
    user_id: null
context:
  id: 01GBGGJTXXXXXX0XW35AYB
  parent_id: 01GBGGJXXXXXXXX7N59PC
  user_id: null

I created 4 different automations for each scripts. So they are being called separately. I think if they are called via single automation then the event id is sent same and it goes crazy :slight_smile:

Weird bug because I am calling scripts seperately with 1 second delay