Skip to content

Latest commit

 

History

History
314 lines (246 loc) · 7.33 KB

File metadata and controls

314 lines (246 loc) · 7.33 KB

Waste Collection Schedule logo

Frequently Asked Questions, or "How Do I ...?"

How do I format dates?

Use strftime in value_template or date_template:

# returns "20.03.2020"
value_template: '{{value.date.strftime("%d.%m.%Y")}}'
date_template: '{{value.date.strftime("%d.%m.%Y")}}'

# returns "03/20/2020"
value_template: '{{value.date.strftime("%m/%d/%Y")}}'
date_template: '{{value.date.strftime("%m/%d/%Y")}}'

# returns "Fri, 03/20/2020"
value_template: '{{value.date.strftime("%a, %m/%d/%Y")}}'
date_template: '{{value.date.strftime("%a, %m/%d/%Y")}}'

How do I show the number of days to the next collection?

Set value_template within the sensor configuration:

value_template: 'in {{value.daysTo}} days'

How do I show Today / Tomorrow instead of in 0 / 1 days?

Set value_template within the sensor configuration:

# returns "Today" if value.daysTo == 0
# returns "Tomorrow" if value.daysTo == 1
# returns "in X days" if value.daysTo > 1
value_template: '{% if value.daysTo == 0 %}Today{% elif value.daysTo == 1 %}Tomorrow{% else %}in {{value.daysTo}} days{% endif %}'

How do I join waste types in a value_template?

Use the join filter:

# returns "Garbage, Recycle"
value_template: '{{value.types|join(", ")}}'

# returns "Garbage+Recycle"
value_template: '{{value.types|join("+")}}'

Note: If you don't specify a value_template, waste types will be joined using the separator configuration variable.

How do I setup a sensor which shows only the days to the next collection?

Set value_template within the sensor configuration:

value_template: '{{value.daysTo}}'

How do I setup a sensor which shows only the date of the next collection?

Set value_template within the sensor configuration:

value_template: '{{value.date.strftime("%m/%d/%Y")}}'

How do I configure a sensor which shows only the waste type of the next collection?

Set value_template within the sensor configuration:

value_template: '{{value.types|join(", ")}}'

How do I configure sensors which show the first, second, third collection?

Set event_index within the sensor configuration:

sensor:
  - platform: waste_collection_schedule
    name: first_garbage_collection
    event_index: 0
    value_template: '{{value.types|join(", ")}} in {{ value.daysTo }} days'

  - platform: waste_collection_schedule
    name: second_garbage_collection
    event_index: 1
    value_template: '{{value.types|join(", ")}} in {{ value.daysTo }} days'

  - platform: waste_collection_schedule
    name: third_garbage_collection
    event_index: 3
    value_template: '{{value.types|join(", ")}} in {{ value.daysTo }} days'

How do I configure a sensor to show only collections of a specific waste type?

Set types within the sensor configuration:

sensor:
  - platform: waste_collection_schedule
    name: next_garbage_collection
    types:
      - Garbage

  - platform: waste_collection_schedule
    name: next_recycle_collection
    types:
      - Recycle

Note: If you have set an alias for a waste type, you must use the alias name.

How can I rename an waste type?

Set alias in the customize section of a source:

waste_collection_schedule:
  sources:
    - name: NAME
      customize:
        - type: Very long garbage name
          alias: Garbage
        - type: Very long recycle name
          alias: Recycle

How can I hide a waste type I don't want to see?

Set show configuration variable to false in the customize section of a source:

waste_collection_schedule:
  sources:
    - name: NAME
      customize:
        - type: Unwanted Waste Type
          show: false

How do I show a coloured Lovelace card depending on the due date?

You can use Button Card to create a coloured Lovelace cards:

Button Card

# configuration.yaml
sensor:
  - platform: waste_collection_schedule
    name: MyButtonCardSensor
    value_template: '{{value.types|join(", ")}}|{{value.daysTo}}|{{value.date.strftime("%d.%m.%Y")}}|{{value.date.strftime("%a")}}'
# button-card configuration
type: 'custom:button-card'
entity: sensor.mybuttoncardsensor
layout: icon_name_state2nd
show_label: true
label: |
  [[[
    var days_to = entity.state.split("|")[1]
    if (days_to == 0)
    { return "Today" }
    else if (days_to == 1)
    { return "Tomorrow" }
    else
    { return "in " + days_to + " days" }
  ]]]
show_name: true
name: |
  [[[
    return entity.state.split("|")[0]
  ]]]
state:
  - color: red
    operator: template
    value: '[[[ return entity.state.split("|")[1] == 0 ]]]'
  - color: orange
    operator: template
    value: '[[[ return entity.state.split("|")[1] == 1 ]]]'
  - value: default

Can I also use the Garbage Collection Card instead?

Yes, the Garbage Collection Card can also be used with Waste Collection Schedule:

# configuration.yaml
sensor:
  - platform: waste_collection_schedule
    name: garbage_days
    details_format: appointment_types
    value_template: "{{ value.daysTo }}"
    types:
      - Garbage

  - platform: template
    sensors:
      garbage:
        value_template: >
          {% if states('sensor.garbage_days')|int > 2 %}
            2
          {% else %}
            {{ states('sensor.garbage_days')|int }}
          {% endif %}
        attribute_templates:
          next_date: "{{ state_attr('sensor.garbage_days', 'Garbage') }}"
          days: "{{ states('sensor.garbage_days')|int }}"
# garbage-collection-card configuration
entity: sensor.garbage
type: 'custom:garbage-collection-card'

How can I sort waste type specific entities?

Prerequisites: You already have dedicated sensors per waste type and want to show the sensor with the next collection in a Lovelace card.

Add add_days_to: True to the configuration of all sensors you want to sort. This will add the attribute daysTo which can be used by e.g. auto-entities to sort entities by day of next collection.