Skip to content

Notification Integrations#151

Open
rmlamarche wants to merge 20 commits intoBrandawg93:mainfrom
rmlamarche:notifications
Open

Notification Integrations#151
rmlamarche wants to merge 20 commits intoBrandawg93:mainfrom
rmlamarche:notifications

Conversation

@rmlamarche
Copy link
Copy Markdown

This is a WIP of #136

I wanted to start the PR early to get feedback on my changes.

The ntfy integration is working, and I added a "stdout" notification provider that "console.logs" the notifications (useful for debugging or if you just love a good old fashioned CLI)

I have not written tests or documentation yet. Before this gets merged I definitely need to add proper tests and documentation, and ideally a few more notification providers/integrations. Would like feedback on what the highest priority ones to add would be? I started with ntfy because that's my preferred provider & I already have it setup, but it's very extensible so long as we document the config options for each provider as we add them.

@rmlamarche
Copy link
Copy Markdown
Author

rmlamarche commented Jan 12, 2025

I'll use the PR to work on some documentation, not sure if this eventually belongs in a readme file in the repo or in the wiki:


Notifications

PeaNUT supports some notification providers. To receive notifications from PeaNUT, you must configure:

  • A Notification Provider (Where do you want to be notified?)
  • Triggers (When do you want to be notified?)
  • Configuration Parameters (How does PeaNUT talk to your notification provider?)
  • A notification interval (How frequently should PeaNUT monitor your NUT servers?)

Example YAML configuration for ntfy (/config/settings.yml):

NOTIFICATION_INTERVAL: 10
NOTIFICATION_PROVIDERS:
  - name: ntfy
    triggers:
      - variable: ups.status
        operation: changes
      - variable: battery.runtime
        operation: is_below
        targetValue: 900
    config:
      server_url: https://ntfy.example.com/
      topic: my-ntfy-topic
      priority: '3'
      tags: peanut,prod

Triggers

Triggers define the events you want to receive notifications for.

Trigger Description
changes Whenever the value of the variable changes
is_above Whenever the value of the variable rises above targetValue
is_below Whenever the value of the variable drops below targetValue

Notification Providers

ntfy

ntfy (https://ntfy.sh/)

Configuration
Parameter Description
server_url The ntfy endpoint, ex: https://ntfy.example.com/
topic ntfy topic
priority ntfy priority
tags comma separated list of tags, ex: peanut,prod,tag123
username ntfy username, must also set password
password ntfy password, must also set username
accessToken ntfy accessToken, if both username/password & accessToken are set, accessToken will take higher priority

stdout

Log notifications to stdout. Any parameters configured for the stdout provider will be dumped to stdout with each notification (this can be useful for debugging).

@armond-avanes
Copy link
Copy Markdown

Great job! Is there any plan to add support for Apprise or a generic form of webhook which can be utilized to use other notification platforms?

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@rmlamarche
Copy link
Copy Markdown
Author

Thanks for fixing the linting/sonarqube issues! Something about the dropdown in the notifications area appears to be broken after the rebase... I will try to get that working and update the PR

@sonarqubecloud
Copy link
Copy Markdown

@rmlamarche
Copy link
Copy Markdown
Author

@Brandawg93 I'm going to mark this ready for review, let me know if you want to see any e2e tests or anything from my environment since I have this setup and working with ntfy.

I also think documentation will be important for this feature, especially as more providers/plugins are added. I documented the providers I implemented in the PR comment above here but I didn't think this really belonged in the global README... maybe the wiki would be a good place, or I can throw it into a separate README file somewhere in the repo if you'd prefer.

Apologies for the delay on getting this ready... life got a little busy for me recently!

@rmlamarche rmlamarche marked this pull request as ready for review April 18, 2025 15:15
@rmlamarche rmlamarche changed the title WIP: Notification Integrations Notification Integrations Apr 19, 2025
@sonarqubecloud
Copy link
Copy Markdown

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.

3 participants