-
-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Final tweaks for Zwave panel #7652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d70ab95
# This is a combination of 3 commits.
turbokongen f9215b9
Add seperate zwave panel
turbokongen 2e57aec
Modify set_config_parameter to accept setting string values
turbokongen b38ca84
descriptions
turbokongen aee711e
Tweaks
turbokongen 8684e1c
Tweaks
turbokongen 4813613
Tweaks
turbokongen 089b7e8
Tweaks
turbokongen 7f4680f
lint
turbokongen 75b29ba
Fallback if no config parameteres are available
turbokongen 59d6012
Update services.yaml
turbokongen 29f7d25
review changes
turbokongen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,8 +78,7 @@ | |
| SET_CONFIG_PARAMETER_SCHEMA = vol.Schema({ | ||
| vol.Required(const.ATTR_NODE_ID): vol.Coerce(int), | ||
| vol.Required(const.ATTR_CONFIG_PARAMETER): vol.Coerce(int), | ||
| vol.Required(const.ATTR_CONFIG_VALUE): vol.Coerce(int), | ||
| vol.Optional(const.ATTR_CONFIG_SIZE): vol.Coerce(int) | ||
| vol.Required(const.ATTR_CONFIG_VALUE): vol.Any(vol.Coerce(int), cv.string), | ||
| }) | ||
| PRINT_CONFIG_PARAMETER_SCHEMA = vol.Schema({ | ||
| vol.Required(const.ATTR_NODE_ID): vol.Coerce(int), | ||
|
|
@@ -410,28 +409,23 @@ def set_config_parameter(service): | |
| node = network.nodes[node_id] | ||
| param = service.data.get(const.ATTR_CONFIG_PARAMETER) | ||
| selection = service.data.get(const.ATTR_CONFIG_VALUE) | ||
| size = service.data.get(const.ATTR_CONFIG_SIZE, 2) | ||
| i = 0 | ||
| for value in ( | ||
| node.get_values(class_id=const.COMMAND_CLASS_CONFIGURATION) | ||
| .values()): | ||
| if value.index == param and value.type == const.TYPE_LIST: | ||
| _LOGGER.debug("Values for parameter %s: %s", param, | ||
| value.data_items) | ||
| i = len(value.data_items) - 1 | ||
| if i == 0: | ||
| node.set_config_param(param, selection, size) | ||
| else: | ||
| if selection > i: | ||
| _LOGGER.error("Config parameter selection does not exist! " | ||
| "Please check zwcfg_[home_id].xml in " | ||
| "your homeassistant config directory. " | ||
| "Available selections are 0 to %s", i) | ||
| return | ||
| node.set_config_param(param, selection, size) | ||
| _LOGGER.info("Setting config parameter %s on Node %s " | ||
| "with selection %s and size=%s", param, node_id, | ||
| selection, size) | ||
| if value.index != param: | ||
| continue | ||
| if value.type in [const.TYPE_LIST, const.TYPE_BOOL]: | ||
| value.data = selection | ||
| _LOGGER.info("Setting config list parameter %s on Node %s " | ||
| "with selection %s", param, node_id, | ||
| selection) | ||
| break | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can just return here (and below) instead of break. Then you won't need param_set |
||
| else: | ||
| value.data = int(selection) | ||
| _LOGGER.info("Setting config parameter %s on Node %s " | ||
| "with selection %s", param, node_id, | ||
| selection) | ||
| break | ||
|
|
||
| def print_config_parameter(service): | ||
| """Print a config parameter from a node.""" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why switch to direct value manipulation instead of node.set_config_param ?
node.set_config_param supports setting params not "known" to ozw via the device config.
While this option is not needed for UI panel it is still useful as a service call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, It might be a usefull service call to have, but my opinion is:
The device should rather be added to OZW than we supporting making changes on an unknown device.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But is there an upside of calling
value.data = selectionas opposed tonode.set_config_param(param, selection, size)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes readability:
Take issue #7608
The provided "value" by the user, does not correspond to the actual value in OZW.
OZW value always corresponds to index within the list of options. But there is no way to retrieve that value from ozw. It always respond with the data or data_as_string.
When retrieving the data_items, it is not sorted in any way, so:
from zwcfg file:
And from the values:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sound good.
Though could you bring back
node.set_config_param(param, selection, size)in case theforloop didn't find a match?