Thanks for your reply, you get it absolutely right. That was my âplanBâ, if nothing else works.
My problem with that solution is, that you have to set the âfriendly_daysâ everywhere you want to use it, not only in one place. I for one have a few different devices, that show my waste collection dates. Iâd have to set the âfriendly_daysâ up in every different viewâŚ
My second point, but that is very specific, Iâd like to use it not only for the âfriendly_daysâ. I need to have something available, that I can use âin codeâ, and to filter for âHEUTEâ is not very user friendly, in my use case not doable, because I additionally need a language variableâŚ
See here for the button-card template:
custom_fields:
notification: >
[[[
if (entity.state == 'unavailable' || entity.state == 'HEUTE' || entity.state == 'MORGEN'){
return `<ha-icon icon="mdi:exclamation" style="width: 12px; height: 12px; color: var(--primary-background-color);"></ha-icon>`
}
]]]
This canât be shared with others, as everyone could have a different name, like âHeuteâ vs. âHEUTEâ or âSpäterâ (yep, have seen that).
IMHO an attribute would be great, one could use the âfriendly_daysâ in value_template
, but could as well check for values.daysTo
. Something like that:
sensor:
- platform: waste_collection_schedule
name: waste_collection_waste
details_format: upcoming
value_template: >-
{% if value.daysTo == 0 %}
HEUTE
{% elif value.daysTo == 1 %}
MORGEN
{% else %}
in {{value.daysTo}} Tagen
{% endif %}
types:
- Restmuelltonne
and in button-card
like this:
custom_fields:
notification: >
[[[
if (entity.state == 'unavailable' || entity.attributes.daysTo == 1 || entity.attributes.daysTo == 0){
return `<ha-icon icon="mdi:exclamation" style="width: 12px; height: 12px; color: var(--primary-background-color);"></ha-icon>`
}
]]]
But maybe Iâm off here and there is a better solution and I just canât see it.