Best architecture for a scaling 'signal' severity master alert framework?

Hey All,
I am looking for the best way to accomplish a unified alert framework and could use some architecture advice to make sure I am doing this in the most 'normal' way, to make the maintenance and long term updating easier. I don't want to swim against what the normal Home Assistant development path is and try to follow normal practices...

I want an alert system that flags when something extreme happens, but I need the "importance" of the signal to increase as it gets further out of spec. For example, a human in front of the doorbell camera should be a low priority if they are only there for 5 seconds. The longer they stay, the severity should ramp up. At 5 seconds, the severity might be 0.1, at 10 seconds it goes to 0.4, and topping out at 1 minute it hits 1.0, which then pushes a notification to my phone and does high priority stuff. I want to apply similar time-ramping logic to things like the garage door being open for over 10 minutes, as it increases etc.

The system could also monitor value-based metrics like CO2 levels, home power consumption and production, main floor temperature, upcoming events, and tasks to do. Things that get more 'time sensitive' etc.

My goal is a modular framework. Each alert needs an icon, severity value, a message, a title, and a severity scale. If multiple alerts are active, the system must automatically switch to display the alert with the highest priority value. If there are no alerts, then it would likely just have a 'no alerts' or something. Even things like updates could be a low priority alert. Low batteries can be another example, as the battery gets lower, the severity increases.

The goal would be for the system to be made in such a way that it can be shared across various platforms with different ways of displaying. It would be a monster to maintain if it was one automation, so perhaps each 'signal' would be it's own automation, where each automation evaluates the current displayed severity, and either does nothing if it's not a high enough alert or some other thing (perhaps a secondary attribute for the second most severe even). That way, referencing a single 'active alert' sensor in various expressions wouldn't be super difficult, then display it across various devices:

  • Phones as persistent alerts.
  • A dashboard display (like my kitchen E-ink android tablet)
  • Watches with gauges, like my Pebble watch (ingesting the alert via [https://excbadacc.es/sorta/custom-url](https://excbadacc.es/sorta/custom-url)).

My current thought process is to either use automations that set a helper value based on when a sensor is something out of the normal, but that means it wouldn't automatically scale (perhaps now it's getting to complex to 'autoscale'...) or trigger-based template sensors for the time-ramping events and standard template sensors for the value deviations. I would then put them all in a group and use a master template sensor with a Jinja namespace loop to aggregate the highest severity state and extract its attributes.

Is this the most 'time-efficient' / future-proof / performant way to handle this in Home Assistant? Are there better ways to manage the ramping logic without creating massive YAML files? Also, there's the fact that you likely want to store multiple active alerts. I was thinking of storing the extra alerts in attributes.

I would appreciate any examples or pointers on the best way to structure this. I think having 'signals from the home' would be a HUGE value to everyone. Basically a 'bubble up the issues' kind of thing. I'm just not super knowledgable about how to best make it easy to update, understand and maintain. I think I'll start chipping away at the idea, but I wanted to ask all of you would may also want to use this type of idea. What started this was using home assistant as digital signage at work, and having 'high performing' solar arrays be highlighted in a card, which then made me think of alerts. Like 'Sonya's Array has been down for 1 hour'. Or 'Internet latency has suddenly increased 400%'

I know it's a lot to read, but I wanted to make sure the core idea was understood. I know that Home Assistant has alert functionality, but just how to tie multiple possible active alerts etc. There's another idea of 'John is home' alert, that never is a 'high' alert, but it tops out at normal, meaning it is displayed on the kitchen dashboard, and it can trigger automations by being in that state but never gets to the 'high' setting...

Here is alink to the final update of the below work: A Simple Extension to the Alert Integration - #9 by KruseLuds

TBH my HA instance now pretty much complete after I finished the below alerting framework). It monitors every aspect of my home network, the health of every single device, I even get a phone call now if my 2011 Dodge has less than 5% in the gas tank! Unfortunately my automations.yaml is now more than 17,000 lines - but it is NOT a mess - very organized, and tweaked frorm here to kingdom come -

I have started relying heavily upon chatgpt / claude to write code snippets which sped up the process condierably. I will NEVER grant any AI to any of my systems, it takes longer but I copy and paste back and forth into the chat window.

With regards to alerts/notifications, there are so many ways of alerting people from HA that is another avenue to consider. I was never happy with the alerts they way they natively worked within HA so I do not use them at all and have a custom coded enhancement, and built out a pretty sophisticated framework that works for me. I took alot of my alerts and laboriously moved them into a centralized framework which I was considering making into another custom integration. The only problem with this as a custom integration is, there are so many parameters that people may not want to bother with the tedious setup! Also to build out logic for the custom integration to add or remove a gazillion helpers during the cusotm integration modification screens would be an excercize… The framework I have now offers 4 ways of alerting:

  1. Persistant Notifications
  2. HA Notifications (with actionable buttons - for example the garage door being open x minutes has an extra button to close the garage)
  3. Text Messages
  4. Phone Calls

To determine to who those alerts go, first I have

  1. Contact Groups in YAML. The HA App (Addon) appdaemon reads this upon startup and populates drop-down group selectors for the above notifcation types for each alert so that I have people arranged in groups (myself, myself and wife, whole family, individuals, etc.)

  2. Centralized logic that is reused by all of the alerts to minimize code

  3. Predefined phrases that are to be used for each one when an alert is sent. (I use Twilio for SMS and phone calls, the text I send in the API call is read back over the phone for the calls :slight_smile: )

You should have a dashboard to control all of your alert parameters so you don’t have to tweak everything in code (hard coded) - and also so that you can put some of your alerts into a test mode -

Here is my alert control dashboard (a little ugly) -

It has a browser-mod popup for each one, for instance you click on the alert for the back door being open and this little control panel comes up:

I actually have numerous other alerts that are not (yet) in the framework, such as reminders to close specific open windows when the weather station detects rain, alert to ask people to close windows when the air goes on or when they open a windows to ask them to turn the air off, etc… (some of that I have turned off as it can get a little picky)

Additionally I have other alerts which are on purpose (for now) not in this framework because they have to be 1,000% bulletproof and this framework is pretty new. Example: my alarm system (see my "Noonlight Enhanced" custom integration for 24/7 monitoring).

To add another whole dimension to the complexity - I have assumed that for each alert type and notification venue there is only one - it could be down the road that for a certain kind of alert one person should only get a text message that is not diriven by the same kind or level of trigger for another person that should get a phone call - ?!?!!

So you can make a career out of this stuff, if not an obsessive hobby. If you want to set up alerts dependent upon someone being home or not home - and ensure that indicator is set up in a reliable manner - then check ot my "HALP!" (Home Assistant Location and Presence) custom integration, that might be of help and you can use it as an alternative to the person location which might be unreliable depending upon how the HA instancew is set up…

I tried this once and found that it actually increased the amount of YAML I needed. Far too many options to pass to the message handler.

So now I just message one of three separate Telegram groups directly based on the severity.

Alerts - needs attention now. e.g. sprinklers did not turn off.

System log - no action required but may be important to know. e.g. time sprinkler turned on or off.

General - low priority, some actionable notifications. e.g. sprinklers scheduled to run but there may be rain later, run? Y/N