Add time to timestamp

Hi,

I’m already breaking my head over this for a couple of days where I searched and tried to find a solution. The thing I’m trying to do is to open my curtains at sunrise but only I the sunrise is later than 07:30. If it is earlier than 07:30 I want to add a random amount of minutes to 07:30. I got everything working in the automation and the random minutes. I want to use the timedelta where the minutes is the random value. I can’t seem to add 07:30 + the time delta minutes I get a string error and I can’t get the 07:30 as time so I can add the minutes. is I use now() + the time delta with the random minutes it works. Any ideas?

Thanks anyway

timedelta is a datetime method, so you need to start with a datetime object. You can get a datetime object from a time string like “07:30” by using the today_at() function:

{{ today_at('07:30') + timedelta( minutes= range(0, 30) | random ) }}

Wow it works. Spend many hours trying to find this. thanks a lot.