Actionable notifications error since 2024.02

HI!
I have a problem since 2024.02. update.

My automation send an Actionable notification to my phone when i power on my TV, and ask if i want to start Home Theater too or not.
If i click YES> a script starts my HomeTheater
If I click NO > Then i got another notification that it is paused
BUT if i don’t hit anything in 60 sec the automation should continue, and clear the notification from my phone after a few minutes. ANd the problem is with this scenario.

Here is my automation:

alias: Tv után LG
description: ""
trigger:
  - platform: state
    entity_id: media_player.my_tv_3
    for:
      hours: 0
      minutes: 0
      seconds: 1
    to: "on"
    from: "off"
condition:
  - condition: time
    after: "15:00:00"
    before: "23:00:00"
action:
  - alias: Set up variables for the actions
    variables:
      action_open: "{{ 'OPEN_' ~ context.id }}"
      action_close: "{{ 'CLOSE_' ~ context.id }}"
  - service: notify.mobile_app_mi_8
    data:
      data:
        actions:
          - action: "{{ action_open }}"
            title: Igen
          - action: "{{ action_close }}"
            title: NEM
        tag: lg_hazimozi
      title: LG házimozi automatizáció
      message: Folytatja?
  - alias: Wait for a response
    wait_for_trigger:
      - platform: event
        event_type: mobile_app_notification_action
        event_data:
          action: "{{ action_open }}"
      - platform: event
        event_type: mobile_app_notification_action
        event_data:
          action: "{{ action_close }}"
    continue_on_timeout: true
    timeout: "60"
  - alias: Perform the action
    choose:
      - conditions:
          - condition: template
            value_template: "{{ wait.trigger.event.data.action == action_open }}"
        sequence:
          - service: script.lg_aux_opt
            data: {}
      - conditions:
          - condition: template
            value_template: "{{ wait.trigger.event.data.action == action_close }}"
        sequence:
          - service: shell_command.test_pause
            data: {}
    default:
      - delay:
          hours: 0
          minutes: 0
          seconds: 1
          milliseconds: 0
  - delay:
      hours: 0
      minutes: 5
      seconds: 0
      milliseconds: 0
  - service: notify.mobile_app_mi_8
    data:
      message: clear_notification
      data:
        tag: lg_hazimozi
mode: single

PROBLEM: If i don’t choose from options on my phone i got this error log, and my whole disk get flood. (more then 10GB after a few hours) and only restart could stop logging errors.

ERROR LOG (many many times)

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 637, in async_trigger
    and not self._cond_func(variables)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 1014, in if_action
    if check(hass, variables) is False:
       ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/condition.py", line 179, in wrapper
    result = condition(hass, variables)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/condition.py", line 787, in template_if
    return async_template(hass, value_template, variables)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/condition.py", line 767, in async_template
    info = value_template.async_render_to_info(variables, parse_result=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 687, in async_render_to_info
    assert self.hass and _render_info.get() is None
AssertionError

I also got this in my log:

2024-03-07 11:59:23.842 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: 'None' has no attribute 'event' when rendering '{{ wait.trigger.event.data.action == action_open }}'
2024-03-07 11:59:23.842 WARNING (MainThread) [homeassistant.helpers.script] Error in 'choose[0]' evaluation: In 'template' condition: UndefinedError: 'None' has no attribute 'event'
2024-03-07 11:59:23.842 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: 'None' has no attribute 'event' when rendering '{{ wait.trigger.event.data.action == action_close }}'
2024-03-07 11:59:23.843 WARNING (MainThread) [homeassistant.helpers.script] Error in 'choose[0]' evaluation: In 'template' condition: UndefinedError: 'None' has no attribute 'event'

I have been experiencing the same error you describe since 2024.02, but I haven’t figured out yet what is causing it, I don’t use the mobile notifications, so it must be another thing in my case, but as you describe it floods the disk after a few hours, in my case it also causes the whole Pi to crash if I don’t restart it before.

I setted up an automation to notify me when the CPU temperature goes above the normal values for my setup, to be aware.

Today it already happened 3 times.
chrome_uV2DjsPrQ6

Captura de pantalla 2024-03-09 113037

I’ll keep investigating.

Your problem is that wait.trigger.event doesn’t exist if you didn’t press the button, so you need to check on that in your template, or you need to change the order in which the options are checked:

Either:

  - alias: Perform the action
    choose:
      - conditions:
          - condition: template
            value_template: >
              {{
                wait.trigger is not none 
                and wait.trigger.event.data.action == action_open
              }}
        sequence: 
          - service: script.lg_aux_opt
      - conditions:
          - condition: template
            value_template: >
              {{
                wait.trigger is not none 
                and wait.trigger.event.data.action == action_close
              }}
        sequence:
          - service: shell_command.test_pause
    default:
      - delay:
          seconds: 1

Or:

  - alias: Perform the action
    choose:
      - conditions:
          - condition: template
            value_template: "{{ wait.trigger is none }}"
        sequence:
          - delay:
              seconds: 1
      - conditions:
          - condition: template
            value_template: "{{ wait.trigger.event.data.action == action_open }}"
        sequence: 
          - service: script.lg_aux_opt
      - conditions:
          - condition: template
            value_template: "{{ wait.trigger.event.data.action == action_close }}"
        sequence:
          - service: shell_command.test_pause

Thanks man. I tried the first method, and I think that it worked!! I’m still testing, but no error since change.

The AssertionError should normally not be reachable, which indicates you have an integration doing non-threadsafe operations on asyncio objects which is corrupting the internal asyncio state.

When an integration modifies the event loop internals from another thread the behavior is undefined and will usually eventually lead to a crash.

If you put asyncio in debug mode, it will be able to detect some of these bad calls and maybe even block them. You can use the profiler service to do that:
https://www.home-assistant.io/integrations/profiler/#service-profilerset_asyncio_debug

If you can’t get far enough along you can also enable debugpy: in configuration.yaml instead (but its much slower)
https://www.home-assistant.io/integrations/debugpy/