Since a couple of weeks (maybe after release 0.115 but not sure as I am not using this sensor very often in my automations) the following sensor is not refreshed unless I am restarting HA… I added the “sensor.date” to have it refreshed once a day, no change… Anything to help me find what’s wrong ? I am running HA in a venv, python 3.7.3 and HA 0.116…
#
# weekday sensor
#
- platform: template
sensors:
week_day:
value_template: "{% if now().weekday() in (0,) %}Lundi
{% elif now().weekday() in (1,) %}Mardi
{% elif now().weekday() in (2,) %}Mercredi
{% elif now().weekday() in (3,) %}Jeudi
{% elif now().weekday() in (4,) %}Vendredi
{% elif now().weekday() in (5,) %}Samedi
{% elif now().weekday() in (6,) %}Dimanche
{% else %}states.sensor.date.state
{% endif %}"
friendly_name: 'Day of the Week'
unit_of_measurement: "Days"
I had a similar problem. If you use now() in a template what you get is not so much a timestamp as a snapshot of the timestamp as it was when configuration.yaml was loaded - so it doesn’t update without a restart.
My solution was to add unique_id: today to the template, which gave me a sensor sensor.today which could be updated from an automation. If you’re only after days of the week this is quite manageable - everyone must have an automation running at midnight.