Feeding/cleaning tracker for the rabbit

This commit is contained in:
2024-04-26 11:53:26 -04:00
parent a48589d892
commit 7ee95a1936
3 changed files with 494 additions and 0 deletions

View File

@ -4838,3 +4838,186 @@
entity_id: button.master_bedroom_day_mode
alias: Activate master bedroom daytime climate mode
mode: single
- id: '1714075850756'
alias: Rabbit Tracker
description: Automation for tracking various aspects of caring for our pet rabbit
trigger:
- platform: time
at: input_datetime.rabbit_feeding_notify
alias: Feeding Notify
id: feeding-notify
- platform: time
at: input_datetime.rabbit_hutch_cleaning_notify
alias: Cleaning Notify
id: cleaning-notify
- platform: state
entity_id:
- input_boolean.rabbit_fed
from: 'off'
to: 'on'
alias: Rabbit Fed
id: rabbit-fed
- platform: state
entity_id:
- input_boolean.rabbit_hutch_cleaned
from: 'off'
to: 'on'
alias: Hutch Cleaned
id: hutch-cleaned
- alias: Feeding Interval Update
platform: state
entity_id:
- input_number.rabbit_feeding_interval
- input_datetime.rabbit_fed
id: feeding-interval-update
- alias: Cleaning Interval Update
platform: state
entity_id:
- input_number.rabbit_hutch_cleaning_interval
- input_datetime.rabbit_hutch_cleaned
id: cleaning-interval-update
condition:
- condition: state
entity_id: input_boolean.vacation_mode
state: 'off'
alias: Vacation Mode is off
action:
- alias: Routing
choose:
- conditions:
- condition: trigger
id:
- feeding-notify
alias: Feeding Notify
sequence:
- alias: Turn off boolean on first reminder
if:
- alias: If this is the first reminder
condition: numeric_state
entity_id: counter.rabbit_feeding_reminder_count
below: 1
then:
- alias: Turn off feeding boolean
service: input_boolean.turn_off
metadata: {}
data: {}
target:
entity_id: input_boolean.rabbit_fed
- service: counter.increment
metadata: {}
data: {}
target:
entity_id: counter.rabbit_feeding_reminder_count
alias: Increment counter
- service: script.rabbit_feeding
metadata: {}
data: {}
alias: Run rabbit feeding script
- conditions:
- condition: trigger
id:
- cleaning-notify
alias: Cleaning Notify
sequence:
- alias: Turn off boolean on first reminder
if:
- condition: numeric_state
entity_id: counter.rabbit_hutch_cleaning_reminder_count
below: 1
alias: If this is the first reminder
then:
- service: input_boolean.turn_off
metadata: {}
data: {}
target:
entity_id: input_boolean.rabbit_hutch_cleaned
alias: Turn off cleaning boolean
- service: counter.increment
metadata: {}
data: {}
target:
entity_id: counter.rabbit_hutch_cleaning_reminder_count
alias: Increment counter
- service: script.rabbit_hutch_cleaning
metadata: {}
data: {}
alias: Run rabbit hutch cleaning script
- conditions:
- condition: trigger
id:
- rabbit-fed
alias: Rabbit Fed
sequence:
- service: input_datetime.set_datetime
alias: Set time rabbit was fed
data:
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0)
}}
'
target:
entity_id: input_datetime.rabbit_fed
- service: counter.reset
metadata: {}
data: {}
target:
entity_id: counter.rabbit_feeding_reminder_count
alias: Reset feeding reminder counter
- conditions:
- condition: trigger
id:
- hutch-cleaned
alias: Hutch Cleaned
sequence:
- service: input_datetime.set_datetime
alias: Set time rabbit hutch was cleaned
data:
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0)
}}
'
target:
entity_id: input_datetime.rabbit_hutch_cleaned
- service: counter.reset
metadata: {}
data: {}
target:
entity_id: counter.rabbit_hutch_cleaning_reminder_count
alias: Reset cleaning reminder counter
- conditions:
- alias: Feeding Interval Update
condition: trigger
id:
- feeding-interval-update
sequence:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.rabbit_feeding_notify
data:
time: '{% set fed = state_attr(''input_datetime.rabbit_fed'',''timestamp'')
| int %} {% set interval = states(''input_number.rabbit_feeding_interval'')
| int %} {% set math = (interval * 60) * 60 %} {% set newtime = fed +
math %} {{ newtime | timestamp_custom(''%H:%M'') }}
'
alias: Update Notification
- conditions:
- alias: Cleaning Interval Update
condition: trigger
id:
- cleaning-interval-update
sequence:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.rabbit_hutch_cleaning_notify
data:
datetime: '{% set cleaned = state_attr(''input_datetime.rabbit_hutch_cleaned'',''timestamp'')
| int %} {% set interval = states(''input_number.rabbit_hutch_cleaning_interval'')
| int %} {% set math = ((interval * 24) * 60) * 60 %} {% set newtime =
cleaned + math %} {{ newtime | timestamp_custom(''%Y-%m-%d %H:%M:%S'')
}}
'
alias: Update Notification
mode: parallel
max: 10

45
packages/pets.yaml Normal file
View File

@ -0,0 +1,45 @@
input_boolean:
rabbit_fed:
name: Rabbit Fed
icon: mdi:rabbit
rabbit_hutch_cleaned:
name: Rabbit Hutch Cleaned
icon: mdi:rabbit
input_datetime:
rabbit_fed:
name: Rabbit Fed
has_date: true
has_time: true
icon: mdi:rabbit
rabbit_feeding_notify:
name: Rabbit Feeding Notify
has_date: false
has_time: true
icon: mdi:rabbit
rabbit_hutch_cleaned:
name: Rabbit Hutch Cleaned
has_date: true
has_time: true
icon: mdi:rabbit
rabbit_hutch_cleaning_notify:
name: Rabbit Hutch Cleaning Notify
has_date: true
has_time: true
icon: mdi:rabbit
input_number:
rabbit_feeding_interval:
name: Rabbit Feeding Interval
min: 0
max: 24
step: 1
unit_of_measurement: hours
icon: mdi:rabbit
rabbit_hutch_cleaning_interval:
name: Rabbit Hutch Cleaning Interval
min: 0
max: 3
step: 1
unit_of_measurement: days
icon: mdi:rabbit

View File

@ -2737,3 +2737,269 @@ reset_annc_switches:
data: {}
mode: single
icon: mdi:bullhorn-outline
rabbit_feeding:
alias: Rabbit Feeding
sequence:
- alias: Send notifications
parallel:
- alias: Play TTS if this is the 3rd or higher reminder
if:
- condition: numeric_state
entity_id: counter.rabbit_feeding_reminder_count
above: 2
then:
- service: script.speech_engine
data:
who: common_areas
type: alert
message: Zeus needs to be fed. This is reminder number {{ states('counter.rabbit_feeding_reminder_count')
}} for today.
alias: Play TTS announcement
- service: script.text_notify
metadata: {}
data:
type: alert
who: parents
title: Rabbit Feeding
message: Zeus needs to be fed, please do this ASAP!
tag: rabbit-feeding
actions:
- action: RABBIT_FEEDING_DONE
name: Fed
- action: RABBIT_FEEDING_SKIPPED
name: Skip
- action: RABBIT_FEEDING_ASK_LATER
name: Ask Later
alias: Send phone notifications
- wait_for_trigger:
- platform: event
event_type: ios.notification_action_fired
event_data:
actionName: RABBIT_FEEDING_DONE
alias: Done
id: done
- alias: Skipped
platform: event
event_type: ios.notification_action_fired
event_data:
actionName: RABBIT_FEEDING_SKIPPED
id: skipped
- alias: Ask Later
platform: event
event_type: ios.notification_action_fired
event_data:
actionName: RABBIT_FEEDING_ASK_LATER
id: ask-later
- platform: state
entity_id:
- binary_sensor.parents_home
from: 'on'
to: 'off'
id: left
alias: Left
- platform: state
entity_id:
- input_boolean.rabbit_fed
from: 'off'
to: 'on'
alias: Manual
id: manual
timeout:
hours: 1
minutes: 0
seconds: 0
milliseconds: 0
alias: Triggers
- choose:
- conditions:
- condition: template
value_template: '{{ wait.trigger.id in [''done'',''manual''] }}'
alias: Feeding done
sequence:
- service: input_boolean.turn_on
metadata: {}
data: {}
target:
entity_id: input_boolean.rabbit_fed
alias: Turn on input boolean
- service: script.text_notify
metadata: {}
data:
type: alert
who: parents
message: clear_notification
tag: rabbit-feeding-critical
alias: Clear critical notification, if it was sent
- conditions:
- condition: template
value_template: '{{ wait.trigger.id == ''ask-later'' }}'
alias: Ask later
sequence:
- service: input_datetime.set_datetime
data:
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(1)
}}
'
target:
entity_id: input_datetime.rabbit_feeding_notify
alias: Bump feeding notification by an hour
- conditions:
- condition: template
value_template: '{{ wait.trigger.id == ''left'' }}'
alias: Left
sequence:
- service: script.text_notify
metadata: {}
data:
type: critical
who: parents
title: YOU DICK
message: YOU FORGOT TO FEED THE RABBIT!
tag: rabbit-feeding-critical
alias: Send critical text notification
- conditions:
- condition: template
value_template: '{{ wait.trigger == ''none'' or wait.trigger.idx is undefined
}}'
alias: None or undefined
sequence:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.rabbit_feeding_notify
data:
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0,1)
}}
'
alias: Notify again
alias: Routing
- service: script.text_notify
metadata: {}
data:
type: alert
who: parents
message: clear_notification
tag: rabbit-feeding
alias: Clear notification
mode: restart
icon: mdi:rabbit
rabbit_hutch_cleaning:
alias: Rabbit Hutch Cleaning
sequence:
- alias: Send notifications
parallel:
- alias: Play TTS if this is the 3rd or higher reminder
if:
- condition: numeric_state
entity_id: counter.rabbit_hutch_cleaning_reminder_count
above: 2
then:
- service: script.speech_engine
data:
who: common_areas
type: normal
message: The rabbit hutch is in need of cleaning. This is reminder number
{{ states('counter.rabbit_hutch_cleaning_reminder_count') }} for today.
alias: Play TTS announcement
- alias: Send phone notifications
service: script.text_notify
metadata: {}
data:
type: alert
who: parents
title: Rabbit Hutch Cleaning
message: The rabbit hutch is in need of cleaning. For the sake of smell, please
do this ASAP!
tag: rabbit-hutch-cleaning
actions:
- action: RABBIT_HUTCH_CLEANING_DONE
name: Cleaned
- action: RABBIT_HUTCH_CLEANING_SKIPPED
name: Skip
- action: RABBIT_HUTCH_CLEANING_ASK_LATER
name: Ask Later
- alias: Triggers
wait_for_trigger:
- alias: Done
platform: event
event_type: ios.notification_action_fired
event_data:
actionName: RABBIT_HUTCH_CLEANING_DONE
id: done
- alias: Skipped
platform: event
event_type: ios.notification_action_fired
event_data:
actionName: RABBIT_HUTCH_CLEANING_SKIPPED
id: skipped
- alias: Ask Later
platform: event
event_type: ios.notification_action_fired
event_data:
actionName: RABBIT_HUTCH_CLEANING_ASK_LATER
id: ask-later
- alias: Manual
platform: state
entity_id:
- input_boolean.rabbit_hutch_cleaned
from: 'off'
to: 'on'
id: manual
timeout:
hours: 1
minutes: 0
seconds: 0
milliseconds: 0
- alias: Routing
choose:
- conditions:
- condition: template
value_template: '{{ wait.trigger.id in [''done'',''manual''] }}'
alias: Cleaning done
sequence:
- alias: Turn on input boolean
service: input_boolean.turn_on
metadata: {}
data: {}
target:
entity_id: input_boolean.rabbit_hutch_cleaned
- conditions:
- condition: template
value_template: '{{ wait.trigger.id == ''ask-later'' }}'
alias: Ask later
sequence:
- service: input_datetime.set_datetime
data:
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(1)
}}
'
target:
entity_id: input_datetime.rabbit_hutch_cleaning_notify
alias: Bump cleaning notification by an hour
- conditions:
- condition: template
value_template: '{{ wait.trigger == ''none'' or wait.trigger.idx is undefined
}}'
alias: None or undefined
sequence:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.rabbit_hutch_cleaning_notify
data:
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0,1)
}}
'
alias: Notify again
- alias: Clear notification
service: script.text_notify
metadata: {}
data:
type: alert
who: parents
message: clear_notification
tag: rabbit-hutch-cleaning
mode: restart
icon: mdi:rabbit