Alert when garage door open between certain times?

yep. you’re right. mindbending sometimes…:wink:

But your initial automation

Would work great, just uncomment the time trigger.

Also not directed at you, I’m Not naysaying node red, but this is a simple automation, while node red will probably handle it just fine, it seems (to me), like a lot of overhead for simple automations. I feel like when people are starting out under standing these kind of automations are a good foundation to really understanding what is going on in the background.

You could also use a “garage open for x minutes” as a trigger. This would not send an notification if the garage is opened then closed within x minutes (when coming home late for example)
But it works if the garage has been opened at 20:59 and left open for x minutes:

- id: garageopenafter        
  alias: "Garage door open between 9pm and 5am"
  trigger:
    - entity_id: cover.sunsetgarage
      for:
        minutes: 5
      from: 'off'
      platform: state
      to: 'on'
  condition:
    - condition: time
      after: '21:00:00'
      before: '05:00:00'
  action:
    - service: notify.telegram
      data:
        message: 'Garage door open, is that correct?'
1 Like

If I remember correctly, in the condition section the default is to And the values, and I believe you want to Or them.

There is no time which is after 21:00 AND before 05:00

Yes that might be a Problem indeed. Perhaps using the sun level as condition would be better? (need to have sun: somewhere in configuration.yaml)

- id: garageopenafter        
  alias: "Garage door open between 9pm and 5am"
  trigger:
    - entity_id: cover.sunsetgarage
      for:
        minutes: 5
      from: 'off'
      platform: state
      to: 'on'
  condition:
  - condition: state
    entity_id: sun.sun
    state: below_horizon
  action:
    - service: notify.telegram
      data:
        message: 'Garage door open, is that correct?

Thanks everyone, I agree with @ptdalen that it’s a good idea to understand the basics before moving onto something like Node Red. I guess based on post by @NigelL an ‘or’ wouldn’t work, per the below? I might just go for Node Red, as in this case it just seems much easier.

- id: garageopenafter        
  alias: "Garage door open between 9pm and 5am"
  trigger:
    - platform: time
      at: '21:00:00'
    - platform: state
      entity_id: 'cover.sunsetgarage'
  condition:
    condition: or
    conditions:
      - condition: time
        after: '21:00:00'
        before: '05:00:00'
      - condition: state
        entity_id: 'cover.sunsetgarage'
        state: 'open'
  action:
    - service: notify.telegram
      data:
        message: 'Garage door open, is that correct?'

Why do you say that? After 2100 before 0500 is 9pm over the midnight then from midnight until 5am. Am I missing something somewhere else, I have many automations using that exact same logic

If I remember correctly (and this is something I have seen being talked about on here, not something I have direct experience of) the comparison is done to the current time, so it can’t be after 9PM, AND be before 5AM. The time comparison compares to the target times on the current day. (I could be misremembering, or just be flat out wrong)

So I believe the condition should be along the lines of (sorry, not testing this)

 condition:
    condition: or
    conditions:
      - condition: time
        after: '21:00:00'
      - condition:time
        before: '05:00:00'
1 Like

I hear what you’re saying and there are many, many examples exactly as you’ve said. Recently though I was shown than that is not necessary by a well trusted community member. I updated several of my automations to test, and they all still work, much simplier.

Thanks all, I’ve gone with the below, I’ll test it out tomorrow.

- id: garageopenafter        
  alias: "Garage door open between 9pm and 5am"
  trigger:
    - platform: time
      at: '21:00:00'
    - platform: state
      entity_id: 'cover.sunsetgarage'
  condition:
    - condition: time
      after: '21:00:00'
      before: '05:00:00'
    - condition: state
      entity_id: 'cover.sunsetgarage'
      state: 'open'
  action:
    - service: notify.telegram
      data:
        message: 'Garage door open, is that correct?'
1 Like

Oh, I must have missed that. If it works, then great, it simplifies things

1 Like

This indeed works…

Anyone able to assist on how to add a reminder every 15 minutes?

First create a 15 minute timer (I used 30 minutes):

north_garage_door:
  duration: '00:30:00'

Then use an automation similar to below:

- alias: 'Notification North GD Open'
  trigger:
    - platform: state
      entity_id: sensor.n_gd_pos_template
      to: 'Open'
      for:
        minutes: 30
    - platform: event
      event_type: timer.finished
      event_data:
        entity_id: timer.north_garage_door
  condition:
    condition: state
    entity_id: sensor.n_gd_pos_template
    state: 'Open'
  action:
    - service: notify.pushbullet_notify
      data:
        message: 'The North Garage Door Is Still Open'
    - service: timer.start
      entity_id: timer.north_garage_door

@finity Thanks. Your post was of great help. Here is my working config via the automation tool.

Another example notifying via HA App

#configurations.yaml

timer:
  garage_door:
    duration: '00:15:00'
    name: 'Garage Door'
#automations.yaml

- id: '0000000000000'
  alias: Garage Door Left Opened
  description: ''
  trigger:
  - entity_id: binary_sensor.visonic_mct_340_e_xxxxxxxx_1_1280
    platform: state
    to: 'on'
  - at: '20:00:00'
    platform: time
  - event_data: {}
    event_type: timer.finished
    platform: event
  condition:
  - condition: state
    entity_id: binary_sensor.visonic_mct_340_e_xxxxxxxx_1_1280
    state: 'on'
  - after: '20:00:00'
    before: 06:00:00
    condition: time
  action:
  - data_template:
      message: '{{now().strftime("%a %b %d %H:%M:%S %p")}}'
      title: '{{ trigger.to_state.attributes.friendly_name }} {% if trigger.to_state.state
        == ''on'' %}Detected {% endif %}'
    service: notify.mobile_app_jason_note
  - entity_id: timer.garage_door
    service: timer.start

IFTTT integration is working, i.e. it response from the developer test interface, but the following automations are not generating any email notifications when they should be:

automation:
  - id: 'garage_open_notification'
    alias: 'Garage Door Open'
    trigger:
      - platform: state
        entity_id: cover.garage_door
        to: 'Open'
        for:
          minutes: 30
    condition: []
    action:
      - service: ifttt.trigger
        data: {"event": "GarageLeftOpen"}

  - id: garageopenafter
    alias: "Garage door open between 9pm and 8am"
    trigger:
      - platform: time_pattern
        minutes: '/5'
    condition:
      - condition: time
        after: '21:00:00'
        before: '08:00:00'
      - condition: state
        entity_id: 'cover.garage_door'
        state: 'Open'
    action:
      - service: ifttt.trigger
        data: {"event": "GarageLeftOpen"}

  - id: garage_opened
    alias: 'Garage Door Opened'
    trigger:
      - platform: state
        entity_id: cover.garage_door
        to: 'Open'
    condition:
      condition: state
      entity_id: cover.garage_door
      state: 'Open'
    action:
      - service: timer.start
        entity_id: timer.garage_door

  - id: garage_closed
    alias: 'Garage Door Closed'
    trigger:
      -  platform: state
         entity_id: cover.garage_door
         to: 'Closed'
    action:
      - service: timer.cancel
        entity_id:  timer.garage_door

  - id: garage_opened_timer_finished
    alias: 'Garage Opened Timer Finished'
    trigger:
      - platform: event
        event_type: timer.finished
        event_data:
          entity_id: timer.garage_door
    condition:
      condition: state
      entity_id: cover.garage_door
      state: 'Open'
    action:
      - service: ifttt.trigger
        data: {"event": "GarageLeftOpen"}
      - service: timer.start
        entity_id: timer.garage_door

timer:
  garage_door:
    duration: '00:30:00'