Help with Door/Window open Automation Blueprint

Hi there,

these are my first steps to make a blueprint, so thank you for being lenient with me… :see_no_evil:

Tried to modifiy this blueprint to use in another scenario: I want to check periodically if any windows or doors are open and then to be notified of.

Sadly my condition seems to be wrong as the blueprint cannot be loaded.

Any help would be really appreciated -
thank you!

blueprint:
  name: Open Window detection & notification for all contact sensors
  description: Regularly test all sensors with 'door' or 'window' device-class 
    for being open and if so execute an action.
  domain: automation
  input:
    time_period:
      name: Time period to test on
      description: Test is run at configured time period
      default: '5'
      selector:
        number:
          min: 1
          max: 30
          unit_of_measurement: 'min'
          mode: slider
          step: 1
    exclude:
      name: Excluded Sensors
      description: Contact sensors (e.g. internal doors) to exclude from detection. Only
        entities are supported, devices must be expanded!
      default:
        entity_id: []
      selector:
        target:
          entity:
            - device_class: door
            - device_class: window
    actions:
      name: Actions
      description: Notifications or similar to be run. {{sensors}} is replaced with
        the names of sensors being open.
      selector:
        action: {}
variables:
  time_period: !input time_period
  exclude: !input exclude
  sensors: >-
    {% set result = namespace(sensors=[]) %} 
    {% for state in states.sensor | selectattr('attributes.device_class', '==', 'binary_sensor') %}\n  
      {% if 'on' <= state.state | int and not state.entity_id in exclude.entity_id %}
        {% set result.sensors = result.sensors + [state.name ~ ' (' ~ state.state ~ ' %)'] %}
      {% endif %}
    {% endfor %} 
    {% for state in states.binary_sensor | selectattr('attributes.device_class', '==', 'binary_sensor') | selectattr('state', '==', 'on') %}
      {% if not state.entity_id in exclude.entity_id %}
        {% set result.sensors = result.sensors + [state.name] %}
      {% endif %}
    {% endfor %}
    {{result.sensors|join(', ')}}
trigger:
- platform: time_pattern
  minutes: /!input time_period
condition:
- '{{ is_state (sensors != '''', 'on') }}'
action:
- choose: []
  default: !input actions
mode: single

Maybe this can help :wink: Yet not another door/window/sensor open warning notification with auto close and reminder

condition: "{{ is_state (sensors != '''', 'on') }}"

Formatting and inner quotes same as outer quotes.

If one of the suggestions listed solves your problem, please consider clicking the solution button to close the thread.

Also topic should be changed from ‘Blueprints Exchange’ to ‘Configuration - Blueprints’ as it deals with a general question as opposed to offering a blueprint for exchange.

THANKS A LOT :kissing: