Skip to content

Commit

Permalink
Small updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Francisco committed Nov 17, 2024
1 parent 86bba14 commit 6c519e8
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions custom_components/lanbon_switch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
for device_id, switches in hass.data[DOMAIN]["known_devices"].items():
for switch_id in switches:
entity_id = f"{device_id}_{switch_id}"
hass.data[DOMAIN]["entities"][entity_id] = True
if entity_id not in hass.data[DOMAIN]["entities"]:
hass.data[DOMAIN]["entities"][entity_id] = True

async def discover_device(msg):
topic = msg.topic
Expand Down Expand Up @@ -97,9 +98,7 @@ async def discover_device(msg):

# Request device states on startup
async def sync_device_states(event):
# Ensure all devices are discovered before sending CHECK commands
await asyncio.sleep(1)
# Send "CHECK" to all known devices
for device_entry in hass.data[DOMAIN]["known_devices"].values():
for switch_info in device_entry.values():
set_topic = switch_info["set_topic"]
Expand Down

0 comments on commit 6c519e8

Please sign in to comment.