Hello,
I’m quite new to HA and currently trying to recreate my IFTTT automations, but I’m stuck on a function concerning calendar events.
In IFTTT I had a button that would create a calender event with the date “next monday”, a function I can’t get to work in HA. Is there a a simple way to do this or would it involvecalculating the current weekday and then the offset to “next monday”? If so I’d be totally out of my depth.
Background: I don’t have a regular schedule for my home-office days and usually plan them only a week ahead. In IFTTT I had a button for every day of the week and on the weekend I’d click the buttons for say Monday and Wednesday. That would create an event on Monday and Tuesday morning, and this event would trigger certain things like turn up the heating etc.
I don’t completely understand how it works, but I think that would’t work within the week? If I used it on Monday for Tuesday the output wouldn’t be tomorrow but the Tuesday the week after, wouldn’t it? I suppose if delta_days is more than 7, 7 would have to be substracted…? No idea how to write that.
And another question: How would I add a fixed time, for example always at 09:00?
Currently my Automation doesn’t yet create an event on at all, but I guess that’s because of my fixed end_date_time, because the error is “Expected all values to have the same timezone”?
Here’s what I have so far. I’m using a toggle, not sure if that’s the best way either:
wrt your monday asking for next tuesday, yes it does the right thing.
that’s the purpose of the 7 - now() part. i did that to get to the end of this week.
so if you asked for next tuesday (wday == 1) and it’s monday (wday == 0),
then it does 7 - 0 (monday). then adds 1 (tuesday). so you get 8. so delta_days == 8 days from now.
on, for setting your time, just pull the date out and add on your time… so for example, change that last part to this to set it at 13:00 (note the leading space is important:
What I meant was that I don’t want it to necessarily be next week. If today is Monday and I want it to set it on next Tuesday, then it should be 1 day from now, not 8. I’m sorry, I didn’t make that clear in my description. So if delta_days is more than 7, I want it to substract 7, if it’s less, I don’t want to substract 7.
Thank you for your script! I tried it out, but I get an error: UndefinedError: ‘dict object’ has no attribute ‘’
Update: OK, the problem was that when creating the script the entity id “script.1709…” was assigned. I changed it manually to “script.create_event” but the button didn’t recognize the new entity ID and suggested “script.17…”. But using this resulted in this error.
So I started over and assigned the “script. create_event” as entity ID on creation, and now it’s working, thanks a lot!