Today it didn’t switch to ‘1’ as I expected, but instead stayed at 30. Running service homeassistant.update_entity sensor.dayofthemonth made the sensor change to the correct value.
Is the update no longer done automatically? I’m running version 115.6
platform: template
sensors:
day_of_the_month:
value_template: >
{% set x = states('sensor.date') %}
{% set suffix = ['st', 'nd', 'rd'] %}
{% set day = now().day %}
{% set index = 3 if day // 10 == 1 or day % 10 == 0 else (day % 10) - 1 %}
{{ day~'th' if index > 2 else day~suffix[index] }}
A recent Home Assistant update caused us not to be able to use entity_id: anymore.
To fix it you can use what I have above or change the entity_id: to something like the set x = states etc which is now the recommended method in Home Assistant.