This repository has been archived by the owner on Oct 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
dog_food.yaml
88 lines (81 loc) · 2.22 KB
/
dog_food.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
automation:
# "arm" the alarm well before feeding time
- alias: "Dog Food Activate"
trigger:
- platform: time
at: '01:00:00'
- platform: time
at: '16:00:00'
action:
- service: input_boolean.turn_on
data:
entity_id: input_boolean.dog_needs_food
# blow up our pohones if we forget to feed her
- alias: "Dog Food Alert"
trigger:
- platform: time
at: '07:30:00'
- platform: time
at: '18:00:00'
condition:
- condition: state
entity_id: input_boolean.dog_needs_food
state: "on"
- condition: state
entity_id: input_boolean.dog_away_mode
state: "off"
action:
- service: notify.phones
data:
message: "Don't forget to feed Paisley!"
# dog has been fed
- alias: "Dog Food Reset"
trigger:
- platform: state
entity_id: binary_sensor.dog_food_bin_sensor
to: "on"
action:
- service: input_boolean.turn_off
data:
entity_id: input_boolean.dog_needs_food
# track state
input_boolean:
dog_needs_food:
name: Paisley Needs Food
dog_away_mode:
name: Paisley Is Away
icon: mdi:beach
# use a template sensor to diplay in the UI
sensor:
- platform: template
sensors:
paisley_food:
value_template: '{% if is_state("input_boolean.dog_needs_food", "on") %}yes{% else %}no{% endif %}'
friendly_name: 'Paisley Needs Food?'
# customize
homeassistant:
customize:
binary_sensor.dog_food_bin_sensor:
icon: mdi:bone
sensor.paisley_food:
icon: mdi:silverware
# Alexa intent
intent_script:
DogFood:
speech:
text: >
{%- if is_state('input_boolean.dog_needs_food', 'on') -%}
{% set responses = [
"She's probably hungry",
"She could use some food",
"She would appreciate some food"
] %}
{%- else -%}
{% set responses = [
"She's already been fed",
"Don't let her fool you, she already ate",
"As much as she'd love it, she doesn't need any food"
] %}
{%- endif -%}
{% set rindex = (range(0, (responses | length - 1) )|random) -%}
{{responses[rindex]}}