Skip to content

Commit

Permalink
Merge pull request #4 from CarsonF/config-path
Browse files Browse the repository at this point in the history
Allow API base path to be configured
  • Loading branch information
elad-bar authored May 24, 2021
2 parents 922744d + e4a3437 commit cac1a96
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion custom_components/shinobi/api/shinobi_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async def initialize(self):
config_data = self.config_data

self.base_url = (
f"{config_data.protocol}://{config_data.host}:{config_data.port}"
f"{config_data.protocol}://{config_data.host}:{config_data.port}{config_data.path}"
)

self.is_logged_in = False
Expand Down
3 changes: 2 additions & 1 deletion custom_components/shinobi/helpers/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
CONF_NAME,
CONF_PASSWORD,
CONF_PORT,
CONF_PATH,
CONF_SSL,
CONF_USERNAME,
CONF_VERIFY_SSL,
Expand All @@ -25,7 +26,7 @@

CONF_SUPPORT_STREAM = "support_stream"

CONF_ARR = [CONF_USERNAME, CONF_PASSWORD, CONF_HOST, CONF_PORT, CONF_SSL]
CONF_ARR = [CONF_USERNAME, CONF_PASSWORD, CONF_HOST, CONF_PORT, CONF_SSL, CONF_PATH]

ENTRY_PRIMARY_KEY = CONF_NAME

Expand Down
1 change: 1 addition & 0 deletions custom_components/shinobi/managers/config_flow_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def _get_default_fields(

fields = {
vol.Optional(CONF_HOST, default=config_data.host): str,
vol.Optional(CONF_PATH, default=config_data.path): str,
vol.Optional(CONF_PORT, default=config_data.port): str,
vol.Optional(CONF_SSL, default=config_data.ssl): bool,
vol.Optional(CONF_USERNAME, default=config_data.username): str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ async def get_basic_data(self, data):
result.host = data.get(CONF_HOST)
result.port = data.get(CONF_PORT, 8080)
result.ssl = data.get(CONF_SSL, False)
result.path = data.get(CONF_PATH, "")

result.username = data.get(CONF_USERNAME)
result.password = data.get(CONF_PASSWORD)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/shinobi/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"domain": "shinobi",
"name": "Shinobi Video NVR",
"documentation": "https://github.com/elad-bar/ha-shinobi",
"issue_tracker": "https://github.com/elad-bar/ha-shinobifitr /issues",
"issue_tracker": "https://github.com/elad-bar/ha-shinobi/issues",
"after_dependencies": [
"mqtt"
],
Expand Down
3 changes: 3 additions & 0 deletions custom_components/shinobi/models/config_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class ConfigData:
host: str
port: int
ssl: bool
path: str
username: Optional[str]
password: Optional[str]
password_clear_text: Optional[str]
Expand All @@ -18,6 +19,7 @@ def __init__(self):
self.host = ""
self.port = DEFAULT_PORT
self.ssl = False
self.path = ""
self.username = None
self.password = None
self.password_clear_text = None
Expand All @@ -44,6 +46,7 @@ def __repr__(self):
CONF_HOST: self.host,
CONF_PORT: self.port,
CONF_SSL: self.ssl,
CONF_PATH: self.path,
CONF_USERNAME: self.username,
CONF_PASSWORD: self.password,
CONF_LOG_LEVEL: self.log_level,
Expand Down
2 changes: 2 additions & 0 deletions custom_components/shinobi/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"data": {
"host": "Host",
"port": "Port",
"path": "Path",
"username": "Username",
"password": "Password",
"ssl": "Is SSL"
Expand All @@ -28,6 +29,7 @@
"host": "Host",
"port": "Port",
"ssl": "Is SSL",
"path": "Path",
"username": "Username",
"password": "Password",
"log_level": "Log level"
Expand Down

0 comments on commit cac1a96

Please sign in to comment.