Partially Solved
While I haven't found a native solution on how to integrate NTFY to glance, I did build up something that actually send basic text streams to glance in an automated way. It's very rudimentary and probably error prone, but that's the best I could do right now... Maybe someone else will chime in and give some better advice/solution.
For those interested postgREST allows to build a simple docker container postgres database you can query for the custom api in glance. It DOES work, but If like myself, your database/json/postgre knowlege is very limited, it only allows basic text response like: "Update Failed".
I did try to get a little further into the rabbit hole, but it does come with the necessity to have a good database and query/response background ? Not a very good solution and will probably not go one or try to improve on that right now... But feel free to give better advice or another lead to follow :)
Further notes:
- https://docs.postgrest.org/en/v12/tutorials/tut0.html
- https://samkhawase.com/blog/postgrest/
- https://deepwiki.com/glanceapp/glance/6.1-template-functions
- https://github.com/glanceapp/glance/blob/main/docs/configuration.md#custom-api
On a final note, I do see a lot of interest in the Glance community and alot of new and interesting updates:
- Added .Options.JSON to the custom API widget which takes any nested option value and turns it into a JSON string v0.8.3
- [Custom API] Synchronous API calls and options property v0.8.0
Hello everyone !
I kinda hit a roadblock here and I'm interested if someone actually have done something similar or an alternative to what I'm trying to achieve.
Some background
Right now I'm playing around with NTFY and works great. I even hooked some automated backup script to my server with stdout/stderr output:
(Please, no bash-shaming ! :P)
#!/bin/bash
$COMMAND
if [ $? -eq 0 ]; then
echo "Success"
issue=$(<stdout.txt)
curl -H "Title: Hello world!" -H "Priority: urgent" -d "$issue" https://mydomain/glancy
else
echo "Failure"
issue=$(<stderr.txt)
curl -H "Title: Hello world!" -H "Priority: urgent" -d "$issue" https://mydomain/glancy
fi
This works great and I receive my notification on every device subscribed to the topic
What I'm trying to achieve?
Send the NTFY notification to a visual dashboard like Glance. If there's no native way to achieve this, self-host a simple json api that get's populated by my server's script response?
What's the issue ?
After skimming all the GitHub repos, there's no mention on any self-hosted dashboard to integrate NTFY as a notification hook. I find it kinda strange because NTFY is just a simple HTTP PUT or POST requests so It should be rather easy no?
And after searching the whole day on the web, there wasn't any good results or resources. So I came to the conclusion that It wasn't that easy and probably needs a bit more of something I'm probably bad at (coding?).
In the glance documentation there's configuration to hook a custom api and looks rather simple, however now I hit a roadblock I'm not able to solve... I have no idea where or how to spin up a self-hosted and dynamic json api that communicates with my server and updates/populate that json file... Here's an example to show what I mean:
Json api: https://api.laut.fm/station/psytrancelicious/last_songs
Custom Glance API template:
- type: custom-api
title: Random Fact
cache: 6h
url: https://api.laut.fm/station/psytrancelicious/last_songs
template: |
<p class="size-h4 color-paragraph">{{ .JSON.String "title" }}</p>
Questions
-
Any native way to hook NTFY's notification to a dashboard like instance (Glance, Homer, Dashy?)
-
If no, Is it possible to self-host a json api that gets populated by my script's response? A good pointer to the right direction would be very nice, preferably a Docker solution !
-
Another solution to have a visual dashboard (not the native NTFY dashboard) and visualize all my script response notification in one place ?
Thank in advance for all your responses :) and sorry for my bad wording, web development terminology is not really my cup of tea !
Hey thanks for your answer ! Yeah probably AI would be a good fit in this little scenario but I don't have the necessary credits to ask something like this. However yesterday, I found out about postgREST and while this is totally out of my league (never touched a database in my life...) Spinning up the docker container with my own domain was easy enough :).
Their tutorial 0 - Get it running was easy to follow for a simple database and even tho it took me the whole day to make it work to my liking. After a lot of trial and error, it does updated my Glance instance with my script's error message ! *Yeahhhhhi !!
While this isn't a direct native link to NTFY, it does work and is simple enough to keep it up. But adding a bit more complexity to it and everything falls apart... Not sure if I will diver deeper in that rabbit hole right now, because working with databases is a whole world on it's own and have why to many other project on hold right now...
I'm glad to hear you got it worked out.
You can use copilot for free, you don't have to install anything just creating an account, you can do it in a vanilla browser They don't even really get that much good information off of you.
For learning something that you've never done before it's honestly pretty damn good of all the horrible things AI is used for this is one of the least detrimental.
Just remember if you do use it for anything don't just copy and paste willy-nilly read it, use it to understand things. Some of the data it's trained on are jokes telling people to delete their hard drives.
Thanks for the pointer !
Haha yeah ! I Always try to understand a command before I copy/past anyway, especially since I learned there can be hidden code execution when copy/pasting... Kinda scary shit !