Add print_config_parameter service to Z-Wave (#5121)

* Add print_config_param service to z-wave

* Add print_config_parameter service to z-wave

* Add print_config_parameter service to z-wave

* Fix typos

* Fix typos

* Fix typo
This commit is contained in:
andrey-git 2017-01-01 22:10:45 +02:00 committed by John Arild Berentsen
parent 01be70cda9
commit 7fbf68df35
3 changed files with 28 additions and 0 deletions

View file

@ -136,6 +136,11 @@ SET_CONFIG_PARAMETER_SCHEMA = vol.Schema({
vol.Required(const.ATTR_CONFIG_VALUE): vol.Coerce(int),
vol.Optional(const.ATTR_CONFIG_SIZE): vol.Coerce(int)
})
PRINT_CONFIG_PARAMETER_SCHEMA = vol.Schema({
vol.Required(const.ATTR_NODE_ID): vol.Coerce(int),
vol.Required(const.ATTR_CONFIG_PARAMETER): vol.Coerce(int),
})
CHANGE_ASSOCIATION_SCHEMA = vol.Schema({
vol.Required(const.ATTR_ASSOCIATION): cv.string,
vol.Required(const.ATTR_NODE_ID): vol.Coerce(int),
@ -463,6 +468,14 @@ def setup(hass, config):
_LOGGER.info("Setting config parameter %s on Node %s "
"with value %s and size=%s", param, node_id, value, size)
def print_config_parameter(service):
"""Print a config parameter from a node."""
node_id = service.data.get(const.ATTR_NODE_ID)
node = NETWORK.nodes[node_id]
param = service.data.get(const.ATTR_CONFIG_PARAMETER)
_LOGGER.info("Config parameter %s on Node %s : %s",
param, node_id, get_config_value(node, param))
def change_association(service):
"""Change an association in the zwave network."""
association_type = service.data.get(const.ATTR_ASSOCIATION)
@ -548,6 +561,11 @@ def setup(hass, config):
descriptions[
const.SERVICE_SET_CONFIG_PARAMETER],
schema=SET_CONFIG_PARAMETER_SCHEMA)
hass.services.register(DOMAIN, const.SERVICE_PRINT_CONFIG_PARAMETER,
print_config_parameter,
descriptions[
const.SERVICE_PRINT_CONFIG_PARAMETER],
schema=PRINT_CONFIG_PARAMETER_SCHEMA)
hass.services.register(DOMAIN, const.SERVICE_CHANGE_ASSOCIATION,
change_association,
descriptions[

View file

@ -24,6 +24,7 @@ SERVICE_HEAL_NETWORK = "heal_network"
SERVICE_SOFT_RESET = "soft_reset"
SERVICE_TEST_NETWORK = "test_network"
SERVICE_SET_CONFIG_PARAMETER = "set_config_parameter"
SERVICE_PRINT_CONFIG_PARAMETER = "print_config_parameter"
SERVICE_STOP_NETWORK = "stop_network"
SERVICE_START_NETWORK = "start_network"
SERVICE_RENAME_NODE = "rename_node"

View file

@ -38,6 +38,15 @@ set_config_parameter:
description: Value to set on parameter. (integer).
size:
description: (Optional) The size of the value. Defaults to 2.
print_config_parameter:
description: Prints a Z-Wave node config parameter value to log.
fields:
node_id:
description: Node id of the device to print the parameter from (integer).
parameter:
description: Parameter number to print (integer).
start_network:
description: Start the Z-Wave network. This might take a while, depending on how big your Z-Wave network is.