mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Use stop method for mysensors on shutdown.
This commit is contained in:
parent
c41d7b8f6d
commit
c72a735851
@ -16,7 +16,7 @@ import homeassistant.external.pymysensors.mysensors.mysensors as mysensors
|
|||||||
import homeassistant.external.pymysensors.mysensors.const as const
|
import homeassistant.external.pymysensors.mysensors.const as const
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
from homeassistant.const import ATTR_BATTERY_LEVEL
|
from homeassistant.const import (ATTR_BATTERY_LEVEL, EVENT_HOMEASSISTANT_STOP)
|
||||||
|
|
||||||
CONF_PORT = "port"
|
CONF_PORT = "port"
|
||||||
|
|
||||||
@ -49,6 +49,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
gateway = mysensors.SerialGateway(port, sensor_update)
|
gateway = mysensors.SerialGateway(port, sensor_update)
|
||||||
gateway.start()
|
gateway.start()
|
||||||
|
|
||||||
|
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP,
|
||||||
|
lambda event: gateway.stop())
|
||||||
|
|
||||||
|
|
||||||
class MySensorsNode(Entity):
|
class MySensorsNode(Entity):
|
||||||
""" Represents a MySensors node. """
|
""" Represents a MySensors node. """
|
||||||
|
Loading…
x
Reference in New Issue
Block a user