I have posted about this blueprint on Reddit a few days ago and promised to put it online, so here it is. I hope it will be useful to someone.
Configuration in action:
Github Gist:
garbage_collection_confirmation_blueprint.yaml (github.com)
Importing
Click the badge to import this Blueprint or import this Blueprint by using the Gist URL.
Prerequisites
You will need the following things to use this blueprint:
- a working waste_collection_schedule integration (see here)
- Custom Button card (this)
- A few helper entities (read on)
Features
This example config will display your waste collection status in grey, orange (collection soon) and red and flashing (move your bins now). If you put out the bins you can push the button to confirm and display a green checkmark. The blueprint will take care of activating the flashing mode as well as resetting after the bins have been emptied. And it prevents the button from flashing in case you have already put it out (aka green checkmark).
Let’s put it together
waste_collection_schedule integration
From the waste_collection_schedule integration you will get a sensor for every waste-type, as an example I will use the paper recycling. The sensor-config should look like this:
platform: waste_collection_schedule
name: paper
types:
- Papiertonne
value_template: "{{ value.daysTo }}"
The important part is to use the correct value_template. This will yield the sensor:
- sensor.paper
Your sensor should now display the number of days left to the next collection
Helper
Now we need to create a helper for every sensor to track the alert-state, in this case we create a sensor called
- input_number.paper_alert
(Create Helper → Number, Set minimum value=0, maximum value=2)
Button
Now we can create the button for paper recycling with this YAML:
type: custom:button-card
entity: sensor.paper
layout: icon_name_state2nd
tap_action:
action: call-service
service: input_number.decrement
service_data:
entity_id: input_number.paper_alert
double_tap_action:
action: call-service
service: input_number.increment
service_data:
entity_id: input_number.paper_alert
show_label: true
label: |
[[[
var days_to = entity.state
if (days_to == 0)
{ return "Today" }
else if (days_to == 1)
{ return "Tomorrow" }
else if (days_to == "unknown")
{ return "TBA" }
else
{ return "in " + days_to + " days" }
]]]
show_name: true
name: Paper
icon: |
[[[
if (states["input_number.paper_alert"].state == 1)
{ return "mdi:check-bold" }
else
{ return entity.attributes.icon }
]]]
state:
- color: red
operator: template
value: '[[[ return states["input_number.paper_alert"].state == 2 ]]]'
styles:
icon:
- animation: blink 1s ease infinite
- color: '#1aba92'
operator: template
value: '[[[ return states["input_number.paper_alert"].state == 1 ]]]'
- color: red
operator: template
value: '[[[ return entity.state == 0 ]]]'
- color: orange
operator: template
value: '[[[ return entity.state == 1 ]]]'
- value: default
- operator: template
value: '[[[ return entity.state > 1 ]]]'
color: '#aaaaaa'
What does the button do?
The input_number.paper_alert helper can take three states:
- 0 → everything normal, take status from sensor
- 1 → garbage bins have been confirmed (taken out), display checkmark
- 2 → alert, flash the icon
If you click the button this will decrease the value, so you can go from flashing to checkmark with one click. If you accidently click again it will go to normal mode, which is not what you want but you can also doubleclick to increase the value again. So if you confirmed you have put out the bins but now remember it was all just a dream, you can doublecklick the green checkmark to put on the flashing icon again
Automation
Now if everything works (cycling through the button-states manually) you can create an automation using the blueprint (one automation per waste-type). Mine is called ‘automation.paper_set_alert’. You have to set the sensor entity and the helper entity as well as the time the alarm should start to display on the day before the collection (default is 16:00 / 4pm).
Now every day at the scheduled time the icon should start to flash.
Let me know if something doesn’t work or you have any questions.
Changelog
- 2022-12-28: Initial version