File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -417,6 +417,25 @@ async def __rest_login(self):
417417 )
418418 return True
419419
420+ async def __probe_rest_availability (self ) -> bool :
421+ """Try a REST login/logout sequence to detect REST-only firmware."""
422+ try :
423+ await self .__rest_request (
424+ "POST" ,
425+ "/api/v1/login" ,
426+ data = {"login" : self .username , "password" : self .password },
427+ )
428+ except (
429+ AuthenticationException ,
430+ UnauthorizedException ,
431+ UnsupportedHostException ,
432+ UnknownException ,
433+ ):
434+ return False
435+
436+ await self .__rest_request ("POST" , "/api/v1/logout" , data = {"_" : "" })
437+ return True
438+
420439 @staticmethod
421440 def __first_value (data : dict [str , Any ], * keys : str ) -> Any :
422441 """Return the first non-None value from data for the given keys."""
@@ -585,6 +604,9 @@ async def get_encryption_method(self) -> EncryptionMethod:
585604 if self .api_mode == ApiMode .REST :
586605 return EncryptionMethod .NONE
587606
607+ if self .api_mode == ApiMode .AUTO and await self .__probe_rest_availability ():
608+ return EncryptionMethod .NONE
609+
588610 for encryption_method in EncryptionMethod :
589611 try :
590612 if encryption_method == EncryptionMethod .NONE :
You can’t perform that action at this time.
0 commit comments