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 !