Notify if the Garage is Opened Late

Between 11 PM and 6AM we want an iphone push alert if the garage is opened for any reason.

alias: garage_late_open_check

trigger:

  - entity_id: binary_sensor.rear_garage

    from: 'off'

    platform: state

    to: 'on'

  - entity_id: binary_sensor.front_garage

    from: 'off'

    platform: state

    to: 'on'

condition:

  - after: '23:00:00'

    before: '23:59:59'

    condition: time

  - after: '00:00:00'

    before: '06:00:00'

    condition: time

action:

  - data:

      message: garage opened late

      title: garage warning

    service: notify.mobile_app_iphone

mode: single

Notify if the Garage was Left Open

At 11PM I want to know if the garage is still open for any reason

alias: late_Garage_check

trigger:

  - platform: sun

    event: sunset

  - platform: time

    at: '23:00:00'

condition:

  - condition: or

    conditions:

      - condition: state

        entity_id: binary_sensor.front_garage

        state: 'on'

      - condition: state

        entity_id: binary_sensor.rear_garage

        state: 'on'

action:

  - data:

      message: Garage open late

      title: Garage Warning

    service: notify.mobile_app_iphone

mode: single

ESPHome Last Will and Testimate for Battery Powered Door Sensors

ESPHome example of sending state messages only when a door is "open", and completely powering down when the door is closed.  This uses the last will and testament feature of mqtt to give us a "closed" signal when the door stops broadcasting open signals.

esphome:

  name: test_binary_sensor

  platform: ESP8266

  board: d1_mini

wifi:

  ssid: ''

  password: ''

  fast_connect: true

# Enable Home Assistant API

# use mqtt instead

#api:

#  password: ''

ota:

  password: ''

  

deep_sleep:

  id: deep_sleep_1

  run_duration: 5s

  sleep_duration: 55s

  

binary_sensor:

  - platform: gpio

    pin:

      number: D2

      mode: INPUT_PULLUP

    name: "test_binary_sensor"

    device_class: door

    

mqtt:

  broker: '192.168.1.160'

  username: 'mosquitto'

  password: 'mosquitto'

  keepalive: 60s

  on_message:

    topic: test_binary_sensor/ota_mode

    payload: 'ON'

    then:

      - deep_sleep.prevent: deep_sleep_1

  will_message:

    topic:  test_binary_sensor/binary_sensor/test_binary_sensor/state

    payload: "OFF"

  shutdown_message:

    topic:  test_binary_sensor/binary_sensor/test_binary_sensor/state

    payload: "OFF"

logger:

  level: INFO