Help building my first rule/automation : Freezer drawer opened

Today the 4 year old left the freezer drawer open only slightly which we didn’t notice but everything started to melt… I have a spare door/window sensor so now there is one attached and now I need to write an automation…
I’m a fresh immigrant from OpenHAB so hopefully I can get some assistance on this journey.

Requirements…

  • After 15 seconds make Alexa say “Don’t forget to closer the freezer!”
  • After a minute say somethng more ominious like “Time to close the freezer or the ice cream will melt”
  • After 5 minutes send a push notification to HA companion on my Android phone to nofity me it is still open.

This is as far as I’ve got, will slowly have to read up and try figure out how to do the rest :slight_smile:

alias: Freezer Drawer 01
description: ''
trigger:
  - type: opened
    platform: device
    device_id: 1a6e83751aa2f96d8526365d45645a61
    entity_id: binary_sensor.xiaomicontact04_contact
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 15
      milliseconds: 0
condition: []
action:
  - service: notify.alexa_media
    data:
      target:
        - media_player.kitchen_echo
      message: Don't forget to close the freezer drawer please!
      data:
        type: tts
mode: single

Does it work, and do you need specific help? Looks OK here: I assume you’ve created it through the UI?

If you did it manually, you can simplify the trigger:

trigger:
  - platform: state
    entity_id: binary_sensor.xiaomicontact04_contact
    to: 'off'
    for:
      seconds: 15

I’m assuming that the sensor goes off when the door is open: check in Developer Tools / States. 15 seconds seems like quite a short time to me!

You can then set up additional such automations with increasing time delays: if the door is shut before a for: time is reached, that automation will not trigger.

1 Like

Exactly. It does look like it will require three, nearly identical automations, but just copy and paste and then edit the “for:” times.