Skip to content

Commit

Permalink
Add binning_mode commands
Browse files Browse the repository at this point in the history
  • Loading branch information
starkillerOG committed Nov 25, 2024
1 parent fdcee73 commit fb2b9be
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
28 changes: 28 additions & 0 deletions reolink_aio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from .baichuan import Baichuan, PortType
from .enums import (
BatteryEnum,
BinningModeEnum,
DayNightEnum,
StatusLedEnum,
SpotlightModeEnum,
Expand Down Expand Up @@ -1024,6 +1025,12 @@ def HDR_state(self, channel: int) -> int:

return self._isp_settings[channel]["Isp"].get("hdr", -1)

def binning_mode(self, channel: int) -> int:
if channel not in self._isp_settings:
return -1

return self._isp_settings[channel]["Isp"].get("binningMode", -1)

def daynight_threshold(self, channel: int) -> int | None:
if channel not in self._isp_settings:
return None
Expand Down Expand Up @@ -1754,6 +1761,9 @@ def construct_capabilities(self, warnings=True) -> None:
if self.bit_rate(channel) is not None:
self._capabilities[channel].add("bit_rate")

if self.api_version("supportIspBinningModeCfg", channel) > 0:
self._capabilities[channel].add("binning_mode")

if self.api_version("ispHue", channel) > 0:
self._capabilities[channel].add("isp_hue")
if self.api_version("ispSatruation", channel) > 0:
Expand Down Expand Up @@ -4894,6 +4904,24 @@ async def set_daynight(self, channel: int, value: str) -> None:

await self.send_setting(body)

async def set_binning_mode(self, channel: int, value: int) -> None:
if channel not in self._channels:
raise InvalidParameterError(f"set_binning_mode: no camera connected to channel '{channel}'")
if not self.supported(channel, "binning_mode"):
raise NotSupportedError(f"set_binning_mode: ISP Binning mode on camera {self.camera_name(channel)} is not available")
await self.get_state(cmd="GetIsp")
if channel not in self._isp_settings or not self._isp_settings[channel]:
raise NotSupportedError(f"set_binning_mode: ISP on camera {self.camera_name(channel)} is not available")

val_list = [val.value for val in BinningModeEnum]
if value not in val_list:
raise InvalidParameterError(f"set_binning_mode: value {value} not in {val_list}")

body: typings.reolink_json = [{"cmd": "SetIsp", "action": 0, "param": self._isp_settings[channel]}]
body[0]["param"]["Isp"]["binningMode"] = value

await self.send_setting(body)

async def set_HDR(self, channel: int, value: bool | int) -> None:
if channel not in self._channels:
raise InvalidParameterError(f"set_HDR: no camera connected to channel '{channel}'")
Expand Down
8 changes: 8 additions & 0 deletions reolink_aio/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ class HDREnum(Enum):
auto = 1


class BinningModeEnum(Enum):
"""Options for the Binning mode setting"""

off = 0
on = 2
auto = 1


class PtzEnum(Enum):
"""Options for PTZ control"""

Expand Down

0 comments on commit fb2b9be

Please sign in to comment.