Enhancing My Smart Alarm System with Time Calculations

Hi all, I’m currently working on expanding my smart alarm system and I’m running into a bit of a challenge with timestamp calculations. I thought I’d share my setup and see if anyone has some insights or tips!

My current system is pretty neat—it’s a wake-up light paired with a radio alarm. I’ve added an On/Off switch and a selector for different radio stations, which makes it super versatile. The whole sequence takes about 20 minutes, which I find perfect for a smooth morning routine. I’ve also set up some automation rules that handle the gradual brightening of the lights and the fading in of the radio. It’s not the most fancy setup, but it works well for me!

Now, I want to add two new features:

  1. TTS Notification: I’d love to have a text-to-speech notification on my Chromecast that tells me how much time I have left until my next alarm. I’m thinking of triggering this with a script using Tasker and my wireless charger as a trigger. It would be a nice way to get a quick update without having to check my phone.

  2. Sleep Time Calculation: I also want to calculate how long I’ve slept and include that in my morning briefing. This would give me a better idea of my sleep patterns and help me track my rest over time.

The main issue I’m facing is figuring out how to calculate the time until the next alarm. I have two timestamps I need to compare: the current time and the wake-up time. The problem is that these timestamps aren’t recognized as actual timestamps by Home Assistant, so I need a way to convert them into complete timestamps (including year, month, day, etc.) to perform the calculation. I’m still pretty new to HA, so I’m not entirely sure how to approach this. Any help or guidance would be greatly appreciated!

I’m really excited about the potential of these new features, and I’m hoping the community can help me work through this challenge. If anyone has experience with timestamp calculations or similar projects, I’d love to hear your thoughts or see examples of how you’ve tackled similar problems!

Looking forward to your insights and happy to share more details if needed. Thanks in advance for your help!