Skip to content

Conversation

mitman98
Copy link

@mitman98 mitman98 commented Jun 17, 2025

I have a tremendous number of alerts in my system, and I recently missed a few important ones in the noise of my alerts manager display. I've implemented a few new configuration options for the UI that are all optional, but allow for further refinement of the UI manager's display. This includes:

  1. Supporting hiding certain states (e.g. off, acked, snoozed, disabled or even acked_on or acked_off, etc.)
  2. Showing only certain priorities
  3. Changing the slider's default starting point (or hiding the top bar entirely with slider and ack_all)
  4. Hiding ack buttons
  5. Changing the color of high, medium, low or off alerts.

This enabled me to have specific tiles in my dashboard showing only on/high priority alerts wtih no other bells and whistles, for example (and other permutations, such as a tile on a system tab showing just "disabled" alerts for maintenance purposes, but hiding them in all other tiles).

I was not able to enhance the tests as I don't have a test environment set up, but wanted to get these features over as they have been tremendously useful and critical for me and were a few features I was thinking about for the past few months given the power of Alert2 to refine it's display organization, especially as I lost a pile of money on perishable goods that froze in a fridge when the alerting worked perfectly, I just didn't spot it in the midst of other alerts).

Thanks very much and happy to contribute!

mitman98 added 3 commits June 16, 2025 23:21
| `hide_states` | An array of alert states to hide from the Overview card. Valid values are: `on`, `off`, `acked_on`, `acked_off`, `disabled_on`, `disabled_off`, `snoozed_on`, `snoozed_off`. Convenience states: `acked` (includes both `acked_on` and `acked_off`), `disabled` (includes both `disabled_on` and `disabled_off`), `snoozed` (includes both `snoozed_on` and `snoozed_off`). If not specified, all states are shown. |
| `show_priorities` | An array of priority levels to show in the Overview card. Valid values are: `low`, `medium`, `high`. Defaults to `["low", "medium", "high"]` (show all priorities). |
| `default_slider_value` | Sets the default time window for the slider. Must be an integer from 0 to 6 corresponding to: 0=1 minute, 1=10 minutes, 2=1 hour, 3=4 hours (default), 4=1 day, 5=4 days, 6=2 weeks. |
| `low_color` | Custom color for low priority alerts when "on". Any valid CSS color (e.g., `"blue"`, `"#0066cc"`, `"rgb(0,102,204)"`). |
| `medium_color` | Custom color for medium priority alerts when "on". Defaults to orange if not specified. |
| `high_color` | Custom color for high priority alerts when "on". Defaults to red if not specified. |
| `off_color` | Custom color for all alerts when "off" (regardless of priority). |
| `hide_top_bar` | Hide the entire top control bar (time slider and "Ack all" button). Can be truthy string values like "true", "on", "yes". Defaults to false. |
| `hide_ack_buttons` | Hide individual "Ack"/"Unack" buttons on each alert. Can be truthy string values like "true", "on", "yes". Defaults to false. |
@mitman98 mitman98 changed the title Added configuration options to UI for changing colors of icons, displaying only certain states and priorities, and hiding various UI eelements Added configuration options to UI for changing colors of icons, displaying only certain states and priorities, and hiding various UI elements Jun 17, 2025
@redstone99
Copy link
Owner

Hi - Thanks so much for the contribution! A quick suggestion is to add some tests to tests/t2.html to exercise the new features. Purpose is to make sure the features continue to work as alert2.js evolves in the future.

The bottom of t2.html has tests I've more recently added. I'd suggest looking at doTestConfig. You could imagine making a harness similar to createExperiment that sets up a few alerts in various states and then checks to see that the UI has the elements you expect (maybe with the styling you expect).

@mitman98
Copy link
Author

Yes, understood on the tests, I actually am not familiar with how this test framework is set up or how to run it to be honest. I also have tried to get a dev HA set up with marginal success so far - I got the dev environment running but I can't seem to get tests working. So struggling to get to a point where I can run tests. Wanted to get the code over sooner as that battle is something I can't get to for a bit with some family things and an upcoming move going on. I can probably get to it in about a month.

@redstone99
Copy link
Owner

Yeah, test framework isn't as polished as it could be. Brief instructions at top of t2.html file:

         Run server with (from the Alert2 repo):
              JTESTDIR=/home/redstone/home-monitoring/homeassistant JTEST_JS_DIR=/home/redstone/tmp/hass-alert2-ui venv/bin/pytest tests/dummy_server.py
         View page at:
             http://localhost:50005/jtest/tests/t2.html

So JTESTDIR points to the root of the custom_components/alert2 directory with alert2 source code.
JTEST_JS_DIR points to the dir containing alert2.js. The server will listen on port 50005. The same setup applies to running t.html.

Btw, took a quick look at the diff, and I might suggest some minor variable renaming, but overall the diff looks good. When you do testing, you'll probably have to fix up some of the existing tests that have the ackbar text hardcoded and whatnot.

… in conjunction with unacked states, also sort on snoozed and disabled after active alerts in the acked section.

Added new configuration options: unacked_off_color for unacked alerts when off, and snoozed_disabled_use_off_color to control color usage for snoozed/disabled alerts.
Updated sorting logic in Alert2 to account for snoozed/disabled states.
Revised README to reflect new configuration options and clarify alert sorting behavior.
@redstone99
Copy link
Owner

A feature request was submitted to make it possible to change the icon of a firing alert. That raises the question, if we allow different colors for the icon of a firing alert, what is the policy for event alerts? For how long after an event alert fires should its icon be a different color?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants