Skip to content

Instantly share code, notes, and snippets.

@cliss
Created August 25, 2025 15:28
Show Gist options
  • Select an option

  • Save cliss/d261194250ce7ba709eaad03f405bf50 to your computer and use it in GitHub Desktop.

Select an option

Save cliss/d261194250ce7ba709eaad03f405bf50 to your computer and use it in GitHub Desktop.
Mailbox Opened Automation YAML for Home Assistant
alias: Mailbox Opened
description: ""
triggers:
- type: opened
device_id: [device id]
entity_id: [entity id]
domain: binary_sensor
trigger: device
conditions:
- condition: time
after: "10:00:00"
weekday:
- sun
- mon
- tue
- thu
- wed
- sat
- fri
actions:
- alias: Handle depending on the last time the mailbox was opened
if:
- alias: The mailbox was last opened yesterday
condition: template
value_template: >-
{# {{ state_attr('automation.mail_is_here', 'last_triggered') <=
today_at("00:00:00") }} #}
{{
as_datetime(states('input_datetime.mailbox_last_opened')).astimezone()
<= today_at('00:00:00') }}
then:
- action: yolink.play_on_speaker_hub
metadata: {}
data:
tone: warn
volume: 13
repeat: 0
target_device: [target device]
message: You’ve got mail!
enabled: true
alias: Announce on the YoLink speaker
- action: mqtt.publish
metadata: {}
data:
qos: "1"
retain: true
topic: statusboard/mail
payload: "1"
alias: Publish the mail is waiting over MQTT
- action: notify.pushover
metadata: {}
data:
title: Mail Status
message: Mail is waiting as of {{ now().strftime('%-I:%M %p') }}
alias: Notify my phone
else:
- action: mqtt.publish
metadata: {}
data:
qos: "1"
retain: true
topic: statusboard/mail
payload: "0"
alias: Publish the mail is collected over MQTT
- action: notify.pushover
metadata: {}
data:
message: >-
Mail was checked at {{ now().strftime('%-I:%M %p') }}. It was
delivered {{
relative_time(as_datetime(states('input_datetime.mailbox_last_opened')).astimezone())
}} ago.
title: Mail Status
alias: Notify my phone
- action: input_datetime.set_datetime
metadata: {}
data:
datetime: "{{ now() }}"
target:
entity_id: input_datetime.mailbox_last_opened
alias: Note the last time the mailbox was opened
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment