Waste Collection Schedule / Stadtreinigung Hamburg

Garbage-HomeAssistant

I posted my solution on FB, but I think it is probably better placed here.
Honestly, this solution was influenced by another programmer, but I cannot find who I would have to mention to provide some Kudos.

The grey button field is ment to be as an ‘Acknowledge’ that the can has been moved outside, because I regularly put the trash outside very late and in SOME cases my family has already done it.
So no need to check at 23:00 outside the situation , if the family has been active before…

Here is my solution for Stadtreinigung Hamburg:

######################################################
Configuration.yaml contents:
######################################################

waste_collection_schedule:
  sources:
    - name: stadtreinigung_hamburg
      args:
        asId: !secret SRHH_ID
        hnId: !secret SRHH_HNR

for acknowledge of ‘Waste has been carried out’:

input_boolean:
  waste_outside:
    name: 'Müll muss raus'
    initial: off
sensor:
  - platform: waste_collection_schedule
    source_index: 0
    name: srh_wcf
    details_format: 'upcoming'
    count: 3
    leadtime: 14
    value_template: '{{value.types|join(", ")}}|{{value.daysTo}}|{{value.date.strftime("%d.%m.%Y")}}|{{value.date.strftime("%a")}} '
binary_sensor:   
#------------------------------------------------------------------------------------------------
#                  STADTREINIGUNG SENSOREN                                         
#------------------------------------------------------------------------------------------------
  - platform: template
    sensors:
      srh_morgen_street_gelb:
        friendly_name: "Gelber Sack"
        value_template: >-
          {% set collection = as_timestamp(states.sensor.stadtreinigung_hamburg_wille_gelbe_wertstofftonne_sack.state, default = 0)|timestamp_custom("%Y-%m-%d", default = 0) %}
          {% set tomorrow = (as_timestamp(now(), default = 0) + 86400)|timestamp_custom("%Y-%m-%d", default = 0) %}
          {{ collection == tomorrow }}
      srh_morgen_street_restmuell:
        friendly_name: "Restmüll"
        value_template: >-
          {% set collection = as_timestamp(states.sensor.stadtreinigung_hamburg_wille_schwarze_restmulltonne.state, default = 0)|timestamp_custom("%Y-%m-%d", default = 0) %}
          {% set tomorrow = (as_timestamp(now(), default = 0) + 86400)|timestamp_custom("%Y-%m-%d", default = 0) %}
          {{ collection == tomorrow }}
      srh_morgen_street_biotonne:
        friendly_name: "Biotonne"
        value_template: >-
          {% set collection = as_timestamp(states.sensor.stadtreinigung_hamburg_wille_grune_biotonne.state, default = 0)|timestamp_custom("%Y-%m-%d", default = 0) %}
          {% set tomorrow = (as_timestamp(now(), default = 0) + 86400)|timestamp_custom("%Y-%m-%d", default = 0) %}
          {{ collection == tomorrow }}
      srh_morgen_street_tanne:
        friendly_name: "Weihnachtsbaum"
        value_template: >-
          {% set collection = as_timestamp(states.sensor.stadtreinigung_hamburg_wille_weihnachtsbaume.state, default = 0)|timestamp_custom("%Y-%m-%d", default = 0) %}
          {% set tomorrow = (as_timestamp(now(), default = 0) + 86400)|timestamp_custom("%Y-%m-%d", default = 0) %}
          {{ collection == tomorrow }}
      srh_morgen_street_laubsack:
        friendly_name: "Laubsäcke"
        value_template: >-
          {% set collection = as_timestamp(states.sensor.stadtreinigung_hamburg_wille_laubsacke.state, default = 0)|timestamp_custom("%Y-%m-%d", default = 0) %}
          {% set tomorrow = (as_timestamp(now(), default = 0) + 86400)|timestamp_custom("%Y-%m-%d", default = 0) %}
          {{ collection == tomorrow }}
      srh_morgen_street_papiertonne_2:
        friendly_name: "Altpapier"
        value_template: >-
          {% set collection = as_timestamp(states.sensor.stadtreinigung_hamburg_wille_blaue_papiertonne_2.state, default = 0)|timestamp_custom("%Y-%m-%d", default = 0) %}
          {% set tomorrow = (as_timestamp(now(), default = 0) + 86400)|timestamp_custom("%Y-%m-%d", default = 0) %}
          {{ collection == tomorrow }}

###########################################################
automation.yaml
###########################################################

- id: '1590038779749'
  alias: Müll raus aktivieren
  description: ''
  trigger:
  - entity_id: binary_sensor.srh_morgen_street_restmuell
    from: 'off'
    platform: state
    to: 'on'
  - entity_id: binary_sensor.srh_morgen_street_gelb
    from: 'off'
    platform: state
    to: 'on'
  - entity_id: binary_sensor.srh_morgen_street_biotonne
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data: {}
    entity_id: input_boolean.waste_outside
    service: homeassistant.turn_on

Card for Dashboard:
Requirement: custom:button-card to be installed

cards:
  - entity: sensor.srh_wcf
    label: |
      [[[
        var days_to = entity.state.split("|")[1]
        if (days_to == 0)
        { return "Heute" }
        else if (days_to == 1)
        { return "Morgen"+ " am " + entity.state.split("|")[3] + ", " + entity.state.split("|")[2] }
        else
        { return "in " + days_to + " Tagen" + " am " + entity.state.split("|")[3] + ", " + entity.state.split("|")[2] }
      ]]]
    layout: icon_name_state2nd
    name: |
      [[[
        return entity.state.split("|")[0]
      ]]]
    show_icon: true
    show_label: true
    show_name: true
    state:
      - color: red
        color_type: icon
        operator: template
        value: '[[[ return entity.state.split("|")[1] == 0 ]]]'
      - card: orange
        operator: template
        value: '[[[ return entity.state.split("|")[1] == 1 ]]]'
      - value: default
    type: custom:button-card
  - cards:
      - type: custom:button-card
        entity: binary_sensor.srh_morgen_street_restmuell
        show_state: false
        size: 25%
        icon: mdi:trash-can-outline
        color: black
        state:
          - icon: mdi:trash-can-outline
            styles:
              card:
                - background-color: red
                  color: black
                  filter: opacity(100%)
              icon:
                - color: black
                  filter: grayscale(0%)
            value: 'on'
          - icon: mdi:trash-can-outline
            styles:
              card:
                - background-color: white
                  color: black
                  filter: opacity(50%)
              icon:
                - color: black
                  filter: grayscale(0%)
            value: 'off'
      - entity: binary_sensor.srh_morgen_street_biotonne
        show_state: false
        size: 25%
        icon: mdi:trash-can-outline
        color: green
        state:
          - icon: mdi:trash-can-outline
            styles:
              card:
                - background-color: red
                  color: black
                  filter: opacity(100%)
              icon:
                - color: green
                  filter: grayscale(0%)
            value: 'on'
          - icon: mdi:trash-can-outline
            styles:
              card:
                - background-color: white
                  color: black
                  filter: opacity(50%)
              icon:
                - color: green
                  filter: grayscale(0%)
            value: 'off'
        type: custom:button-card
      - entity: binary_sensor.srh_morgen_street_gelb
        show_state: false
        size: 25%
        icon: mdi:recycle-variant
        color: orange
        state:
          - icon: mdi:recycle
            styles:
              card:
                - background-color: white
                  color: black
                  filter: opacity(50%)
              icon:
                - color: orange
                  filter: grayscale(0%)
            value: 'off'
          - icon: mdi:recycle
            styles:
              card:
                - background-color: red
                  color: yellow
                  filter: opacity(100%)
              icon:
                - color: yellow
                  filter: grayscale(0%)
            value: 'on'
        type: custom:button-card
      - entity: binary_sensor.srh_morgen_street_papiertonne_2
        show_state: false
        size: 25%
        icon: mdi:trash-can-outline
        color: blue
        state:
          - icon: mdi:trash-can-outline
            styles:
              card:
                - background-color: white
                  color: black
                  filter: opacity(50%)
              icon:
                - color: blue
                  filter: grayscale(40%)
            value: 'off'
          - icon: mdi:trash-can-outline
            styles:
              card:
                - background-color: red
                  color: black
                  filter: opacity(100%)
              icon:
                - color: blue
                  filter: grayscale(0%)
            value: 'on'
        type: custom:button-card
      - type: conditional
        conditions:
          - entity: binary_sensor.srh_morgen_street_tanne
            state: 'on'
        card:
          entity: binary_sensor.srh_morgen_street_tanne
          show_state: false
          size: 25%
          icon: mdi:pine-tree
          color: green
          state:
            - icon: mdi:pine-tree
              styles:
                card:
                  - background-color: white
                    color: black
                    filter: opacity(50%)
                icon:
                  - color: lightgreen
                    filter: grayscale(0%)
              value: 'off'
            - icon: mdi:pine-tree
              styles:
                card:
                  - background-color: red
                    color: black
                    filter: opacity(100%)
                icon:
                  - color: lightgreen
                    filter: grayscale(0%)
              value: 'on'
          type: custom:button-card
    type: horizontal-stack
  - entity: input_boolean.waste_outside
    show_state: true
    size: 10%
    state:
      - icon: mdi:transit-transfer
        styles:
          card:
            - background-color: grey
              color: red
              filter: opacity(100%)
          icon:
            - color: red
              filter: grayscale(0%)
        value: 'on'
      - icon: mdi:transit-transfer
        styles:
          card:
            - background-color: white
              color: black
              filter: opacity(50%)
          icon:
            - color: black
              filter: grayscale(0%)
        value: 'off'
    type: custom:button-card
type: vertical-stack

Since I am still (after 2 years) a beginner - I’m not finally sure, that the following component is required…at least it is installed …

For those , who might try this, good luck :slight_smile:

Greets from hamburg,
Joerg

2 Likes

Danke, Grüße aus Schnelsen :wink:

where can i find the SRHHID? I use the Stadtreinigung Hamburg integration but im not happy with it.