Severity attribute for entities

I would like to be able to set a severity grade/limit for my sensors individually so that hassio will know when a value is out of the ordinary. Many monitoringsystems use this to filter out sensors.

Home assistant does often grow with huge amounts of sensors and users may find it hard to find critical information. Not everything fits in one single dashboard. Color coding value limits helps a lot but you have to do that with styles in lovelace and hassio still does not know if something actually is wrong.

Next step would be to have hassio learn these valuetrends itself. For example PRTG wich is a monitoring software that can tell me if a certain value is unusually high or low for this hour of the day. Now this may be a bit more than necessary for most users but at least really critical values would be great to show

If we then could have a dashboard with all these warnings would be nice

just a thought!

You’re best off doing this with something like the Prometheus / Alertmanager stack. Ingest the data from your sensors into Prometheus first, then set up alerts for whatever time series that are outside of the ordinary — and then Alertmanager can send you notifications when these values fall outside the expected range.

I actually do this for my devices’ batteries and other sensors! Here is an alert sample:

      # Home Assistant alerts.
        - alert: SensorBatteryLow
          expr: homeassistant_sensor_battery_percent{entity!=".*(galaxy|pixel|sm.a235m).*"} < 20
          for: 5m
              The battery of sensor {{ $labels.friendly_name }} is at {{ $value }} percent.
        - alert: SensorMalfunctioning
          expr: (time() - homeassistant_last_updated_time_seconds{entity!~".*(pixel|galaxy|magnet|sm.a235m).*", entity!~".*motion_sensor.*", domain="sensor", entity=~".*_temperature"}) > 14400
          for: 1m
              Sensor {{ $labels.friendly_name }} has not updated in over {{ $value }} seconds.

Thanks but I can fix the alerts easily with simple automation also. The interesting part is to find out if the feature would be interesting to others as well. I want to make it easier and integrated into ha, and also something that is managed centrally, that’s the reason I made a thread.

it’s not only the notifications I’m after but also a an easy way to filter out these states in lovelace

Alerting in HA is very basic. It doesn’t give you the ability to silence alerts for a certain time, or categorize alerts based on priority (which is what you want), or repeat alerts for unsolved issues that require your attention, route different categories of alerts through different pipelines (“emergency should call, notice should pop up a notification in your phone”). Whereas alerting with Prometheus+Alertmanager does all of that — and you can feed back Alertmanager alerts to HA, in order to use whatever you already have for notifications.

Actually I dont even need to be alerted, that would be a bonus but not what I’m asking primarily. I’m not talking about a surveilance system here, I simply think that sensors in HA could be aware of what is normal or not with an extra attribute, and I think this is a pretty basic feature in most systems that use sensors of some kind.

Mabye the community will see a need for this in the future and expand its features more towards smarter and simpler alerting like it tweaks many other things every month. Its the simplicity in HA that I always liked and that part fades away when you need to set up different platforms to get what you need. This could surely be expanded in the future also, for example to be used with some kind of AI engine :slight_smile:

For your consideration, here’s one way to achieve your goal using existing features.

Using Manual Customization, define new attributes for the sensors that you wish to monitor. The following example adds tolerance_max and tolerance_min to three sensors.

  tolerance_max: 90
  tolerance_min: 60

  tolerance_max: 10
  tolerance_min: 5

  tolerance_max: 200
  tolerance_min: 50

Create an automation that reports when the value of one of the three sensors is not within its tolerance levels.

alias: Out of tolerance
mode: queued
  t_max: "{{ state_attr(trigger.entity_id, 'tolerance_max') }}"
  t_min: "{{ state_attr(trigger.entity_id, 'tolerance_min') }}"
  val: "{{ trigger.to_state.state | float(0) }}"
  - platform: state
      - sensor.first
      - sensor.second
      - sensor.third
  - condition: template
    value_template: "{{ not t_min < val < t_max }}"
  - service: notify.persistent_notification
      title: "{{ trigger.entity_id }} is out of tolerance."
      message: "Value: {{ val }}, Range: {{ t_min }}, {{t_max }}"
1 Like

Nice! Thats is exactly what I’m after. Mabye I’ll even use this… at least for some of my most critical sensors.

But still… I belive that the true upgrade would be to let HA learn this by itself :smiley:

Now I’m not a programmer and dont know whats possible at all… But mabye this could be achieved with some plain median measurements over time and let HA decide what is out of the ordinary trend and what is not.

Imagine the feeling that most of the things you put into HA will somehow be supervised by the system itself. Things you dont think about or forget, HA will warn you about :wink:

Another way is to define a dictionary of sensors and their tolerance ranges directly within the template (i.e. no need for custom attributes).

You might want to examine the Statistics integration. It offers a median calculation.