From 1b9b82a32becf3c5e7c7b6d5a3613b15d9a1785f Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 18 Aug 2017 17:04:25 +0300 Subject: [PATCH 1/2] Improvements for zwave group config --- panels/config/zwave/zwave-groups.html | 102 ++++++++++++++++---------- 1 file changed, 64 insertions(+), 38 deletions(-) diff --git a/panels/config/zwave/zwave-groups.html b/panels/config/zwave/zwave-groups.html index 02deb5fe7eea..4f0a0d3f97a1 100644 --- a/panels/config/zwave/zwave-groups.html +++ b/panels/config/zwave/zwave-groups.html @@ -32,61 +32,65 @@ padding-right: 24px; } -
- -
- - - - - -
-
@@ -164,15 +168,37 @@ computeMaxAssociations: function (selectedGroup) { if (selectedGroup === -1) return -1; var maxAssociations = this.groups[selectedGroup].value.max_associations; - if (!maxAssociations) return ['None']; + if (!maxAssociations) return 'None'; return maxAssociations; }, computeOtherGroupNodes: function (selectedGroup) { if (selectedGroup === -1) return -1; - var associations = Object.values(this.groups[selectedGroup].value.associations); + var associations = Object.values(this.groups[selectedGroup].value.association_instances); if (!associations.length) return ['None']; - return associations; + return associations.map((assoc) => { + if (!assoc.length || assoc.length !== 2) { + return 'Unknown Node: ' + assoc; + } + const id = assoc[0]; + const instance = assoc[1]; + const node = this.nodes.find(n => n.attributes.node_id === id); + if (!node) { + return 'Unknown Node (id: ' + (instance ? id + '.' + instance : id) + ')'; + } + let caption = this.computeSelectCaption(node); + if (instance) { + caption += '/ Instance: ' + instance; + } + return caption; + }); + }, + + computeTargetInGroup: function (selectedGroup, selectedTargetNode) { + if (selectedGroup === -1 || selectedTargetNode === -1) return false; + const associations = Object.values(this.groups[selectedGroup].value.associations); + if (!associations.length) return false; + return associations.indexOf(this.nodes[selectedTargetNode].attributes.node_id) !== -1; }, computeSelectCaption: function (stateObj) { @@ -186,11 +212,11 @@ }, computeIsTargetNodeSelected: function (selectedTargetNode) { - return (!this.nodes || selectedTargetNode === -1); + return this.nodes && selectedTargetNode !== -1; }, computeIsGroupSelected: function (selectedGroup) { - return (!this.nodes || this.selectedNode === -1 || selectedGroup === -1); + return this.nodes && this.selectedNode !== -1 && selectedGroup !== -1; }, computeAssocServiceData: function (selectedGroup, type) { From 57b6b412e68de83e982dc41bf61b5775fbefea92 Mon Sep 17 00:00:00 2001 From: Andrey Date: Sat, 19 Aug 2017 16:58:21 +0300 Subject: [PATCH 2/2] Apply ha-config-section --- panels/config/zwave/ha-config-zwave.html | 100 ++++---- panels/config/zwave/zwave-groups.html | 110 +++++---- panels/config/zwave/zwave-log.html | 32 ++- panels/config/zwave/zwave-network.html | 246 +++++++++++--------- panels/config/zwave/zwave-node-options.html | 4 +- 5 files changed, 263 insertions(+), 229 deletions(-) diff --git a/panels/config/zwave/ha-config-zwave.html b/panels/config/zwave/ha-config-zwave.html index 2e943ae78b21..022857935d07 100644 --- a/panels/config/zwave/ha-config-zwave.html +++ b/panels/config/zwave/ha-config-zwave.html @@ -13,6 +13,9 @@ + + + @@ -84,21 +87,28 @@ hass='[[hass]]' > -
- -
- -
- + + + + +
+ Z-Wave Node Management +
+ + Run Z-Wave commands that affect a single node. Pick a node to see a list of available commands. + + +
-
- + - - - - - - - - - -
- -
+
+ + + + + + @@ -406,28 +414,28 @@ this.selectedGroup = -1; this.hass.callApi('GET', 'zwave/config/' + this.nodes[selectedNode].attributes.node_id).then( - function (configs) { + (configs) => { this.config = this._objToArray(configs); - }.bind(this)); + }); this.hass.callApi('GET', 'zwave/values/' + this.nodes[selectedNode].attributes.node_id).then( - function (values) { + (values) => { this.values = this._objToArray(values); - }.bind(this)); + }); this.hass.callApi('GET', 'zwave/groups/' + this.nodes[selectedNode].attributes.node_id).then( - function (groups) { + (groups) => { this.groups = this._objToArray(groups); - }.bind(this)); + }); this.hasNodeUserCodes = false; this.notifyPath('hasNodeUserCodes'); this.hass.callApi('GET', 'zwave/usercodes/' + this.nodes[selectedNode].attributes.node_id).then( - function (usercodes) { + (usercodes) => { this.userCodes = this._objToArray(usercodes); this.hasNodeUserCodes = this.userCodes.length > 0; this.notifyPath('hasNodeUserCodes'); - }.bind(this)); + }); }, computeSelectedEntityAttrs: function (selectedEntity) { diff --git a/panels/config/zwave/zwave-groups.html b/panels/config/zwave/zwave-groups.html index 4f0a0d3f97a1..38345f787bc5 100644 --- a/panels/config/zwave/zwave-groups.html +++ b/panels/config/zwave/zwave-groups.html @@ -30,69 +30,68 @@ .help-text { padding-left: 24px; padding-right: 24px; + padding-bottom: 12px; } -
- - -
- + + +
+ + + + + +
+ @@ -249,4 +248,3 @@ }, }); - diff --git a/panels/config/zwave/zwave-log.html b/panels/config/zwave/zwave-log.html index 0487765cd295..27d8c1b6a0ac 100644 --- a/panels/config/zwave/zwave-log.html +++ b/panels/config/zwave/zwave-log.html @@ -2,6 +2,8 @@ + + diff --git a/panels/config/zwave/zwave-network.html b/panels/config/zwave/zwave-network.html index 73be3d928b30..a5f585a53c3c 100644 --- a/panels/config/zwave/zwave-network.html +++ b/panels/config/zwave/zwave-network.html @@ -4,6 +4,8 @@ + +