Skip to content
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

Add service descriptions in zwave panel #306

Merged
merged 4 commits into from
Jun 18, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 36 additions & 13 deletions panels/zwave/ha-panel-zwave.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<link rel="import" href="../../bower_components/app-layout/app-header-layout/app-header-layout.html">
<link rel="import" href="../../bower_components/app-layout/app-header/app-header.html">
<link rel="import" href="../../bower_components/app-layout/app-toolbar/app-toolbar.html">
<link rel="import" href="../../bower_components/iron-icon/iron-icon.html">
<link rel="import" href="../../bower_components/paper-dropdown-menu/paper-dropdown-menu.html">
<link rel='import' href='../../bower_components/paper-item/paper-item.html'>
<link rel='import' href="../../bower_components/paper-listbox/paper-listbox.html">
Expand All @@ -28,7 +29,6 @@

.node-info {
margin-left: 16px;
text-transform: capitalize;
}

.help-text {
Expand Down Expand Up @@ -67,7 +67,8 @@
<!--Node card-->
<div class='content'>
<paper-card heading='Z-Wave Node Management'>
<div class='card-content'>
<iron-icon on-tap='toggleHelp' style='padding: 14px 0 14px 12px' icon='mdi:help-circle'></iron-icon>
<div style='display:inline-block' class='card-content'>
Z-Wave Node controls.
</div>
<div class='device-picker'>
Expand All @@ -81,35 +82,44 @@
</paper-listbox>
</paper-dropdown-menu>
</div>
<template is='dom-if' if='[[!computeIsNodeSelected(selectedNode)]]'>
<template is='dom-if' if='[[showHelp]]'>
<div style='color: grey; padding: 12px'>Select node to view per-node options</div>
</template>
</template>

<template is='dom-if' if='[[!computeIsNodeSelected(selectedNode)]]'>
<template is='dom-if' if='[[computeIsNodeSelected(selectedNode)]]'>
<div class='card-actions'>
<ha-call-service-button
hass='[[hass]]'
domain='zwave'
service='refresh_node'
service-data=[[computeNodeServiceData(selectedNode)]]
show-description=[[showHelp]]
>Refresh Node</ha-call-service-button>
<ha-call-service-button
hass='[[hass]]'
domain='zwave'
service='remove_failed_node'
service-data=[[computeNodeServiceData(selectedNode)]]
show-description=[[showHelp]]
>Remove Failed Node</ha-call-service-button>
<ha-call-service-button
hass='[[hass]]'
domain='zwave'
service='replace_failed_node'
service-data=[[computeNodeServiceData(selectedNode)]]
show-description=[[showHelp]]
>Replace Failed Node</ha-call-service-button>
<ha-call-service-button
hass='[[hass]]'
domain='zwave'
service='print_node'
service-data=[[computeNodeServiceData(selectedNode)]]
show-description=[[showHelp]]
>Print Node</ha-call-service-button>
</div>
<div class='card-actions'>
</div>
<div class='card-actions'>
<paper-input
float-label="New node name"
type=text
Expand All @@ -121,6 +131,7 @@
domain='zwave'
service='rename_node'
service-data=[[computeNodeNameServiceData(newNodeNameInput)]]
show-description=[[showHelp]]
>Rename Node</ha-call-service-button>
</div>

Expand All @@ -142,6 +153,7 @@
domain='zwave'
service='refresh_entity'
service-data=[[computeRefreshEntityServiceData(selectedEntity)]]
show-description=[[showHelp]]
>Refresh Entity</ha-call-service-button>
</div>
<div class='content'>
Expand All @@ -162,15 +174,15 @@
</paper-card>
</div>
<!--Node info card-->
<template is='dom-if' if='[[!computeIsNodeSelected(selectedNode)]]'>
<template is='dom-if' if='[[computeIsNodeSelected(selectedNode)]]'>
<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)]]'>
<template is='dom-if' if='[[computeIsNodeSelected(selectedNode)]]'>
<zwave-values
hass='[[hass]]'
nodes='[[nodes]]'
Expand All @@ -179,7 +191,7 @@
></zwave-values>
</template>
<!--Group card-->
<template is='dom-if' if='[[!computeIsNodeSelected(selectedNode)]]'>
<template is='dom-if' if='[[computeIsNodeSelected(selectedNode)]]'>
<zwave-groups
hass='[[hass]]'
nodes='[[nodes]]'
Expand All @@ -188,7 +200,7 @@
></zwave-groups>
</template>
<!--Config card-->
<template is='dom-if' if='[[!computeIsNodeSelected(selectedNode)]]'>
<template is='dom-if' if='[[computeIsNodeSelected(selectedNode)]]'>
<zwave-node-config
hass='[[hass]]'
nodes='[[nodes]]'
Expand Down Expand Up @@ -296,7 +308,12 @@

hasNodeUserCodes: {
type: Boolean,
value: false
value: false,
},

showHelp: {
type: Boolean,
value: false,
},
},

Expand Down Expand Up @@ -334,10 +351,12 @@
(!(ent.entity_id).match('zwave[.]')));
})
.sort(function (entityA, entityB) {
if (entityA.entity_id < entityB.entity_id) {
var nameA = window.hassUtil.computeStateName(entityA);
var nameB = window.hassUtil.computeStateName(entityB);
if (nameA < nameB) {
return -1;
}
if (entityA.entity_id > entityB.entity_id) {
if (nameA > nameB) {
return 1;
}
return 0;
Expand Down Expand Up @@ -411,7 +430,7 @@
},

computeIsNodeSelected: function () {
return (!this.nodes || this.selectedNode === -1);
return (this.nodes && this.selectedNode !== -1);
},

computeIsEntitySelected: function (selectedEntity) {
Expand All @@ -437,5 +456,9 @@
if (selectedEntity === -1) return -1;
return { entity_id: this.entities[selectedEntity].entity_id };
},

toggleHelp: function () {
this.showHelp = !this.showHelp;
},
});
</script>
27 changes: 26 additions & 1 deletion panels/zwave/zwave-network.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/paper-card/paper-card.html">
<link rel="import" href="../../bower_components/iron-icon/iron-icon.html">
<link rel="import" href="../../src/components/buttons/ha-call-service-button.html">

<dom-module id='zwave-network'>
Expand All @@ -20,53 +21,68 @@
}
</style>
<paper-card heading='Z-Wave Network Management'>
<div class='card-content'>
<iron-icon on-tap='helpTap' style='padding: 14px 0 14px 12px' icon='mdi:help-circle'></iron-icon>
<div style='display:inline-block' class='card-content'>
Z-Wave Network controls.
</div>
<div class='card-actions'>
<ha-call-service-button
hass='[[hass]]'
domain='zwave'
service='add_node_secure'
show-description=[[showDescription]]
>Add Node Secure</ha-call-service-button>
<ha-call-service-button
hass='[[hass]]'
domain='zwave'
service='add_node'
show-description=[[showDescription]]
>Add Node</ha-call-service-button>
<ha-call-service-button
hass='[[hass]]'
domain='zwave'
service='remove_node'
show-description=[[showDescription]]
>Remove Node</ha-call-service-button>
</div>
<div class='card-actions warning'>
<ha-call-service-button
hass='[[hass]]'
domain='zwave'
service='cancel_command'
show-description=[[showDescription]]
>Cancel Command</ha-call-service-button>
</div>
<div class='card-actions'>
<ha-call-service-button
hass='[[hass]]'
domain='zwave'
service='heal_network'
show-description=[[showDescription]]
>Heal Network</ha-call-service-button>
<ha-call-service-button
hass='[[hass]]'
domain='zwave'
service='start_network'
show-description=[[showDescription]]
>Start Network</ha-call-service-button>
<ha-call-service-button
hass='[[hass]]'
domain='zwave'
service='stop_network'
show-description=[[showDescription]]
>Stop Network</ha-call-service-button>
<ha-call-service-button
hass='[[hass]]'
domain='zwave'
service='soft_reset'
show-description=[[showDescription]]
>Soft Reset</ha-call-service-button>
<ha-call-service-button
hass='[[hass]]'
domain='zwave'
service='test_network'
show-description=[[showDescription]]
>Test Network</ha-call-service-button>
</div>
</paper-card>
Expand All @@ -81,6 +97,15 @@
hass: {
type: Object,
},

showDescription: {
type: Boolean,
value: false,
},
},

helpTap: function () {
this.showDescription = !this.showDescription;
}
});
</script>
1 change: 0 additions & 1 deletion panels/zwave/zwave-node-information.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

.node-info {
margin-left: 16px;
text-transform: capitalize;
}

paper-card {
Expand Down
18 changes: 17 additions & 1 deletion src/components/buttons/ha-call-service-button.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
progress='[[progress]]'
on-tap='buttonTapped'
><slot></slot></ha-progress-button>
<template is='dom-if' if='[[showDescription]]'>
<div style="color: grey">[[getDescription(hass, domain, service)]]</div>
</template>
</template>
</dom-module>

Expand Down Expand Up @@ -37,6 +40,11 @@
type: Object,
value: {},
},

showDescription: {
type: Boolean,
value: false,
},
},

buttonTapped: function () {
Expand All @@ -60,6 +68,14 @@
}).then(function () {
el.fire('hass-service-called', eventData);
});
}
},

getDescription: function (hass, domain, service) {
var domainServices = hass.config.services[domain];
if (!domainServices) return '';
var serviceObject = domainServices[service];
if (!serviceObject) return '';
return serviceObject.description;
},
});
</script>