Skip to content

Commit

Permalink
Add: Periodically pull data to ensure connection is alive
Browse files Browse the repository at this point in the history
  • Loading branch information
JurajNyiri committed Dec 12, 2023
1 parent eeb1902 commit 4885759
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions custom_components/lights_app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):

async def async_update_data():
LOGGER.debug("async_update_data - entry")
await sendCommand(
hass.data[DOMAIN][entry.entry_id],
hass.data[DOMAIN][entry.entry_id]["connection"]["client"],
hass.data[DOMAIN][entry.entry_id]["connection"]["service"],
getLightStateCommand(),
)
await sendCommand(
hass.data[DOMAIN][entry.entry_id],
hass.data[DOMAIN][entry.entry_id]["connection"]["client"],
hass.data[DOMAIN][entry.entry_id]["connection"]["service"],
getModeStateCommand(),
)
if not hass.data[DOMAIN][entry.entry_id]["connection"]["connected"]:
LOGGER.debug("Not connected, reconnecting...")
await setupConnection(hass, address, entry)
Expand Down

0 comments on commit 4885759

Please sign in to comment.