I’m using the following code to convert strings to emoticons on my Apple Watch.
This code has worked a few years ago, but now it no longer does.
I’m using the Template tab in the Developer tools.
{% if not is_state('sensor.recycleapp_tomorrow', 'None') %}
{{ ['Ma ','Di ','Wo ','Do ','Vr ','Za ','Zo '][(now().weekday()+1)%7] + states('sensor.recycleapp_tomorrow') | regex_replace(find='pmd', replace='🥫', ignorecase=False) | regex_replace(find='restafval', replace='🗑️', ignorecase=False) | regex_replace(find='papier', replace='📰', ignorecase=False) | regex_replace(find='glas', replace='🍾', ignorecase=False) | regex_replace(find='kerstbomen', replace='🎄', ignorecase=False) | regex_replace(find=',', replace='', ignorecase=False) }}
{% elif not is_state('sensor.recycleapp_today', 'None') %}
{{ ['Ma ','Di ','Wo ','Do ','Vr ','Za ','Zo '][now().weekday()] + states('sensor.recycleapp_today') | regex_replace(find='pmd', replace='🥫', ignorecase=False) | regex_replace(find='restafval', replace='🗑️', ignorecase=False) | regex_replace(find='papier', replace='📰', ignorecase=False) | regex_replace(find='glas', replace='🍾', ignorecase=False) | regex_replace(find='kerstbomen', replace='🎄', ignorecase=False) | regex_replace(find=',', replace='', ignorecase=False) }}
{% endif %}
The result is the following:
So it’s definitely not find-replacing.
However, when I change the code to resemble the case of the sensor states:
{% if not is_state('sensor.recycleapp_tomorrow', 'None') %}
{{ ['Ma ','Di ','Wo ','Do ','Vr ','Za ','Zo '][(now().weekday()+1)%7] + states('sensor.recycleapp_tomorrow') | regex_replace(find='PMD', replace='🥫', ignorecase=False) | regex_replace(find='Restafval', replace='🗑️', ignorecase=False) | regex_replace(find='Papier', replace='📰', ignorecase=False) | regex_replace(find='Glas', replace='🍾', ignorecase=False) | regex_replace(find='Kerstbomen', replace='🎄', ignorecase=False) | regex_replace(find=',', replace='', ignorecase=False) }}
{% elif not is_state('sensor.recycleapp_today', 'None') %}
{{ ['Ma ','Di ','Wo ','Do ','Vr ','Za ','Zo '][now().weekday()] + states('sensor.recycleapp_today') | regex_replace(find='PMD', replace='🥫', ignorecase=False) | regex_replace(find='Restafval', replace='🗑️', ignorecase=False) | regex_replace(find='Papier', replace='📰', ignorecase=False) | regex_replace(find='Glas', replace='🍾', ignorecase=False) | regex_replace(find='Kerstbomen', replace='🎄', ignorecase=False) | regex_replace(find=',', replace='', ignorecase=False) }}
{% endif %}
It is find-replacing.
Any suggestions on why the ignorecase is not working?