SimpleCloudDetect - I made an ASCOM Alpaca based safety monitor and cloud detection using Allsky camera images

14 replies‱240 views
chvvkumar avatar

đŸ“· image.pngimage.png

This uses a Machine Learning model that you can train yourself to detect sky conditions and acts as an ASCOM Alpaca SafetyMonitor.

It runs in docker and can be run on either x86 or on the Raspberry Pi that runs the AllSky system. This is primarily based on TJ's AllSky platform but it can easily be used to detect any thing you want as long as the model is trained for it.

https://github.com/chvvkumar/simpleCloudDetect/tree/main

Features

  • ML Cloud Classification - Detects Clear, Wisps, Mostly Cloudy, Overcast, Rain, and Snow conditions

  • Home Assistant Integration - MQTT Discovery for automatic setup or legacy manual configuration

  • ASCOM Alpaca SafetyMonitor - Compatible with N.I.N.A., SGP, TheSkyX, and other astronomy software

  • Docker Support - Easy deployment with both services running simultaneously

  • Flexible Image Sources - Supports URL-based and local file images

  • Custom Models - Bring your own trained model and labels

  • Confidence Scores - Includes detection confidence and timing metrics

Training the model is also very essay without any coding required. The process is explained in the repo's readme.


Full settings page:

Helpful
sebaromano avatar

It looks quite nice and interesting. The GUI looks super nice and very intuitive. I would love to try it out for sure.

I have been using my own code (written in Python). Very simple solution that return a text file with either SAFE or UNSAFE wording which are used by ASCOM Generic FIle Driver (in NINA) to trigger the SAFE/UNSAFE condition during my aquisition session. Thats text file is an output of my APP upon of analysisng the image produced by AllSkeye software from my all sky camera and then based on AI traned model (Teachable Machine) assignd the SAFE/UNSAFE logic.

So I hope you don’t mind if I ask a few questions:

  • Is your App compatible with Allskeye software? I needed to use this one since I use WIndows.

  • Does your app return any text file that can be used in NINA in the Safety Monitor? Otherwise how does triger the Safety Monitoring condition?

  • Is there a simple PDF user guide to read more in deep the functionalities?

Best,

Sebastiano

EDIT:

I just click the link and found the user guide. I will read it throught and perhaps find my answers :)

chvvkumar avatar

sebaromano · Dec 30, 2025, 07:49 PM

It looks quite nice and interesting. The GUI looks super nice and very intuitive. I would love to try it out for sure.

I have been using my own code (written in Python). Very simple solution that return a text file with either SAFE or UNSAFE wording which are used by ASCOM Generic FIle Driver (in NINA) to trigger the SAFE/UNSAFE condition during my aquisition session. Thats text file is an output of my APP upon of analysisng the image produced by AllSkeye software from my all sky camera and then based on AI traned model (Teachable Machine) assignd the SAFE/UNSAFE logic.

So I hope you don’t mind if I ask a few questions:

  • Is your App compatible with Allskeye software? I needed to use this one since I use WIndows.

  • Does your app return any text file that can be used in NINA in the Safety Monitor? Otherwise how does triger the Safety Monitoring condition?

  • Is there a simple PDF user guide to read more in deep the functionalities?

Best,

Sebastiano

Thank you for taking a look! I am actually writing an architecture doc for this. It is in draft stage but can be found below:

https://github.com/chvvkumar/simpleCloudDetect/blob/snd/architecture.md

I actually started this project with the filesafetymonitor in mind but switched over to Alpaca as it seemed to be a better fit (and native TCP) for talking to NINA rather than trying to manage SMB or NFS mounts required to update the file where NINA can read from it.

As of right now the container does not really output a file per se. But That can easily added and if not, since this already does REST API for ALPACA, it would be trivial to write a script to query the API end point and write it to a local file.

API end point:

/api/v1/safetymonitor/{device_number}/issafe

Response with GET method:

{"ClientTransactionID": 0,"ErrorMessage": "","ErrorNumber": 0,"ServerTransactionID": 117,"Value": false}

Helpful
sebaromano avatar

Thanks for the additional details. So I guess this is not suitable for Windows users like me, correct?

Well Written
chvvkumar avatar

sebaromano · Dec 30, 2025, 08:25 PM

Thanks for the additional details. So I guess this is not suitable for Windows users like me, correct?

I have not tried it under windows as I run it on the same Pi as my AllSky software or in Debian while testing. This requires network_mode: host for UDP functionality for now and host networking support in Windows was in beta stage last I checked it a while ago.

I know you can specify EXPOSE PORT/udp but I have not had the time to test this yet.


EDIT: To answer your question, I have not tried to use this in Windows yet.

Well Written Concise
chvvkumar avatar

sebaromano · Dec 30, 2025, 07:49 PM

I have been using my own code (written in Python). Very simple solution that return a text file with either SAFE or UNSAFE wording which are used by ASCOM Generic FIle Driver (in NINA) to trigger the SAFE/UNSAFE condition during my aquisition session.

I started this in a similar way, hence the name simple in the title. It kind of got out of hand as I started using it and wanted more features. Originally it was just detect.py with about a hundred lines of code.

Frédéric Tapissier avatar

french

je trouve ça super. je voulais faire de meme avec un script gĂ©nĂ©rĂ© par IA qui compterai le nombre d’étoiles visible et analyserai si le nombre augmente ou diminue, maiis ton script est bien intelligent et Ă©laborĂ© que le mon idĂ©e je te fĂ©licite, c’est vraiment super (et tu m’économise beaucoup de travail car j’y connais pas grand-chose en dĂ©veloppement logiciel)

si j’ai bien compris ce script tourne en docker sur linux ?

Anglais

I think it's great. I wanted to do the same thing with an AI-generated script that would count the number of visible stars and analyze whether the number increases or decreases, but your script is much smarter and more sophisticated than my idea. Congratulations, it's really great (and you've saved me a lot of work because I don't know much about software development).

If I understand correctly, this script runs in Docker on Linux?

chvvkumar avatar

Frédéric Tapissier · Jan 1, 2026, 01:38 AM

je trouve ça super. je voulais faire de meme avec un script gĂ©nĂ©rĂ© par IA qui compterai le nombre d’étoiles visible et analyserai si le nombre augmente ou diminue, maiis ton script est bien intelligent et Ă©laborĂ© que le mon idĂ©e je te fĂ©licite, c’est vraiment super (et tu m’économise beaucoup de travail car j’y connais pas grand-chose en dĂ©veloppement logiciel)

si j’ai bien compris ce script tourne en docker sur linux ?

—-Google translation—-

Merci pour ton commentaire enthousiaste!

Pour répondre à ta question : Oui, tu as tout à fait raison, ce script est conçu pour tourner sous Docker sur Linux.

—-English—-

Thank you for your enthusiastic comment!

To answer your question: Yes, you are absolutely right, this script is designed to run under Docker on Linux.

Frédéric Tapissier avatar

chvvkumar · Jan 1, 2026, 01:44 AM

Frédéric Tapissier · Jan 1, 2026, 01:38 AM

je trouve ça super. je voulais faire de meme avec un script gĂ©nĂ©rĂ© par IA qui compterai le nombre d’étoiles visible et analyserai si le nombre augmente ou diminue, maiis ton script est bien intelligent et Ă©laborĂ© que le mon idĂ©e je te fĂ©licite, c’est vraiment super (et tu m’économise beaucoup de travail car j’y connais pas grand-chose en dĂ©veloppement logiciel)

si j’ai bien compris ce script tourne en docker sur linux ?

—-Google translation—-

Merci pour ton commentaire enthousiaste!

Pour répondre à ta question : Oui, tu as tout à fait raison, ce script est conçu pour tourner sous Docker sur Linux.

—-English—-

Thank you for your enthusiastic comment!

To answer your question: Yes, you are absolutely right, this script is designed to run under Docker on Linux.

Hello. Do you think I can run your Docker in Docker Desktop for Windows (I already have dockerized applications on it)

chvvkumar avatar

sebaromano · Dec 30, 2025, 08:25 PM

Thanks for the additional details. So I guess this is not suitable for Windows users like me, correct?

Frédéric Tapissier · Jan 1, 2026, 11:03 AM

chvvkumar · Jan 1, 2026, 01:44 AM

Frédéric Tapissier · Jan 1, 2026, 01:38 AM

je trouve ça super. je voulais faire de meme avec un script gĂ©nĂ©rĂ© par IA qui compterai le nombre d’étoiles visible et analyserai si le nombre augmente ou diminue, maiis ton script est bien intelligent et Ă©laborĂ© que le mon idĂ©e je te fĂ©licite, c’est vraiment super (et tu m’économise beaucoup de travail car j’y connais pas grand-chose en dĂ©veloppement logiciel)

si j’ai bien compris ce script tourne en docker sur linux ?

—-Google translation—-

Merci pour ton commentaire enthousiaste!

Pour répondre à ta question : Oui, tu as tout à fait raison, ce script est conçu pour tourner sous Docker sur Linux.

—-English—-

Thank you for your enthusiastic comment!

To answer your question: Yes, you are absolutely right, this script is designed to run under Docker on Linux.

Hello. Do you think I can run your Docker in Docker Desktop for Windows (I already have dockerized applications on it)

I just tested this in windows 11 using Docker desktop. And it looks like it works!

I used this docker compose config with selectively forwarding UDP port to the container for Alpaca discovery.:

On my desktop:

network_mode: host ←—remove this

ports: ←—Add explicit port forwarding

      - "11111:11111/tcp"

      - "32227:32227/udp"

NINA running on my imaging PC can discover and connect to it:

đŸ“· image.pngimage.pngand the container in Docker desktop:

đŸ“· image.pngimage.png

chvvkumar avatar

Added multiple client support. Now multiple clients can connect to and read from a single container. Theoretically many many clients can connect but I don't have a way to practically test the limits. I have tested with:

Rostokko avatar

I just wanted to thanks @chvvkumar for this simple, yet powerful tool he shared.

I have tied it to my all sky camera (Deep Sky Dad), trained it as suggested through Google’s Teachable Machines (it doesn’t take long; the all sky camera feeds you plenty of images you can easily classify over a few days of varied sky conditions), and hooked it to my NINA sequence.

It works great and reliably; and if you see some specific “sky” getting a dubious classification, it’s easy enough to add that/those image/s to the correct bucket and update the model.

This past night it was a good mix of clouds-clear-clouds-clear; my sequence automatically waited for clear conditions before opening the backyard observatory; then shot targets for a few hours; then, when clouds rolled in, shot flats and wrapped it up (my choice is to just call it a night when the clouds roll in after a certain point - even at the risk of losing a change of clearing later - but the beauty of this is that you can design whatever logic fits you best!).

Thanks again for this work; the tool is quite polished and well thought out.

Helpful Insightful Respectful Engaging Supportive
chvvkumar avatar

Rostokko · Jan 8, 2026, 01:45 PM

I just wanted to thanks @chvvkumar for this simple, yet powerful tool he shared.

I have tied it to my all sky camera (Deep Sky Dad), trained it as suggested through Google’s Teachable Machines (it doesn’t take long; the all sky camera feeds you plenty of images you can easily classify over a few days of varied sky conditions), and hooked it to my NINA sequence.

It works great and reliably; and if you see some specific “sky” getting a dubious classification, it’s easy enough to add that/those image/s to the correct bucket and update the model.

This past night it was a good mix of clouds-clear-clouds-clear; my sequence automatically waited for clear conditions before opening the backyard observatory; then shot targets for a few hours; then, when clouds rolled in, shot flats and wrapped it up (my choice is to just call it a night when the clouds roll in after a certain point - even at the risk of losing a change of clearing later - but the beauty of this is that you can design whatever logic fits you best!).

Thanks again for this work; the tool is quite polished and well thought out.

Thank you Rostokko for your feedback. Yes, the training data makes all the difference. The model can be trained to be very sensitive to rain, so much so that it can detect a single drop of rain on the dome and set unsafe conditions based off of that. I find it quicker and more sensitive than any other physical rain gauge I have tried it against.

đŸ“· image.pngimage.pngI have Home Assistant trigger a rain alert on my home Nest speakers whenever there is rain detected and while the scope is out and powered ON. I ended up using images from an year’s worth of data to train my model. About ~7000 images per class.

Well Written Helpful Insightful Respectful Engaging
Rostokko avatar

chvvkumar · Jan 8, 2026, 05:58 PM

I ended up using images from an year’s worth of data to train my model. About ~7000 images per class.

That is a lot of pictures! I am getting good results with about 1,000 images per class - but then, I am really interested in detected “good/bad” shooting conditions - rain/snow/overcast/mostly cloudy are all equally deal breakers to me.

chvvkumar avatar

Rostokko · Jan 8, 2026, 06:34 PM

chvvkumar · Jan 8, 2026, 05:58 PM

I ended up using images from an year’s worth of data to train my model. About ~7000 images per class.

That is a lot of pictures! I am getting good results with about 1,000 images per class - but then, I am really interested in detected “good/bad” shooting conditions - rain/snow/overcast/mostly cloudy are all equally deal breakers to me.

That’s a good sample size to use. Variation within the data is more important than sheer quantity. In my case I wanted to see if I could detect lightning, aurorae etc. as well and save the images to a separate location for archival. I haven’t done that part yet.

Well Written