From 7fbf68df35808a1d2c4f57f50eb8f2887bedec4a Mon Sep 17 00:00:00 2001 From: andrey-git Date: Sun, 1 Jan 2017 22:10:45 +0200 Subject: [PATCH] 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 --- homeassistant/components/zwave/__init__.py | 18 ++++++++++++++++++ homeassistant/components/zwave/const.py | 1 + homeassistant/components/zwave/services.yaml | 9 +++++++++ 3 files changed, 28 insertions(+) diff --git a/homeassistant/components/zwave/__init__.py b/homeassistant/components/zwave/__init__.py index 7c4d5e02879..c0666f77c73 100755 --- a/homeassistant/components/zwave/__init__.py +++ b/homeassistant/components/zwave/__init__.py @@ -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[ diff --git a/homeassistant/components/zwave/const.py b/homeassistant/components/zwave/const.py index d30cb6c5f92..b5dbf2f402a 100644 --- a/homeassistant/components/zwave/const.py +++ b/homeassistant/components/zwave/const.py @@ -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" diff --git a/homeassistant/components/zwave/services.yaml b/homeassistant/components/zwave/services.yaml index cfe2edab5c9..2a44096ce0e 100644 --- a/homeassistant/components/zwave/services.yaml +++ b/homeassistant/components/zwave/services.yaml @@ -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.