Run automation at beginning of month?

Hi all,
I want to make an automation to reset my energy meters and send me an e-mail report at 00:00:00 on day 0 of a month. I got the notification and service call parts working. I just can’t figure out how to make it go at the beginning (or end) of the month. I can run it daily using the time trigger, but couldn’t get it much farther than that.

Any help appreciated. Thanks.

trigger:
  platform: time
  at: '00:00:01'
condition:
  condition: template
  value_template: "{{ now().day == 1 }}"
action:
  .....
7 Likes

Thanks. Is now() more efficient than adding the time_date sensor and polling that? I saw that with some searching but looks like a lot of templates use now().

I set up a test to run tonight. I’ll let you know how it goes.

I don’t think there is any effect on efficiency. It’s just what works best for the circumstance.

Worked last night. I’ll reconfigure for first of the month and we’ll see then.

Thanks for the help!

1 Like

hey!

will this work with month as well?

thx

It certainly will.

Thank you

So i will try this:


  condition:
  - condition: template
    value_template: 'value_template: "{{ now().month == 10 }}"'
  action:

By the way: how I can make this a trigger? Trigger if month change to „10“
But with the condition should result in same

Thx

You can’t use now() in a trigger as it is only evaluated once. So in a condition it is evaluated once for every time the automation triggers, but in a trigger it would not ever be evaluated again.

the new replacement would probably do:

{{as_local(states.sensor.time.last_updated).month == 10}}

?

in this case maybe even better

{{as_local(states.sensor.date.last_updated).month == 10}}

since that only triggers once a day

2 Likes