added option to set polling interval
This commit is contained in:
1 parent
6361e661c0
commit
ed10127a90
6 files changed
+26
-7
No files matched your search
@@ -12,7 +12,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
|
||||
from .const import DATA_COORDINATOR, DOMAIN, MANUFACTURER, CONF_USE_CONTROLS, DATA_POLLING_RUNNING
|
||||
from .const import CONF_POLLING_INTERVAL, DATA_COORDINATOR, DOMAIN, MANUFACTURER, CONF_USE_CONTROLS, DATA_POLLING_RUNNING
|
||||
from .coordinator import PollingCoordinator
|
||||
|
||||
PLATFORMS: [Platform] = [Platform.BINARY_SENSOR, Platform.SENSOR]
|
||||
@@ -25,6 +25,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
address = entry.data.get(CONF_ADDRESS)
|
||||
device_name = entry.data.get(CONF_NAME)
|
||||
use_controls = entry.data.get(CONF_USE_CONTROLS)
|
||||
polling_interval = entry.data.get(CONF_POLLING_INTERVAL, 20)
|
||||
|
||||
if address is None:
|
||||
return False
|
||||
@@ -38,7 +39,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
hass.data[DOMAIN][entry.entry_id].setdefault(DATA_POLLING_RUNNING, False)
|
||||
|
||||
# Create coordinator for polling
|
||||
coordinator = PollingCoordinator(hass, address, device_name)
|
||||
coordinator = PollingCoordinator(hass, address, device_name, polling_interval)
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
hass.data[DOMAIN][entry.entry_id].setdefault(DATA_COORDINATOR, coordinator)
|
||||
|
||||
|
||||
Reference in new issue
Block a user