Skip to content

Commit

Permalink
Make test RTSP creds optional
Browse files Browse the repository at this point in the history
  • Loading branch information
RenierM26 committed Jan 5, 2025
1 parent e845bd9 commit 642a008
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 197 deletions.
9 changes: 6 additions & 3 deletions custom_components/ezviz_cloud/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
CONF_FFMPEG_ARGUMENTS,
CONF_RF_SESSION_ID,
CONF_SESSION_ID,
CONF_TEST_RTSP_CREDENTIALS,
DEFAULT_CAMERA_USERNAME,
DEFAULT_FFMPEG_ARGUMENTS,
DEFAULT_TIMEOUT,
Expand Down Expand Up @@ -151,12 +152,13 @@ async def _validate_and_create_camera_rtsp(self, data: dict) -> ConfigFlowResult
_get_cam_enc_key, data, ezviz_client
)

# If newer camera, the encryption key is the password.
if data[CONF_PASSWORD] == "fetch_my_key":
data[CONF_PASSWORD] = data[CONF_ENC_KEY]

# Test camera RTSP credentials. Older cameras still use the verification code on the camra and not the encryption key.

await self.hass.async_add_executor_job(_wake_camera, data, ezviz_client)
# Test camera RTSP credentials. Older cameras still use the verification code on the camera and not the encryption key.
if data[CONF_TEST_RTSP_CREDENTIALS]:
await self.hass.async_add_executor_job(_wake_camera, data, ezviz_client)

return self.async_create_entry(
title=data[ATTR_SERIAL],
Expand Down Expand Up @@ -342,6 +344,7 @@ async def async_step_confirm(
{
vol.Required(CONF_USERNAME, default=DEFAULT_CAMERA_USERNAME): str,
vol.Required(CONF_PASSWORD, default="fetch_my_key"): str,
vol.Optional(CONF_TEST_RTSP_CREDENTIALS, default=True): bool,
}
)

Expand Down
1 change: 1 addition & 0 deletions custom_components/ezviz_cloud/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
CONF_RF_SESSION_ID = "rf_session_id"
CONF_EZVIZ_ACCOUNT = "ezviz_account"
CONF_ENC_KEY = "enc_key"
CONF_TEST_RTSP_CREDENTIALS = "test_rtsp_credentials"

# Service names
SERVICE_WAKE_DEVICE = "wake_device"
Expand Down
3 changes: 2 additions & 1 deletion custom_components/ezviz_cloud/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"description": "Enter RTSP credentials for EZVIZ camera {serial} with IP {ip_address}",
"data": {
"username": "[%key:common::config_flow::data::username%]",
"password": "[%key:common::config_flow::data::password%]"
"password": "[%key:common::config_flow::data::password%]",
"test_rtsp_credentials": "Test RTSP credentials"
}
},
"reauth_confirm": {
Expand Down
Loading

0 comments on commit 642a008

Please sign in to comment.