Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion homeassistant/components/synology_dsm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from synology_dsm.exceptions import SynologyDSMNotLoggedInException

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 @@ -63,6 +63,10 @@ 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 entry.options.get(CONF_TIMEOUT):
options = dict(entry.options)
options.pop(CONF_TIMEOUT)
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
3 changes: 1 addition & 2 deletions homeassistant/components/synology_dsm/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
CONF_PASSWORD,
CONF_PORT,
CONF_SSL,
CONF_TIMEOUT,
CONF_USERNAME,
CONF_VERIFY_SSL,
)
Expand Down Expand Up @@ -119,7 +118,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 DEFAULT_TIMEOUT,
timeout=DEFAULT_TIMEOUT,
device_token=self._entry.data.get(CONF_DEVICE_TOKEN),
)
await self.async_login()
Expand Down
7 changes: 0 additions & 7 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 @@ -394,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
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