Skip to content

Commit

Permalink
Add: Check for cold storage path existing before accepting it
Browse files Browse the repository at this point in the history
  • Loading branch information
JurajNyiri committed Nov 29, 2024
1 parent 243c346 commit 694fa4f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
11 changes: 10 additions & 1 deletion custom_components/tapo_control/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import voluptuous as vol
import os

from homeassistant.core import callback

Expand Down Expand Up @@ -1047,6 +1048,11 @@ async def async_step_media(self, user_input=None):
else:
media_sync_cold_storage_path = ""

if media_sync_cold_storage_path != "" and not os.path.exists(
media_sync_cold_storage_path
):
raise Exception("Cold storage path does not exist")

allConfigData[MEDIA_VIEW_DAYS_ORDER] = media_view_days_order
allConfigData[MEDIA_VIEW_RECORDINGS_ORDER] = media_view_recordings_order
allConfigData[MEDIA_SYNC_HOURS] = media_sync_hours
Expand All @@ -1059,7 +1065,10 @@ async def async_step_media(self, user_input=None):
)
return self.async_create_entry(title="", data=None)
except Exception as e:
errors["base"] = "unknown"
if "Cold storage path does not exist" in str(e):
errors["base"] = "cold_storage_path_does_not_exist"
else:
errors["base"] = "unknown"
LOGGER.error(e)

return self.async_show_form(
Expand Down
2 changes: 2 additions & 0 deletions custom_components/tapo_control/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"unknown": "Unknown error",
"connection_failed": "Connection failed",
"invalid_auth_cloud": "Invalid cloud password.\nMake sure you are entering the password for your cloud account and NOT the password which you created via the camera settings (unless they are the same).\nYou need to enter password which you used with your email when signing into the Tapo app.",
"cold_storage_path_does_not_exist": "Cold storage path does not exist",
"camera_requires_admin": "Your camera requires cloud password for control",
"already_configured": "IP address already configured",
"incorrect_peak_value": "Incorrect sound detection peak value."
Expand Down Expand Up @@ -134,6 +135,7 @@
"unknown": "Unknown error",
"connection_failed": "Connection failed",
"invalid_auth_cloud": "Invalid cloud password.\nMake sure you are entering the password for your cloud account and NOT the password which you created via the camera settings (unless they are the same).\nYou need to enter password which you used with your email when signing into the Tapo app.",
"cold_storage_path_does_not_exist": "Cold storage path does not exist",
"camera_requires_admin": "Camera requires cloud password for control",
"incorrect_peak_value": "Incorrect sound detection peak value.",
"incorrect_options_action": "Incorrect action chosen"
Expand Down
2 changes: 2 additions & 0 deletions custom_components/tapo_control/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"unknown": "Unknown error",
"connection_failed": "Connection failed",
"invalid_auth_cloud": "Invalid cloud password.\nMake sure you are entering the password for your cloud account and NOT the password which you created via the camera settings (unless they are the same).\nYou need to enter password which you used with your email when signing into the Tapo app.",
"cold_storage_path_does_not_exist": "Cold storage path does not exist",
"camera_requires_admin": "Your camera requires cloud password for control",
"already_configured": "IP address already configured",
"incorrect_peak_value": "Incorrect sound detection peak value."
Expand Down Expand Up @@ -134,6 +135,7 @@
"unknown": "Unknown error",
"connection_failed": "Connection failed",
"invalid_auth_cloud": "Invalid cloud password.\nMake sure you are entering the password for your cloud account and NOT the password which you created via the camera settings (unless they are the same).\nYou need to enter password which you used with your email when signing into the Tapo app.",
"cold_storage_path_does_not_exist": "Cold storage path does not exist",
"camera_requires_admin": "Camera requires cloud password for control",
"incorrect_peak_value": "Incorrect sound detection peak value.",
"incorrect_options_action": "Incorrect action chosen"
Expand Down

0 comments on commit 694fa4f

Please sign in to comment.