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:
parent
08aabd18ad
commit
fce04e7ad0
1 changed files with 16 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue