Overview
This post describes how I made a garbage reminder that changes every week. In my area, rubbish collection is on a two week cycle as per the following table
Week 1 | Week2 | |
---|---|---|
Monday | Recycling / Council Rubbish | |
Tuesday | Glass | Green waste / Rubbish Bin |
There has been some changes to what Home Assistant (HA) can provide, so this is all being done using the native options, without relying on third party plugins. This solution allows for an image to change depending upon the week. There are three components to make this solution
- Toggle switch is the brains of the system
- Picture card – displays an image depending upon the position of the toggle switch
- Calendar event – toggles the switch when an event occurs.
Toggle Switch
Lets get the brains of this solution configured first
- Go to Settings > Devices and Services > Helpers
- Create a new helper of type Toggle
- I have called my Recycle Week and when turned on represents week 1 of my schedule
- Make note of the entity ID as we will need this (input_boolean.recycle_week).
- Set the toggle to on to represent the first week
Picture Card
Now we have our toggle switch, lets now get the picture card working, and then we can toggle the switch as required and confirm all works as expected. For this blog, I have used two random pictures to represent each week. Later I will update these to represent actual pictures of what I want.
I did this with XML code. Not sure if you can do this with built in editor.
- Switch to a dashboard where you want the card to be displayed
- Click the Add Card button
- Select Picture Entity
- Select the Show code editor entity
- Replace the XML with the code below
- Make modifications as follows:
- Set the input_boolean value as created above
- Change the photos URL (see below)
- Click Save
type: picture-entity entity: input_boolean.recycle_week show_name: false show_state: false state_image: 'on': >- https://images.unsplash.com/photo-1682686581551-867e0b208bd1?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDF8MHxlZGl0b3JpYWwtZmVlZHwxfHx8ZW58MHx8fHx8 'off': >- https://images.unsplash.com/photo-1703555508141-4397207fc6d2?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHw1fHx8ZW58MHx8fHx8 tap_action: none
Testing Image Toggling
On the same dashboard
- Press Add Card
- Change tab to By Entity
- Search or scroll and find Recycle Week entity
- Put a tick in the checkbox next to it
- Press Continue
- Press Add to Dashboard
- Toggle the slide switch of Recycle Switch card and the image in the picture card should change.
- Once satisfied that this works, then delete the Recycle Week toggle card if desired.
Note: We are only temporarily putting this on the dash board for us to test with. Once working, then we can remove this card.
Calendar
Recurring event
If you do not have the local calendar integration installed, then you need to go into settings and install it. This will allow us to create a recurring schedule entry.
Create a new calendar (I have called mine Automations) where we are going to put into the repeating event.
Add a repeating calendar event, weekly. Since I have a Monday/Tuesday collection, I have made the event occur at 4:30pm on a Tuesday. I have chosen then, as by 4:30 on a Tuesday it is too late to put out the Rubbish, and then from Wednesday onward, it is correct. However, chose a time that suits yourself. Make a note of the name of the event you created, as we need this later – my event is called Change Recycling Week
Set the duration of the calendar event to 1 minute. We are only going to be reacting to the start of the event.
Automation
Now we have an event that is recurring, we now need to set up and automation that fires when the calendar event starts.
- Go to Settings > Automations & Scenes
- Under the Automations tab, select Create Automation
- Select Create a new automation
- Under Triggers, select Add Trigger
- Select Calendar
- Select the calendar that has the trigger event
- Leave the rest of the trigger options as default
- Add a condition
- Select Template
- add the following in, changing the value on the right hand side to equal what the calendar event is called: {{ trigger.calendar_event.summary == ‘Test Event’ }}
- Add an Action
- select: Call a service
- Select: Input Boolean: Toggle
- Select the entity we created: Recycle Week
- Click Save
- Give it a name, for example: Automation: Change Recycle Week
- Click Save
Testing it all out
Change the calender event time to be > 15 minutes from now (HA only reads the calendar every 15 minutes). Make a note of the setting of the switch, and then see if it changes when the time elapses.