Skip to content

Instantly share code, notes, and snippets.

@tathamoddie
Created August 5, 2022 03:58
Show Gist options
  • Save tathamoddie/17abf9211524a2716a139cbd07ab0630 to your computer and use it in GitHub Desktop.
Save tathamoddie/17abf9211524a2716a139cbd07ab0630 to your computer and use it in GitHub Desktop.
## ui-views/0-home.yaml
title: Home
path: home
icon: mdi:home
badges:
- sun.sun
- sensor.moon
- person.matt
- person.tats
cards:
- type: entities
title: 🏠 Home
show_header_toggle: false
entities:
- type: custom:template-entity-row
entity: sensor.next_collection
name: "{{ states.sensor.next_collection.state }}"
state: |-
{% set days_to = state_attr('sensor.next_collection', 'daysTo') %}
{% if days_to == 0 %}
Today
{% elif days_to == 1 %}
Out Tonight
{% elif days_to <= 7 %}
{{ (now() + timedelta(days = days_to)).strftime('%A') }}
{% else %}
in {{days_to}} days
{% endif %}
active: "{{ states.sensor.next_collection.attributes.daysTo <= 1 }}"
- type: custom:template-entity-row
entity: sensor.next_hard_waste_collection
name: Hard Waste
state: "{{ strptime(states.sensor.next_hard_waste_collection.attributes.upcoming[0].date, '%Y-%m-%d').strftime('%d %b') }}"
active: "{{ states.sensor.next_hard_waste_collection.attributes.daysTo <= 7 }}"
condition: "{{ states.sensor.next_hard_waste_collection.attributes.daysTo <= 14 }}"
# This approach allows breaking down configuration.yaml into smaller parts
homeassistant:
packages: !include_dir_named packages
title: Our House
views: !include_dir_list ui-views/
## packages/waste_collection.yaml
waste_collection_schedule:
sources:
- name: stonnington_vic_gov_au
args:
street_address: 421 Chapel Street, South Yarra
customize:
- type: General Waste
alias: Garbage
- type: Food and Green Waste
alias: Green Waste
sensor waste:
- platform: waste_collection_schedule
name: next_collection
add_days_to: true
details_format: generic
value_template: '{{value.types|join(", ")}}'
- platform: waste_collection_schedule
name: next_garbage_collection
add_days_to: true
details_format: generic
types:
- Garbage
- platform: waste_collection_schedule
name: next_green_waste_collection
add_days_to: true
details_format: generic
types:
- Green Waste
- platform: waste_collection_schedule
name: next_recycling_collection
add_days_to: true
details_format: generic
types:
- Recycling
- platform: waste_collection_schedule
name: next_hard_waste_collection
add_days_to: true
details_format: generic
types:
- Hard Waste
@tathamoddie
Copy link
Author

It's just a cafe as an example address. But when I'm back at a laptop, I'll swap it out for a !secret as a better practice example. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment