There is already the optional protection built in between the roof and the mount. The roof has the Mount Policy propertyand the mount has the Roof Policy property. So a parked roof can prevent the mount from unparking/moving? And the upnarked mount can stop the roof from closing. Adding external sensors to detect park would ensure the mount is not reporting parked state when it is unparked. Don't know if that is a thing or not.
If KStars fails I think the Watchdog driver will go a long way to letting you do a safety shut down using the built in capabilities.
indilib.org/aux/watchdog.html.
Perhaps you could write a driver to handle your power detection requirements and it could in turn initiate a shut down by notifying the watchdog like the weather drivers do.
The rain detection might not need special handling, if things are not working normally then the obs should already be shutting down.
If some processing does need to be outside of Ekos for the rain or other reason, it could be handled by a script or external program. I can't find the forum discussion, but attached is a script user Haans provided. I edited it for local equipment. It is interesting, demonstrating what kind of control can be applied. Don't know off hand how much if any of Ekos that needs to be running for it to work. But could always use a script to locate running processes and kill them off before starting a new subset to work with.
Somewhat related:https://indilib.org/about/ekos/153-robotic-observatory-with-ekos-scheduler.html
DBus scripting might be something to research.
indilib.org/forum/development/11869-buil...hon-dbus-script.html