Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible fix by differentiating newer model floodlightmode APIs for coaxial API use on floodlights. #315

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion custom_components/dahua/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def __init__(self, hass: HomeAssistant, events: list, address: str, port: int, r
self._supports_disarming_linkage = False
self._supports_smart_motion_detection = False
self._supports_lighting = False
self._supports_floodlightmode = False
self._serial_number: str
self._profile_mode = "0"
self._supports_profile_mode = False
Expand Down Expand Up @@ -258,6 +259,8 @@ async def _async_update_data(self):
is_flood_light = self.is_flood_light()
_LOGGER.info("Device is a floodlight=%s", is_flood_light)

self._supports_floodlightmode = self.supports_floodlightmode()

try:
await self.client.async_get_config_lighting(self._channel, self._profile_mode)
self._supports_lighting = True
Expand Down Expand Up @@ -549,6 +552,10 @@ def is_flood_light(self) -> bool:
m = self.model.upper()
return m.startswith("ASH26") or "L26N" in m or "L46N" in m or m.startswith("V261LC") or m.startswith("W452ASD")

def supports_floodlightmode(self) -> bool:
""" Returns true if this camera supports floodlight mode """
return "W452ASD" in self.model.upper() or "L46N" in self.model.upper()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think one of my cams is a different model but supports the floodlight. Once I get home I'll try to check...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ASH26 flood light is still broken in 0.9.54. Anyway we can get this merged on the next release?


def supports_infrared_light(self) -> bool:
"""
Returns true if this camera has an infrared light. For example, the IPC-HDW3849HP-AS-PV does not, but most
Expand Down Expand Up @@ -635,7 +642,7 @@ def is_illuminator_on(self) -> bool:

def is_flood_light_on(self) -> bool:

if self._supports_coaxial_control:
if self._supports_floodlightmode:
#'coaxialControlIO.cgi?action=getStatus&channel=1'
return self.data.get("status.status.WhiteLight", "") == "On"
else:
Expand Down
4 changes: 2 additions & 2 deletions custom_components/dahua/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def should_poll(self):

async def async_turn_on(self, **kwargs):
"""Turn the light on"""
if self._coordinator._supports_coaxial_control:
if self._coordinator._supports_floodlightmode:
channel = self._coordinator.get_channel()
self._coordinator._floodlight_mode = await self._coordinator.client.async_get_floodlightmode()
await self._coordinator.client.async_set_floodlightmode(2)
Expand All @@ -262,7 +262,7 @@ async def async_turn_on(self, **kwargs):

async def async_turn_off(self, **kwargs):
"""Turn the light off"""
if self._coordinator._supports_coaxial_control:
if self._coordinator._supports_floodlightmode:
channel = self._coordinator.get_channel()
await self._coordinator.client.async_set_coaxial_control_state(channel, SECURITY_LIGHT_TYPE, False)
await self._coordinator.client.async_set_floodlightmode(self._coordinator._floodlight_mode)
Expand Down
Loading