Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 54 additions & 46 deletions panels/config/zwave/ha-config-zwave.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<link rel="import" href="../../../src/components/buttons/ha-call-service-button.html">
<link rel="import" href="../../../src/components/ha-service-description.html">
<link rel="import" href="../../../src/resources/ha-style.html">

<link rel="import" href="../ha-config-section.html">

<link rel="import" href="./zwave-log.html">
<link rel="import" href="./zwave-network.html">
<link rel="import" href="./zwave-node-information.html">
Expand Down Expand Up @@ -84,21 +87,28 @@
hass='[[hass]]'
></zwave-node-options>

<div class='content'>
<zwave-network
id='zwave-network'
hass='[[hass]]'
></zwave-network>
</div>
<!--Node card-->
<div class='content'>
<paper-card heading='Z-Wave Node Management'>
<zwave-network
id='zwave-network'
is-wide='[[isWide]]'
hass='[[hass]]'
></zwave-network>

<!--Node card-->
<ha-config-section is-wide='[[isWide]]'>
<div style="position: relative" slot='header'>
<span>Z-Wave Node Management</span>
<paper-icon-button
class='toggle-help-icon'
class="toggle-help-icon"
on-tap='toggleHelp'
icon='mdi:help-circle'
></paper-icon-button>

</div>
<span slot='introduction'>
Run Z-Wave commands that affect a single node. Pick a node to see a list of available commands.
</span>

<paper-card class="content">
<div class='device-picker'>
<paper-dropdown-menu label="Nodes" class="flex">
<paper-listbox
Expand Down Expand Up @@ -234,59 +244,57 @@
</template>
</template>
</paper-card>
</div>
<!--Node info card-->

<template is='dom-if' if='[[computeIsNodeSelected(selectedNode)]]'>
<!--Node info card-->
<zwave-node-information
id='zwave-node-information'
nodes='[[nodes]]'
selected-node='[[selectedNode]]'
></zwave-node-information>
</template>
<!--Value card-->
<template is='dom-if' if='[[computeIsNodeSelected(selectedNode)]]'>

<!--Value card-->
<zwave-values
hass='[[hass]]'
nodes='[[nodes]]'
selected-node='[[selectedNode]]'
values='[[values]]'
></zwave-values>
</template>
<!--Group card-->
<template is='dom-if' if='[[computeIsNodeSelected(selectedNode)]]'>

<!--Group card-->
<zwave-groups
hass='[[hass]]'
nodes='[[nodes]]'
selected-node='[[selectedNode]]'
groups='[[groups]]'
></zwave-groups>
</template>
<!--Config card-->
<template is='dom-if' if='[[computeIsNodeSelected(selectedNode)]]'>

<!--Config card-->
<zwave-node-config
hass='[[hass]]'
nodes='[[nodes]]'
selected-node='[[selectedNode]]'
config='[[config]]'
></zwave-node-config>
</template>
<!--User Codes-->
<template is='dom-if' if='{{hasNodeUserCodes}}'>
<zwave-usercodes
id='zwave-usercodes'
hass='[[hass]]'
nodes='[[nodes]]'
user-codes='[[userCodes]]'
selected-node='[[selectedNode]]'
></zwave-usercodes>
</template>
<!--Ozw log-->
<div class='content'>
<ozw-log
id='ozw-log'
hass='[[hass]]'
></ozw-log>
</div>
</ha-config-section>

<!--User Codes-->
<template is='dom-if' if='{{hasNodeUserCodes}}'>
<zwave-usercodes
id='zwave-usercodes'
hass='[[hass]]'
nodes='[[nodes]]'
user-codes='[[userCodes]]'
selected-node='[[selectedNode]]'
></zwave-usercodes>
</template>

<!--Ozw log-->
<ozw-log
is-wide='[[isWide]]'
hass='[[hass]]'
></ozw-log>

</app-header-layout>
</template>
Expand Down Expand Up @@ -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) {
Expand Down
126 changes: 75 additions & 51 deletions panels/config/zwave/zwave-groups.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,65 +30,68 @@
.help-text {
padding-left: 24px;
padding-right: 24px;
padding-bottom: 12px;
}
</style>
<div class='content'>
<paper-card heading='Node group associations'>
<div class='device-picker'>
<paper-card class="content" heading='Node group associations'>
<!--TODO make api for getting groups and members-->
<div class='device-picker'>
<paper-dropdown-menu label="Group" class='flex'>
<paper-listbox
slot="dropdown-content"
selected='{{selectedGroup}}'>
<template is='dom-repeat' items='[[groups]]' as='state'>
<paper-item>[[computeSelectCaptionGroup(state)]]</paper-item>
</template>
</paper-listbox>
</paper-dropdown-menu>
</div>
<template is='dom-if' if='[[computeIsGroupSelected(selectedGroup)]]'>
<div class='device-picker'>
<paper-dropdown-menu label="Node to control" class='flex'>
<paper-listbox
slot="dropdown-content"
selected='{{selectedTargetNode}}'>
<template is='dom-repeat' items='[[nodes]]' as='state'>
slot="dropdown-content"
selected='{{selectedTargetNode}}'>
<template is='dom-repeat' items='[[nodes]]' as='state'>
<paper-item>[[computeSelectCaption(state)]]</paper-item>
</template>
</paper-listbox>
</paper-dropdown-menu>
</div>
<template is='dom-if' if='[[!computeIsTargetNodeSelected(selectedTargetNode)]]'>
<!--TODO make api for getting groups and members-->
<div class='device-picker'>
<paper-dropdown-menu label="Group" class='flex'>
<paper-listbox
slot="dropdown-content"
selected='{{selectedGroup}}'>
<template is='dom-repeat' items='[[groups]]' as='state'>
<paper-item>[[computeSelectCaptionGroup(state)]]</paper-item>
</template>
</paper-listbox>
</paper-dropdown-menu>
</div>
</template>
<template is='dom-if' if='[[!computeIsGroupSelected(selectedGroup)]]'>
<div class='help-text'>
<span>Other Nodes in this group:</span>
<template is='dom-repeat' items='[[otherGroupNodes]]' as='state'>
<span>[[state]]</span>
</template>
</div>
<div class='help-text'>
<span>Max Associations:</span>
<span>[[maxAssociations]]</span>
</div>
<div class='card-actions'>
<template is='dom-if' if='[[!noAssociationsLeft]]'>
<ha-call-service-button
</div>

<div class='help-text'>
<span>Other Nodes in this group:</span>
<template is='dom-repeat' items='[[otherGroupNodes]]' as='state'>
<div>[[state]]</div>
</template>
</div>
<div class='help-text'>
<span>Max Associations:</span>
<span>[[maxAssociations]]</span>
</div>
</template>

<template is='dom-if' if='[[computeIsTargetNodeSelected(selectedTargetNode)]]'>
<div class='card-actions'>
<template is='dom-if' if='[[!noAssociationsLeft]]'>
<ha-call-service-button
hass='[[hass]]'
domain='zwave'
service='change_association'
service-data='[[computeAssocServiceData(selectedGroup, "add")]]'
>Add To Group</ha-call-service-button>
</template>
<ha-call-service-button
hass='[[hass]]'
domain='zwave'
service='change_association'
service-data='[[computeAssocServiceData(selectedGroup, "remove")]]'
>Remove From Group</ha-call-service-button>
>Add To Group</ha-call-service-button>
</template>
<template is='dom-if' if='[[computeTargetInGroup(selectedGroup, selectedTargetNode)]]'>
<ha-call-service-button
hass='[[hass]]'
domain='zwave'
service='change_association'
service-data='[[computeAssocServiceData(selectedGroup, "remove")]]'
>Remove From Group</ha-call-service-button>
</template>
</div>
</template>
</paper-card>
</div>
</paper-card>
</template>
</dom-module>

Expand Down Expand Up @@ -164,15 +167,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) {
Expand All @@ -186,11 +211,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) {
Expand Down Expand Up @@ -223,4 +248,3 @@
},
});
</script>

Loading