Hi @Mariusthvdb,
Thank you for the quick responses. I’ve tried to incorporate your code into the correct YAML files. I assume this is also the intention? Below, you can see everything I’ve managed to put together so far.
Somehow, I can’t find the sensor “sensor.today” anymore. In the map, you can see this as “Today, unknown: Gft, paper.”
As you can see on the card, there are 2 types of waste being collected on September 26th, namely “GFT and Paper.” I haven’t been able to split the image into two parts for this either. I saw in the community that it’s possible, but I wasn’t able to find the “How To” guide. Perhaps you have a solution for this?
It’s a lot. I hope that you’re willing and able to help me further. After all, I also want to learn from it. Just keep in mind that coding is not my strongest skill.
The Card (so far)
Somehow the “sensor.today” is not showing up anymore.
Code of the card
type: custom:mod-card
card_mod:
style: |
:host {
--stack-card-margin: 0px;
}
card:
type: vertical-stack
cards:
- type: custom:button-card
name: Afvalwijzer
template: null
hold_action:
action: navigate
navigation_path: |
[[[ return window.location.pathname.split('/')[2] == 'kalender'
? '/ui-data/summary' : null; ]]]
styles:
card:
- background-color: var(--background-color-off)
- color: Darkgreen
- font-size: 20px
- font-weight: Bold
- padding: 12px
name:
- justify-self: left
- type: custom:hui-element
card_type: markdown
card_mod:
style: |
ha-card.type-markdown {
box-shadow: none;
}
content: >
<font color={{states('sensor.trash_color')}}><ha-icon icon=
{{'mdi:delete-alert' if states('sensor.afvalwijzer_today') != 'geen'
else 'mdi:delete-outline'}}> </ha-icon></font> Vandaag,
{{states('sensor.today')}}: <font color=
{{states('sensor.trash_color')}}>**{{states('sensor.afvalwijzer_today')|capitalize}}</font>**
<font color={{states('sensor.trash_next_color')}}><ha-icon icon=
{{states('sensor.trash_next_icon')}}> </ha-icon></font> Volgende
afval-ophaal over **<font
color={{states('sensor.trash_next_color')}}>{{states('sensor.afvalwijzer_next_in_days')}}</font>**
{{'dag' if states('sensor.afvalwijzer_next_in_days') == '1' else
'dagen'}} op:
<ha-icon icon= 'mdi:delete-alert'> </ha-icon>
{{states('sensor.afvalwijzer_next_date')}}: **<font
color={{states('sensor.trash_next_color')}}>{{states('sensor.afvalwijzer_next_type')|capitalize}}</font>**
- type: horizontal-stack
cards:
- type: picture-entity
card_mod:
style: |
ha-card {
box-shadow: none;
animation: {% if is_state('input_boolean.afval_vandaag_notificatie','on')
and states('sensor.afvalwijzer_today') != 'geen' -%}
blink 2s linear infinite;
{% else -%} none
{% endif %}
}
@keyframes blink {
100% {opacity: 0;}
}
entity: sensor.afvalwijzer_today
name: Vandaag
show_state: false
state_image:
gft: /local/afvalwijzer/gft.png
papier: /local/afvalwijzer/papier.png
restafval: /local/afvalwijzer/restafval.png
plastic: /local/afvalwijzer/plastic.png
geen: /local/afvalwijzer/geen.png
unknown: /local/afvalwijzer/geen.png
- type: picture-entity
card_mod:
style: |
ha-card {
box-shadow: none;
animation: {% if is_state('input_boolean.afval_morgen_notificatie','on')
and states('sensor.afvalwijzer_morgen') != 'geen' -%}
blink 2s linear infinite;
{% else -%} none
{% endif %}
}
@keyframes blink {
100% {opacity: 0;}
}
entity: sensor.afvalwijzer_tomorrow
name: Morgen
show_state: false
state_image:
gft: /local/afvalwijzer/gft.png
papier: /local/afvalwijzer/papier.png
restafval: /local/afvalwijzer/restafval.png
plastic: /local/afvalwijzer/plastic.png
geen: /local/afvalwijzer/geen.png
unknown: /local/afvalwijzer/geen.png
- type: picture-entity
entity: sensor.afvalwijzer_day_after_tomorrow
card_mod:
style: |
ha-card {
box-shadow: none;
}
name: Overmorgen
show_state: false
state_image:
gft: /local/afvalwijzer/gft.png
papier: /local/afvalwijzer/papier.png
restafval: /local/afvalwijzer/restafval.png
plastic: /local/afvalwijzer/plastic.png
geen: /local/afvalwijzer/geen.png
unknown: /local/afvalwijzer/geen.png
- type: custom:auto-entities
card:
type: entities
filter:
exclude:
- entity_id: sensor.afvalwijzer*next*
- entity_id: sensor.afvalwijzer*to*
- entity_id: sensor.afvalwijzer*until*
include:
- entity_id: sensor.afvalwijzer_*
options:
type: custom:template-entity-row
image: >
{% set type = config.entity.split('afvalwijzer_')[1] %}
/local/afvalwijzer/{{type}}.png
state: >
{% set trash = config.entity %} {% set today =
state_attr(trash,'is_collection_date_today') %} {% set future =
state_attr(trash,'days_until_collection_date') %} {% if future
is none or
(is_state(trash,'geen') and future == 0) %} Tba
{% else %} {{as_timestamp(strptime(states(trash),'%d-%m-%Y'))
|timestamp_custom('%-d %b')}}
{% endif %}
secondary: >
{% set trash = config.entity %} {% set today =
state_attr(trash,'is_collection_date_today') %} {% set future =
state_attr(trash,'days_until_collection_date') %} {% if future
is none or
(is_state(trash,'geen') and future == 0) %} Nog niet gepubliceerd
{% else %}
{% set count =
state_attr(trash,'days_until_collection_date')|int(default=0) %}
{% set dagnummer = as_timestamp(strptime(states(trash),'%d-%m-%Y'))
|timestamp_custom('%w')|int(default=0) %}
{% set dagen =
['Zondag','Maandag', 'Dinsdag', 'Woensdag','Donderdag','Vrijdag',
'Zaterdag'] %}
{% set dag = dagen[dagnummer] %}
{% set unit = 'dag' if count == 1 else 'dagen' %}
{% if count >= 28 %} {% set phrase = dag + ' over 4 weken' %}
{% elif count >= 21 %} {% set phrase = dag + ' over 3 weken' %}
{% elif count >= 14 %} {% set phrase = dag + ' over 2 weken' %}
{% elif count >= 7 %} {% set phrase = 'Volgende week ' + dag %}
{% elif count >= 3 %} {% set phrase = 'komende ' + dag %}
{% elif count == 2 %} {% set phrase = dag + ', overmorgen' %}
{% elif count == 1 %} {% set phrase = 'morgen, ' + dag %}
{% else %} {% set phrase = 'Vandaag, ' + dag %}
{% endif %}
{{phrase}} {% if count != 0 %} ({{count}} {{unit}}) {% endif %}
{% endif %}
sort:
method: attribute
attribute: days_until_collection_date
numeric: true
entities:
- type: custom:fold-entity-row
head:
type: section
label: Automaten
card_mod:
style: |
.label {
margin-left: 0px;
}
group_config:
state_color: true
secondary_info: last-triggered
padding: 0
entities:
- entity: input_boolean.afval_reminder
secondary_info: last-changed
- entity: input_boolean.afval_staat_voor
secondary_info: last-changed
- type: divider
- entity: automation.afval_vandaag
name: Notify vandaag
- entity: automation.afval_morgen
name: Notify morgen
- entity: automation.saver_offline
- entity: automation.reset_trash_notification
- entity: automation.mark_trash_as_moved_outside_from_notification
/config/sensors.yaml
#### Afvalwijzer ##################################
- platform: afvalwijzer
provider: rd4 # (required, default = mijnafvalwijzer) either choose mijnafvalwijzer or afvalstoffendienstkalender
postal_code: 9999AA # (required, default = '')
street_number: 99 # (required, default = '')
# suffix: A # (optional, default = '')
# exclude_pickup_today: true # (optional, default = true) to take or not to take Today into account in the next pickup.
default_label: Geen # (optional, default = Geen) label if no date found
# id: '' # (optional, default = '') use if you'd like to have multiple waste pickup locations in HASS
# exclude_list: '' # (optional, default = '') comma separated list of wast types (case ignored). F.e. "papier, gft"
/config/customize.yaml
sensor.afvalwijzer_vandaag: &afval
hide_attributes: templates
templates:
entity_picture: >
var path = '/local/afvalwijzer/';
var ext = '.png';
var type = ['restafval','gft','pmd','papier','best_tas','snoeiafval'];
return type.includes(state) ? path + state + ext : path + 'geen' + ext;
sensor.afvalwijzer_morgen: *afval
sensor.afvalwijzer_overmorgen: *afval
# niet in frontend
# sensor.afvalwijzer_next_in_days:
# hide_attributes: templates
# templates:
# icon: >
# if (state === 'Geen') return 'mdi:calendar-question';
# var items = ['1','2','3','4','5','6','7','8','9'];
# if (items.includes(state))
# return 'mdi:numeric-' + state + '-box-multiple-outline';
# return 'mdi:help';
/config/templates.yaml
- trigger:
- platform: homeassistant
event: start
- platform: time_pattern
hours: '/1'
sensor:
- unique_id: trash_alert
state: >-
{% if has_value('sensor.afvalwijzer_tomorrow') or
has_value('sensor.afvalwijzer_today') %}
{%- if states('sensor.afvalwijzer_tomorrow') != 'geen' and
states('input_boolean.afval_morgen_notificatie') == 'on'%}
Afval: {{states('sensor.afvalwijzer_tomorrow')|title}} wordt morgen opgehaald
{%- elif states('sensor.afvalwijzer_today') != 'geen'%}
Afval: {{states('sensor.afvalwijzer_today')|title}} wordt vandaag opgehaald
{%- else -%} Geen afval alert
{%- endif -%}
{% else %} Geen sensors gemaakt
{% endif %}
- unique_id: trash_next_icon
state: >
{% set days = states('sensor.afvalwijzer_next_in_days') %}
{% if days != 'geen' %}
{% if days|int <= 9 %} mdi:numeric-{{days}}-box-multiple-outline
{% else %} mdi:numeric-9-plus-box-multiple-outline
{% endif%}
{% else %} mdi:checkbox-blank-outline
{% endif %}
- unique_id: trash_next_color
state: >
{% set next = states('sensor.afvalwijzer_next_type') %}
{% set colors = {'papier':'deepskyblue','gft':'darkgreen',
'plastic':'orange','restafval':'black'} %}
{{colors.get(next,'grey')}}
- unique_id: trash_color
state: >
{% set vandaag = states('sensor.afvalwijzer_today') %}
{% set colors = {'papier':'deepskyblue','gft':'darkgreen',
'plastic':'orange','restafval':'black'} %}
{{colors.get(vandaag,'grey')}}
- unique_id: volgende_afval_ophaal_dag
state: >
{%- set next = as_timestamp(strptime(states('sensor.afvalwijzer_next_date'),
'%d-%m-%Y',none),none) %}
{% set months = ['Januari','Februari','Maart','April','Mei','Juni','Juli',
'Augustus','September','Oktober','November','December'] %}
{%- set wdays = ['Zondag','Maandag','Dinsdag','Woensdag','Donderdag',
'Vrijdag','Zaterdag'] %}
{%- set wday = next|timestamp_custom('%w',default=none)|int(default=0) %}
/config/scripts.yaml
notify_trash_today:
mode: restart
sequence:
- condition: state
entity_id: input_boolean.notify_utility
state: 'on'
- service: notify.notify
data:
title: >
{{states('sensor.vandaag').split('dag ')[1]}}: Afval vandaag
message: >
{{states('sensor.afvalwijzer_vandaag')|title}} wordt vandaag opgehaald!
persistent_trash_today:
mode: restart
sequence:
- condition: state
entity_id: input_boolean.persistent_notification_create
state: 'on'
- service: persistent_notification.create
data:
notification_id: afval_vandaag_notificatie
title: >
{{states('sensor.vandaag').split('dag ')[1]}}: Afval vandaag
message: >
{{states('sensor.afvalwijzer_vandaag')|title}} wordt vandaag opgehaald!
- service: input_boolean.turn_on
target:
entity_id: input_boolean.afval_vandaag_notificatie
notify_trash_tomorrow:
mode: restart
sequence:
- condition: state
entity_id: input_boolean.notify_utility
state: 'on'
- service: notify.notify
data:
title: >
{{states('sensor.vandaag').split('dag ')[1]}}: Afval morgen
message: >
{{states('sensor.afvalwijzer_morgen')|title}} wordt morgen opgehaald!
persistent_trash_tomorrow:
mode: restart
sequence:
- condition: state
entity_id: input_boolean.persistent_notification_create
state: 'on'
- service: persistent_notification.create
data:
notification_id: afval_morgen_notificatie
title: >
{{states('sensor.vandaag').split('dag ')[1]}}: Afval morgen
message: >
{{states('sensor.afvalwijzer_morgen')|title}} wordt morgen opgehaald!
- service: input_boolean.turn_on
target:
entity_id: input_boolean.afval_morgen_notificatie
trash_outside_tomorrow:
mode: restart
sequence:
- condition: state
entity_id: input_boolean.afval_staat_voor
state: 'off'
- condition: state
entity_id: input_boolean.afval_reminder
state: 'on'
- service: notify.mobile_app_marijn
data:
title: iOS notification
message: >
{% set title = states('sensor.afvalwijzer_morgen')|title %}
{{title}} wordt morgen opgehaald, zet het afval aan de straat
data:
actions:
- action: MARK_TRASH_MOVED
title: Afval verwerkt
destructive: true
push:
badge: 5
sound: US-EN-Morgan-Freeman-Cleaning-Supplies-Closet-Opened.wav
trash_outside_today:
mode: restart
sequence:
- condition: state
entity_id: input_boolean.afval_staat_voor
state: 'off'
- condition: state
entity_id: input_boolean.afval_reminder
state: 'on'
- service: notify.mobile_app_marijn
data:
title: iOS notification
message: >
{% set title = states('sensor.afvalwijzer_vandaag')|title %}
{{title}} wordt vandaag opgehaald, zet het afval aan de straat
data:
actions:
- action: MARK_TRASH_MOVED
title: Afval verwerkt
destructive: true
push:
badge: 5
sound: US-EN-Morgan-Freeman-Cleaning-Supplies-Closet-Opened.wav
action_data:
entity_id: input_boolean.afval_staat_voor
/config/automations.yaml
- id: '1692794685448'
alias: Stalamp Abbygael schakelen
description: Stalamp slaapkamer Abbygael geschakeld met tweevoudige schakelaar
trigger:
- platform: device
domain: mqtt
device_id: 13bfa105be59e6e04453dd11fb9ef379
type: action
subtype: 1_single
discovery_id: 0xf4b3b1fffe45cd92 action_1_single
condition: []
action:
- type: toggle
device_id: fcac236e31949416cbb8d63f62176eea
entity_id: 7906cef79b8897909ab931db4ab62e21
domain: light
mode: single
- id: '1692797554562'
alias: Licht woonkamer schakelen
description: ''
trigger:
- platform: sun
event: sunset
offset: -00:20:00
id: Lampen aan
- platform: time
at: '23:00:00'
id: Lampen uit
condition: []
action:
- choose:
- conditions:
- condition: trigger
id:
- Lampen aan
sequence:
- service: light.turn_on
data:
brightness_pct: 50
target:
entity_id:
- light.lampen_woonkamer_50
- service: light.turn_on
data:
brightness_pct: 35
target:
entity_id: light.lampen_woonkamer_35
- conditions:
- condition: trigger
id:
- Lampen uit
sequence:
- service: light.turn_off
data: {}
target:
entity_id: light.lampen_woonkamer
mode: single
- id: '1695670434798'
alias: saver_offline
description: ''
trigger:
platform: state
entity_id: binary_sensor.saver_offline
to: 'on'
action:
- service: persistent_notification.create
data:
notification_id: saver_notificatie
title: Saver melding
message: '{{now().strftime(''%d %B'')}}: Saver is Offline
'
- service: script.intercom_message
data:
message_nl: 'Het is {{states(''sensor.vandaag'').split(''dag '')[1]}}: Saver
is Offline, geen data voor Home Assistant
'
message_en: 'Today is {{now().strftime(''%A %-d %B'')}}: Saver is Offline and
experiencing issues, no data provided to Home Assistant
'
- id: '1695670498783'
alias: afval_vandaag
description: ''
trigger:
platform: time
at: 07:00
condition:
- '{{has_value(''sensor.afvalwijzer_vandaag'')}}
'
- not:
condition: state
entity_id: sensor.afvalwijzer_vandaag
state: geen
action:
- service: script.intercom_message
data:
message_nl: '{% set vandaag = states(''sensor.afvalwijzer_vandaag'') %} {{states(''sensor.vandaag'').split(''dag
'')[1]}}: vandaag wordt {{vandaag}} opgehaald!
'
message_en: '{% set today = states(''sensor.afvalwijzer_vandaag'') %} {{now().strftime(''%A
%-d %B'')}}: today {{today}} will be collected!
'
- service: script.persistent_trash_today
- service: script.trash_outside_today
- id: '1695670548995'
alias: afval_morgen
description: ''
trigger:
platform: time
at: '21:00'
condition:
- '{{has_value(''sensor.afvalwijzer_morgen'')}}
'
- not:
condition: state
entity_id: sensor.afvalwijzer_morgen
state: geen
action:
- service: script.intercom_message
data:
message_nl: 'Het is {{states(''sensor.vandaag'').split(''dag '')[1]}}: Morgen
wordt {{states(''sensor.afvalwijzer_morgen'')|title}} opgehaald!
'
message_en: 'Today is {{now().strftime(''%d %B'')}}: Tomorrow {{states(''sensor.afvalwijzer_morgen'')|title}}
will be picked up!
'
- service: script.persistent_trash_tomorrow
- service: script.trash_outside_tomorrow
- id: '1695670581563'
alias: reset_trash_notification
description: ''
trigger:
platform: state
entity_id: input_boolean.afval_staat_voor
to: 'on'
for:
hours: 5
action:
service: input_boolean.turn_off
target:
entity_id: input_boolean.afval_staat_voor
- id: '1695670617793'
alias: reset_trash_notification_today
description: ''
trigger:
platform: state
entity_id: sensor.afvalwijzer_vandaag
to: geen
condition:
condition: state
entity_id: input_boolean.afval_vandaag_notificatie
state: 'on'
action:
- service: persistent_notification.dismiss
data:
notification_id: afval_vandaag_notificatie
- service: input_boolean.turn_off
target:
entity_id: input_boolean.afval_vandaag_notificatie
- id: '1695670651401'
alias: reset_trash_notification_tomorrow
description: ''
trigger:
platform: state
entity_id: sensor.afvalwijzer_morgen
to: geen
condition:
condition: state
entity_id: input_boolean.afval_morgen_notificatie
state: 'on'
action:
- service: persistent_notification.dismiss
data:
notification_id: afval_morgen_notificatie
- service: input_boolean.turn_off
target:
entity_id: input_boolean.afval_morgen_notificatie
- id: '1695670701224'
alias: dismiss_afval_notificatie
description: ''
trigger:
- platform: persistent_notification
update_type: removed
notification_id: afval_vandaag_notificatie
- platform: persistent_notification
update_type: removed
notification_id: afval_morgen_notificatie
condition:
or:
- condition: state
entity_id: input_boolean.afval_vandaag_notificatie
state: 'on'
- condition: state
entity_id: input_boolean.afval_morgen_notificatie
state: 'on'
action:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.afval_staat_voor
- service: input_boolean.turn_off
data:
entity_id: 'input_boolean.{{trigger.notification.notification_id}}
'
- service: notify.mobile_app_marijn
data:
title: iOS notification
message: Afval staat aan de straat
data:
push:
badge: 0
sound: 'US-EN-Morgan-Freeman-Good-{{(states(''sensor.part_of_day'') in [''Morning'',''Afternoon''])|iif(''Morning'',''Night'')}}.wav
'
- id: '1695670755636'
alias: mark_trash_as_moved_outside_from_notification
description: ''
trigger:
platform: event
event_type: mobile_app_notification_action
event_data:
action: MARK_TRASH_MOVED
action:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.afval_staat_voor
- service: persistent_notification.dismiss
data:
notification_id: "afval_{{is_state('input_boolean.afval_vandaag_notificatie','on')\n
\ |iif('vandaag','morgen')}}_notificatie\n"
- service: input_boolean.turn_off
data:
entity_id: "input_boolean.afval_{{is_state('input_boolean.afval_vandaag_notificatie','on')\n
\ |iif('vandaag','morgen')}}_notificatie\n"
- service: notify.mobile_app_marijn
data:
title: iOS notification
message: Afval staat aan de straat
data:
push:
badge: 0
sound: 'US-EN-Morgan-Freeman-Good-{{(states(''sensor.part_of_day'') in [''Morning'',''Afternoon''])|iif(''Morning'',''Night'')}}.wav
The images