Lovelace notify and alert

Getting a little frustrated. I have been running behind on HA and still have my main setup on 0.89.2. In this version, when a door is left open an alert will show up on my main HA screen. I also have an alert setup to email/gmail me.

I have setup a current 0.100.3 version I am trying to migrate to but cannot get these previous alerts to work.

1st issue: no auto alert. I added a card but it doesn’t give me the option to turn it off. If I click to open it, there is a switch but it always reverts to on.
image

2nd issue: I am not getting notifications (emails):
in alerts.yaml:

 garage_door:
   name: Garage Door is open
   entity_id: binary_sensor.garage_door_sensor
   state: 'Open'
   repeat:
     - 5
     - 30
     - 60
   can_acknowledge: True
   skip_first: True
   notifiers:
     - gmail

in configuration.yaml:

alert: !include alerts.yaml

notify:
  - name: gmail
    platform: smtp
    server: smtp.gmail.com
    port: 587
    sender: !secret gmail_sender
    encryption: starttls
    username: !secret gmail_user
    password: !secret gmail_password
    recipient:
      - !secret gmail_recipient
    sender_name: Home Assistant

I have tried without using the ‘secrets’ just in case. The old HA (89.2) still works with the original settings so I am guessing I am missing something that changed in one of the versions. Any thoughts?

Are there any relevant errors in your home assistant log?

negative. I also added the debug: true line to the gmail notify in case I was overlooking something.

I think I got it although I also think I have this overdone. I missed a step in my copying in which I had a templated sensor.

- platform: template
  sensors:
    gdstatus:
      value_template: '{% if is_state("sensor.garaged_alarm_level", "0") %}Closed{% else %}Open{% endif %}'
      friendly_name: 'GD'

I feel as though I should be able to pull it from the existing binary sensor.

 garage_door:
   name: Garage Door is open
   entity_id: sensor.gdstatus
   state: 'Open'
   repeat:
     - 5
     - 30
     - 60
   can_acknowledge: True
   skip_first: True
   notifiers:
     - gmail

Try changing your sensor to a binary sensor, this has the advantage of using device classes which make the icons pretty and take care of the states (open/closed) for you. Note though that in templates you still use on/off states for the binary sensor rather than what the device class displays in the frontend:

binary_sensor:
- platform: template
  sensors:
    gdstatus:
      value_template: "{{ is_state('sensor.garaged_alarm_level', '1') }}"
      friendly_name: 'GD'
      device_class: garage_door

Check the open state message is ‘1’. I guessed. The template needs to resolve true for ‘open’. If there are many messages for open and you can only use the closed state in teh template, use this value template:

value_template: "{{ not is_state('sensor.garaged_alarm_level', '0') }}"

Either way your alert becomes:

 garage_door:
   name: Garage Door is open
   entity_id: binary_sensor.gdstatus
   state: 'on'
   repeat:
     - 5
     - 30
     - 60
   can_acknowledge: True
   skip_first: True
   notifiers:
     - gmail

So the actual sensor for this one comes in from an ESPHome garage door opener which is a binary sensor, which is what I was originally trying to use.

image

if I change the alert to use the existing binary sensor, the alert does not work (tried open & on)

 garage_door:
   name: Garage Door is open
   entity_id: binary_sensor.garage_door_sensor
#   entity_id: sensor.gdstatus
   state: 'on'
#   state: 'Open'
   repeat:
     - 5
     - 30
     - 60
   can_acknowledge: True
   skip_first: True
   notifiers:
     - gmail