Let's see if I can plan garbage collection eh?

This commit is contained in:
2023-05-06 04:52:40 -04:00
parent 82dbb7baea
commit eba66b4d79
5 changed files with 107 additions and 0 deletions

View File

@ -424,6 +424,63 @@ script:
{{ (state_attr('input_datetime.tina_workday_end', 'timestamp') + 3600) | timestamp_custom('%H:%M', false) }}
{% endif %}
{% endif %}
- if:
- condition: state
entity_id: sensor.today_is
state: 'Monday'
then:
- if:
- condition: template
value_template: >
{% from 'easy_time.jinja' import count_the_days, month_week_day %}
{% set month = as_timestamp(now()) | timestamp_custom('%-m') %}
{{ count_the_days(month_week_day(month,3,2)) | int < 7 }}
then:
- service: calendar.create_event
target:
entity_id: calendar.garbage_collection
data:
summary: Large Garbage Pickup
description: Bulk items ARE accepted
start_date: >
{% from 'easy_time.jinja' import this_weekday, count_the_days %}
{% set holiday = state_attr('calendar.holidays','next_holiday') %}
{% if holiday in ["New Year's Day","Memorial Day","Independence Day","Labor Day","Thanksgiving","Christmas"] and count_the_days('calendar.holidays','start_time') | int <= 4 %}
{{ as_timestamp(this_weekday(3)) | timestamp_custom('%Y-%m-%d') }}
{% else %}
{{ as_timestamp(this_weekday(2)) | timestamp_custom('%Y-%m-%d') }}
{% endif %}
end_date: >
{% from 'easy_time.jinja' import this_weekday, count_the_days %}
{% set holiday = state_attr('calendar.holidays','next_holiday') %}
{% if holiday in ["New Year's Day","Memorial Day","Independence Day","Labor Day","Thanksgiving","Christmas"] and count_the_days('calendar.holidays','start_time') | int <= 4 %}
{{ as_timestamp(this_weekday(4)) | timestamp_custom('%Y-%m-%d') }}
{% else %}
{{ as_timestamp(this_weekday(3)) | timestamp_custom('%Y-%m-%d') }}
{% endif %}
else:
- service: calendar.create_event
target:
entity_id: calendar.garbage_collection
data:
summary: Normal Garbage Pickup
description: Bulk items not accepted
start_date: >
{% from 'easy_time.jinja' import this_weekday, count_the_days %}
{% set holiday = state_attr('calendar.holidays','next_holiday') %}
{% if holiday in ["New Year's Day","Memorial Day","Independence Day","Labor Day","Thanksgiving","Christmas"] and count_the_days('calendar.holidays','start_time') | int <= 4 %}
{{ as_timestamp(this_weekday(3)) | timestamp_custom('%Y-%m-%d') }}
{% else %}
{{ as_timestamp(this_weekday(2)) | timestamp_custom('%Y-%m-%d') }}
{% endif %}
end_date: >
{% from 'easy_time.jinja' import this_weekday, count_the_days %}
{% set holiday = state_attr('calendar.holidays','next_holiday') %}
{% if holiday in ["New Year's Day","Memorial Day","Independence Day","Labor Day","Thanksgiving","Christmas"] and count_the_days('calendar.holidays','start_time') | int <= 4 %}
{{ as_timestamp(this_weekday(4)) | timestamp_custom('%Y-%m-%d') }}
{% else %}
{{ as_timestamp(this_weekday(3)) | timestamp_custom('%Y-%m-%d') }}
{% endif %}
- if:
- condition: template
value_template: "{{ states('sensor.todays_high_temp') | int >= states('input_number.hot_day_threshold') | int }}"

View File

@ -384,6 +384,18 @@
{% endif %}
</p>
<p>
{% if count_the_days('calendar.garbage_collection','start_time') == 1 %}
{% if state_attr('calendar.garbage_collection','message') == 'Large Garbage Pickup' %}
Tomorrow is the monthly unlimited garbage pickup. Make sure to take out all regular trash, as well as any larger items that need to be disposed of.
{% else %}
Tomorrow is regular garbage pickup. Make sure that all trash cans are emptied and the outside bin has been wheeled to the curb.
{% endif %}
{% elif is_state('calendar.garbage_collection','on') %}
Today is garbage day. Please make sure to wheel the garbage bin back to the house.
{% endif %}
</p>
<p>
{% from 'sports.jinja' import sports_pregame, sports_main %}
{% if is_state('input_boolean.sports_updates','on') %}

View File

@ -156,6 +156,18 @@
{% endif %}
</p>
<p>
{% if count_the_days('calendar.garbage_collection','start_time') == 1 %}
{% if state_attr('calendar.garbage_collection','message') == 'Large Garbage Pickup' %}
Tomorrow is the monthly unlimited garbage pickup. Make sure to take out all regular trash, as well as any larger items that need to be disposed of.
{% else %}
Tomorrow is regular garbage pickup. Make sure that all trash cans are emptied and the outside bin has been wheeled to the curb.
{% endif %}
{% elif is_state('calendar.garbage_collection','on') %}
Today is garbage day. If the garbage has already been picked up at this time, please wheel the garbage bin back to the house.
{% endif %}
</p>
<p>
{% from 'sports.jinja' import sports_pregame, sports_main %}
{% if is_state('input_boolean.sports_updates','on') %}

View File

@ -5,6 +5,7 @@
{% from 'time.jinja' import input_datetime_12hr, read_time_from_calendar %}
{% from 'status.jinja' import emma_sleep %}
{% from 'formatting.jinja' import cleanup %}
{% from 'easy_time.jinja' import count_the_days %}
<p>
{{ greeting() }}
</p>
@ -251,6 +252,18 @@
{% endif %}
</p>
<p>
{% if count_the_days('calendar.garbage_collection','start_time') == 1 %}
{% if state_attr('calendar.garbage_collection','message') == 'Large Garbage Pickup' %}
Tomorrow is the monthly unlimited garbage pickup. Make sure to take out all regular trash, as well as any larger items that need to be disposed of.
{% else %}
Tomorrow is regular garbage pickup. Make sure that all trash cans are emptied and the outside bin has been wheeled to the curb.
{% endif %}
{% elif is_state('calendar.garbage_collection','on') %}
The garbage was picked up today. Please make sure to wheel the garbage bin back to the house if you have not already.
{% endif %}
</p>
<p>
{{ [
"For some useless trivia that no one asked for, I present to you the following: ",

View File

@ -5,6 +5,7 @@
{% from 'time.jinja' import input_datetime_12hr %}
{% from 'status.jinja' import emma_sleep %}
{% from 'formatting.jinja' import cleanup %}
{% from 'easy_time.jinja' import count_the_days %}
<p>
"Welcome home, "
{% if is_state('person.tony_stork','home') and is_state('person.christina_stork','home') %}
@ -154,6 +155,18 @@
{{ cleanup(emma_sleep()) }}
</p>
<p>
{% if count_the_days('calendar.garbage_collection','start_time') == 1 %}
{% if state_attr('calendar.garbage_collection','message') == 'Large Garbage Pickup' %}
Tomorrow is the monthly unlimited garbage pickup. Make sure to take out all regular trash, as well as any larger items that need to be disposed of.
{% else %}
Tomorrow is regular garbage pickup. Make sure that all trash cans are emptied and the outside bin has been wheeled to the curb.
{% endif %}
{% elif is_state('calendar.garbage_collection','on') %}
Today is garbage day. If the garbage has already been picked up, please wheel the garbage bin back to the house.
{% endif %}
</p>
<p>
{{ dadjoke() }}
</p>