Door sensor timer

Hello,

I’m trying to do the following. If Someone opens the door and it is not closed after 2 spoken messages, the messages should repeat untill the door is closed

I have an automation to check but it stops after 2 spoken messages. I have another automation to check if the door is closed and I get a message when the door is closed.

I hope someone can help me to get messages until the door is closed.

Thx for looking

alias: Iemand komt binnen
description: Open
trigger:
  - platform: state
    entity_id:
      - binary_sensor.aqara_door_and_window_sensor_p2_deur
    from: "off"
    to: "on"
condition:
  - condition: state
    entity_id: binary_sensor.aqara_door_and_window_sensor_p2_deur
    state: "on"
    enabled: false
action:
  - service: media_player.play_media
    target:
      entity_id: media_player.wekker
    data:
      media_content_id: >-
        media-source://tts/tts.google_en_com?message=Voordeur+is+geopend&language=nl
      media_content_type: provider
    metadata:
      title: Voordeur is geopend
      thumbnail: https://brands.home-assistant.io/_/tts/logo.png
      media_class: app
      children_media_class: null
      navigateIds:
        - {}
        - media_content_type: app
          media_content_id: media-source://tts
        - media_content_type: provider
          media_content_id: >-
            media-source://tts/tts.google_en_com?message=Voordeur+is+geopend&language=nl
  - service: media_player.play_media
    target:
      entity_id: media_player.radio
    data:
      media_content_id: >-
        media-source://tts/tts.google_en_com?message=Voordeur+is+geopend&language=nl
      media_content_type: provider
    metadata:
      title: Voordeur is geopend
      thumbnail: https://brands.home-assistant.io/_/tts/logo.png
      media_class: app
      children_media_class: null
      navigateIds:
        - {}
        - media_content_type: app
          media_content_id: media-source://tts
        - media_content_type: provider
          media_content_id: >-
            media-source://tts/tts.google_en_com?message=Voordeur+is+geopend&language=nl
    enabled: true
  - delay:
      hours: 0
      minutes: 0
      seconds: 3
      milliseconds: 0
  - service: media_player.turn_off
    metadata: {}
    data: {}
    target:
      device_id:
        - 77310f2a090febe47323a226e07fe42c
        - 0a35fa3e9ba2c4c2737afeb43ef6b19c
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - choose:
      - conditions:
          - type: is_not_open
            condition: device
            device_id: 53a4f102cf90cbd563dd287983462bf5
            entity_id: a076c02a70725e1a97e6c4f84667da3d
            domain: binary_sensor
        sequence:
          - service: media_player.play_media
            target:
              entity_id: media_player.radio
            data:
              media_content_id: >-
                media-source://tts/tts.google_en_com?message=Voordeur+is+dicht&language=nl
              media_content_type: provider
            metadata:
              title: Voordeur is dicht
              thumbnail: https://brands.home-assistant.io/_/tts/logo.png
              media_class: app
              children_media_class: null
              navigateIds:
                - {}
                - media_content_type: app
                  media_content_id: media-source://tts
                - media_content_type: provider
                  media_content_id: >-
                    media-source://tts/tts.google_en_com?message=Voordeur+is+dicht&language=nl
      - conditions:
          - type: is_open
            condition: device
            device_id: 53a4f102cf90cbd563dd287983462bf5
            entity_id: a076c02a70725e1a97e6c4f84667da3d
            domain: binary_sensor
        sequence:
          - service: media_player.play_media
            target:
              entity_id: media_player.radio
            data:
              media_content_id: >-
                media-source://tts/tts.google_en_com?message=Voordeur+staat+nog+steeds+open&language=nl
              media_content_type: provider
            metadata:
              title: Voordeur staat nog steeds open
              thumbnail: https://brands.home-assistant.io/_/tts/logo.png
              media_class: app
              children_media_class: null
              navigateIds:
                - {}
                - media_content_type: app
                  media_content_id: media-source://tts
                - media_content_type: provider
                  media_content_id: >-
                    media-source://tts/tts.google_en_com?message=Voordeur+staat+nog+steeds+open&language=nl
mode: restart

Please format your automation properly. See How to help us help you - or How to ask a good question - #3 for more details

I use action “repeat - until”. Your “until” is when door is closed.
Example below executes a script every minute, until one of two conditions is met. I hope it will help.

action:
  - repeat:
      until:
        - condition: or
          conditions:
            - condition: state
              entity_id: input_boolean.pasja_voda
              state: "off"
            - condition: state
              entity_id: binary_sensor.pasja_voda_nivo
              state: "off"
      sequence:
        - service: script.hp_ha_kuhinja_posoda_za_vodo
          data: {}
        - delay:
            hours: 0
            minutes: 1
            seconds: 0
            milliseconds: 0
1 Like

What does this do? I should replace it with?

Thx for helping me

In my case this triggers my custom script. In your case replace it with your action (like media_server.play_media).

i don’t understand dutch and i don’t understand your media player, but i’ll presume you’ve got that figured out.

i don’t understand also why you have the first block of hard coded voice messages twice, so i deleted those…

here’s my resulting version:

alias: Iemand komt binnen
description: Open
trigger:
  - platform: state
    entity_id:
      - binary_sensor.aqara_door_and_window_sensor_p2_deur
    from: "off"
    to: "on"
condition: []
action:
  - repeat:
      sequence:
        - service: media_player.play_media
          target:
            entity_id: media_player.radio
          data:
            media_content_id: >-
              media-source://tts/tts.google_en_com?message=Voordeur+staat+nog+steeds+open&language=nl
            media_content_type: provider
          metadata:
            title: Voordeur staat nog steeds open
            thumbnail: https://brands.home-assistant.io/_/tts/logo.png
            media_class: app
            children_media_class: null
            navigateIds:
              - {}
              - media_content_type: app
                media_content_id: media-source://tts
              - media_content_type: provider
                media_content_id: >-
                  media-source://tts/tts.google_en_com?message=Voordeur+staat+nog+steeds+open&language=nl
        - delay:
            seconds: 5
      while:
        - condition: state
          entity_id:
            - binary_sensor.aqara_door_and_window_sensor_p2_deur
          state: "on"
  - service: media_player.play_media
    target:
      entity_id: media_player.radio
    data:
      media_content_id: >-
        media-source://tts/tts.google_en_com?message=Voordeur+is+dicht&language=nl
      media_content_type: provider
    metadata:
      title: Voordeur is dicht
      thumbnail: https://brands.home-assistant.io/_/tts/logo.png
      media_class: app
      children_media_class: null
      navigateIds:
        - {}
        - media_content_type: app
          media_content_id: media-source://tts
        - media_content_type: provider
          media_content_id: >-
            media-source://tts/tts.google_en_com?message=Voordeur+is+dicht&language=nl
mode: restart

1 Like

Hello armedad,

This works perfect. I just figured out how to do it myself using:

alias: "Voordeur "
description: open/dicht
trigger:
  - platform: state
    entity_id:
      - binary_sensor.aqara_door_and_window_sensor_p2_deur
    to: "on"
    from: "off"
condition: []
action:
  - repeat:
      sequence:
        - service: script.voordeur_open
          data: {}
        - delay:
            hours: 0
            minutes: 0
            seconds: 15
            milliseconds: 0
      while:
        - condition: state
          entity_id: binary_sensor.aqara_door_and_window_sensor_p2_deur
          state: "on"
  - service: script.voordeur_dicht
    metadata: {}
    data: {}
mode: single

Thx Guys

1 Like