Add heal_node and test_node services. (#10369)
* Add heal_node and test_node services. * lint
This commit is contained in:
parent
bc51bd93f4
commit
c07e651013
4 changed files with 86 additions and 0 deletions
|
@ -123,6 +123,17 @@ SET_WAKEUP_SCHEMA = vol.Schema({
|
|||
vol.All(vol.Coerce(int), cv.positive_int),
|
||||
})
|
||||
|
||||
HEAL_NODE_SCHEMA = vol.Schema({
|
||||
vol.Required(const.ATTR_NODE_ID): vol.Coerce(int),
|
||||
vol.Optional(const.ATTR_RETURN_ROUTES, default=False): cv.boolean,
|
||||
})
|
||||
|
||||
TEST_NODE_SCHEMA = vol.Schema({
|
||||
vol.Required(const.ATTR_NODE_ID): vol.Coerce(int),
|
||||
vol.Optional(const.ATTR_MESSAGES, default=1): cv.positive_int,
|
||||
})
|
||||
|
||||
|
||||
DEVICE_CONFIG_SCHEMA_ENTRY = vol.Schema({
|
||||
vol.Optional(CONF_POLLING_INTENSITY): cv.positive_int,
|
||||
vol.Optional(CONF_IGNORED, default=DEFAULT_CONF_IGNORED): cv.boolean,
|
||||
|
@ -564,6 +575,22 @@ def setup(hass, config):
|
|||
_LOGGER.info("Node %s on instance %s does not have resettable "
|
||||
"meters.", node_id, instance)
|
||||
|
||||
def heal_node(service):
|
||||
"""Heal a node on the network."""
|
||||
node_id = service.data.get(const.ATTR_NODE_ID)
|
||||
update_return_routes = service.data.get(const.ATTR_RETURN_ROUTES)
|
||||
node = network.nodes[node_id]
|
||||
_LOGGER.info("Z-Wave node heal running for node %s", node_id)
|
||||
node.heal(update_return_routes)
|
||||
|
||||
def test_node(service):
|
||||
"""Send test messages to a node on the network."""
|
||||
node_id = service.data.get(const.ATTR_NODE_ID)
|
||||
messages = service.data.get(const.ATTR_MESSAGES)
|
||||
node = network.nodes[node_id]
|
||||
_LOGGER.info("Sending %s test-messages to node %s.", messages, node_id)
|
||||
node.test(messages)
|
||||
|
||||
def start_zwave(_service_or_event):
|
||||
"""Startup Z-Wave network."""
|
||||
_LOGGER.info("Starting Z-Wave network...")
|
||||
|
@ -684,6 +711,16 @@ def setup(hass, config):
|
|||
set_poll_intensity,
|
||||
descriptions[const.SERVICE_SET_POLL_INTENSITY],
|
||||
schema=SET_POLL_INTENSITY_SCHEMA)
|
||||
hass.services.register(DOMAIN, const.SERVICE_HEAL_NODE,
|
||||
heal_node,
|
||||
descriptions[
|
||||
const.SERVICE_HEAL_NODE],
|
||||
schema=HEAL_NODE_SCHEMA)
|
||||
hass.services.register(DOMAIN, const.SERVICE_TEST_NODE,
|
||||
test_node,
|
||||
descriptions[
|
||||
const.SERVICE_TEST_NODE],
|
||||
schema=TEST_NODE_SCHEMA)
|
||||
|
||||
# Setup autoheal
|
||||
if autoheal:
|
||||
|
|
|
@ -8,7 +8,9 @@ ATTR_INSTANCE = "instance"
|
|||
ATTR_GROUP = "group"
|
||||
ATTR_VALUE_ID = "value_id"
|
||||
ATTR_OBJECT_ID = "object_id"
|
||||
ATTR_MESSAGES = "messages"
|
||||
ATTR_NAME = "name"
|
||||
ATTR_RETURN_ROUTES = "return_routes"
|
||||
ATTR_SCENE_ID = "scene_id"
|
||||
ATTR_SCENE_DATA = "scene_data"
|
||||
ATTR_BASIC_LEVEL = "basic_level"
|
||||
|
@ -32,7 +34,9 @@ SERVICE_ADD_NODE_SECURE = "add_node_secure"
|
|||
SERVICE_REMOVE_NODE = "remove_node"
|
||||
SERVICE_CANCEL_COMMAND = "cancel_command"
|
||||
SERVICE_HEAL_NETWORK = "heal_network"
|
||||
SERVICE_HEAL_NODE = "heal_node"
|
||||
SERVICE_SOFT_RESET = "soft_reset"
|
||||
SERVICE_TEST_NODE = "test_node"
|
||||
SERVICE_TEST_NETWORK = "test_network"
|
||||
SERVICE_SET_CONFIG_PARAMETER = "set_config_parameter"
|
||||
SERVICE_PRINT_CONFIG_PARAMETER = "print_config_parameter"
|
||||
|
|
|
@ -28,6 +28,17 @@ cancel_command:
|
|||
|
||||
heal_network:
|
||||
description: Start a Z-Wave network heal. This might take a while and will slow down the Z-Wave network greatly while it is being processed. Refer to OZW.log for progress.
|
||||
fields:
|
||||
return_routes:
|
||||
description: Wheter or not to update the return routes from the nodes to the controller. Defaults to False.
|
||||
example: True
|
||||
|
||||
heal_node:
|
||||
description: Start a Z-Wave node heal. Refer to OZW.log for progress.
|
||||
fields:
|
||||
return_routes:
|
||||
description: Wheter or not to update the return routes from the node to the controller. Defaults to False.
|
||||
example: True
|
||||
|
||||
remove_node:
|
||||
description: Remove a node from the Z-Wave network. Refer to OZW.log for progress.
|
||||
|
@ -120,6 +131,16 @@ soft_reset:
|
|||
test_network:
|
||||
description: This will send test to nodes in the Z-Wave network. This will greatly slow down the Z-Wave network while it is being processed. Refer to OZW.log for progress.
|
||||
|
||||
test_node:
|
||||
description: This will send test messages to a node in the Z-Wave network. This could bring back dead nodes.
|
||||
fields:
|
||||
node_id:
|
||||
description: ID of the node to send test messages to.
|
||||
example: 10
|
||||
messages:
|
||||
description: Optional. Amount of test messages to send.
|
||||
example: 3
|
||||
|
||||
rename_node:
|
||||
description: Set the name of a node. This will also affect the IDs of all entities in the node.
|
||||
fields:
|
||||
|
|
|
@ -1253,3 +1253,27 @@ class TestZWaveServices(unittest.TestCase):
|
|||
|
||||
assert node.refresh_info.called
|
||||
assert len(node.refresh_info.mock_calls) == 1
|
||||
|
||||
def test_heal_node(self):
|
||||
"""Test zwave heal_node service."""
|
||||
node = MockNode(node_id=19)
|
||||
self.zwave_network.nodes = {19: node}
|
||||
self.hass.services.call('zwave', 'heal_node', {
|
||||
const.ATTR_NODE_ID: 19,
|
||||
})
|
||||
self.hass.block_till_done()
|
||||
|
||||
assert node.heal.called
|
||||
assert len(node.heal.mock_calls) == 1
|
||||
|
||||
def test_test_node(self):
|
||||
"""Test the zwave test_node service."""
|
||||
node = MockNode(node_id=19)
|
||||
self.zwave_network.nodes = {19: node}
|
||||
self.hass.services.call('zwave', 'test_node', {
|
||||
const.ATTR_NODE_ID: 19,
|
||||
})
|
||||
self.hass.block_till_done()
|
||||
|
||||
assert node.test.called
|
||||
assert len(node.test.mock_calls) == 1
|
||||
|
|
Loading…
Add table
Reference in a new issue