mysmarthome/packages/usps.yaml

106 lines
4.0 KiB
YAML
Raw Normal View History

2019-04-17 22:46:06 +00:00
###############################################################################
# @Author : Mahasri Kalavala
# @Date : 01/27/2018
# @Package : USPS Package - notifies me of mails and packages.
###############################################################################
homeassistant:
customize:
sensor.usps_mail:
friendly_name: USPS Mail
icon: mdi:email-outline
sensor.usps_packages:
friendly_name: USPS Packages
icon: mdi:package-variant
sensor:
- platform: mqtt
2019-12-20 15:32:28 +00:00
name: "USPS Mail"
state_topic: "/usps/mails"
2019-04-17 22:46:06 +00:00
value_template: "{{ value }}"
- platform: mqtt
name: USPS Packages
2019-12-20 15:32:28 +00:00
state_topic: "/usps/packages"
2019-04-17 22:46:06 +00:00
value_template: "{{ value }}"
camera:
- platform: generic
name: USPS Mail Pictures
still_image_url: !secret usps_camera_url
###############################################################################
2019-12-20 15:32:28 +00:00
# _ _ _
# /\ | | | | (_)
# / \ _ _| |_ ___ _ __ ___ __ _| |_ _ ___ _ __ ___
2019-04-17 22:46:06 +00:00
# / /\ \| | | | __/ _ \| '_ ` _ \ / _` | __| |/ _ \| '_ \/ __|
# / ____ \ |_| | || (_) | | | | | | (_| | |_| | (_) | | | \__ \
# /_/ \_\__,_|\__\___/|_| |_| |_|\__,_|\__|_|\___/|_| |_|___/
2019-12-20 15:32:28 +00:00
#
2019-04-17 22:46:06 +00:00
###############################################################################
automation:
2019-12-20 15:32:28 +00:00
# Notify USPS mails via TTS, and iOS notification with attachment
###############################################################################
2019-04-17 22:46:06 +00:00
- alias: Notify USPS Mail
initial_state: true
trigger:
- platform: state
entity_id: sensor.usps_mail
condition:
- condition: template
2019-12-20 15:32:28 +00:00
value_template: "{{ states('sensor.usps_mail') != 'unknown' }}"
- condition: template
value_template: "{{ states('sensor.usps_mail') | int > 0 }}"
2019-04-17 22:46:06 +00:00
- condition: template
2019-12-20 15:32:28 +00:00
value_template: "{{ ((now().hour | int) > 7) and ((now().hour | int) < 16) }}"
2019-04-17 22:46:06 +00:00
action:
- service: script.voice_notify
data_template:
message: >
2019-12-20 15:32:28 +00:00
{%- if states('sensor.usps_mail') | int == 1 -%}
Attention: USPS is delivering {{ states('sensor.usps_mail') }} mail today.
2019-04-17 22:46:06 +00:00
{%- else -%}
2019-12-20 15:32:28 +00:00
Attention: USPS is delivering {{ states('sensor.usps_mail') }} mails today.
2019-04-17 22:46:06 +00:00
{%- endif -%}
2020-03-14 00:10:10 +00:00
- service: script.led_message
data_template:
message: >
{%- if states('sensor.usps_mail') | int == 1 -%}
USPS is delivering {{ states('sensor.usps_mail') }} mail today.
{%- else -%}
USPS is delivering {{ states('sensor.usps_mail') }} mails today.
{%- endif -%}
2019-04-17 22:46:06 +00:00
- service: notify.ios_devices
data_template:
2019-12-20 15:32:28 +00:00
message: "USPS will be delivering {{ states('sensor.usps_mail') }} mail(s) today."
2019-04-17 22:46:06 +00:00
data:
push:
category: camera
entity_id: "camera.usps_mail_pictures"
attachment:
2019-05-25 17:28:07 +00:00
url: "{{ state_attr('camera.usps_mail_pictures', 'entity_picture') }}"
2019-04-17 22:46:06 +00:00
content-type: jpg
2019-12-20 15:32:28 +00:00
# Notify USPS packages via TTS. Usually there are no pictures for packages
###############################################################################
2019-04-17 22:46:06 +00:00
- alias: Notify USPS Packages
initial_state: true
trigger:
- platform: state
entity_id: sensor.usps_packages
condition:
- condition: template
2019-12-20 15:32:28 +00:00
value_template: "{{ states('sensor.usps_packages') != 'unknown' }}"
- condition: template
value_template: "{{ states('sensor.usps_packages') | int > 0 }}"
2019-04-17 22:46:06 +00:00
- condition: template
2019-12-20 15:32:28 +00:00
value_template: "{{ ((now().hour | int) > 7) and ((now().hour | int) < 16) }}"
2019-04-17 22:46:06 +00:00
action:
- service: script.voice_notify
data_template:
message: >
2019-12-20 15:32:28 +00:00
{%- if states('sensor.usps_packages') | int == 1 -%}
Attention: USPS is delivering {{ states('sensor.usps_packages') }} package today.
2019-04-17 22:46:06 +00:00
{%- else -%}
2019-12-20 15:32:28 +00:00
Attention: USPS is delivering {{ states('sensor.usps_packages') }} packages today.
{%- endif -%}