Hi there,
One of my automations requires me to compare a day from my input_datetime with a current date.
After some studying of HA docs I came across to the below config:
- condition: template
value_template: '{{ (states.input_datetime.grass_next.attributes.timestamp| int | timestamp_custom("%Y%m%d", False)|int)|string == (now().year ~ "%02d"|format(now().month) ~ "%02d"|format(now().day) ) }}'
One of the problems is that the timestamp_custom filter outputs the month and day number with a leading zero and I didnât find a way to make now() to be output with the leading zero for month and day and I had to split it into strings and format separately.
It turns out to be a complete template nightmare that one cannot simply embrace and understand
Is there a way to do this simpler?
I feel this should be super simple like comparing A with B. but it\s not. I think the date_time entity and the now() variable should be unified and have a uniform set of attributes that we could compare in our templates.
Something like date comparison seems like an obvious and natural thing in automations. It should be super simple because of this. The current solution is truly cumbersome. In a ânativeâ Python script that would be a lot simpler I guess.