mirror of
https://github.com/home-assistant/frontend.git
synced 2025-06-17 15:46:36 +00:00
Zwave poll intensity (#402)
* Add polling intensity to values card Round 1 Rebase * Move form-group out of car-actions
This commit is contained in:
parent
a46e6b4cfa
commit
ff1b667546
@ -15,6 +15,7 @@
|
|||||||
<link rel="import" href="../../../src/resources/ha-style.html">
|
<link rel="import" href="../../../src/resources/ha-style.html">
|
||||||
|
|
||||||
<link rel="import" href="../ha-config-section.html">
|
<link rel="import" href="../ha-config-section.html">
|
||||||
|
<link rel="import" href="../ha-form-style.html">
|
||||||
|
|
||||||
<link rel="import" href="./zwave-log.html">
|
<link rel="import" href="./zwave-log.html">
|
||||||
<link rel="import" href="./zwave-network.html">
|
<link rel="import" href="./zwave-network.html">
|
||||||
@ -23,11 +24,10 @@
|
|||||||
<link rel="import" href="./zwave-groups.html">
|
<link rel="import" href="./zwave-groups.html">
|
||||||
<link rel="import" href="./zwave-node-config.html">
|
<link rel="import" href="./zwave-node-config.html">
|
||||||
<link rel="import" href="./zwave-usercodes.html">
|
<link rel="import" href="./zwave-usercodes.html">
|
||||||
<link rel="import" href="./zwave-node-options.html">
|
|
||||||
|
|
||||||
<dom-module id="ha-config-zwave">
|
<dom-module id="ha-config-zwave">
|
||||||
<template>
|
<template>
|
||||||
<style include="iron-flex ha-style">
|
<style include="iron-flex ha-style ha-form-style">
|
||||||
.content {
|
.content {
|
||||||
margin-top: 24px;
|
margin-top: 24px;
|
||||||
}
|
}
|
||||||
@ -82,11 +82,6 @@
|
|||||||
</app-toolbar>
|
</app-toolbar>
|
||||||
</app-header>
|
</app-header>
|
||||||
|
|
||||||
<zwave-node-options
|
|
||||||
is-wide='[[isWide]]'
|
|
||||||
hass='[[hass]]'
|
|
||||||
></zwave-node-options>
|
|
||||||
|
|
||||||
<zwave-network
|
<zwave-network
|
||||||
id='zwave-network'
|
id='zwave-network'
|
||||||
is-wide='[[isWide]]'
|
is-wide='[[isWide]]'
|
||||||
@ -228,6 +223,29 @@
|
|||||||
hidden$='[[!showHelp]]'
|
hidden$='[[!showHelp]]'
|
||||||
></ha-service-description>
|
></ha-service-description>
|
||||||
</div>
|
</div>
|
||||||
|
<div class='form-group'>
|
||||||
|
<paper-checkbox
|
||||||
|
checked='{{entityIgnored}}'
|
||||||
|
class='form-control'
|
||||||
|
>
|
||||||
|
Exclude this entity from Home Assistant
|
||||||
|
</paper-checkbox>
|
||||||
|
<paper-input
|
||||||
|
disabled='{{entityIgnored}}'
|
||||||
|
label="Polling intensity"
|
||||||
|
type=number
|
||||||
|
min=0
|
||||||
|
value={{entityPollingIntensity}}>
|
||||||
|
</paper-input>
|
||||||
|
</div>
|
||||||
|
<div class='card-actions'>
|
||||||
|
<ha-call-service-button
|
||||||
|
hass='[[hass]]'
|
||||||
|
domain='zwave'
|
||||||
|
service='set_poll_intensity'
|
||||||
|
service-data=[[computePollIntensityServiceData(entityPollingIntensity)]]
|
||||||
|
>Save</ha-call-service-button>
|
||||||
|
</div>
|
||||||
<div class='content'>
|
<div class='content'>
|
||||||
<div class='card-actions'>
|
<div class='card-actions'>
|
||||||
<paper-button toggles raised noink active={{entityInfoActive}}>Entity Attributes</paper-button>
|
<paper-button toggles raised noink active={{entityInfoActive}}>Entity Attributes</paper-button>
|
||||||
@ -338,8 +356,7 @@ Polymer({
|
|||||||
selectedEntity: {
|
selectedEntity: {
|
||||||
type: Number,
|
type: Number,
|
||||||
value: -1,
|
value: -1,
|
||||||
observers: ['computeIsEntitySelected',
|
observer: 'selectedEntityChanged',
|
||||||
'computeRefreshEntityServiceData']
|
|
||||||
},
|
},
|
||||||
|
|
||||||
selectedEntityAttrs: {
|
selectedEntityAttrs: {
|
||||||
@ -375,6 +392,25 @@ Polymer({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false,
|
value: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
entityIgnored: {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
|
|
||||||
|
entityPollingIntensity: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
listeners: {
|
||||||
|
'hass-service-called': 'serviceCalled',
|
||||||
|
},
|
||||||
|
|
||||||
|
serviceCalled: function (ev) {
|
||||||
|
var el = this;
|
||||||
|
if ((ev.detail.success) && (ev.detail.service === 'set_poll_intensity')) {
|
||||||
|
el.saveEntity();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
computeNodes: function (hass) {
|
computeNodes: function (hass) {
|
||||||
@ -438,6 +474,24 @@ Polymer({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
selectedEntityChanged: function (selectedEntity) {
|
||||||
|
if (selectedEntity === -1) return;
|
||||||
|
var el = this;
|
||||||
|
el.hass.callApi('GET', 'zwave/values/' + el.nodes[el.selectedNode].attributes.node_id).then(
|
||||||
|
(values) => {
|
||||||
|
el.values = el._objToArray(values);
|
||||||
|
});
|
||||||
|
|
||||||
|
var valueId = el.entities[selectedEntity].attributes.value_id;
|
||||||
|
var valueData = el.values.find(function (obj) { return obj.key === valueId; });
|
||||||
|
var valueIndex = el.values.indexOf(valueData);
|
||||||
|
el.hass.callApi('GET', 'config/zwave/device_config/' + valueId)
|
||||||
|
.then(function (data) {
|
||||||
|
el.entityIgnored = data.ignored || false;
|
||||||
|
el.entityPollingIntensity = el.values[valueIndex].value.poll_intensity;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
computeSelectedEntityAttrs: function (selectedEntity) {
|
computeSelectedEntityAttrs: function (selectedEntity) {
|
||||||
if (selectedEntity === -1) return 'No entity selected';
|
if (selectedEntity === -1) return 'No entity selected';
|
||||||
var entityAttrs = this.entities[selectedEntity].attributes;
|
var entityAttrs = this.entities[selectedEntity].attributes;
|
||||||
@ -487,6 +541,24 @@ Polymer({
|
|||||||
return { entity_id: this.entities[selectedEntity].entity_id };
|
return { entity_id: this.entities[selectedEntity].entity_id };
|
||||||
},
|
},
|
||||||
|
|
||||||
|
computePollIntensityServiceData: function (entityPollingIntensity) {
|
||||||
|
if (!this.selectedNode === -1 || this.selectedEntity === -1) return -1;
|
||||||
|
return {
|
||||||
|
node_id: this.nodes[this.selectedNode].attributes.node_id,
|
||||||
|
value_id: this.entities[this.selectedEntity].attributes.value_id,
|
||||||
|
poll_intensity: parseInt(entityPollingIntensity),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
saveEntity: function () {
|
||||||
|
var data = {
|
||||||
|
ignored: this.entityIgnored,
|
||||||
|
polling_intensity: parseInt(this.entityPollingIntensity),
|
||||||
|
};
|
||||||
|
return this.hass.callApi(
|
||||||
|
'POST', 'config/zwave/device_config/' + this.entities[this.selectedEntity].entity_id, data);
|
||||||
|
},
|
||||||
|
|
||||||
toggleHelp: function () {
|
toggleHelp: function () {
|
||||||
this.showHelp = !this.showHelp;
|
this.showHelp = !this.showHelp;
|
||||||
},
|
},
|
||||||
|
@ -1,78 +0,0 @@
|
|||||||
<link rel="import" href="../../../bower_components/polymer/polymer.html">
|
|
||||||
|
|
||||||
<link rel="import" href="../ha-form-style.html">
|
|
||||||
|
|
||||||
<dom-module id="ha-form-zwave-device">
|
|
||||||
<template>
|
|
||||||
<style include="iron-flex ha-style ha-form-style">
|
|
||||||
</style>
|
|
||||||
<div class='form-group'>
|
|
||||||
<paper-checkbox
|
|
||||||
checked='{{entityIgnored}}'
|
|
||||||
class='form-control'
|
|
||||||
>
|
|
||||||
Exclude from Home Assistant
|
|
||||||
</paper-checkbox>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class='form-group'>
|
|
||||||
<paper-dropdown-menu
|
|
||||||
class='form-control flex'
|
|
||||||
label='Polling intensity'
|
|
||||||
disabled='[[entityIgnored]]'
|
|
||||||
>
|
|
||||||
<paper-listbox
|
|
||||||
slot="dropdown-content"
|
|
||||||
selected='{{entityPollingIntensity}}'
|
|
||||||
>
|
|
||||||
<paper-item>Do not poll (0)</paper-item>
|
|
||||||
<paper-item>Poll every time (1)</paper-item>
|
|
||||||
<paper-item>Poll every other time (2)</paper-item>
|
|
||||||
</paper-listbox>
|
|
||||||
</paper-dropdown-menu>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</dom-module>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
Polymer({
|
|
||||||
is: 'ha-form-zwave-device',
|
|
||||||
|
|
||||||
properties: {
|
|
||||||
hass: {
|
|
||||||
type: Object,
|
|
||||||
},
|
|
||||||
|
|
||||||
entity: {
|
|
||||||
type: Object,
|
|
||||||
},
|
|
||||||
|
|
||||||
entityIgnored: {
|
|
||||||
type: Boolean,
|
|
||||||
},
|
|
||||||
|
|
||||||
entityPollingIntensity: {
|
|
||||||
type: Number,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
loadEntity: function (entity) {
|
|
||||||
this.entity = entity;
|
|
||||||
var el = this;
|
|
||||||
return this.hass.callApi('GET', 'config/zwave/device_config/' + entity.entity_id)
|
|
||||||
.then(function (data) {
|
|
||||||
el.entityIgnored = data.ignored || false;
|
|
||||||
el.entityPollingIntensity = data.polling_intensity || 0;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
saveEntity: function () {
|
|
||||||
var data = {
|
|
||||||
ignored: this.entityIgnored,
|
|
||||||
polling_intensity: this.entityPollingIntensity,
|
|
||||||
};
|
|
||||||
return this.hass.callApi(
|
|
||||||
'POST', 'config/zwave/device_config/' + this.entity.entity_id, data);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
|
@ -59,6 +59,7 @@
|
|||||||
service='rename_value'
|
service='rename_value'
|
||||||
service-data=[[computeValueNameServiceData(newValueNameInput)]]
|
service-data=[[computeValueNameServiceData(newValueNameInput)]]
|
||||||
>Rename Value</ha-call-service-button>
|
>Rename Value</ha-call-service-button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</paper-card>
|
</paper-card>
|
||||||
@ -90,6 +91,7 @@ Polymer({
|
|||||||
selectedValue: {
|
selectedValue: {
|
||||||
type: Number,
|
type: Number,
|
||||||
value: -1,
|
value: -1,
|
||||||
|
observer: 'selectedValueChanged'
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -98,8 +100,8 @@ Polymer({
|
|||||||
},
|
},
|
||||||
|
|
||||||
serviceCalled: function (ev) {
|
serviceCalled: function (ev) {
|
||||||
if (ev.detail.success) {
|
|
||||||
var foo = this;
|
var foo = this;
|
||||||
|
if (ev.detail.success) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
foo.refreshValues(foo.selectedNode);
|
foo.refreshValues(foo.selectedNode);
|
||||||
}, 5000);
|
}, 5000);
|
||||||
@ -141,6 +143,16 @@ Polymer({
|
|||||||
name: newValueNameInput,
|
name: newValueNameInput,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
selectedValueChanged: function (selectedValue) {
|
||||||
|
if (!this.selectedNode === -1 || this.selectedValue === -1) return;
|
||||||
|
var el = this;
|
||||||
|
this.hass.callApi('GET', 'config/zwave/device_config/' + this.values[selectedValue].value.entity_id)
|
||||||
|
.then(function (data) {
|
||||||
|
el.entityIgnored = data.ignored || false;
|
||||||
|
el.entityPollingIntensity = el.values[selectedValue].value.poll_intensity;
|
||||||
|
});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user