Remove timeout option and set timeout static to 30 seconds in Synology DSM (#116815)
* remove timeout option, set timeout static to 30 seconds * be slightly faster :)
This commit is contained in:
parent
b53081dc51
commit
203d110787
4 changed files with 7 additions and 15 deletions
|
@ -10,7 +10,7 @@ from synology_dsm.api.surveillance_station.camera import SynoCamera
|
|||
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
|
||||
|
@ -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)
|
||||
|
||||
# Continue setup
|
||||
api = SynoApi(hass, entry)
|
||||
|
|
|
@ -29,7 +29,6 @@ from homeassistant.const import (
|
|||
CONF_PASSWORD,
|
||||
CONF_PORT,
|
||||
CONF_SSL,
|
||||
CONF_TIMEOUT,
|
||||
CONF_USERNAME,
|
||||
CONF_VERIFY_SSL,
|
||||
)
|
||||
|
@ -119,7 +118,7 @@ class SynoApi:
|
|||
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()
|
||||
|
|
|
@ -34,7 +34,6 @@ from homeassistant.const import (
|
|||
CONF_PORT,
|
||||
CONF_SCAN_INTERVAL,
|
||||
CONF_SSL,
|
||||
CONF_TIMEOUT,
|
||||
CONF_USERNAME,
|
||||
CONF_VERIFY_SSL,
|
||||
)
|
||||
|
@ -394,12 +393,6 @@ class SynologyDSMOptionsFlowHandler(OptionsFlow):
|
|||
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(
|
||||
|
|
|
@ -19,7 +19,6 @@ from homeassistant.components.synology_dsm.const import (
|
|||
CONF_SNAPSHOT_QUALITY,
|
||||
DEFAULT_SCAN_INTERVAL,
|
||||
DEFAULT_SNAPSHOT_QUALITY,
|
||||
DEFAULT_TIMEOUT,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.config_entries import (
|
||||
|
@ -35,7 +34,6 @@ from homeassistant.const import (
|
|||
CONF_PORT,
|
||||
CONF_SCAN_INTERVAL,
|
||||
CONF_SSL,
|
||||
CONF_TIMEOUT,
|
||||
CONF_USERNAME,
|
||||
CONF_VERIFY_SSL,
|
||||
)
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue