Skip to content

Front end setup #3

Description

@Makin-Things

Hey,
Thanks for the integration. I thought I would share how I set up the front end to display stuff in a card. Hopefully others might find it useful.

This is what the card looks like.
image

Card config:

type: grid
cards:
  - type: custom:button-card
    layout: icon_label
    entity_picture: |
      [[[ 
        if (states['binary_sensor.act_garbage_today'].state == 'on' || states['binary_sensor.act_garbage_tomorrow'].state == 'on')
          return '/local/icons/bin_icons/bin_red.png';
        else
          return '/local/icons/bin_icons/bin_grey.png';
      ]]]
    label: |
      [[[
        if (states['binary_sensor.act_garbage_today'].state == 'on')
          return '<div style="text-align: left; display:inline-block;width:120px">'+variables.name+':</div><div style="text-align: left; display:inline-block;width:100px">'+'Today'+'</div>';
        else if (states['binary_sensor.act_garbage_tomorrow'].state == 'on')
          return '<div style="text-align: left; display:inline-block;width:120px">'+variables.name+':</div><div style="text-align: left; display:inline-block;width:100px">'+'Tomorrow'+'</div>';
        else
          return '<div style="text-align: left; display:inline-block;width:120px">'+variables.name+':</div><div style="text-align: left; display:inline-block;width:150px">'+states['sensor.act_garbage_pickup_day'].state+'</div>';
      ]]]
    show_label: true
    show_entity_picture: true
    size: 60px
    entity: sensor.act_garbage_pickup
    variables:
      name: Garbage
    show_name: false
    styles:
      card:
        - height: 64px
        - padding: 0px
      label:
        - justify-self: start
  - type: custom:button-card
    layout: icon_label
    entity_picture: |
      [[[ 
        if (states['binary_sensor.act_recycling_today'].state == 'on' || states['binary_sensor.act_recycling_tomorrow'].state == 'on')
          return '/local/icons/bin_icons/bin_yellow.png';
        else
          return '/local/icons/bin_icons/bin_grey.png';
      ]]]
    label: |
      [[[
        if (states['binary_sensor.act_recycling_today'].state == 'on')
          return '<div style="text-align: left; display:inline-block;width:120px">'+variables.name+':</div><div style="text-align: left; display:inline-block;width:100px">'+'Today'+'</div>';
        else if (states['binary_sensor.act_recycling_tomorrow'].state == 'on')
          return '<div style="text-align: left; display:inline-block;width:120px">'+variables.name+':</div><div style="text-align: left; display:inline-block;width:100px">'+'Tomorrow'+'</div>';
        else
          return '<div style="text-align: left; display:inline-block;width:120px">'+variables.name+':</div><div style="text-align: left; display:inline-block;width:150px">'+states['sensor.act_recycling_pickup_day'].state+'</div>';
      ]]]
    show_label: true
    show_entity_picture: true
    size: 60px
    entity: sensor.act_recycling_pickup
    variables:
      name: Recycling
    show_name: false
    styles:
      card:
        - height: 64px
        - padding: 0px
      label:
        - justify-self: start
  - type: custom:button-card
    layout: icon_label
    entity_picture: |
      [[[ 
        if (states['binary_sensor.act_greenwaste_today'].state == 'on' || states['binary_sensor.act_greenwaste_tomorrow'].state == 'on')
          return '/local/icons/bin_icons/bin_green.png';
        else
          return '/local/icons/bin_icons/bin_grey.png';
      ]]]
    label: |
      [[[
        if (states['binary_sensor.act_greenwaste_today'].state == 'on')
          return '<div style="text-align: left; display:inline-block;width:120px">'+variables.name+':</div><div style="text-align: left; display:inline-block;width:100px">'+'Today'+'</div>';
        else if (states['binary_sensor.act_greenwaste_tomorrow'].state == 'on')
          return '<div style="text-align: left; display:inline-block;width:120px">'+variables.name+':</div><div style="text-align: left; display:inline-block;width:100px">'+'Tomorrow'+'</div>';
        else
          return '<div style="text-align: left; display:inline-block;width:120px">'+variables.name+':</div><div style="text-align: left; display:inline-block;width:150px">'+states['sensor.act_greenwaste_pickup_day'].state+'</div>';
      ]]]
    show_label: true
    show_entity_picture: true
    size: 60px
    entity: sensor.act_greenwaste_pickup
    variables:
      name: Green Waste
    show_name: false
    styles:
      card:
        - height: 64px
        - padding: 0px
      label:
        - justify-self: start
columns: 1
square: false

Extra needed sensors config:

- platform: template
  sensors:
    act_garbage_pickup_day:
      friendly_name: Next Garbage Pickup Day
      icon_template: mdi:trash-can-outline
      value_template: "{{ (strptime(states('sensor.act_garbage_pickup'), '%d/%m/%Y').date()).strftime('%A')+(' Week' if ((strptime(states('sensor.act_garbage_pickup'), '%d/%m/%Y').date() - strptime(states('sensor.date_time_iso'), '%Y-%m-%dT%H:%M:%S').date()).days > 6) else '') if states('sensor.act_garbage_pickup') != 'unknown' }}"

    act_recycling_pickup_day:
      friendly_name: Next Recycling Pickup Day
      icon_template: mdi:recycle
      value_template: "{{ (strptime(states('sensor.act_recycling_pickup'), '%d/%m/%Y').date()).strftime('%A')+(' Week' if ((strptime(states('sensor.act_recycling_pickup'), '%d/%m/%Y').date() - strptime(states('sensor.date_time_iso'), '%Y-%m-%dT%H:%M:%S').date()).days > 6) else '') if states('sensor.act_recycling_pickup') != 'unknown' }}"

    act_greenwaste_pickup_day:
      friendly_name: Next Greenwaste Pickup Day
      icon_template: mdi:pine-tree-box
      value_template: "{{ (strptime(states('sensor.act_greenwaste_pickup'), '%d/%m/%Y').date()).strftime('%A')+(' Week' if ((strptime(states('sensor.act_greenwaste_pickup'), '%d/%m/%Y').date() - strptime(states('sensor.date_time_iso'), '%Y-%m-%dT%H:%M:%S').date()).days > 6) else '') if states('sensor.act_greenwaste_pickup') != 'unknown' }}"

- platform: time_date
  display_options:
    - "time"
    - "date_time_iso"
    - "time_date"

I have attached the images I used for the card which need to be placed in /config/www/icons/bin_icons

bin_yellow
bin_green
bin_grey
bin_red

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions