@@ -236,7 +236,7 @@ def __init__(
236236
237237 ##############################################################################
238238 # API-versions and capabilities
239- self ._api_version : dict [str , int ] = {}
239+ self ._api_version : dict [str , int | dict [ int | None , int ] ] = {}
240240 self ._abilities : dict [str , Any ] = {} # raw response from NVR/camera
241241 self ._capabilities : dict [int | str , set [str ]] = {"Host" : set ()} # processed by construct_capabilities
242242
@@ -791,19 +791,19 @@ def audio_alarm_enabled(self, channel: int) -> bool:
791791 return self ._audio_alarm_settings [channel ]["schedule" ]["enable" ] == 1
792792
793793 def ir_enabled (self , channel : int ) -> bool :
794- return self ._ir_settings .get (channel , {}).get ("IrLights" , {}). get ( " state" ) == "Auto"
794+ return self ._ir_settings .get (channel , {}).get ("state" ) == "Auto"
795795
796796 def status_led_enabled (self , channel : int ) -> bool :
797797 if channel not in self ._status_led_settings :
798798 return False
799799
800- return self ._status_led_settings [channel ][ "PowerLed" ] .get ("state" , "Off" ) == "On"
800+ return self ._status_led_settings [channel ].get ("state" , "Off" ) == "On"
801801
802802 def doorbell_led (self , channel : int ) -> str :
803803 if channel not in self ._status_led_settings :
804804 return "Off"
805805
806- return self ._status_led_settings [channel ][ "PowerLed" ] .get ("eDoorbellLightState" , "Off" )
806+ return self ._status_led_settings [channel ].get ("eDoorbellLightState" , "Off" )
807807
808808 def doorbell_led_list (self , channel : int ) -> list [str ]:
809809 mode_values = []
@@ -812,7 +812,7 @@ def doorbell_led_list(self, channel: int) -> list[str]:
812812 mode_values .extend ([StatusLedEnum .auto , StatusLedEnum .alwaysonatnight ])
813813 ledCtrl = self .baichuan .api_version ("ledCtrl" , channel )
814814 if self .api_version ("supportDoorbellLightKeepOn" , channel ) > 0 or (ledCtrl >> 15 ) & 1 : # 16th bit (32768), shift 15:
815- options = self ._status_led_range .get (channel , {}).get ("PowerLed" , {}). get ( " eDoorbellLightState" , [])
815+ options = self ._status_led_range .get (channel , {}).get ("eDoorbellLightState" , [])
816816 if "KeepOn" in options or (ledCtrl >> 15 ) & 1 :
817817 mode_values .append (StatusLedEnum .alwayson )
818818 else :
@@ -1631,7 +1631,7 @@ def capabilities(self) -> dict[int | str, set[str]]:
16311631 return self ._capabilities
16321632
16331633 @property
1634- def checked_api_versions (self ) -> dict [str , int ]:
1634+ def checked_api_versions (self ) -> dict [str , int | dict [ int | None , int ] ]:
16351635 return self ._api_version
16361636
16371637 @property
@@ -1949,7 +1949,10 @@ def supported(self, channel: int | None, capability: str) -> bool:
19491949 def api_version (self , capability : str , channel : int | None = None , no_key_return : int = 0 ) -> int :
19501950 """Return the api version of a capability, 0=not supported, >0 is supported"""
19511951 if capability in self ._api_version :
1952- return self ._api_version [capability ]
1952+ ver = self ._api_version [capability ]
1953+ if isinstance (ver , dict ):
1954+ return ver .get (channel , no_key_return )
1955+ return ver
19531956
19541957 if channel is None :
19551958 return self ._abilities .get (capability , {}).get ("ver" , 0 )
@@ -4052,14 +4055,14 @@ def map_channel_json_response(self, json_data: typings.reolink_json, channel: in
40524055 self ._image_settings [channel ] = data ["value" ]
40534056
40544057 elif data ["cmd" ] == "GetIrLights" :
4055- self ._ir_settings [channel ] = data ["value" ]
4058+ self ._ir_settings [channel ] = data ["value" ][ "IrLights" ]
40564059
40574060 elif data ["cmd" ] == "GetPowerLed" :
40584061 # GetPowerLed returns incorrect channel
40594062 # response_channel = data["value"]["PowerLed"]["channel"]
4060- self ._status_led_settings [channel ] = data ["value" ]
4063+ self ._status_led_settings [channel ] = data ["value" ][ "PowerLed" ]
40614064 if "range" in data :
4062- self ._status_led_range [channel ] = data ["range" ]
4065+ self ._status_led_range [channel ] = data ["range" ][ "PowerLed" ]
40634066
40644067 elif data ["cmd" ] == "GetWhiteLed" :
40654068 value = data ["value" ]["WhiteLed" ]
0 commit comments