Zwave: Add remove/replace failed node services. (#6248)

* Zwave: Add remove/replace failed node services.

* Fix text
This commit is contained in:
Andrey 2017-03-02 13:36:40 +02:00 committed by John Arild Berentsen
parent 50887e7e2c
commit 597ae2e716
3 changed files with 37 additions and 2 deletions

View file

@ -156,7 +156,7 @@ PRINT_CONFIG_PARAMETER_SCHEMA = vol.Schema({
vol.Required(const.ATTR_CONFIG_PARAMETER): vol.Coerce(int),
})
PRINT_NODE_SCHEMA = vol.Schema({
NODE_SERVICE_SCHEMA = vol.Schema({
vol.Required(const.ATTR_NODE_ID): vol.Coerce(int),
})
@ -525,6 +525,18 @@ def setup(hass, config):
_LOGGER.info(
"Renamed ZWave node %d to %s", node_id, name)
def remove_failed_node(service):
"""Remove failed node."""
node_id = service.data.get(const.ATTR_NODE_ID)
_LOGGER.info('Trying to remove zwave node %d', node_id)
NETWORK.controller.remove_failed_node(node_id)
def replace_failed_node(service):
"""Replace failed node."""
node_id = service.data.get(const.ATTR_NODE_ID)
_LOGGER.info('Trying to replace zwave node %d', node_id)
NETWORK.controller.replace_failed_node(node_id)
def set_config_parameter(service):
"""Set a config parameter to a node."""
node_id = service.data.get(const.ATTR_NODE_ID)
@ -671,6 +683,15 @@ def setup(hass, config):
descriptions[
const.SERVICE_PRINT_CONFIG_PARAMETER],
schema=PRINT_CONFIG_PARAMETER_SCHEMA)
hass.services.register(DOMAIN, const.SERVICE_REMOVE_FAILED_NODE,
remove_failed_node,
descriptions[const.SERVICE_REMOVE_FAILED_NODE],
schema=NODE_SERVICE_SCHEMA)
hass.services.register(DOMAIN, const.SERVICE_REPLACE_FAILED_NODE,
replace_failed_node,
descriptions[const.SERVICE_REPLACE_FAILED_NODE],
schema=NODE_SERVICE_SCHEMA)
hass.services.register(DOMAIN, const.SERVICE_CHANGE_ASSOCIATION,
change_association,
descriptions[
@ -685,7 +706,7 @@ def setup(hass, config):
print_node,
descriptions[
const.SERVICE_PRINT_NODE],
schema=PRINT_NODE_SCHEMA)
schema=NODE_SERVICE_SCHEMA)
# Setup autoheal
if autoheal:

View file

@ -28,6 +28,8 @@ SERVICE_TEST_NETWORK = "test_network"
SERVICE_SET_CONFIG_PARAMETER = "set_config_parameter"
SERVICE_PRINT_CONFIG_PARAMETER = "print_config_parameter"
SERVICE_PRINT_NODE = "print_node"
SERVICE_REMOVE_FAILED_NODE = "remove_failed_node"
SERVICE_REPLACE_FAILED_NODE = "replace_failed_node"
SERVICE_SET_WAKEUP = "set_wakeup"
SERVICE_STOP_NETWORK = "stop_network"
SERVICE_START_NETWORK = "start_network"

View file

@ -27,6 +27,18 @@ heal_network:
remove_node:
description: Remove a node from the Z-Wave network. Refer to OZW.log for details.
remove_failed_node:
descsription: This command will remove a failed node from the network. The node should be on the controllers failed nodes list, otherwise this command will fail. Refer to OZW.log for details.
fields:
node_id:
description: Node id of the device to remove (integer).
replace_failed_node:
descsription: Replace a failed node with another. If the node is not in the controller's failed nodes list, or the node responds, this command will fail. Refer to OZW.log for details.
fields:
node_id:
description: Node id of the device to replace (integer).
set_config_parameter:
description: Set a config parameter to a node on the Z-Wave network.
fields: