home-assistant-configuration/config/packages/usps.yaml

92 lines
3.1 KiB
YAML
Raw Normal View History

2019-02-21 17:49:55 +00:00
###############################################################################
# @author : Jeffrey Stone
# @date : 02/19/2019
# @package : USPS
# @description : Notifies us of mails and packages.
# Package modified from https://github.com/skalavala/smarthome/blob/master/packages/usps.yaml
###############################################################################
homeassistant:
customize:
sensor.usps_mail:
friendly_name: USPS Mail
icon: mdi:mailbox
sensor.usps_packages:
friendly_name: USPS Packages
icon: mdi:package-variant
sensor:
- platform: mqtt
name: 'USPS Mail'
state_topic: 'house/usps/mails'
value_template: "{{ value }}"
- platform: mqtt
name: USPS Packages
state_topic: 'house/usps/packages'
value_template: "{{ value }}"
camera:
- platform: generic
name: USPS Mail Pictures
still_image_url: !secret usps_camera_url
2019-11-09 15:23:56 +00:00
automation:
2019-02-21 17:49:55 +00:00
# Notify USPS mails via TTS, and iOS notification with attachment
###############################################################################
- id: notify_usps_mail
alias: Notify USPS Mail
initial_state: true
trigger:
- platform: state
entity_id: sensor.usps_mail
condition:
- condition: template
value_template: '{{ states.sensor.usps_mail.state | int > 0 }}'
action:
- service: script.ah_report
2019-07-14 01:38:53 +00:00
data_template:
usps: >-
2019-02-21 17:49:55 +00:00
{%- if states.sensor.usps_mail.state | int == 1 -%}
2019-07-11 11:43:49 +00:00
USPS is delivering {{ states.sensor.usps_mail.state }} piece of mail today.
2019-02-21 17:49:55 +00:00
{%- else -%}
2019-07-11 11:43:49 +00:00
USPS is delivering {{ states.sensor.usps_mail.state }} pieces of mail today.
2019-02-21 17:49:55 +00:00
{%- endif -%}
call_interuption: 1
2019-07-14 01:38:53 +00:00
- service: script.text_notify
2019-02-21 17:49:55 +00:00
data_template:
2019-07-14 01:38:53 +00:00
who: "jeff"
title: "USPS Delivering Today"
2019-02-21 17:49:55 +00:00
message: "USPS will be delivering {{ states.sensor.usps_mail.state }} piece(s) of mail today."
2019-07-14 01:38:53 +00:00
# data:
# push:
# category: camera
# entity_id: "camera.usps_mail_pictures"
# attachment:
# url: "{{ states.camera.usps_mail_pictures.attributes.entity_picture }}"
# content-type: jpg
2019-02-21 17:49:55 +00:00
# Notify USPS packages via TTS. Usually there are no pictures for packages
###############################################################################
- id: notify_usps_packages
alias: Notify USPS Packages
initial_state: true
trigger:
- platform: state
entity_id: sensor.usps_packages
condition:
- condition: template
value_template: '{{ states.sensor.usps_packages.state | int > 0 }}'
action:
- service: script.ah_report
2019-02-21 17:49:55 +00:00
data_template:
usps: >
2019-02-21 17:49:55 +00:00
{%- if states.sensor.usps_packages.state | int == 1 -%}
2019-07-11 11:43:49 +00:00
USPS is delivering {{ states.sensor.usps_packages.state }} package today.
2019-02-21 17:49:55 +00:00
{%- else -%}
2019-07-11 11:43:49 +00:00
USPS is delivering {{ states.sensor.usps_packages.state }} packages today.
{%- endif -%}
call_interuption: 1