Using 'Month' in a condition

There are open issues for templates and zones in the condition tester.

This seems to just be an issue with the test button, it does not actually affect the function of automations.

1 Like

So why isn’t yesterday part of the month of april?

Executed: 20 April 2022, 19:30:00
Result:

result: false
entities: []

You keep giving us bits and pieces.
The only time you actually posted the full automation then there was a clear error.

Two have now confirmed the code works, as long as you keep posting just snippets of automations and traces then it’s very hard to see the issue.

can you go to automations and click on the timer on the right hand side.

so we can see something like this

And please post your final yaml code as well as your results from automations.

It actually triggered yesterday.

from what I can see from the history the code looks the same, but maybe the Visual interface puts some extra " ’ or something that breaked it.

Thanks for going through the troubleshooting above because he helped me implement this and work through the same “test button” error myself.

The template condition for months is working perfectly.

1 Like

Try creating a sensor and using that in your condition. Your can use the ‘B’ and ‘m’ switches to return the month name (eg ‘October’) or the number (eg ‘10’)

month:
  friendly_name: 'Month'
  value_template: "{{now().strftime('%B')}}"
 
month_number:      
  friendly_name: 'Month of the Year'      
  value_template: "{{now().strftime('%m')}}"
2 Likes

Thank you!