Untitled

 avatar
unknown
plain_text
18 days ago
4.5 kB
3
Indexable
alias: Check Windows - Gregor
description: >-
  Checks all Aqara window/door sensors and sends separate notifications for each
  room
triggers:
  - event_type: check_aqara_g
    trigger: event
actions:
  - data:
      message: Check Aqara automation triggered
      level: info
    action: system_log.write
  - variables:
      open_count: 0
      dnevna_open: []
      pisarna_open: []
      kuhinja_open: []
      p1s_open: false
  - if:
      condition: state
      entity_id: binary_sensor.dnevna_spalnica_left_window_contact
      state: "on"
    then:
      - variables:
          dnevna_open: "{{ dnevna_open + ['Left'] }}"
          open_count: "{{ open_count + 1 }}"
  - if:
      condition: state
      entity_id: binary_sensor.dnevna_spalnica_middle_window_contact
      state: "on"
    then:
      - variables:
          dnevna_open: "{{ dnevna_open + ['Middle'] }}"
          open_count: "{{ open_count + 1 }}"
  - if:
      condition: state
      entity_id: binary_sensor.dnevna_spalnica_right_window_contact
      state: "on"
    then:
      - variables:
          dnevna_open: "{{ dnevna_open + ['Right'] }}"
          open_count: "{{ open_count + 1 }}"
  - if:
      condition: state
      entity_id: binary_sensor.kuhinja_left_window_contact
      state: "on"
    then:
      - variables:
          kuhinja_open: "{{ kuhinja_open + ['Left'] }}"
          open_count: "{{ open_count + 1 }}"
  - if:
      condition: state
      entity_id: binary_sensor.kuhinja_right_window_contact
      state: "on"
    then:
      - variables:
          kuhinja_open: "{{ kuhinja_open + ['Right'] }}"
          open_count: "{{ open_count + 1 }}"
  - if:
      condition: state
      entity_id: binary_sensor.p1s_black_door_contact
      state: "on"
    then:
      - variables:
          p1s_open: true
          open_count: "{{ open_count + 1 }}"
  - if:
      condition: state
      entity_id: binary_sensor.pisarna_left_window_contact
      state: "on"
    then:
      - variables:
          pisarna_open: "{{ pisarna_open + ['Left'] }}"
          open_count: "{{ open_count + 1 }}"
  - if:
      condition: state
      entity_id: binary_sensor.pisarna_right_window_contact
      state: "on"
    then:
      - variables:
          pisarna_open: "{{ pisarna_open + ['Right'] }}"
          open_count: "{{ open_count + 1 }}"
  - if:
      condition: template
      value_template: "{{ dnevna_open | length > 0 }}"
    then:
      - variables:
          dnevna_msg: |-
            {% if dnevna_open | length == 3 %}
              All open
            {% else %}
              {{ dnevna_open | join(' and ') }} open
            {% endif %}
      - data:
          title: Dnevna
          message: "{{ dnevna_msg }}"
          data:
            priority: high
        action: notify.mobile_app_iphone
  - if:
      condition: template
      value_template: "{{ kuhinja_open | length > 0 }}"
    then:
      - variables:
          kuhinja_msg: |-
            {% if kuhinja_open | length == 2 %}
              All open
            {% else %}
              {{ kuhinja_open | join(' and ') }} open
            {% endif %}
      - data:
          title: Kuhinja
          message: "{{ kuhinja_msg }}"
          data:
            priority: high
        action: notify.mobile_app_iphone
  - if:
      condition: template
      value_template: "{{ pisarna_open | length > 0 }}"
    then:
      - variables:
          pisarna_msg: |-
            {% if pisarna_open | length == 2 %}
              All open
            {% else %}
              {{ pisarna_open | join(' and ') }} open
            {% endif %}
      - data:
          title: Pisarna
          message: "{{ pisarna_msg }}"
          data:
            priority: high
        action: notify.mobile_app_iphone
  - if:
      condition: template
      value_template: "{{ p1s_open }}"
    then:
      - data:
          title: P1S
          message: Black Door open
          data:
            priority: high
        action: notify.mobile_app_iphone
  - if:
      - condition: template
        value_template: "{{ open_count == 0 }}"
    then:
      - data:
          message: All windows/doors are closed
          level: info
        action: system_log.write
      - data:
          title: Status
          message: All closed
        action: notify.mobile_app_iphone
Editor is loading...
Leave a Comment