Fix thread termination on exit.

This commit is contained in:
pavoni 2016-04-01 15:27:50 +01:00
parent 5aa04de006
commit 6ee086c0bb
4 changed files with 14 additions and 6 deletions

View File

@ -7,12 +7,13 @@ https://home-assistant.io/components/sensor.loop_energy/
import logging import logging
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
DOMAIN = "loopenergy" DOMAIN = "loopenergy"
REQUIREMENTS = ['pyloopenergy==0.0.4'] REQUIREMENTS = ['pyloopenergy==0.0.5']
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
@ -45,6 +46,13 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
gas_secret gas_secret
) )
def stop_loopenergy(event):
"""Shutdown loopenergy thread on exit."""
_LOGGER.info("Shutting down loopenergy.")
controller.terminate()
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop_loopenergy)
sensors = [LoopEnergyElec(controller)] sensors = [LoopEnergyElec(controller)]
if gas_serial: if gas_serial:

View File

@ -16,7 +16,7 @@ from homeassistant.const import (
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.loader import get_component from homeassistant.loader import get_component
REQUIREMENTS = ['pyvera==0.2.8'] REQUIREMENTS = ['pyvera==0.2.10']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View File

@ -9,7 +9,7 @@ import logging
from homeassistant.components import discovery from homeassistant.components import discovery
from homeassistant.const import EVENT_HOMEASSISTANT_STOP from homeassistant.const import EVENT_HOMEASSISTANT_STOP
REQUIREMENTS = ['pywemo==0.3.23'] REQUIREMENTS = ['pywemo==0.3.24']
DOMAIN = 'wemo' DOMAIN = 'wemo'
DISCOVER_LIGHTS = 'wemo.light' DISCOVER_LIGHTS = 'wemo.light'

View File

@ -183,7 +183,7 @@ pyfttt==0.3
pyicloud==0.7.2 pyicloud==0.7.2
# homeassistant.components.sensor.loopenergy # homeassistant.components.sensor.loopenergy
pyloopenergy==0.0.4 pyloopenergy==0.0.5
# homeassistant.components.device_tracker.netgear # homeassistant.components.device_tracker.netgear
pynetgear==0.3.2 pynetgear==0.3.2
@ -235,10 +235,10 @@ python-wink==0.6.4
pyuserinput==0.1.9 pyuserinput==0.1.9
# homeassistant.components.vera # homeassistant.components.vera
pyvera==0.2.8 pyvera==0.2.10
# homeassistant.components.wemo # homeassistant.components.wemo
pywemo==0.3.23 pywemo==0.3.24
# homeassistant.components.thermostat.radiotherm # homeassistant.components.thermostat.radiotherm
radiotherm==1.2 radiotherm==1.2