How to check for non blank values

Dear community,
I am new to Yaml, I have programmed quite a bit in ABAP. I am trying to find a way to return a true value in a variable if the return variable of my get.calendar.event is not blank (contains any value). My code is as follows:

alias: Check Vacations For next week for Alarm
description: “”
triggers:

  • at: “20:00:00”
    trigger: time
    weekday:
    • sun
      conditions:
      actions:
  • sequence:
    • alias: Get calendar events for Monday
      data:
      start_date_time: “{{ today_at() + timedelta(days=1) }}”
      duration:
      hours: 24
      response_variable: agenda_mo
      action: calendar.get_events
      target:
      entity_id:
      - calendar.vacations
      - calendar.spain_ct
    • variables:
      Monday: >
      {{ agenda_mo[‘calendar.vacations’].events | selectattr(‘summary’,
      ‘search’, ‘X’, true) | list | count > 0 }}
  • parallel:
    • alias: If Monday is Vacation Turn off Monday Alarm
      if:
      • condition: template
        value_template: “{{ Monday == true }}”
        then:
      • type: turn_off
        device_id: xxxxxxx
        entity_id: xxxxxxx
        domain: switch

I have tried to repace the X with many different values but it only works if the text matches with the text of the event. Is there any way to just return true if the attributr summary has any none blank value? like in ABAP wildcard *?

https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

1 Like