Change rest sensors update interval for Shelly Motion (#44692)

* Change rest sensors update interval for Shelly Motion

* Cleaning

* Fix typo

* Remove unnecessary parentheses
This commit is contained in:
Maciej Bieniek 2021-01-04 13:14:07 +01:00 committed by GitHub
parent a7a4875f52
commit f771d8ff14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -24,6 +24,7 @@ from homeassistant.helpers import (
)
from .const import (
BATTERY_DEVICES_WITH_PERMANENT_CONNECTION,
COAP,
DATA_CONFIG_ENTRY,
DOMAIN,
@ -241,12 +242,21 @@ class ShellyDeviceRestWrapper(update_coordinator.DataUpdateCoordinator):
def __init__(self, hass, device: aioshelly.Device):
"""Initialize the Shelly device wrapper."""
if (
device.settings["device"]["type"]
in BATTERY_DEVICES_WITH_PERMANENT_CONNECTION
):
update_interval = (
SLEEP_PERIOD_MULTIPLIER * device.settings["coiot"]["update_period"]
)
else:
update_interval = REST_SENSORS_UPDATE_INTERVAL
super().__init__(
hass,
_LOGGER,
name=get_device_name(device),
update_interval=timedelta(seconds=REST_SENSORS_UPDATE_INTERVAL),
update_interval=timedelta(seconds=update_interval),
)
self.device = device

View File

@ -32,3 +32,6 @@ INPUTS_EVENTS_DICT = {
"SL": "single_long",
"LS": "long_single",
}
# List of battery devices that maintain a permanent WiFi connection
BATTERY_DEVICES_WITH_PERMANENT_CONNECTION = ["SHMOS-01"]