Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion homeassistant/components/synology_dsm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from synology_dsm.api.surveillance_station.camera import SynoCamera

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_MAC, CONF_VERIFY_SSL
from homeassistant.const import CONF_MAC, CONF_TIMEOUT, CONF_VERIFY_SSL
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import config_validation as cv, device_registry as dr
Expand Down Expand Up @@ -62,6 +62,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
hass.config_entries.async_update_entry(
entry, data={**entry.data, CONF_VERIFY_SSL: DEFAULT_VERIFY_SSL}
)
if (options := dict(entry.options)) and options.get(CONF_TIMEOUT):
options.pop(CONF_TIMEOUT)
Comment thread
mib1185 marked this conversation as resolved.
Outdated
hass.config_entries.async_update_entry(entry, data=entry.data, options=options)
Comment thread
mib1185 marked this conversation as resolved.

# Continue setup
api = SynoApi(hass, entry)
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/synology_dsm/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
CONF_PASSWORD,
CONF_PORT,
CONF_SSL,
CONF_TIMEOUT,
CONF_USERNAME,
CONF_VERIFY_SSL,
)
Expand All @@ -38,6 +37,7 @@

from .const import (
CONF_DEVICE_TOKEN,
DEFAULT_TIMEOUT,
EXCEPTION_DETAILS,
EXCEPTION_UNKNOWN,
SYNOLOGY_CONNECTION_EXCEPTIONS,
Expand Down Expand Up @@ -92,7 +92,7 @@ async def async_setup(self) -> None:
self._entry.data[CONF_USERNAME],
self._entry.data[CONF_PASSWORD],
self._entry.data[CONF_SSL],
timeout=self._entry.options.get(CONF_TIMEOUT) or 10,
timeout=DEFAULT_TIMEOUT,
device_token=self._entry.data.get(CONF_DEVICE_TOKEN),
)
await self.dsm.login()
Expand Down
11 changes: 3 additions & 8 deletions homeassistant/components/synology_dsm/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
CONF_PORT,
CONF_SCAN_INTERVAL,
CONF_SSL,
CONF_TIMEOUT,
CONF_USERNAME,
CONF_VERIFY_SSL,
)
Expand Down Expand Up @@ -179,7 +178,9 @@ async def async_validate_input_create_entry(
port = DEFAULT_PORT

session = async_get_clientsession(self.hass, verify_ssl)
api = SynologyDSM(session, host, port, username, password, use_ssl, timeout=30)
api = SynologyDSM(
session, host, port, username, password, use_ssl, timeout=DEFAULT_TIMEOUT
)

errors = {}
try:
Expand Down Expand Up @@ -392,12 +393,6 @@ async def async_step_init(
CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL
),
): cv.positive_int,
vol.Required(
CONF_TIMEOUT,
default=self.config_entry.options.get(
CONF_TIMEOUT, DEFAULT_TIMEOUT
),
): cv.positive_int,
vol.Required(
CONF_SNAPSHOT_QUALITY,
default=self.config_entry.options.get(
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/synology_dsm/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
DEFAULT_PORT_SSL = 5001
# Options
DEFAULT_SCAN_INTERVAL = 15 # min
DEFAULT_TIMEOUT = 10 # sec
DEFAULT_TIMEOUT = 30 # sec
DEFAULT_SNAPSHOT_QUALITY = SNAPSHOT_PROFILE_BALANCED

ENTITY_UNIT_LOAD = "load"
Expand Down
6 changes: 1 addition & 5 deletions tests/components/synology_dsm/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
CONF_SNAPSHOT_QUALITY,
DEFAULT_SCAN_INTERVAL,
DEFAULT_SNAPSHOT_QUALITY,
DEFAULT_TIMEOUT,
DOMAIN,
)
from homeassistant.config_entries import (
Expand All @@ -35,7 +34,6 @@
CONF_PORT,
CONF_SCAN_INTERVAL,
CONF_SSL,
CONF_TIMEOUT,
CONF_USERNAME,
CONF_VERIFY_SSL,
)
Expand Down Expand Up @@ -608,18 +606,16 @@ async def test_options_flow(hass: HomeAssistant, service: MagicMock) -> None:
)
assert result["type"] is FlowResultType.CREATE_ENTRY
assert config_entry.options[CONF_SCAN_INTERVAL] == DEFAULT_SCAN_INTERVAL
assert config_entry.options[CONF_TIMEOUT] == DEFAULT_TIMEOUT
assert config_entry.options[CONF_SNAPSHOT_QUALITY] == DEFAULT_SNAPSHOT_QUALITY

# Manual
result = await hass.config_entries.options.async_init(config_entry.entry_id)
result = await hass.config_entries.options.async_configure(
result["flow_id"],
user_input={CONF_SCAN_INTERVAL: 2, CONF_TIMEOUT: 30, CONF_SNAPSHOT_QUALITY: 0},
user_input={CONF_SCAN_INTERVAL: 2, CONF_SNAPSHOT_QUALITY: 0},
)
assert result["type"] is FlowResultType.CREATE_ENTRY
assert config_entry.options[CONF_SCAN_INTERVAL] == 2
assert config_entry.options[CONF_TIMEOUT] == 30
assert config_entry.options[CONF_SNAPSHOT_QUALITY] == 0


Expand Down