Hi, just testing notifications

I am a bit of starting to “play” with HA automations

for that I have started with a door sensor and trying to send notifications to 2 devices

thisnis how ffar I have got. and works great!!!

alias: Puerta abierta +30
description: La puerta lleva abierta + de 30m  tras la puesta del sol.
trigger:
  - type: opened
    platform: device
    device_id: bf74e3e1c26adc5b2a1b1ba859b9a16a
    entity_id: ec50a80aa65e529895564bed3aad72d3
    domain: binary_sensor
    for:
      hours: 0
      minutes: 5
      seconds: 0
condition:
  - condition: and
    conditions:
      - condition: sun
        before: sunrise
      - condition: sun
        after: sunset
action:
  - parallel:
      - service: notify.mobile_app_mipad
        metadata: {}
        data:
          message: Puerta exterior abierta durante +5min. Por favor compruebe!
          title: ALERTA!
          data:
            subject: deberías comprobarlo
      - service: notify.mobile_app_mi14
        metadata: {}
        data:
          message: Puerta exterior abierta durante +5min. Por favor compruebe!
          title: ALERTA!
          data:
            subject: deberías comprobarlo
            color: "#00ac1d"
            message: >
              Este es un mensaje <span style="color:
              #FF0004">importante&nbsp;</span><span style="color: #000000">La
              puerta exterior ha estado abierta durante demasiado tiempo para
              ser de noche</span>Por favor compruébelo&nbsp;
      - service: notify.mobile_app_iphone_de_pilar
        data:
          data:
            subtitle: deberías comprobarlo
          title: ALERTA!
          message: Puerta exterior abierta durante +5min. Por favor compruebe!
mode: restart

what I see is that when the first message is sent, the automation stops looking for the door, if its opened or not, so I won´t receive further messeges after the firts one.

is it possibble, sure it is jeje, to tell the automation to keep cheeking the door state, even better, to tell what time after the first message to start looking again?

and how to, for example
send the first with green icon, the second alert make it yellow and a third with red icon?

let´s see what we can do

thank you in advance

Try changing the trigger from device to state. Like this:

trigger:
  - platform: state
    entity_id:
      - binary_sensor.front_door_sensor_opening
    from: "off"
    to: "on"

I use a similar automation, it works each time.

1 Like

nice, I´ll try.thankl you very much

could you explain the difference? just curious :grinning:

https://community.home-assistant.io/t/why-and-how-to-avoid-device-ids-in-automations-and-scripts/605517

I don’t think that will solve the OP’s problem.

it’s my understanding that the OP will get a notification each time the door is opened as the automation is written. But they want a continuous notification if the door continues to stay open (not closed and then opened again).

If that’s the case then the you could look into using the “Alert” integration which will do everything except change the icon color.

if you want to stay with the automation route then you will need to investigate a “repeat-until” action in the automation.

just “repeat” the notification at an interval “until” the door is closed. You can then maybe use the repeat.index value to set the icon color.

1 Like