this post was submitted on 24 May 2025
28 points (100.0% liked)

Selfhosted

46676 readers
271 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 2 years ago
MODERATORS
 

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:

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

  1. Any native way to hook NTFY's notification to a dashboard like instance (Glance, Homer, Dashy?)

  2. 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 !

  3. 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 !

you are viewing a single comment's thread
view the rest of the comments
[–] N0x0n@lemmy.ml 1 points 8 hours ago (1 children)

Hello thanks for the answer !

What do you mean? Can you elaborate?

I tried to add the json stream to glance via the custom API, but it throws an error... Probably because this is a continuous streams and the custom API can't handle this ?

[–] talentedkiwi@sh.itjust.works 1 points 6 hours ago (1 children)

I've never really played with it, but was hoping it might help. If I have some time this afternoon I can play some more (honestly I'm intrigued as well).

In the mean time, you might try the command below and see if it will work instead. It should just return messages already sent, it I'm not sure how many.

ntfy.sh/mytopic/json?poll=1
[–] N0x0n@lemmy.ml 1 points 4 hours ago

Hello :)

This looked promising, thank you for the hint ! However, the format is probably not what Glance is expecting (ndjson) so there is no way to query the expected key and throws the following error: invalid response JSON !

This would have been so nice and easier than to mess around with a database and postgREST haha ! I think I going to stop here as it gets kinda messy and out of my personal comfort... Maybe in the near future there will be someone adding a widget who knows xD Myself I'm not able to do so... Will probably give also AI a try with copilote as mentioned by another user see if I get better results.

My "half-baked" solution involves a postgREST database container which gets it's query from my bash script send via curl... It somehow works for simple queries like "Backup failed" but as soon as they are some special characters (from stderr), it just breaks...