Thanks! Blijft vreemd dat ik het issue niet kan simmuleren, maar desondanks ga ik jouw data in een json zetten en dan parse ik dat… kijken wat er gebeurd
…update volgt vandaag
Het was even puzzelen, maar het is gefixt in release 4.4.8.
De code voor de api zoekt/werkt voornamelijk op datums, de scraper daarintegen zoekt/werkt voornamelijk op afvaltype(n).
hey, 4.4.8 werkt bijna helemaal goed in scrape versie. Enige afwijking hier is dat wij geen PMD hebben maar PBD.
opmerkelijk is wel dat de trash sensor daarvoor in de scraper wel gevonden wordt:
terwijl die in de api variant gewoon PBD wordt genoemd, en ook zo op de Phone App van Saver staat vermeld. Daar staat overigens ook GFT+E terwijl in de scraper gft wordt vermeld… Vandaar dat mijn template sensors _next nog niet correct zijn.
Wat te doen? PBD toevoegen aan de opties in de HA integratie en de scraper? of de template sensors aanpassen…?
thanks!
Hoi Marius, dat klopt! Lang verhaal, maar daar kan ik helaas niets aan veranderen bij de scraper, dan wordt de code erachter te onoverzichtelijk en mogelijk onstabiel. Laten we hopen dat de api alsnog binnenkort wordt opengesteld.
Wel was er nog een bug in de first_next sensors, vandaag werd default nog meegerekend. Dat is opgelost in 4.4.9
Super. 4.4.8 werkte hier goed…
zag hem al binnen komen:
ik zal de update doen, en heb de templates aangepast.
dank!
btw, ook de nieuwe versie werkt naar behoren: uitstekend dus:
sorry for the Dutch language, we’re not supposed to do that. This (specific Dutch) integration makes that very hard though, apologies to the community…
Maybe a stupid question, but my trash_gft / trash_pmd etc sensors doesn’t have the “picture” but stil the MDI icons
I tried to force this pictures within the custimize.yaml like
Blockquotesensor.trash_gft:
entity_picture: /local/mijnafvalwijzer/gft3.png
sensor.trash_papier:
entity_picture: /local/mijnafvalwijzer/papier3.png
sensor.trash_pmd:
entity_picture: /local/mijnafvalwijzer/plastic3.png
sensor.trash_restafval:
entity_picture: /local/mijnafvalwijzer/rest3.png
But that doesn’t do anything.
Also in th GUI it’s not possible to force this , anybody who can help me
Check it here:
And put your images in the folder: my-hass-config/www/afvalwijzer at master · xirixiz/my-hass-config · GitHub
Goedemiddag allen, ik ben redelijk nieuw met HA maar ik kom er wel, denk ik, haha. Nu heb ik afgelopen weekend de afvalwijzer geïnstalleerd en dat ziet er goed uit! Maar wat ik mis (aan kennis) is wat nu precies de stappen zijn om e.e.a. mooi op het dashboard zichtbaar te maken en een korte uitleg per stap. Wie zou mij willen helpen?
The bottom part of you lovelace card looks very nice Marius.
Care to share that part a bit more :D?
sure, here you go:
type: custom:stack-in-card
keep:
background: true
cards:
- type: custom:hui-element
card_type: markdown
content: >
# <font color = {{states('sensor.trash_color')}}>Afvalkalender</font>
<font color={{states('sensor.trash_color')}}><ha-icon icon= {{'mdi:delete-alert' if states('sensor.saver_trash_today') != 'Geen' else 'mdi:delete-outline'}}> </ha-icon></font> Vandaag, {{states('sensor.vandaag')}}: <font color= {{states('sensor.trash_color')}}>**{{states('sensor.saver_trash_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.saver_trash_first_next_in_days')}}</font>** {{'dag' if states('sensor.saver_trash_first_next_in_days') == '1' else 'dagen'}} op:
<ha-icon icon= 'mdi:delete-alert'> </ha-icon> {{states('sensor.volgende_afval_ophaal_dag')}}: **<font color={{states('sensor.trash_next_color')}}>{{states('sensor.saver_trash_first_next_item')|capitalize}}</font>**
- type: horizontal-stack
cards:
- type: picture-entity
style: |
ha-card {
box-shadow: none;
animation: {% if is_state('persistent_notification.trash_notification', 'notifying') and
states('sensor.saver_trash_today') != 'Geen' %} blink 2s linear infinite;
{% else %} none
{% endif %}
}
@keyframes blink {
100% {opacity: 0;}
}
entity: sensor.saver_trash_today
name: Vandaag
show_state: false
state_image: &state_image
gft: /local/afvalwijzer/gft.png
papier: /local/afvalwijzer/papier.png
restafval: /local/afvalwijzer/restafval.png
pmd: /local/afvalwijzer/pmd.png
Geen: /local/afvalwijzer/kliko_geen.png
unknown: /local/afvalwijzer/kliko_geen.png
- type: picture-entity
style: |
ha-card {
box-shadow: none;
animation: {% if is_state('persistent_notification.trash_notification', 'notifying') and
states('sensor.saver_trash_tomorrow') != 'Geen' %} blink 2s linear infinite;
{% else %} none
{% endif %}
}
@keyframes blink {
100% {opacity: 0;}
}
entity: sensor.saver_trash_tomorrow
name: Morgen
show_state: false
state_image: *state_image
- type: picture-entity
style: |
ha-card {
box-shadow: none;
}
entity: sensor.saver_trash_day_after_tomorrow
name: Overmorgen
show_state: false
state_image: *state_image
- type: custom:auto-entities
card:
type: entities
title: Volgende ophaaldata
filter:
include:
- entity_id: sensor.saver_trash_*_next
options:
type: custom:template-entity-row
state: >
{{state_attr(config.entity,'date')}}
secondary: >
{% set count = states(config.entity)|int %}
{% set unit = 'Dag' if count == 1 else 'Dagen' %}
{% if count == 0 %} Vandaag
{% else %} Over {{count}} {{unit}}
{% endif %}
sort:
method: state
numeric: true
- type: entities
style: |
ha-card {
background: url('/local/afvalwijzer/background.png');
background-size: cover;
}
show_header_toggle: false
entities:
- input_boolean.trash_reminder
- input_boolean.trash_outside
- type: divider
- entity: automation.afval_vandaag
name: Notify vandaag
- entity: automation.afval_morgen
name: Notify morgen
I did create a few template sensors to do this, and some other goodies
Hi Marius, I like the wife friendly card.
Thanks for sharing the lovelace code. Is it possible to share the “few template sensors and other goodies”. I like to build the card, but reverse engineering takes a lot time :D?
well, sure, but isnt the fun of this project to create your own things to the exact detail of your needs?
my templates have grown on me, developing along with the changes in the integration, the data put forward by Saver, and possibilities of Lovelace/HA backend. As a matter of fact, I’ve even adapted them yesterday.
here’s my full package:
EDIT
updated the package below to follow the new CC version 5.X
##########################################################################################
## AfvalWijzer Custom Component
## created by @xirixiz, more info on https://github.com/xirixiz/home-assistant-config
## https://community.home-assistant.io/t/garbage-pickup-date-mijnafvalwijzer-nl-custom-component/34631
# place this package in /config/packages
# place the custom component sensor.py in /config/custom_components/afvalwijzer
# @mariusthvdb
# up to date for version 5.x of the CC
##########################################################################################
homeassistant:
customize:
sensor.afvalwijzer_restafval_next:
entity_picture: /local/afvalwijzer/restafval_saver.png
sensor.afvalwijzer_plastic_next:
entity_picture: /local/afvalwijzer/plastic_saver.png
sensor.afvalwijzer_gft_next:
entity_picture: /local/afvalwijzer/gft_saver.png
sensor.afvalwijzer_papier_next:
entity_picture: /local/afvalwijzer/papier_saver.png
sensor.afvalwijzer_restafval:
entity_picture: /local/afvalwijzer/restafval_saver.png
friendly_name: Restafval
sensor.afvalwijzer_plastic:
entity_picture: /local/afvalwijzer/plastic_saver.png
friendly_name: Plastic
sensor.afvalwijzer_gft:
entity_picture: /local/afvalwijzer/gft_saver.png
friendly_name: Gft
sensor.afvalwijzer_papier:
entity_picture: /local/afvalwijzer/papier_saver.png
friendly_name: Papier
sensor.afvalwijzer_first_next_in_days:
friendly_name: Days to next pickup
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:numeric-9-plus-box-multiple-outline';
sensor.afvalwijzer_today:
friendly_name: Afval vandaag
templates: &trash_picture
entity_picture: >
var items = ['papier','gft','plastic','restafval'];
if (items.includes(state))
return '/local/afvalwijzer/' + state + '.png';
return '/local/afvalwijzer/kliko_geen.png';
#previously
# if (state in ['papier','gft','plastic','restafval'])
# return '/local/afvalwijzer/' + state + '.png';
# return '/local/afvalwijzer/kliko_geen.png';
sensor.afvalwijzer_tomorrow:
friendly_name: Afval morgen
templates: *trash_picture
sensor.afvalwijzer_day_after_tomorrow:
friendly_name: Afval Dat
templates: *trash_picture
##########################################################################################
# Sensors
##########################################################################################
sensor:
- platform: afvalwijzer
provider: mijnafvalwijzer # (required, default = mijnafvalwijzer) either choose mijnafvalwijzer or afvalstoffendienstkalender
postal_code: !secret postcode # (required, default = 1111AA)
street_number: !secret huisnummer # (required, default = 11)
# suffix: None #(optional, default = None)
# include_date_today: false #(optional, default = false) to take or not to take Today into account in the next pickup.
default_label: Geen #(optional, default = Geen) label if no date found
- platform: template
sensors:
trash_alert:
value_template: >-
{% if states.sensor.afvalwijzer_today is not none and
states.sensor.afvalwijzer_tomorrow is not none %}
{%- if states('sensor.afvalwijzer_today') != 'Geen'%}
Afval: {{states('sensor.afvalwijzer_today')|title}} wordt vandaag opgehaald
{%- elif states('sensor.afvalwijzer_tomorrow') != 'Geen'%}
Afval: {{states('sensor.afvalwijzer_tomorrow')|title}} wordt morgen opgehaald
{%- else -%} No trash alert
{%- endif -%}
{% else %} No sensors in initiated
{% endif %}
trash_next_icon:
value_template: >
{% set days = states('sensor.afvalwijzer_first_next_in_days') %}
{% if days != 'Geen' %}
{% if days <= '9'%} mdi:numeric-{{days}}-box-multiple-outline
{% else %} mdi:numeric-9-plus-box-multiple-outline
{% endif%}
{% else %} mdi:checkbox-blank-outline
{% endif %}
trash_next_color:
value_template: >
{% set next = states('sensor.afvalwijzer_first_next_item') %}
{% set mapper = {'papier':'deepskyblue',
'gft':'green',
'plastic':'orange',
'restafval':'black'} %}
{% set color = mapper[next] if next in mapper else 'grey' %}
{{color}}
trash_color:
value_template: >
{% set vandaag = states('sensor.afvalwijzer_today') %}
{% set mapper = {'papier':'deepskyblue',
'gft':'green',
'plastic':'orange',
'restafval':'black'} %}
{% set color = mapper[vandaag] if vandaag in mapper else 'grey' %}
{{color}}
volgende_afval_ophaal_dag:
friendly_name: Volgende afval-ophaal dag
entity_id: sensor.afvalwijzer_first_next_date
value_template: >
{%- set tracker_timestamp = as_timestamp(strptime(states('sensor.afvalwijzer_first_next_date'),'%d-%m-%Y')) %}
{% 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 = tracker_timestamp|timestamp_custom('%w')|int %}
{%- set month = tracker_timestamp |timestamp_custom('%m')|int %}
{{tracker_timestamp|timestamp_custom(wdays[wday] + ' ' '%d' ' ' + months[month-1])}}
#https://community.home-assistant.io/t/markdown-card-with-template-wont-format-correctly/137697/2
afvalwijzer_restafval_next:
friendly_name: Restafval
value_template: >
{{state_attr('sensor.afvalwijzer_restafval','days_until_collection_date')}}
attribute_templates:
date: >
{{as_timestamp(strptime(states('sensor.afvalwijzer_restafval'),'%d-%m-%Y'))
|timestamp_custom('%a %d %b')}}
timestamp: >
{{as_timestamp(strptime(states('sensor.afvalwijzer_restafval'),'%d-%m-%Y'))}}
afvalwijzer_plastic_next:
friendly_name: Plastic
value_template: >
{{state_attr('sensor.afvalwijzer_plastic','days_until_collection_date')}}
attribute_templates:
date: >
{{as_timestamp(strptime(states('sensor.afvalwijzer_plastic'),'%d-%m-%Y'))
|timestamp_custom('%a %d %b')}}
timestamp: >
{{as_timestamp(strptime(states('sensor.afvalwijzer_plastic'),'%d-%m-%Y'))}}
afvalwijzer_gft_next:
friendly_name: Gft
value_template: >
{{state_attr('sensor.afvalwijzer_gft','days_until_collection_date')}}
attribute_templates:
date: >
{{as_timestamp(strptime(states('sensor.afvalwijzer_gft'),'%d-%m-%Y'))
|timestamp_custom('%a %d %b')}}
timestamp: >
{{as_timestamp(strptime(states('sensor.afvalwijzer_gft'),'%d-%m-%Y'))}}
afvalwijzer_papier_next:
friendly_name: Papier
value_template: >
{{state_attr('sensor.afvalwijzer_papier','days_until_collection_date')}}
attribute_templates:
date: >
{{as_timestamp(strptime(states('sensor.afvalwijzer_papier'),'%d-%m-%Y'))
|timestamp_custom('%a %d %b')}}
timestamp: >
{{as_timestamp(strptime(states('sensor.afvalwijzer_papier'),'%d-%m-%Y'))}}
binary_sensor:
- platform: template
sensors:
trash_notification:
friendly_name: Trash is notifying
value_template: >
{{is_state('persistent_notification.trash_notification','notifying')}}
saver_offline:
friendly_name: Saver offline
value_template: >
{{states.sensor.afvalwijzer_today is none}}
device_class: problem
##############################################################################################################
# Automations
##############################################################################################################
automation:
- alias: Saver offline
id: Saver offline
trigger:
platform: state
entity_id: binary_sensor.saver_offline
to: 'on'
action:
- service: persistent_notification.create
data:
notification_id: >
saver-notification
title: >
{{now().strftime('%d %B')}}: Saver melding
message: >
Saver is Offline of heeft andere problemen, geen data voor HA
- service: script.intercom_message
data:
message_nl: >
Het is {{now().strftime('%A %-d %B')}}: Saver is Offline of heeft andere problemen, geen data voor Home Assistant
message_en: >
It is {{now().strftime('%A %-d %B')}}: Saver is Offline and experiencing issues, no data provided to Home Assistant
##############################################################################################################
# Vandaag moet het afval worden voorgezet
##############################################################################################################
#datetime.date.today().strftime('%Y-%m-%d')
- alias: Afval vandaag
id: Afval vandaag
trigger:
platform: time
at: '07:00:00'
condition:
- >
{{states.sensor.afvalwijzer_today is not none}}
- >
{{states('sensor.afvalwijzer_today') != 'Geen'}}
action:
- service: script.intercom_message
data:
message_nl: >
Het is {{now().strftime('%A %-d %B')}}: vandaag wordt {{states('sensor.afvalwijzer_today')}} opgehaald!
message_en: >
It is {{now().strftime('%A %-d %B')}}: today {{states('sensor.afvalwijzer_today')}} will be collected!
- service: script.notify_trash_today
- service: script.persistent_trash_today
- service: script.trash_outside_today
##############################################################################################################
# Morgen moet het afval worden voorgezet
##############################################################################################################
- alias: Afval morgen
id: Afval morgen
trigger:
platform: time
at: '21:00:00'
condition:
- >
{{states.sensor.afvalwijzer_tomorrow is not none}}
- >
{{states('sensor.afvalwijzer_tomorrow') != 'Geen'}}
action:
- service: script.intercom_message
data:
message_nl: >
Het is {{now().strftime('%d %B')}}: Morgen wordt
{{states('sensor.afvalwijzer_tomorrow')|title}} opgehaald!
message_en: >
It is {{now().strftime('%d %B')}}: Tomorrow
{{states('sensor.afvalwijzer_tomorrow')|title}} will be picked up!
- service: script.notify_trash_tomorrow
- service: script.persistent_trash_tomorrow
- service: script.trash_outside_tomorrow
- alias: Reset trash notification
trigger:
platform: state
entity_id: input_boolean.trash_outside
to: 'on'
for:
hours: 5
action:
service: input_boolean.turn_off
entity_id: input_boolean.trash_outside
- alias: Mark trash as moved outside from notification
trigger:
platform: event
event_type: ios.notification_action_fired
event_data:
actionName: MARK_TRASH_MOVED
condition:
>
{{(trigger.event.data.actionName == 'MARK_TRASH_MOVED')}}
action:
- service: input_boolean.turn_on
entity_id: input_boolean.trash_outside
- service: persistent_notification.dismiss
data:
notification_id: trash-notification
- service: notify.mobile_app_calltheboss
data:
title: iOS notification
message: >
Afval staat aan de straat
data:
push:
badge: 0
sound: US-EN-Morgan-Freeman-Garage-Door-Closed.wav
##############################################################################################################
# Scripts
##############################################################################################################
script:
notify_trash_today:
alias: Notify trash today
mode: restart
sequence:
- condition: state
entity_id: input_boolean.notify_utility
state: 'on'
- service: notify.notify
data:
title: >
{{now().strftime('%d %B')}}: Afvalmelding vandaag
message: >
{{states('sensor.afvalwijzer_today')|title}} wordt vandaag opgehaald!
persistent_trash_today:
alias: Persistent trash today
mode: restart
sequence:
- condition: state
entity_id: input_boolean.persistent_notification_create
state: 'on'
- service: persistent_notification.create
data:
notification_id: >
trash-notification
title: >
{{now().strftime('%d %B')}}: Afvalmelding vandaag
message: >
{{states('sensor.afvalwijzer_today')|title}} wordt vandaag opgehaald!
notify_trash_tomorrow:
alias: Notify trash tomorrow
mode: restart
sequence:
- condition: state
entity_id: input_boolean.notify_utility
state: 'on'
- service: notify.notify
data:
title: >
{{now().strftime('%d %B')}}: Afvalmelding morgen
message: >
{{states('sensor.afvalwijzer_tomorrow')|title}} wordt morgen opgehaald!
persistent_trash_tomorrow:
alias: Persistent trash tomorrow
mode: restart
sequence:
- condition: state
entity_id: input_boolean.persistent_notification_create
state: 'on'
- service: persistent_notification.create
data:
notification_id: >
trash-notification
title: >
{{now().strftime('%d %B')}}: Afvalmelding morgen
message: >
{{states('sensor.afvalwijzer_tomorrow')|title}} wordt morgen opgehaald!
trash_outside_tomorrow:
alias: Trash outside tomorrow
mode: restart
sequence:
- condition: state
entity_id: input_boolean.trash_outside
state: 'off'
- condition: state
entity_id: input_boolean.trash_reminder
state: 'on'
- service: notify.mobile_app_calltheboss
data:
title: iOS notification
message: >
{{states('sensor.afvalwijzer_tomorrow')|title}} wordt morgen opgehaald, zet het afval aan de straat
data:
push:
badge: 5
category: 'afval'
sound: US-EN-Alexa-Garage-Door-Opened.wav
trash_outside_today:
alias: Trash outside today
mode: restart
sequence:
- condition: state
entity_id: input_boolean.trash_outside
state: 'off'
- condition: state
entity_id: input_boolean.trash_reminder
state: 'on'
- service: notify.mobile_app_calltheboss
data:
title: iOS notification
message: >
{{states('sensor.afvalwijzer_today')|title}} wordt vandaag opgehaald, zet het afval aan de straat
data:
push:
badge: 5
category: 'afval'
sound: US-EN-Alexa-Garage-Door-Opened.wav
action_data:
entity_id: input_boolean.trash_outside
###############################################################################################################
## Ios
###############################################################################################################
#
ios:
push:
categories:
- name: Afval
identifier: 'afval'
actions:
- identifier: 'MARK_TRASH_MOVED'
title: Afval verwerkt
activationMode: 'background'
authenticationRequired: no
destructive: yes
# behavior: 'default'
###############################################################################################################
## Inputs
###############################################################################################################
input_boolean:
trash_outside:
name: Trash is outside
initial: 'off'
icon: mdi:delete-empty
trash_reminder:
name: Trash reminder enabled
icon: mdi:cellphone-message
and the trash alert button showing on a pickup day:
type: custom:button-card
template: button_body
entity: automation.mark_trash_as_moved_outside_from_notification
name: Mark trash outside
label: >
[[[ var trash = states['sensor.saver_trash_today'].state != 'Geen'
? states['sensor.saver_trash_today'].state : states['sensor.saver_trash_tomorrow'].state;
return trash.charAt(0).toUpperCase() + trash.slice(1); ]]]
icon: mdi:delete-alert
show_state: false
variables:
view: >
[[[ return window.location.pathname.split('lovelace/')[1] == 'home'; ]]]
styles:
card:
- animation: blink 2s ease infinite
label:
- color: >
[[[ var trash = states['sensor.saver_trash_today'].state != 'Geen'
? states['sensor.saver_trash_today'].state : states['sensor.saver_trash_tomorrow'].state;
var mapper = {papier:'deepskyblue',
gft:'green',
plastic:'orange',
restafval: 'black'}
return mapper[trash] ? mapper[trash] :'grey';
]]]
icon:
- color: >
[[[ var trash = states['sensor.saver_trash_today'].state != 'Geen'
? states['sensor.saver_trash_today'].state : states['sensor.saver_trash_tomorrow'].state;
if (trash == 'papier') return 'deepskyblue';
if (trash == 'gft') return 'green';
if (trash == 'plastic') return 'orange';
if (trash == 'restafval') return 'black';
return 'grey';
]]]
tap_action:
action: navigate
navigation_path: /lovelace/tijd_agenda
hold_action:
action: >
[[[ return variables.view ? 'navigate' : 'call-service'; ]]]
navigation_path: >
[[[ return variables.view ? 'tijd_agenda' : null; ]]]
service: >
[[[ return variables.view ? null : 'automation.trigger'; ]]]
service_data:
entity_id: >
[[[ return variables.view ? null : entity.entity_id ]]]
Just noticed that I now got xx days
before xx type
of trash pick up.
I cant remember getting this data from ‘MijnAfvalwijzer’
This gives some nice possibilities. Thanks for sharing !
Edit:
also noticed that some sensor.trash_… have the state None
instead of Geen
Would love to have that back in Dutch again if that’s possible?
Is it a setting somewhere? Or do I just have to deal with it because its data from the Scraper api?
you can set that in the config. ‘Geen’ is supposed to be default, but I needed to actively set it.
Release 5.0.0 has been finalized!!! Please update carefully as there are breaking changes (easy to fix though).
the customize
sensor.afvalwijzer_gft:
friendly_name: GFT
entity_picture: /local/mijnafvalwijzer/gft3.png
sensor.afvalwijzer_papier:
friendly_name: Papier
entity_picture: /local/mijnafvalwijzer/papier3.png
sensor.afvalwijzer_pmd:
friendly_name: PMD
entity_picture: /local/mijnafvalwijzer/plastic3.png
sensor.afvalwijzer_restafval:
friendly_name: Restafval
entity_picture: /local/mijnafvalwijzer/rest3.png
doesn’t work anymore afther the 5.0 upgrade
you should check the sensor names, and adjust accordingly, working perfectly here.
@xirixiz
you might want to add to the breaking changes that ‘next_pickup_in_days’ was changed to ‘days_until_collection_date’…
pmd has changed to plastic