spanzetta
(Stefano Panzetta)
March 2, 2023, 6:47pm
1
Hello all,
I tried to setup those 2 automation… but both simply doesn’t work …
If I don’t use the “template” condition of course they work… but that would mean every day… while I need to have them every 2 days (one) and one every “last day of the month” (the other one)
What am I doing wrong?
Thanks in advance to who will help me…
EdwardTFN
(Edward Firmo)
March 2, 2023, 7:27pm
2
Anything in your log?
What about when you click on test on your condition in the UI editor?
By the way, this is not chn9the results and is not a solution to your issue, but I think this looks a bit more readable:
{{ (now() + timedelta(days=1)).day == 1 }}
finity
March 2, 2023, 7:42pm
3
You should get into the habit of posting properly formatted actual text code instead of screen shots.
it makes it easier for people to help you if they can just copy/paste/edit the code instead of having to type it all out from scratch.
1 Like
spanzetta
(Stefano Panzetta)
March 3, 2023, 1:27pm
4
You are right… I thought that screenshot was easier to see the entire settings page… but here it is the 2 conditions code…
EVERY DAY
condition:
condition: template
value_template: “{{ now().timetuple().tm_yday % 2 == 0 }}”
LAST DAY OF THE MONTH
condition:
condition: template
value_template: “{{(now() + timedelta(days=1)).strftime(’%-d’) == ‘1’ }}”
1 Like
spanzetta
(Stefano Panzetta)
March 3, 2023, 1:28pm
5
About test button … it says “did not pass”… but to test the “last day of the month” need to wait … the last day of the month …
I will now test your code…
thanks
spanzetta
(Stefano Panzetta)
March 4, 2023, 12:46pm
6
it seems it doesn’t work… also the 2nd day the test button says “did not pass”
spanzetta
(Stefano Panzetta)
March 7, 2023, 10:41am
7
This one seems to work fine (every 2 days)
condition: template
value_template: "{{ now() - as_datetime(states('sensor.last_boot')) > timedelta(days=2) }}"
spanzetta
(Stefano Panzetta)
March 8, 2023, 2:31pm
8
Amd this one seems to work as “last day of the month”
condition: template
value_template: "{{(now() + timedelta(days=1)).strftime('%-d') == '1' }}"