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:
parent
a7a4875f52
commit
f771d8ff14
2 changed files with 14 additions and 1 deletions
|
@ -24,6 +24,7 @@ from homeassistant.helpers import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
|
BATTERY_DEVICES_WITH_PERMANENT_CONNECTION,
|
||||||
COAP,
|
COAP,
|
||||||
DATA_CONFIG_ENTRY,
|
DATA_CONFIG_ENTRY,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
|
@ -241,12 +242,21 @@ class ShellyDeviceRestWrapper(update_coordinator.DataUpdateCoordinator):
|
||||||
|
|
||||||
def __init__(self, hass, device: aioshelly.Device):
|
def __init__(self, hass, device: aioshelly.Device):
|
||||||
"""Initialize the Shelly device wrapper."""
|
"""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__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
name=get_device_name(device),
|
name=get_device_name(device),
|
||||||
update_interval=timedelta(seconds=REST_SENSORS_UPDATE_INTERVAL),
|
update_interval=timedelta(seconds=update_interval),
|
||||||
)
|
)
|
||||||
self.device = device
|
self.device = device
|
||||||
|
|
||||||
|
|
|
@ -32,3 +32,6 @@ INPUTS_EVENTS_DICT = {
|
||||||
"SL": "single_long",
|
"SL": "single_long",
|
||||||
"LS": "long_single",
|
"LS": "long_single",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# List of battery devices that maintain a permanent WiFi connection
|
||||||
|
BATTERY_DEVICES_WITH_PERMANENT_CONNECTION = ["SHMOS-01"]
|
||||||
|
|
Loading…
Add table
Reference in a new issue