Skip to content

Commit

Permalink
Fix defence mode service
Browse files Browse the repository at this point in the history
  • Loading branch information
RenierM26 committed Feb 21, 2021
1 parent 1c9ecdf commit a47623a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
13 changes: 4 additions & 9 deletions custom_components/ezviz_cloud/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,7 @@ async def async_setup_entry(
platform.async_register_entity_service(
"ezviz_defence_mode_change",
{
vol.Required(ATTR_SWITCH): vol.In(
[
ATTR_HOME,
ATTR_AWAY,
]
),
vol.Required(ATTR_SWITCH): vol.In([ATTR_HOME, ATTR_AWAY]),
},
"perform_ezviz_defence_mode_change",
)
Expand Down Expand Up @@ -345,10 +340,10 @@ def perform_ezviz_sound_alarm(self, enable):

self.coordinator.ezviz_client.sound_alarm(self._serial, enable)

def perform_ezviz_defence_mode_change(self, defence_type):
def perform_ezviz_defence_mode_change(self, switch):
"""Sound the alarm on a camera."""
_LOGGER.debug("EZVIZ Defence mode to %s", type)
service_switch = getattr(DefenseModeType, defence_type)
_LOGGER.debug("EZVIZ Defence mode to %s", switch)
service_switch = getattr(DefenseModeType, switch)

self.coordinator.ezviz_client.api_set_defence_mode(service_switch.value)

Expand Down
5 changes: 4 additions & 1 deletion custom_components/ezviz_cloud/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ ezviz_sound_alarm:
ezviz_defence_mode_change:
description: 'Change ezviz defence mode to away or home.'
fields:
mode:
switch:
description: 'Enter HOME_MODE or AWAY_MODE.'
example: 'HOME_MODE'
entity_id:
description: 'Name(s) of entities to perform action on.'
example: 'camera.living_room_camera'
ezviz_wake_device:
description: 'This can also be used to wake device from hibernation.'
fields:
Expand Down

0 comments on commit a47623a

Please sign in to comment.