Skip to content

Commit

Permalink
Added DEFAULT_UPDATE_INTERVAL
Browse files Browse the repository at this point in the history
  • Loading branch information
maziggy committed Feb 24, 2025
1 parent 86d77ee commit 407520c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions custom_components/aqua_medic_dc_runner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from datetime import timedelta

from .client import AquaMedicClient
from .const import DOMAIN
from .const import DOMAIN, DEFAULT_UPDATE_INTERVAL

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -46,7 +46,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
# Set default value only if entity exists
service_data_set = {
"entity_id": update_interval_entity,
"value": 30 # Default to 30 seconds
"value": DEFAULT_UPDATE_INTERVAL
}

try:
Expand Down
4 changes: 2 additions & 2 deletions custom_components/aqua_medic_dc_runner/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
_LOGGER,
name="aqua_medic_motor_speed_update",
update_method=lambda: client.get_latest_device_data(device_id),
update_interval=timedelta(seconds=15),
update_interval=timedelta(seconds=DEFAULT_UPDATE_INTERVAL),
)

await coordinator.async_config_entry_first_refresh()
Expand Down Expand Up @@ -104,7 +104,7 @@ def __init__(self, entry, device_id):
self._attr_name = "Update Interval"
self._attr_unique_id = f"aqua_medic_dc_runner_{device_id}_update_interval"
self._attr_native_min_value = 5
self._attr_native_max_value = 3600
self._attr_native_max_value = 300
self._attr_native_step = 1
self._attr_native_unit_of_measurement = "seconds"
self._attr_native_value = DEFAULT_UPDATE_INTERVAL
Expand Down
4 changes: 2 additions & 2 deletions custom_components/aqua_medic_dc_runner/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import timedelta
from homeassistant.components.switch import SwitchEntity
from homeassistant.helpers.update_coordinator import CoordinatorEntity, DataUpdateCoordinator
from .const import DOMAIN
from .const import DOMAIN, DEFAULT_UPDATE_INTERVAL

_LOGGER = logging.getLogger(__name__)

Expand All @@ -26,7 +26,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
_LOGGER,
name="aqua_medic_switch_update",
update_method=lambda: client.get_latest_device_data(device_id),
update_interval=timedelta(seconds=5), # 🔹 Reduce polling interval to 5 sec
update_interval=timedelta(seconds=DEFAULT_UPDATE_INTERVAL), # 🔹 Reduce polling interval to 5 sec
)

await coordinator.async_config_entry_first_refresh() # Ensure first data load
Expand Down

0 comments on commit 407520c

Please sign in to comment.