Skip to content

Commit

Permalink
set vto channel correctly (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
si458 committed Dec 29, 2023
1 parent 47671ad commit 7b038ee
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions custom_components/dahua/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,6 @@ async def _async_update_data(self):
# Do the one time initialization (do this when Home Assistant starts)
if not self.initialized:
try:
try:
await self.client.async_get_snapshot(0)
# If able to take a snapshot with index 0 then most likely this cams channel needs to be reset
self._channel_number = self._channel
except ClientError:
pass
_LOGGER.info("Using channel number %s", self._channel_number)

# Find the max number of streams. 1 main stream + n number of sub-streams
self._max_streams = await self.client.get_max_extra_streams() + 1
_LOGGER.info("Using max streams %s", self._max_streams)
Expand Down Expand Up @@ -229,6 +221,16 @@ async def _async_update_data(self):
self.machine_name = data.get("table.General.MachineName")
self._serial_number = data.get("serialNumber")

try:
await self.client.async_get_snapshot(0)
# If able to take a snapshot with index 0 then most likely this cams channel needs to be reset
# but check if unit is not a doorbell first as channel 0 doesnt exist for VTOs
if not self.is_doorbell():
self._channel_number = self._channel
except ClientError:
pass
_LOGGER.info("Using channel number %s", self._channel_number)

try:
await self.client.async_get_coaxial_control_io_status()
self._supports_coaxial_control = True
Expand Down

0 comments on commit 7b038ee

Please sign in to comment.