Added inclusion / exclusion events

Events may be used to start inclusion / exclusion of zwave devices.
This is especially useful in the case of a Z-Wave stick without
"hardware" inclusion button.
This commit is contained in:
xifle 2016-01-10 14:44:46 +01:00
parent 08aabd18ad
commit fce04e7ad0

View file

@ -26,6 +26,9 @@ CONF_POLLING_INTERVAL = "polling_interval"
DEFAULT_ZWAVE_CONFIG_PATH = os.path.join(sys.prefix, 'share',
'python-openzwave', 'config')
EVENT_ZWAVE_ADD_NODE = "zwave_add_node"
EVENT_ZWAVE_REMOVE_NODE = "zwave_remove_node"
DISCOVER_SENSORS = "zwave.sensors"
DISCOVER_SWITCHES = "zwave.switch"
DISCOVER_LIGHTS = "zwave.light"
@ -176,6 +179,14 @@ def setup(hass, config):
dispatcher.connect(
value_added, ZWaveNetwork.SIGNAL_VALUE_ADDED, weak=False)
def add_node(event):
""" Switch into inclusion mode """
NETWORK.controller.begin_command_add_device()
def remove_node(event):
""" Switch into exclusion mode"""
NETWORK.controller.begin_command_remove_device()
def stop_zwave(event):
""" Stop Z-wave. """
NETWORK.stop()
@ -190,6 +201,11 @@ def setup(hass, config):
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop_zwave)
# listen for add/remove events, for zwave sticks without
# hardware inclusion button
hass.bus.listen(EVENT_ZWAVE_ADD_NODE, add_node)
hass.bus.listen(EVENT_ZWAVE_REMOVE_NODE, remove_node)
hass.bus.listen_once(EVENT_HOMEASSISTANT_START, start_zwave)
return True