"Next Alarm" automation event

Hey there!

I would find very useful a new automation event, containing the next upcoming alarm, that could fire whenever an alarm rings or is edited.

My usecase is as follows:
I’ve got SleepAsAndroid pushing events to an MQTT queue, and Home Assistant listening for them. I want to know when the next alarm is, so I can dim my lights 8 hours before the alarm, or have an announcement like “Your next alarm is in X hours Y minutes” on my speakers.

Would it be possible to have a new automation event (containing the time and name of the next alarm) that fires whenever:

  1. Any alarm is edited or disabled (There’s already an ALARM_RESCHEDULED, but that’s different. If I have an alarm A for 9am and an alarm B for 10am, and I change B from 10:00 to 10:30, I’d still want to receive “NEXT_ALARM A at 9:00”, while ALARM_RESCHEDULED notifies about alarm B)
  2. An alarm rings (if I have an alarm that rings daily at 9am, when it rings on Monday the event should get sent out, because now the next alarm is at 9am on Tuesday)

I think this could fix issues the home assistant community is having when trying to integrate with SleepAsAndroid (as currently the only real way to get the next alarm is through a home assistant sensor that’s extremely buggy and unreliable). There’s a few posts of people having issues with the next alarm sensor, that having this event would 100% fix:

  1. https://old.reddit.com/r/homeassistant/comments/mi3hj1/a_rambling_post_about_using_sleep_as_android_in/
  2. Next Alarm sensor not updating / stuck in the past (Samsung Galaxy S22) - Home Assistant Companion for Android - Home Assistant Community
    I’ve had my own issues with this sensor (I set an alarm for tomorrow at 8 am, then immediately changed it to 9am. The next alarm sensor is still announcing the next alarm is at 8 am, not terribly useful)