Monitor configurable MQTT topics and forward the messages to ntfy.sh topics.
Project description
NSP Ntfy
Overview
NSP-NTFY is a bridge between Night Sky Pi's MQTT messages and ntfy.sh push notifications. When Night Sky Pi detects events (like satellite passes or ISS visibility), it can publish these to a local MQTT broker. NSP-NTFY subscribes to these events and forwards them as push notifications to your devices via ntfy.sh, allowing you to receive real-time astronomy alerts without exposing your local network.
Table of Contents
- Prerequisites
- Installation
- Configuration
- Usage
- Notification Examples
- Troubleshooting
- Contributing
- License
Prerequisites
Before deploying NSP-NTFY, ensure you have the following prerequisites configured:
Python
NSP-NTFY is written in Python and has been tested with the following Python versions:
- Python 3.12
MQTT Broker
Night Sky Pi has the ability to publish events to an MQTT broker. The intent of this is so that other modules can react to the events to complete additional actions. Initially this broker will only run locally therefore only allow clients that reside on the same device as intended. Firstly we need to install MQTT on the Raspberry Pi.
sudo apt update && sudo apt upgrade
sudo apt install -y mosquitto
sudo apt install -y mosquitto-clients # Optional for testing locally
sudo systemctl enable mosquitto.service
sudo reboot # Just something I like to do, this is optional as well
Installation
Installing NSP-NTFY is straightforward using pip:
# Install from PyPI
pip install nsp-ntfy
# Or install development version directly from GitHub
pip install git+https://github.com/joe-mccarthy/nsp-ntfy.git
Configuration
NSP Configuration
First, ensure your Night Sky Pi is configured to publish MQTT messages. These settings are in the Night Sky Pi configuration file:
"device" : {
"mqtt" : {
"enabled": true,
"host": "127.0.0.1"
}
}
NSP-NTFY Configuration
Create a configuration file for NSP-NTFY (nsp-ntfy-config.json):
{
"mqtt": {
"broker": "127.0.0.1",
"port": 1883,
"username": "",
"password": "",
"topic": "nsp/notifications/#"
},
"ntfy": {
"server": "https://ntfy.sh",
"topic": "your-unique-topic-name",
"priority": "default",
"tags": ["satellite", "astronomy"]
},
"logging": {
"level": "INFO",
"file": "/var/log/nsp-ntfy.log"
}
}
Configuration options explained:
-
MQTT Settings:
broker: Address of your MQTT broker (default: 127.0.0.1)port: MQTT broker port (default: 1883)username&password: Credentials if your broker requires authenticationtopic: MQTT topic pattern to subscribe to (default: "nsp/notifications/#")
-
NTFY Settings:
server: NTFY server URL (default: https://ntfy.sh)topic: Your unique notification topic - keep this private as anyone with this name can send/receive notificationspriority: Default notification priority (default, min, low, high, urgent)tags: Default tags to include with notifications
-
Logging Settings:
level: Logging level (DEBUG, INFO, WARNING, ERROR)file: Log file path
Usage
Running as a Service
It's recommended that NSP-NTFY is run as a service. This ensures that it doesn't stop if a user logs off and continues running after system restarts.
sudo nano /etc/systemd/system/nsp-ntfy.service
Next step is to update the service definition to the correct paths and running as the correct user:
[Unit]
Description=nsp-ntfy
After=network.target
[Service]
Type=Simple
# update this to be your current user
User=username
# the location of the nsp-ntfy to work within
WorkingDirectory=/home/username/
# update these paths to be the location of the nsp-ntfy.sh
# update argument to where you previously copied the json configuration.
ExecStart=nsp-ntfy /home/username/nsp-ntfy-config.json /home/username/nsp-config.json
Restart=on-failure
[Install]
WantedBy=multi-user.target
Next is to enable and start the service.
sudo systemctl daemon-reload
sudo systemctl start nsp-ntfy
sudo systemctl enable nsp-ntfy
Manual Execution
To run NSP-NTFY manually, execute the following command:
nsp-ntfy /path/to/nsp-ntfy-config.json /path/to/nsp-config.json
Notification Examples
Here are some examples of notifications you might receive:
- Satellite Pass: "Satellite XYZ will be visible at 10:15 PM for 5 minutes."
- ISS Visibility: "The ISS will be visible at 9:30 PM for 6 minutes."
- Astronomy Alert: "Meteor shower peak tonight at 11:00 PM."
Troubleshooting
If you encounter issues, check the following:
- Logs: Review the log file specified in the configuration (
/var/log/nsp-ntfy.log). - MQTT Broker: Ensure the MQTT broker is running and accessible.
- Configuration: Verify the configuration files for any errors.
- Service Status: Check the status of the NSP-NTFY service:
sudo systemctl status nsp-ntfy
Contributing
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (git checkout -b feature/AmazingFeature)
- Commit your Changes (git commit -m 'Add some AmazingFeature')
- Push to the Branch (git push origin feature/AmazingFeature)
- Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nsp_ntfy-2.0.2.tar.gz.
File metadata
- Download URL: nsp_ntfy-2.0.2.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1679b3c95abb40c70e882422439bed58288141cdfc8205b0a405fde9147a71ce
|
|
| MD5 |
f8d52ec8643d57f964efb061a86c5986
|
|
| BLAKE2b-256 |
2ef1afe08b5752d3e99f676df32d2191ecbf72c6f9d18ea833e0e4c66e1347b4
|
Provenance
The following attestation bundles were made for nsp_ntfy-2.0.2.tar.gz:
Publisher:
publish.yml on joe-mccarthy/nsp-ntfy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nsp_ntfy-2.0.2.tar.gz -
Subject digest:
1679b3c95abb40c70e882422439bed58288141cdfc8205b0a405fde9147a71ce - Sigstore transparency entry: 258435637
- Sigstore integration time:
-
Permalink:
joe-mccarthy/nsp-ntfy@1628394edf7a0e5a18e84188fe14596219cf381b -
Branch / Tag:
refs/tags/2.0.2 - Owner: https://github.com/joe-mccarthy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1628394edf7a0e5a18e84188fe14596219cf381b -
Trigger Event:
push
-
Statement type:
File details
Details for the file nsp_ntfy-2.0.2-py3-none-any.whl.
File metadata
- Download URL: nsp_ntfy-2.0.2-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
134dafb80a2a33e379717b9965f6c804094c03d30931ca35fc31a918c756e63e
|
|
| MD5 |
e2b8b438d371bf1139acf09eacf3834b
|
|
| BLAKE2b-256 |
cec49e29285cf75043e3cd2090d28cfd00a23022280e870ed5854376e5247b0d
|
Provenance
The following attestation bundles were made for nsp_ntfy-2.0.2-py3-none-any.whl:
Publisher:
publish.yml on joe-mccarthy/nsp-ntfy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nsp_ntfy-2.0.2-py3-none-any.whl -
Subject digest:
134dafb80a2a33e379717b9965f6c804094c03d30931ca35fc31a918c756e63e - Sigstore transparency entry: 258435656
- Sigstore integration time:
-
Permalink:
joe-mccarthy/nsp-ntfy@1628394edf7a0e5a18e84188fe14596219cf381b -
Branch / Tag:
refs/tags/2.0.2 - Owner: https://github.com/joe-mccarthy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1628394edf7a0e5a18e84188fe14596219cf381b -
Trigger Event:
push
-
Statement type: