Skip to content

Commit

Permalink
Merge pull request #2 from zenz/development
Browse files Browse the repository at this point in the history
采用async_listen_once来实现一次性的监听。
  • Loading branch information
zenz authored Aug 26, 2024
2 parents 14f9b58 + c44a0eb commit 255b831
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions custom_components/airtub_udp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ async def handle_data_received_event(event):
hass.async_create_task(
discovery.async_load_platform(hass, "climate", DOMAIN, {}, config)
)
# Remove the listener after handling the event
hass.bus.async_remove_listener(EVENT_NEW_DATA, handle_data_received_event)

try:
hass.data[DOMAIN] = {"device": device, "data": {}, "ip": None}
Expand All @@ -244,7 +242,7 @@ async def handle_data_received_event(event):
)

# Register the event listener
hass.bus.async_listen(EVENT_NEW_DATA, handle_data_received_event)
hass.bus.async_listen_once(EVENT_NEW_DATA, handle_data_received_event)

hass.states.async_set(f"{DOMAIN}.status", "ready")
hass.services.async_register(
Expand Down

0 comments on commit 255b831

Please sign in to comment.