diff -up nut-2.8.0/scripts/python/app/NUT-Monitor-py3qt5.in.unreachable nut-2.8.0/scripts/python/app/NUT-Monitor-py3qt5.in
--- nut-2.8.0/scripts/python/app/NUT-Monitor-py3qt5.in.unreachable 2022-05-09 17:20:11.629621005 +0200
+++ nut-2.8.0/scripts/python/app/NUT-Monitor-py3qt5.in 2022-05-09 17:20:52.674024537 +0200
@@ -693,6 +693,11 @@ along with this program. If not, see <h
self.gui_status_notification( _("Device '%s' not found on server") % self.__current_ups, "warning.png" )
return
+ if not self.__ups_handler.CheckUPSAvailable( self.__current_ups ):
+ self.gui_status_message( _("UPS '{0}' is not reachable").format( self.__current_ups ) )
+ self.gui_status_notification( _("UPS '{0}' is not reachable").format( self.__current_ups ), "warning.png" )
+ return
+
self.__connected = True
self.__widgets["ups_connect"].hide()
self.__widgets["ups_disconnect"].show()
diff -up nut-2.8.0/scripts/python/module/PyNUT.py.in.unreachable nut-2.8.0/scripts/python/module/PyNUT.py.in
--- nut-2.8.0/scripts/python/module/PyNUT.py.in.unreachable 2022-05-09 17:20:32.100323526 +0200
+++ nut-2.8.0/scripts/python/module/PyNUT.py.in 2022-05-09 17:21:35.505402117 +0200
@@ -170,6 +170,21 @@ available vars.
return( ups_vars )
+ def CheckUPSAvailable( self, ups="") :
+ """ Check whether UPS is reachable
+
+Just tries to contact UPS with safe command.
+The result is True (rechable) or False (unreachable)
+ """
+ self.__srv_handler.write( "LIST CMD %s\n" % ups )
+ result = self.__srv_handler.read_until( "\n" )
+ if result != "BEGIN LIST CMD %s\n" % ups :
+ return False
+
+ self.__srv_handler.read_until( "END LIST CMD %s\n" % ups )
+ return True
+
+
def GetUPSCommands( self, ups="" ) :
""" Get all available commands for the specified UPS