Skip to content

Commit

Permalink
Fix long Hass reboot
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Feb 25, 2021
1 parent e8423c0 commit d963821
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions custom_components/dataplicity/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from threading import Thread

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
from homeassistant.core import HomeAssistant
from homeassistant.requirements import async_process_requirements
from homeassistant.util import package
Expand Down Expand Up @@ -39,6 +40,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
client.port_forward.add_service('web', hass.config.api.port)
Thread(name=DOMAIN, target=client.run_forever).start()

async def hass_stop(event):
client.exit()

hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, hass_stop)

return True


Expand Down

0 comments on commit d963821

Please sign in to comment.