Need help with LG Fridge door open notifications

Hi:
Relative but not total Homeassistant Noob, with a mental block about YAML syntax.

I have an LG Fridge connected to ThinQ, and I have both the HACS SmartThinQ LGE Sensors and the new official LG ThinQ integrations installed.

I would like to be notified if the door if the fridge is left open for some time. I have tried a couple approaches but neither really works properly:

APPROACH 1:

alias: Notify Fridge Open
description: to DWXr
triggers:
  - entity_id:
      - binary_sensor.lgfridge_door_open
      - binary_sensor.lgthinqfridge_door
    for:
      hours: 0
      minutes: 0
      seconds: 25
    trigger: state
    from: "off"
conditions: []
actions:
  - data:
      message: Fridge or Freezer door left open
      title: Fridge or Freezer door left open
    action: notify.mobile_app_myphone
  - action: notify.myemail_gmail_com
    metadata: {}
    data:
      message: FRIDGE DOOR LEFT OPEN!
      target: [email protected]
mode: single

APPROACH 2:

alias: LG Fridge Notification
description: to myphone
triggers:
  - entity_id:
      - event.lgthinqfridge_notification
    trigger: state
    from: null
conditions: []
actions:
  - data:
      message: >-
        LG ThinQ Fridge Notification: New state is {{
        states('event.lgThinQFridge.notification') }}
      title: Fridge or Freezer State change
      data: {}
    action: notify.mobile_app_myphone
  - action: notify.myemail_gmail_com
    data:
      message: >-
        LG ThinQ Fridge Notification: New state is {{
        states('event.lgThinQFridge.notification') }}
      target: [email protected]
mode: single

Approach 1 “sort of” works, but also randomly sends notifications even when the fridge is not touched. Approach 2 doesn’t seem to work at all.

I confess I do not really understand what I am doing. I’ve written a bunch of automations but frequently need help.

Help?

Change approach 1 trigger to:

alias: Notify Fridge Open
description: to DWXr
triggers:
  - entity_id:
      - binary_sensor.lgfridge_door_open
      - binary_sensor.lgthinqfridge_door
    for:
      hours: 0
      minutes: 0
      seconds: 25
    trigger: state
    from: "off"
    to: 'on'  # <--- add this

This way you won’t get random triggers if the state goes from ‘off’ to unknown or unavailable (like at restarts).

this works for me a long time already:

alias: Koelkast deur te lang open
description: ""
mode: single
triggers:
  - type: opened
    device_id: 63b33aef118b11eb9281afb567acd2c3
    entity_id: binary_sensor.koelkast_door_open
    domain: binary_sensor
    for:
      hours: 0
      minutes: 2
      seconds: 0
    trigger: device
conditions: []

Yeah don’t do that.

sorry Tom, tell that to HA devs. I did make this automation somewhere in the past with entities only, in YAML. Somewhere with some of the updates it got converted…

Home Assistant never changes your YAML. Even when integrations are imported into the UI it is still up to you to delete the old YAML.

It can re-arrange the YAML options sorting order (to alphabetic order) if you open an automation in the UI editor but it will never change the trigger type. The order the options are listed in is not important. e.g.

- trigger: time
  at: 12:00:00

is the same as

- at: 12:00:00
  trigger: time

If you want to avoid it re-ordering the options of your YAML in your automations you can do this in your configuration.yaml file:

automation: !include automations.yaml # UI editor uses this one
automation yaml: !include automations_yaml.yaml # your yaml automations go in this file

Note if you do this you will only be able to view, not edit, your yaml automations in the UI editor. Traces still work.

1 Like

Hello Dave,

This is available from me if you want to use it or copy any code from it…
HA_Blueprints/Automations/door_open_tts_cloud_say_and_Piper_announcer_Piper_OR_nabu_casa_required.md at d1c15d75a7b5fa3042d60f7eee2d7633ea8a27a3 · SirGoodenough/HA_Blueprints · GitHub.