Skip to content

Commit

Permalink
Merge pull request #178 from BaQs/update_to_new_api
Browse files Browse the repository at this point in the history
Just updating to make compare easier.
  • Loading branch information
RenierM26 authored Jan 18, 2025
2 parents 29a51c1 + fad06c6 commit 17d3424
Show file tree
Hide file tree
Showing 14 changed files with 242 additions and 130 deletions.
2 changes: 1 addition & 1 deletion pyezviz/__init__.py → pyezvizapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""init pyezviz."""
"""init pyezvizapi."""
from .camera import EzvizCamera
from .cas import EzvizCAS
from .client import EzvizClient
Expand Down
4 changes: 2 additions & 2 deletions pyezviz/__main__.py → pyezvizapi/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""pyezviz command line."""
"""pyezvizapi command line."""
import argparse
import json
import logging
Expand All @@ -17,7 +17,7 @@

def main() -> Any:
"""Initiate arg parser."""
parser = argparse.ArgumentParser(prog="pyezviz")
parser = argparse.ArgumentParser(prog="pyezvizapi")
parser.add_argument("-u", "--username", required=True, help="Ezviz username")
parser.add_argument("-p", "--password", required=True, help="Ezviz Password")
parser.add_argument(
Expand Down
23 changes: 13 additions & 10 deletions pyezviz/api_endpoints.py → pyezvizapi/api_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,36 @@
API_ENDPOINT_LOGOUT = "/v3/users/logout/v2"
API_ENDPOINT_REFRESH_SESSION_ID = "/v3/apigateway/login"
API_ENDPOINT_SERVER_INFO = "/v3/configurations/system/info"

API_ENDPOINT_USER_ID = "/v3/userdevices/v1/token"
API_ENDPOINT_GROUP_DEFENCE_MODE = "/v3/userdevices/v1/group/defenceMode"
API_ENDPOINT_PAGELIST = "/v3/userdevices/v1/resources/pagelist"
API_ENDPOINT_SWITCH_DEFENCE_MODE = "/v3/userdevices/v1/group/switchDefenceMode"

API_ENDPOINT_PANORAMIC_DEVICES_OPERATION = "/v3/panoramicDevices/operation"
API_ENDPOINT_UPGRADE_DEVICE = "/v3/upgrades/v1/devices/"
API_ENDPOINT_SEND_CODE = "/v3/sms/nologin/checkcode"
API_ENDPOINT_UNIFIEDMSG_LIST_GET = "/v3/unifiedmsg/list"
API_ENDPOINT_IOT_FEATURE = "/v3/iot-feature/feature/"
API_ENDPOINT_CALLING_NOTIFY = "/v3/calling/"

API_ENDPOINT_ALARMINFO_GET = "/v3/alarms/v2/advanced"
API_ENDPOINT_UNIFIEDMSG_LIST_GET = "/v3/unifiedmsg/list"
API_ENDPOINT_V3_ALARMS = "/v3/alarms/"
API_ENDPOINT_SET_LUMINANCE = "/v3/alarms/device/alarmLight"
API_ENDPOINT_SET_LUMINANCE = "/v3/alarms/device/alarmLight/"

API_ENDPOINT_PAGELIST = "/v3/userdevices/v1/resources/pagelist"
API_ENDPOINT_SWITCH_DEFENCE_MODE = "/v3/userdevices/v1/group/switchDefenceMode"
API_ENDPOINT_DEVCONFIG_BY_KEY = "/v3/devconfig/v1/keyValue/"
API_ENDPOINT_CAM_AUTH_CODE = "/v3/devconfig/authcode/query/"

API_ENDPOINT_DETECTION_SENSIBILITY = "/api/device/configAlgorithm"
API_ENDPOINT_DETECTION_SENSIBILITY_GET = "/api/device/queryAlgorithmConfig"
API_ENDPOINT_SET_DEFENCE_SCHEDULE = "/api/device/defence/plan2"
API_ENDPOINT_CAM_ENCRYPTKEY = "/api/device/query/encryptkey"
API_ENDPOINT_OFFLINE_NOTIFY = "/api/device/notify/switch"
API_ENDPOINT_CANCEL_ALARM = "/api/device/cancelAlarm"
API_ENDPOINT_DEVICE_SYS_OPERATION = "/api/device/v2/sysOper/"
API_ENDPOINT_DEVICE_STORAGE_STATUS = "/api/device/queryStorageStatus"
API_ENDPOINT_DEVCONFIG_BY_KEY = "/v3/devconfig/v1/keyValue/"
API_ENDPOINT_IOT_FEATURE = "/v3/iot-feature/feature/"
API_ENDPOINT_CREATE_PANORAMIC = "/api/panoramic/devices/pics/collect"
API_ENDPOINT_RETURN_PANORAMIC = "/api/panoramic/devices/pics"

# Videogo DeviceApi
API_ENDPOINT_DEVICES = "/v3/devices/"
Expand All @@ -41,10 +47,7 @@
API_ENDPOINT_SWITCH_SOUND_ALARM = "/sendAlarm"
API_ENDPOINT_DO_NOT_DISTURB = "/nodisturb"
API_ENDPOINT_VIDEO_ENCRYPT = "encryptedInfo/risk"
API_ENDPOINT_CHANGE_DEFENCE_STATUS = "changeDefenceStatusReq"

API_ENDPOINT_CREATE_PANORAMIC = "/api/panoramic/devices/pics/collect"
API_ENDPOINT_RETURN_PANORAMIC = "/api/panoramic/devices/pics"
API_ENDPOINT_CHANGE_DEFENCE_STATUS = "/changeDefenceStatusReq"

# MQTT
API_ENDPOINT_REGISTER_MQTT = "/v1/getClientId"
Expand Down
7 changes: 5 additions & 2 deletions pyezviz/camera.py → pyezvizapi/camera.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""pyezviz camera api."""
"""pyezvizapi camera api."""

from __future__ import annotations

import datetime
Expand Down Expand Up @@ -43,7 +44,7 @@ def _alarm_list(self) -> None:

if fetch_nested_value(_alarmlist, ["page", "totalResults"], 0) > 0:
self._last_alarm = _alarmlist["alarms"][0]
return self._motion_trigger()
self._motion_trigger()

def _local_ip(self) -> Any:
"""Fix empty ip value for certain cameras."""
Expand Down Expand Up @@ -123,6 +124,8 @@ def status(self) -> dict[Any, Any]:
"local_ip": self._local_ip(),
"wan_ip": self.fetch_key(["CONNECTION", "netIp"]),
"mac_address": self.fetch_key(["deviceInfos", "mac"]),
"offline_notify": bool(self.fetch_key(["deviceInfos", "offlineNotify"])),
"last_offline_time": self.fetch_key(["deviceInfos", "offlineTime"]),
"local_rtsp_port": self.fetch_key(["CONNECTION", "localRtspPort"], "554")
if self.fetch_key(["CONNECTION", "localRtspPort"], "554") != 0
else "554",
Expand Down
2 changes: 1 addition & 1 deletion pyezviz/cas.py → pyezvizapi/cas.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Ezviz CAS API Functions."""
"""pyezvizapi CAS API Functions."""

from io import BytesIO
from itertools import cycle
Expand Down
Loading

0 comments on commit 17d3424

Please sign in to comment.