What day is it currently where you are?
Secondly, you’re using the same entity_id in all your template sensors. You need to change each one to the correct entity_id.
What day is it currently where you are?
Secondly, you’re using the same entity_id in all your template sensors. You need to change each one to the correct entity_id.
oh damn i feel stupid for the last one haha, i will correct this.
Currently its thursday the 4th
change now()
in your templates to today_at()
{{ (strptime(states('sensor.mijnafvalwijzer_gft'), '%d-%m-%Y') | as_local - today_at()).days }}
and if you want the unit_of_measurement to show days. Just add that to the template sensor.
- name: afvalbeheer_gft
unique_id: afvalbeheer_gft
state: "{{ (strptime(states('sensor.mijnafvalwijzer_gft'), '%d-%m-%Y') | as_local - today_at()).days }}"
availability: "{{ 'sensor.mijnafvalwijzer_gft' | has_value }}"
unit_of_measurement: Days
I have another template for you, it should state Today,.Tomorrow, 2 Days, 3 Days etc. depending on the date.
{% set days = (((strptime(states('sensor.mijnafvalwijzer_gft'), '%d-%m-%Y') | as_local - now()).days + 1) | int) %}
{% if days == 0 %}
Today
{% elif days == 1 %}
Tomorrow
{% else %}
{{ days }} Days
{% endif %}
Wow Thank you , you are the wizard! this is already much better!
I still wanna read days until (preferably i will write this in dutch) but this is already a big improvement!
looks good aswell,
Will this be just instead of the state:… line
if its not to much trouble, could you show me how to put this my current yaml.
This what your showing would be exactly how i want this to work.
Yes, for example
- name: "Bin Collection Day"
unique_id: "Bin Collection Day"
icon: mdi:calendar
state: >
{% set days = (((strptime(states('sensor.mijnafvalwijzer_gft'), '%d-%m-%Y') | as_local - now()).days + 1) | int) %}
{% if days == 0 %}
Today
{% elif days == 1 %}
Tomorrow
{% else %}
{{ days }} Days
{% endif %}
oke i see this, but i dont see a entity specified. is this an overall change of the date?
is this a one time template, or do i need to make this for each entity.
you can see my current yaml files. you can probably tell me exactly how to fit this in so that with each entity (trash bin) i would get to see today tomorrow and so on.
Your help is much appreciated. i tryd to do it myself but i realy got stuck
I’ve been posting my test script, hold on
See Above, posts edited, please test.
FYI I have a whole library that does all of this for you in your own language
{% from 'easy_time.jinja' import speak_the_days %}
{{ speak_the_days(strptime(states('sensor.mijnafvalwijzer_gft'), '%d-%m-%Y')) }}
Its Working, only thing is bacause now im using words i guess, the sortation of left to right is messed up, but i will see if i can fix this later.
Thank you guys this was very helpfull! i really appreciate all the support for this!!!
Oh thanks i will look in to this this evening!!
If you have any tip on how to sort this from left to right it would be completely done!
I think it will be hard to sort, unless i will go back to:
0 days, 3 days , 4 days etc
In this way it will be able to sort by numeric state
You have to use auto-entities custom card to sort left to right.
If you end up using it. Post here and I’ll help you make new template sensors using easy_time
that will allow you to sort left to right with auto-entities.
i know, this i already had done before starting to try to get the ‘‘days until’’
type: custom:auto-entities
card:
square: true
type: grid
columns: 4
card_param: cards
filter:
include:
- entity_id: sensor.afvalbeheer_gft_2
options:
type: picture-entity
show_name: false
image: /local/afbeeldingen/GFT1.png
card_mod:
style: |
ha-card
{background: transparent;
border-style: none;
color: red;
- entity_id: sensor.afvalbeheer_papier_2
options:
type: picture-entity
show_name: false
image: /local/afbeeldingen/PAPIER1.png
card_mod:
style: |
ha-card
{background: transparent;
border-style: none;
- entity_id: sensor.afvalbeheer_pmd_2
options:
type: picture-entity
show_name: false
image: /local/afbeeldingen/PLASTIC1.png
card_mod:
style: |
ha-card
{background: transparent;
border-style: none;
- entity_id: sensor.afvalbeheer_restafval
options:
type: picture-entity
show_name: false
image: /local/afbeeldingen/REST1.png
card_mod:
style: |
ha-card
{background: transparent;
border-style: none;
exclude: []
sort:
method: state
numeric: false
this was already in the yaml i shared before
this was working fine, but ofcourse not any more because im using either letters or numbers,
I could make a different post, but i cant seem to figure out how to remove the bottom “shadow” that surrounds the text on the bottom,
I did manage to make the rest of the card invisible… borders and so on. Just not the bottom part.
The letters can stay white since im using a different background
I changed it to a conditional card.
Only displaying the bins that are due to be emptied today or tomorrow.
Still these sensors where very helpfull for this!
So… this will be a bit complex. But… this is how you’d get what you want.
Change your template sensors to this after installing easy_time. Make sure to set your language in easy_time.
- name: "Bin Collection Day"
unique_id: "Bin Collection Day"
icon: mdi:calendar
state: >
{% from 'easy_time.jinja' import speak_the_days %}
{{ speak_the_days(strptime(states('sensor.mijnafvalwijzer_gft'), '%d-%m-%Y')) }}
attributes:
days: >
{% from 'easy_time.jinja' import count_the_days %}
{{ count_the_days(strptime(states('sensor.mijnafvalwijzer_gft'), '%d-%m-%Y')) }}
Then your auto_entities card…
type: custom:auto-entities
card:
square: true
type: grid
columns: 4
card_param: cards
filter:
template: >
[{%- set entities = [
'sensor.afvalbeheer_gft_2',
'sensor.afvalbeheer_papier_2',
'sensor.afvalbeheer_pmd_2',
'sensor.afvalbeheer_restafval',
] -%}
{%- set images = [
'/local/afbeeldingen/GFT1.png',
'/local/afbeeldingen/PAPIER1.png',
'/local/afbeeldingen/PLASTIC1.png',
'/local/afbeeldingen/REST1.png',
] -%}
{%- for so in entities | expand | sort(attribute='attributes.days') %}
{
"type": "picture-entity",
"show_name": false,
"image": "{{ images[loop.index] }}",
"card_mod": {"style": "ha-card {background: transparent; border-style: none;}"},
"entity_id": "{{ so.entity_id }}"
},
{%- endfor %}]