Sorry, didn’t see the post until now. Is this a template sensor or automation? In any case, you’re missing the trigger that will cause the automation to run or the sensor state to change.
I haven’t used triggers on my template sensors, but if it’s done as an automation with a trigger it should work fine. As far as template sensors with triggers, there are a few sources on the HA Community Forums of folks that have utilized this method.
If you’re using it as a template sensor without a trigger it would likely only change whenever you either would restart HA or reload the template sensors. To reload the template sensors you can write a script (that is called by an automation when it is a certain time):
If you prefer the full script:
alias: "RELOAD: Template Entities"
- service: template.reload
But just to advise, the sensor/template/script won’t update until you have a trigger (Automation Triggers). Or see Template Sensor Triggers
Hope this helps