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%'

