Update frontend
This commit is contained in:
1 parent
eb473600f6
commit
6662b7f52d
4 files changed
+649
-3
No files matched your search
@@ -18,6 +18,6 @@ FINGERPRINTS = {
|
||||
"panels/ha-panel-iframe.html": "d920f0aa3c903680f2f8795e2255daab",
|
||||
"panels/ha-panel-logbook.html": "6dd6a16f52117318b202e60f98400163",
|
||||
"panels/ha-panel-map.html": "31c592c239636f91e07c7ac232a5ebc4",
|
||||
"panels/ha-panel-zwave.html": "84fb45638d2a69bac343246a687f647c",
|
||||
"panels/ha-panel-zwave.html": "19336d2c50c91dd6a122acc0606ff10d",
|
||||
"websocket_test.html": "575de64b431fe11c3785bf96d7813450"
|
||||
}
|
||||
@@ -1 +1,647 @@
|
||||
<html><head><meta charset="UTF-8"></head><body><div hidden="" by-vulcanize=""><style>[hidden]{display:none!important}</style><style is="custom-style">:root{--layout:{display:-ms-flexbox;display:-webkit-flex;display:flex};--layout-inline:{display:-ms-inline-flexbox;display:-webkit-inline-flex;display:inline-flex};--layout-horizontal:{@apply(--layout);-ms-flex-direction:row;-webkit-flex-direction:row;flex-direction:row};--layout-horizontal-reverse:{@apply(--layout);-ms-flex-direction:row-reverse;-webkit-flex-direction:row-reverse;flex-direction:row-reverse};--layout-vertical:{@apply(--layout);-ms-flex-direction:column;-webkit-flex-direction:column;flex-direction:column};--layout-vertical-reverse:{@apply(--layout);-ms-flex-direction:column-reverse;-webkit-flex-direction:column-reverse;flex-direction:column-reverse};--layout-wrap:{-ms-flex-wrap:wrap;-webkit-flex-wrap:wrap;flex-wrap:wrap};--layout-no-wrap:{-ms-flex-wrap:nowrap;-webkit-flex-wrap:nowrap;flex-wrap:nowrap};--layout-wrap-reverse:{-ms-flex-wrap:wrap-reverse;-webkit-flex-wrap:wrap-reverse;flex-wrap:wrap-reverse};--layout-flex-auto:{-ms-flex:1 1 auto;-webkit-flex:1 1 auto;flex:1 1 auto};--layout-flex-none:{-ms-flex:none;-webkit-flex:none;flex:none};--layout-flex:{-ms-flex:1 1 .000000001px;-webkit-flex:1;flex:1;-webkit-flex-basis:.000000001px;flex-basis:.000000001px};--layout-flex-2:{-ms-flex:2;-webkit-flex:2;flex:2};--layout-flex-3:{-ms-flex:3;-webkit-flex:3;flex:3};--layout-flex-4:{-ms-flex:4;-webkit-flex:4;flex:4};--layout-flex-5:{-ms-flex:5;-webkit-flex:5;flex:5};--layout-flex-6:{-ms-flex:6;-webkit-flex:6;flex:6};--layout-flex-7:{-ms-flex:7;-webkit-flex:7;flex:7};--layout-flex-8:{-ms-flex:8;-webkit-flex:8;flex:8};--layout-flex-9:{-ms-flex:9;-webkit-flex:9;flex:9};--layout-flex-10:{-ms-flex:10;-webkit-flex:10;flex:10};--layout-flex-11:{-ms-flex:11;-webkit-flex:11;flex:11};--layout-flex-12:{-ms-flex:12;-webkit-flex:12;flex:12};--layout-start:{-ms-flex-align:start;-webkit-align-items:flex-start;align-items:flex-start};--layout-center:{-ms-flex-align:center;-webkit-align-items:center;align-items:center};--layout-end:{-ms-flex-align:end;-webkit-align-items:flex-end;align-items:flex-end};--layout-baseline:{-ms-flex-align:baseline;-webkit-align-items:baseline;align-items:baseline};--layout-start-justified:{-ms-flex-pack:start;-webkit-justify-content:flex-start;justify-content:flex-start};--layout-center-justified:{-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center};--layout-end-justified:{-ms-flex-pack:end;-webkit-justify-content:flex-end;justify-content:flex-end};--layout-around-justified:{-ms-flex-pack:distribute;-webkit-justify-content:space-around;justify-content:space-around};--layout-justified:{-ms-flex-pack:justify;-webkit-justify-content:space-between;justify-content:space-between};--layout-center-center:{@apply(--layout-center);@apply(--layout-center-justified)};--layout-self-start:{-ms-align-self:flex-start;-webkit-align-self:flex-start;align-self:flex-start};--layout-self-center:{-ms-align-self:center;-webkit-align-self:center;align-self:center};--layout-self-end:{-ms-align-self:flex-end;-webkit-align-self:flex-end;align-self:flex-end};--layout-self-stretch:{-ms-align-self:stretch;-webkit-align-self:stretch;align-self:stretch};--layout-self-baseline:{-ms-align-self:baseline;-webkit-align-self:baseline;align-self:baseline};--layout-start-aligned:{-ms-flex-line-pack:start;-ms-align-content:flex-start;-webkit-align-content:flex-start;align-content:flex-start};--layout-end-aligned:{-ms-flex-line-pack:end;-ms-align-content:flex-end;-webkit-align-content:flex-end;align-content:flex-end};--layout-center-aligned:{-ms-flex-line-pack:center;-ms-align-content:center;-webkit-align-content:center;align-content:center};--layout-between-aligned:{-ms-flex-line-pack:justify;-ms-align-content:space-between;-webkit-align-content:space-between;align-content:space-between};--layout-around-aligned:{-ms-flex-line-pack:distribute;-ms-align-content:space-around;-webkit-align-content:space-around;align-content:space-around};--layout-block:{display:block};--layout-invisible:{visibility:hidden!important};--layout-relative:{position:relative};--layout-fit:{position:absolute;top:0;right:0;bottom:0;left:0};--layout-scroll:{-webkit-overflow-scrolling:touch;overflow:auto};--layout-fullbleed:{margin:0;height:100vh};--layout-fixed-top:{position:fixed;top:0;left:0;right:0};--layout-fixed-right:{position:fixed;top:0;right:0;bottom:0};--layout-fixed-bottom:{position:fixed;right:0;bottom:0;left:0};--layout-fixed-left:{position:fixed;top:0;bottom:0;left:0};}</style><dom-module id="iron-image" assetpath="../../bower_components/iron-image/"><template><style>:host{display:inline-block;overflow:hidden;position:relative}#sizedImgDiv{@apply(--layout-fit);display:none}#img{display:block;width:var(--iron-image-width,auto);height:var(--iron-image-height,auto)}:host([sizing]) #sizedImgDiv{display:block}:host([sizing]) #img{display:none}#placeholder{@apply(--layout-fit);bLine truncated
|
||||
<html><head><meta charset="UTF-8"></head><body><div hidden="" by-vulcanize=""><style>[hidden]{display:none!important}</style><style is="custom-style">:root{--layout:{display:-ms-flexbox;display:-webkit-flex;display:flex};--layout-inline:{display:-ms-inline-flexbox;display:-webkit-inline-flex;display:inline-flex};--layout-horizontal:{@apply(--layout);-ms-flex-direction:row;-webkit-flex-direction:row;flex-direction:row};--layout-horizontal-reverse:{@apply(--layout);-ms-flex-direction:row-reverse;-webkit-flex-direction:row-reverse;flex-direction:row-reverse};--layout-vertical:{@apply(--layout);-ms-flex-direction:column;-webkit-flex-direction:column;flex-direction:column};--layout-vertical-reverse:{@apply(--layout);-ms-flex-direction:column-reverse;-webkit-flex-direction:column-reverse;flex-direction:column-reverse};--layout-wrap:{-ms-flex-wrap:wrap;-webkit-flex-wrap:wrap;flex-wrap:wrap};--layout-no-wrap:{-ms-flex-wrap:nowrap;-webkit-flex-wrap:nowrap;flex-wrap:nowrap};--layout-wrap-reverse:{-ms-flex-wrap:wrap-reverse;-webkit-flex-wrap:wrap-reverse;flex-wrap:wrap-reverse};--layout-flex-auto:{-ms-flex:1 1 auto;-webkit-flex:1 1 auto;flex:1 1 auto};--layout-flex-none:{-ms-flex:none;-webkit-flex:none;flex:none};--layout-flex:{-ms-flex:1 1 .000000001px;-webkit-flex:1;flex:1;-webkit-flex-basis:.000000001px;flex-basis:.000000001px};--layout-flex-2:{-ms-flex:2;-webkit-flex:2;flex:2};--layout-flex-3:{-ms-flex:3;-webkit-flex:3;flex:3};--layout-flex-4:{-ms-flex:4;-webkit-flex:4;flex:4};--layout-flex-5:{-ms-flex:5;-webkit-flex:5;flex:5};--layout-flex-6:{-ms-flex:6;-webkit-flex:6;flex:6};--layout-flex-7:{-ms-flex:7;-webkit-flex:7;flex:7};--layout-flex-8:{-ms-flex:8;-webkit-flex:8;flex:8};--layout-flex-9:{-ms-flex:9;-webkit-flex:9;flex:9};--layout-flex-10:{-ms-flex:10;-webkit-flex:10;flex:10};--layout-flex-11:{-ms-flex:11;-webkit-flex:11;flex:11};--layout-flex-12:{-ms-flex:12;-webkit-flex:12;flex:12};--layout-start:{-ms-flex-align:start;-webkit-align-items:flex-start;align-items:flex-start};--layout-center:{-ms-flex-align:center;-webkit-align-items:center;align-items:center};--layout-end:{-ms-flex-align:end;-webkit-align-items:flex-end;align-items:flex-end};--layout-baseline:{-ms-flex-align:baseline;-webkit-align-items:baseline;align-items:baseline};--layout-start-justified:{-ms-flex-pack:start;-webkit-justify-content:flex-start;justify-content:flex-start};--layout-center-justified:{-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center};--layout-end-justified:{-ms-flex-pack:end;-webkit-justify-content:flex-end;justify-content:flex-end};--layout-around-justified:{-ms-flex-pack:distribute;-webkit-justify-content:space-around;justify-content:space-around};--layout-justified:{-ms-flex-pack:justify;-webkit-justify-content:space-between;justify-content:space-between};--layout-center-center:{@apply(--layout-center);@apply(--layout-center-justified)};--layout-self-start:{-ms-align-self:flex-start;-webkit-align-self:flex-start;align-self:flex-start};--layout-self-center:{-ms-align-self:center;-webkit-align-self:center;align-self:center};--layout-self-end:{-ms-align-self:flex-end;-webkit-align-self:flex-end;align-self:flex-end};--layout-self-stretch:{-ms-align-self:stretch;-webkit-align-self:stretch;align-self:stretch};--layout-self-baseline:{-ms-align-self:baseline;-webkit-align-self:baseline;align-self:baseline};--layout-start-aligned:{-ms-flex-line-pack:start;-ms-align-content:flex-start;-webkit-align-content:flex-start;align-content:flex-start};--layout-end-aligned:{-ms-flex-line-pack:end;-ms-align-content:flex-end;-webkit-align-content:flex-end;align-content:flex-end};--layout-center-aligned:{-ms-flex-line-pack:center;-ms-align-content:center;-webkit-align-content:center;align-content:center};--layout-between-aligned:{-ms-flex-line-pack:justify;-ms-align-content:space-between;-webkit-align-content:space-between;align-content:space-between};--layout-around-aligned:{-ms-flex-line-pack:distribute;-ms-align-content:space-around;-webkit-align-content:space-around;align-content:space-around};--layout-block:{display:block};--layout-invisible:{visibility:hidden!important};--layout-relative:{position:relative};--layout-fit:{position:absolute;top:0;right:0;bottom:0;left:0};--layout-scroll:{-webkit-overflow-scrolling:touch;overflow:auto};--layout-fullbleed:{margin:0;height:100vh};--layout-fixed-top:{position:fixed;top:0;left:0;right:0};--layout-fixed-right:{position:fixed;top:0;right:0;bottom:0};--layout-fixed-bottom:{position:fixed;right:0;bottom:0;left:0};--layout-fixed-left:{position:fixed;top:0;bottom:0;left:0};}</style><dom-module id="iron-image" assetpath="../../bower_components/iron-image/"><template><style>:host{display:inline-block;overflow:hidden;position:relative}#sizedImgDiv{@apply(--layout-fit);display:none}#img{display:block;width:var(--iron-image-width,auto);height:var(--iron-image-height,auto)}:host([sizing]) #sizedImgDiv{display:block}:host([sizing]) #img{display:none}#placeholder{@apply(--layout-fit);bLine truncated
|
||||
is: 'zwave-node-information',
|
||||
|
||||
properties: {
|
||||
nodes: {
|
||||
type: Array,
|
||||
observer: 'nodeChanged'
|
||||
},
|
||||
|
||||
selectedNode: {
|
||||
type: Number,
|
||||
value: -1,
|
||||
observer: 'nodeChanged'
|
||||
},
|
||||
|
||||
selectedNodeAttrs: {
|
||||
type: Array,
|
||||
},
|
||||
|
||||
nodeInfoActive: {
|
||||
type: Boolean,
|
||||
},
|
||||
},
|
||||
|
||||
nodeChanged: function (selectedNode) {
|
||||
if (!this.nodes || selectedNode === -1) return;
|
||||
var nodeAttrs = this.nodes[this.selectedNode].attributes;
|
||||
var att = [];
|
||||
Object.entries(nodeAttrs).forEach(([key, value]) => {
|
||||
att.push(key + ': ' + value);
|
||||
});
|
||||
this.selectedNodeAttrs = att.sort();
|
||||
},
|
||||
});</script><dom-module id="zwave-node-config" assetpath="./"><template><style include="iron-flex ha-style">.content{margin-top:24px}paper-card{display:block;margin:0 auto;max-width:600px}.device-picker{@apply(--layout-horizontal);@apply(--layout-center-center);padding-left:24px;padding-right:24px;padding-bottom:24px}.help-text{padding-left:24px;padding-right:24px}</style><div class="content"><paper-card heading="Node config options"><template is="dom-if" if="[[wakeupNode]]"><div class="card-actions"><paper-input float-label="Wakeup Interval" type="number" value="{{wakeupInput}}" placeholder="[[computeGetWakeupValue(selectedNode)]]"><div suffix="">seconds</div></paper-input><ha-call-service-button hass="[[hass]]" domain="zwave" service="set_wakeup" service-data="[[computeWakeupServiceData(wakeupInput)]]">Set Wakeup</ha-call-service-button></div></template><div class="device-picker"><paper-dropdown-menu label="Config parameter" class="flex"><paper-listbox class="dropdown-content" selected="{{selectedConfigParameter}}"><template is="dom-repeat" items="[[config]]" as="state"><paper-item>[[computeSelectCaptionConfigParameter(state)]]</paper-item></template></paper-listbox></paper-dropdown-menu></div><template is="dom-if" if="[[isConfigParameterSelected(selectedConfigParameter, 'List')]]"><div class="device-picker"><paper-dropdown-menu label="Config value" class="flex" placeholder="{{loadedConfigValue}}"><paper-listbox class="dropdown-content" selected="{{selectedConfigValue}}"><template is="dom-repeat" items="[[selectedConfigParameterValues]]" as="state"><paper-item>[[state]]</paper-item></template></paper-listbox></paper-dropdown-menu></div></template><template is="dom-if" if="[[isConfigParameterSelected(selectedConfigParameter, 'Byte Short Int')]]"><div class="card-actions"><paper-input label="{{selectedConfigParameterNumValues}}" type="number" value="{{selectedConfigValue}}" max="{{configParameterMax}}" min="{{configParameterMin}}"></paper-input></div></template><template is="dom-if" if="[[isConfigParameterSelected(selectedConfigParameter, 'Bool Button')]]"><div class="device-picker"><paper-dropdown-menu label="Config value" class="flex" placeholder="{{loadedConfigValue}}"><paper-listbox class="dropdown-content" selected="{{selectedConfigValue}}"><template is="dom-repeat" items="[[selectedConfigParameterValues]]" as="state"><paper-item>[[state]]</paper-item></template></paper-listbox></paper-dropdown-menu></div></template><div class="help-text"><span>[[configValueHelpText]]</span></div><template is="dom-if" if="[[isConfigParameterSelected(selectedConfigParameter, 'Bool Button Byte Short Int List')]]"><div class="card-actions"><ha-call-service-button hass="[[hass]]" domain="zwave" service="set_config_parameter" service-data="[[computeSetConfigParameterServiceData(selectedConfigValue)]]">Set Config Parameter</ha-call-service-button></div></template></paper-card></div></template></dom-module><script>Polymer({
|
||||
is: 'zwave-node-config',
|
||||
|
||||
properties: {
|
||||
hass: {
|
||||
type: Object,
|
||||
},
|
||||
|
||||
nodes: {
|
||||
type: Array,
|
||||
observer: 'nodesChanged'
|
||||
},
|
||||
|
||||
selectedNode: {
|
||||
type: Number,
|
||||
value: -1,
|
||||
observer: 'nodesChanged'
|
||||
},
|
||||
|
||||
config: {
|
||||
type: Array,
|
||||
value: function () {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
|
||||
selectedConfigParameter: {
|
||||
type: Number,
|
||||
value: -1,
|
||||
observer: 'selectedConfigParameterChanged'
|
||||
},
|
||||
|
||||
configParameterMax: {
|
||||
type: Number,
|
||||
value: -1
|
||||
},
|
||||
|
||||
configParameterMin: {
|
||||
type: Number,
|
||||
value: -1
|
||||
},
|
||||
|
||||
configValueHelpText: {
|
||||
type: String,
|
||||
value: '',
|
||||
computed: 'computeConfigValueHelp(selectedConfigParameter)'
|
||||
},
|
||||
|
||||
selectedConfigParameterType: {
|
||||
type: String,
|
||||
value: ''
|
||||
},
|
||||
|
||||
selectedConfigValue: {
|
||||
type: Number,
|
||||
value: -1,
|
||||
observer: 'computeSetConfigParameterServiceData'
|
||||
},
|
||||
|
||||
selectedConfigParameterValues: {
|
||||
type: Array,
|
||||
value: function () {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
|
||||
selectedConfigParameterNumValues: {
|
||||
type: String,
|
||||
value: ''
|
||||
},
|
||||
|
||||
loadedConfigValue: {
|
||||
type: Number,
|
||||
value: -1
|
||||
},
|
||||
|
||||
wakeupInput: {
|
||||
type: Number,
|
||||
},
|
||||
|
||||
wakeupNode: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
},
|
||||
|
||||
listeners: {
|
||||
'hass-service-called': 'serviceCalled',
|
||||
},
|
||||
|
||||
serviceCalled: function (ev) {
|
||||
if (ev.detail.success) {
|
||||
var foo = this;
|
||||
setTimeout(function () {
|
||||
foo.refreshConfig(foo.selectedNode);
|
||||
}, 5000);
|
||||
}
|
||||
},
|
||||
|
||||
nodesChanged: function () {
|
||||
if (!this.nodes) return;
|
||||
this.wakeupNode = (this.nodes[this.selectedNode].attributes.wake_up_interval === 0 ||
|
||||
this.nodes[this.selectedNode].attributes.wake_up_interval);
|
||||
if (this.wakeupNode) {
|
||||
if (this.nodes[this.selectedNode].attributes.wake_up_interval === 0) this.wakeupInput = '';
|
||||
else this.wakeupInput = this.nodes[this.selectedNode].attributes.wake_up_interval;
|
||||
}
|
||||
},
|
||||
|
||||
computeGetWakeupValue: function (selectedNode) {
|
||||
if (this.selectedNode === -1 ||
|
||||
!this.nodes[selectedNode].attributes.wake_up_interval) return 'unknown';
|
||||
return (this.nodes[selectedNode].attributes.wake_up_interval);
|
||||
},
|
||||
|
||||
computeWakeupServiceData: function (wakeupInput) {
|
||||
return { node_id: this.nodes[this.selectedNode].attributes.node_id,
|
||||
value: wakeupInput };
|
||||
},
|
||||
|
||||
computeConfigValueHelp: function (selectedConfigParameter) {
|
||||
if (selectedConfigParameter === -1) return '';
|
||||
var helpText = this.config[selectedConfigParameter].value.help;
|
||||
if (!helpText) return ['No helptext available'];
|
||||
return helpText;
|
||||
},
|
||||
|
||||
computeSetConfigParameterServiceData: function (selectedConfigValue) {
|
||||
if (this.selectedNode === -1 || this.selectedConfigParameter === -1) return -1;
|
||||
var valueData = null;
|
||||
if (('Short Byte Int').includes(this.selectedConfigParameterType)) {
|
||||
valueData = parseInt(selectedConfigValue, 10);
|
||||
} if (('Bool Button').includes(this.selectedConfigParameterType)) {
|
||||
valueData = this.selectedConfigParameterValues[selectedConfigValue];
|
||||
} if (this.selectedConfigParameterType === 'List') {
|
||||
valueData = this.selectedConfigParameterValues[selectedConfigValue];
|
||||
}
|
||||
return { node_id: this.nodes[this.selectedNode].attributes.node_id,
|
||||
parameter: this.config[this.selectedConfigParameter].key,
|
||||
value: valueData };
|
||||
},
|
||||
|
||||
selectedConfigParameterChanged: function (selectedConfigParameter) {
|
||||
if (selectedConfigParameter === -1) return;
|
||||
this.selectedConfigValue = -1;
|
||||
this.loadedConfigValue = -1;
|
||||
this.selectedConfigParameterValues = [];
|
||||
this.selectedConfigParameterType = this.config[selectedConfigParameter].value.type;
|
||||
this.configParameterMax = this.config[selectedConfigParameter].value.max;
|
||||
this.configParameterMin = this.config[selectedConfigParameter].value.min;
|
||||
this.loadedConfigValue = this.config[selectedConfigParameter].value.data;
|
||||
this.configValueHelpText = this.config[selectedConfigParameter].value.help;
|
||||
if (('Short Byte Int').includes(this.selectedConfigParameterType)) {
|
||||
this.selectedConfigParameterNumValues = this.config[selectedConfigParameter].value.data_items;
|
||||
this.selectedConfigValue = this.loadedConfigValue;
|
||||
}
|
||||
if (('Bool Button').includes(this.selectedConfigParameterType)) {
|
||||
this.selectedConfigParameterValues = ['True', 'False'];
|
||||
if (this.config[selectedConfigParameter].value.data) {
|
||||
this.loadedConfigValue = 'True';
|
||||
} else this.loadedConfigValue = 'False';
|
||||
}
|
||||
if (('List').includes(this.selectedConfigParameterType)) {
|
||||
this.selectedConfigParameterValues = this.config[selectedConfigParameter].value.data_items;
|
||||
}
|
||||
},
|
||||
|
||||
isConfigParameterSelected: function (selectedConfigParameter, type) {
|
||||
if (selectedConfigParameter === -1) return false;
|
||||
if (this.config[selectedConfigParameter].value.type === type) return true;
|
||||
if (type.includes(this.config[selectedConfigParameter].value.type)) return true;
|
||||
return false;
|
||||
},
|
||||
|
||||
computeSelectCaptionConfigParameter: function (stateObj) {
|
||||
return (stateObj.key + ': ' + stateObj.value.label);
|
||||
},
|
||||
|
||||
refreshConfig: function (selectedNode) {
|
||||
var configData = [];
|
||||
this.hass.callApi('GET', 'zwave/config/' + this.nodes[selectedNode].attributes.node_id).then(function (config) {
|
||||
Object.entries(config).forEach(([key, value]) => {
|
||||
configData.push({ key, value });
|
||||
});
|
||||
this.config = configData;
|
||||
this.selectedConfigParameterChanged(this.selectedConfigParameter);
|
||||
}.bind(this));
|
||||
},
|
||||
});</script><dom-module id="zwave-usercodes" assetpath="./"><template><style include="iron-flex ha-style">.content{margin-top:24px}paper-card{display:block;margin:0 auto;max-width:600px}.device-picker{@apply(--layout-horizontal);@apply(--layout-center-center);padding-left:24px;padding-right:24px;padding-bottom:24px}</style><div class="content"><paper-card heading="Node user codes"><div class="device-picker"><paper-dropdown-menu label="Code slot" class="flex"><paper-listbox class="dropdown-content" selected="{{selectedUserCode}}"><template is="dom-repeat" items="[[userCodes]]" as="state"><paper-item>[[computeSelectCaptionUserCodes(state)]]</paper-item></template></paper-listbox></paper-dropdown-menu></div><template is="dom-if" if="[[isUserCodeSelected(selectedUserCode)]]"><div class="card-actions"><paper-input label="User code" type="number" value="{{selectedUserCodeValue}}" maxlength="{{userCodeMaxLen}}" min="0"></paper-input></div><div class="card-actions"><ha-call-service-button hass="[[hass]]" domain="lock" service="set_usercode" service-data="[[computeUserCodeServiceData(selectedUserCodeValue, "Add")]]">Set Usercode</ha-call-service-button><ha-call-service-button hass="[[hass]]" domain="lock" service="clear_usercode" service-data="[[computeUserCodeServiceData(selectedUserCode, "Delete")]]">Delete Usercode</ha-call-service-button></div></template></paper-card></div></template></dom-module><script>Polymer({
|
||||
is: 'zwave-usercodes',
|
||||
|
||||
properties: {
|
||||
hass: {
|
||||
type: Object,
|
||||
},
|
||||
|
||||
nodes: {
|
||||
type: Array,
|
||||
},
|
||||
|
||||
selectedNode: {
|
||||
type: Number,
|
||||
},
|
||||
|
||||
userCodes: {
|
||||
type: Object,
|
||||
},
|
||||
|
||||
userCodeMaxLen: {
|
||||
type: Number,
|
||||
value: 4
|
||||
},
|
||||
|
||||
selectedUserCode: {
|
||||
type: Number,
|
||||
value: -1,
|
||||
observer: 'selectedUserCodeChanged'
|
||||
},
|
||||
|
||||
selectedUserCodeValue: {
|
||||
type: Number,
|
||||
value: -1
|
||||
},
|
||||
},
|
||||
|
||||
listeners: {
|
||||
'hass-service-called': 'serviceCalled',
|
||||
},
|
||||
serviceCalled: function (ev) {
|
||||
if (ev.detail.success) {
|
||||
var foo = this;
|
||||
setTimeout(function () {
|
||||
foo.refreshUserCodes(foo.selectedNode);
|
||||
}, 5000);
|
||||
}
|
||||
},
|
||||
|
||||
isUserCodeSelected: function (selectedUserCode) {
|
||||
if (selectedUserCode === -1) return false;
|
||||
return true;
|
||||
},
|
||||
|
||||
computeSelectCaptionUserCodes: function (stateObj) {
|
||||
return (stateObj.key + ': ' + stateObj.value.label);
|
||||
},
|
||||
|
||||
selectedUserCodeChanged: function (selectedUserCode) {
|
||||
if (this.selectedUserCode === -1 || selectedUserCode === -1) return;
|
||||
var value = (parseInt((this.userCodes[selectedUserCode].value.code).trim()));
|
||||
this.userCodeMaxLen = (this.userCodes[selectedUserCode].value.length);
|
||||
if (isNaN(value)) this.selectedUserCodeValue = '';
|
||||
else this.selectedUserCodeValue = value;
|
||||
},
|
||||
|
||||
computeUserCodeServiceData: function (selectedUserCodeValue, type) {
|
||||
if (this.selectedNode === -1 || !selectedUserCodeValue) return -1;
|
||||
var serviceData = null;
|
||||
var valueData = null;
|
||||
if (type === 'Add') {
|
||||
valueData = selectedUserCodeValue;
|
||||
serviceData = { node_id: this.nodes[this.selectedNode].attributes.node_id,
|
||||
code_slot: this.selectedUserCode,
|
||||
usercode: valueData };
|
||||
}
|
||||
if (type === 'Delete') {
|
||||
serviceData = { node_id: this.nodes[this.selectedNode].attributes.node_id,
|
||||
code_slot: this.selectedUserCode };
|
||||
}
|
||||
return serviceData;
|
||||
},
|
||||
|
||||
refreshUserCodes: function (selectedNode) {
|
||||
this.selectedUserCodeValue = '';
|
||||
var userCodes = [];
|
||||
this.hass.callApi('GET', 'zwave/usercodes/' + this.nodes[selectedNode].attributes.node_id).then(function (usercodes) {
|
||||
Object.entries(usercodes).forEach(([key, value]) => {
|
||||
userCodes.push({ key, value });
|
||||
});
|
||||
this.userCodes = userCodes;
|
||||
this.selectedUserCodeChanged(this.selectedUserCode);
|
||||
}.bind(this));
|
||||
},
|
||||
});</script><dom-module id="zwave-groups" assetpath="./"><template><style include="iron-flex ha-style">.content{margin-top:24px}paper-card{display:block;margin:0 auto;max-width:600px}.device-picker{@apply(--layout-horizontal);@apply(--layout-center-center);padding-left:24px;padding-right:24px;padding-bottom:24px}.help-text{padding-left:24px;padding-right:24px}</style><div class="content"><paper-card heading="Node group associations"><div class="device-picker"><paper-dropdown-menu label="Node to control" class="flex"><paper-listbox class="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)]]"><div class="device-picker"><paper-dropdown-menu label="Group" class="flex"><paper-listbox class="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 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></div></template></paper-card></div></template></dom-module><script>Polymer({
|
||||
is: 'zwave-groups',
|
||||
|
||||
properties: {
|
||||
hass: {
|
||||
type: Object,
|
||||
},
|
||||
|
||||
nodes: {
|
||||
type: Array,
|
||||
},
|
||||
|
||||
groups: {
|
||||
type: Array,
|
||||
},
|
||||
|
||||
selectedNode: {
|
||||
type: Number,
|
||||
},
|
||||
|
||||
selectedTargetNode: {
|
||||
type: Number,
|
||||
value: -1
|
||||
},
|
||||
|
||||
selectedGroup: {
|
||||
type: Number,
|
||||
value: -1,
|
||||
observer: 'selectedGroupChanged'
|
||||
},
|
||||
|
||||
otherGroupNodes: {
|
||||
type: Array,
|
||||
value: -1,
|
||||
computed: 'computeOtherGroupNodes(selectedGroup)'
|
||||
},
|
||||
|
||||
maxAssociations: {
|
||||
type: String,
|
||||
value: '',
|
||||
computed: 'computeMaxAssociations(selectedGroup)'
|
||||
},
|
||||
|
||||
noAssociationsLeft: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
computed: 'computeAssociationsLeft(selectedGroup)'
|
||||
},
|
||||
},
|
||||
|
||||
listeners: {
|
||||
'hass-service-called': 'serviceCalled',
|
||||
},
|
||||
|
||||
serviceCalled: function (ev) {
|
||||
if (ev.detail.success) {
|
||||
var foo = this;
|
||||
setTimeout(function () {
|
||||
foo.refreshGroups(foo.selectedNode);
|
||||
}, 5000);
|
||||
}
|
||||
},
|
||||
|
||||
computeAssociationsLeft: function (selectedGroup) {
|
||||
if (selectedGroup === -1) return true;
|
||||
return (this.maxAssociations === this.otherGroupNodes.length);
|
||||
},
|
||||
|
||||
computeMaxAssociations: function (selectedGroup) {
|
||||
if (selectedGroup === -1) return -1;
|
||||
var maxAssociations = this.groups[selectedGroup].value.max_associations;
|
||||
if (!maxAssociations) return ['None'];
|
||||
return maxAssociations;
|
||||
},
|
||||
|
||||
computeOtherGroupNodes: function (selectedGroup) {
|
||||
if (selectedGroup === -1) return -1;
|
||||
var associations = Object.values(this.groups[selectedGroup].value.associations);
|
||||
if (!associations.length) return ['None'];
|
||||
return associations;
|
||||
},
|
||||
|
||||
computeSelectCaption: function (stateObj) {
|
||||
return window.hassUtil.computeStateName(stateObj) + ' (Node:' +
|
||||
stateObj.attributes.node_id + ' ' +
|
||||
stateObj.attributes.query_stage + ')';
|
||||
},
|
||||
|
||||
computeSelectCaptionGroup: function (stateObj) {
|
||||
return (stateObj.key + ': ' + stateObj.value.label);
|
||||
},
|
||||
|
||||
computeIsTargetNodeSelected: function (selectedTargetNode) {
|
||||
return (!this.nodes || selectedTargetNode === -1);
|
||||
},
|
||||
|
||||
computeIsGroupSelected: function (selectedGroup) {
|
||||
return (!this.nodes || this.selectedNode === -1 || selectedGroup === -1);
|
||||
},
|
||||
|
||||
computeAssocServiceData: function (selectedGroup, type) {
|
||||
if (!this.groups === -1 || selectedGroup === -1 || this.selectedNode === -1) return -1;
|
||||
return { node_id: this.nodes[this.selectedNode].attributes.node_id,
|
||||
association: type,
|
||||
target_node_id: this.nodes[this.selectedTargetNode].attributes.node_id,
|
||||
group: this.groups[selectedGroup].key };
|
||||
},
|
||||
|
||||
refreshGroups: function (selectedNode) {
|
||||
var groupData = [];
|
||||
this.hass.callApi('GET', 'zwave/groups/' + this.nodes[selectedNode].attributes.node_id).then(function (groups) {
|
||||
Object.entries(groups).forEach(([key, value]) => {
|
||||
groupData.push({ key, value });
|
||||
});
|
||||
this.groups = groupData;
|
||||
this.selectedGroupChanged(this.selectedGroup);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
selectedGroupChanged: function (selectedGroup) {
|
||||
if (this.selectedGroup === -1 || selectedGroup === -1) return;
|
||||
this.maxAssociations = this.groups[selectedGroup].value.max_associations;
|
||||
this.otherGroupNodes = Object.values(this.groups[selectedGroup].value.associations);
|
||||
},
|
||||
});</script></div><dom-module id="ha-panel-zwave"><template><style include="iron-flex ha-style">.content{margin-top:24px}.node-info{margin-left:16px;text-transform:capitalize}.help-text{padding-left:24px;padding-right:24px}paper-card{display:block;margin:0 auto;max-width:600px}.device-picker{@apply(--layout-horizontal);@apply(--layout-center-center);padding-left:24px;padding-right:24px;padding-bottom:24px}</style><app-header-layout has-scrolling-region=""><app-header fixed=""><app-toolbar><ha-menu-button narrow="[[narrow]]" show-menu="[[showMenu]]"></ha-menu-button><div main-title="">Z-Wave Manager</div></app-toolbar></app-header><div class="content"><zwave-network id="zwave-network" hass="[[hass]]"></zwave-network></div><div class="content"><paper-card heading="Z-Wave Node Management"><div class="card-content">Z-Wave Node controls.</div><div class="device-picker"><paper-dropdown-menu label="Nodes" class="flex"><paper-listbox class="dropdown-content" selected="{{selectedNode}}"><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="[[!computeIsNodeSelected(selectedNode)]]"><div class="card-actions"><ha-call-service-button hass="[[hass]]" domain="zwave" service="refresh_node" service-data="[[computeNodeServiceData(selectedNode)]]">Refresh Node</ha-call-service-button><ha-call-service-button hass="[[hass]]" domain="zwave" service="remove_failed_node" service-data="[[computeNodeServiceData(selectedNode)]]">Remove Failed Node</ha-call-service-button><ha-call-service-button hass="[[hass]]" domain="zwave" service="replace_failed_node" service-data="[[computeNodeServiceData(selectedNode)]]">Replace Failed Node</ha-call-service-button><ha-call-service-button hass="[[hass]]" domain="zwave" service="print_node" service-data="[[computeNodeServiceData(selectedNode)]]">Print Node</ha-call-service-button></div><div class="card-actions"><paper-input float-label="New node name" type="text" value="{{newNodeNameInput}}" placeholder="[[computeGetNodeName(selectedNode)]]"></paper-input><ha-call-service-button hass="[[hass]]" domain="zwave" service="rename_node" service-data="[[computeNodeNameServiceData(newNodeNameInput)]]">Rename Node</ha-call-service-button></div><div class="device-picker"><paper-dropdown-menu label="Entities of this node" class="flex"><paper-listbox class="dropdown-content" selected="{{selectedEntity}}"><template is="dom-repeat" items="[[entities]]" as="state"><paper-item>[[computeSelectCaptionEnt(state)]]</paper-item></template></paper-listbox></paper-dropdown-menu></div><template is="dom-if" if="[[!computeIsEntitySelected(selectedEntity)]]"><div class="card-actions"><ha-call-service-button hass="[[hass]]" domain="zwave" service="refresh_entity" service-data="[[computeRefreshEntityServiceData(selectedEntity)]]">Refresh Entity</ha-call-service-button></div><div class="content"><div class="card-actions"><paper-button toggles="" raised="" noink="" active="{{entityInfoActive}}">Entity Attributes</paper-button></div><template is="dom-if" if="{{entityInfoActive}}"><template is="dom-repeat" items="[[selectedEntityAttrs]]" as="state"><div class="node-info"><span>[[state]]</span></div></template></template></div></template></template></paper-card></div><template is="dom-if" if="[[!computeIsNodeSelected(selectedNode)]]"><zwave-node-information id="zwave-node-information" nodes="[[nodes]]" selected-node="[[selectedNode]]"></zwave-node-information></template><template is="dom-if" if="[[!computeIsNodeSelected(selectedNode)]]"><zwave-groups hass="[[hass]]" nodes="[[nodes]]" selected-node="[[selectedNode]]" groups="[[groups]]"></zwave-groups></template><template is="dom-if" if="[[!computeIsNodeSelected(selectedNode)]]"><zwave-node-config hass="[[hass]]" nodes="[[nodes]]" selected-node="[[selectedNode]]" config="[[config]]"></zwave-node-config></template><template is="dom-if" if="{{hasNodeUserCodes}}"><zwave-usercodes id="zwave-usercodes" hass="[[hass]]" nodes="[[nodes]]" user-codes="[[userCodes]]" selected-node="[[selectedNode]]"></zwave-usercodes></template><div class="content"><ozw-log id="ozw-log" hass="[[hass]]"></ozw-log></div></app-header-layout></template></dom-module><script>Polymer({
|
||||
is: 'ha-panel-zwave',
|
||||
|
||||
properties: {
|
||||
hass: {
|
||||
type: Object,
|
||||
},
|
||||
|
||||
narrow: {
|
||||
type: Boolean,
|
||||
},
|
||||
|
||||
showMenu: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
|
||||
nodes: {
|
||||
type: Array,
|
||||
computed: 'computeNodes(hass)'
|
||||
},
|
||||
|
||||
selectedNode: {
|
||||
type: Number,
|
||||
value: -1,
|
||||
observer: 'selectedNodeChanged'
|
||||
},
|
||||
|
||||
config: {
|
||||
type: Array,
|
||||
value: function () {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
|
||||
entities: {
|
||||
type: Array,
|
||||
computed: 'computeEntities(selectedNode)',
|
||||
},
|
||||
|
||||
entityInfoActive: {
|
||||
type: Boolean,
|
||||
},
|
||||
|
||||
selectedEntity: {
|
||||
type: Number,
|
||||
value: -1,
|
||||
observers: ['computeIsEntitySelected',
|
||||
'computeRefreshEntityServiceData']
|
||||
},
|
||||
|
||||
selectedEntityAttrs: {
|
||||
type: Array,
|
||||
computed: 'computeSelectedEntityAttrs(selectedEntity)'
|
||||
},
|
||||
|
||||
groups: {
|
||||
type: Array,
|
||||
},
|
||||
|
||||
newNodeNameInput: {
|
||||
type: String,
|
||||
},
|
||||
|
||||
userCodes: {
|
||||
type: Array,
|
||||
value: function () {
|
||||
return [];
|
||||
},
|
||||
},
|
||||
|
||||
hasNodeUserCodes: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
},
|
||||
|
||||
computeNodes: function (hass) {
|
||||
return Object.keys(hass.states)
|
||||
.map(function (key) { return hass.states[key]; })
|
||||
.filter(function (ent) {
|
||||
return (!ent.attributes.hidden &&
|
||||
(ent.entity_id).match('zwave[.]'));
|
||||
})
|
||||
.sort(function (entityA, entityB) {
|
||||
if (entityA.entity_id < entityB.entity_id) {
|
||||
return -1;
|
||||
}
|
||||
if (entityA.entity_id > entityB.entity_id) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
},
|
||||
|
||||
computeEntities: function (selectedNode) {
|
||||
if (!this.nodes || selectedNode === -1) return -1;
|
||||
var hass = this.hass;
|
||||
var nodeid = this.nodes[this.selectedNode].attributes.node_id;
|
||||
return Object.keys(hass.states)
|
||||
.map(function (key) { return hass.states[key]; })
|
||||
.filter(function (ent) {
|
||||
if (ent.attributes.node_id === undefined) {
|
||||
return false;
|
||||
}
|
||||
return (!ent.attributes.hidden &&
|
||||
'node_id' in ent.attributes &&
|
||||
ent.attributes.node_id === nodeid &&
|
||||
(!(ent.entity_id).match('zwave[.]')));
|
||||
})
|
||||
.sort(function (entityA, entityB) {
|
||||
if (entityA.entity_id < entityB.entity_id) {
|
||||
return -1;
|
||||
}
|
||||
if (entityA.entity_id > entityB.entity_id) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
},
|
||||
|
||||
selectedNodeChanged: function (selectedNode) {
|
||||
if (selectedNode === -1) return;
|
||||
this.selectedConfigParameter = -1;
|
||||
this.selectedConfigParameterValue = -1;
|
||||
this.selectedGroup = -1;
|
||||
var configData = [];
|
||||
this.hass.callApi('GET', 'zwave/config/' + this.nodes[selectedNode].attributes.node_id).then(function (configs) {
|
||||
Object.entries(configs).forEach(([key, value]) => {
|
||||
configData.push({ key, value });
|
||||
});
|
||||
this.config = configData;
|
||||
}.bind(this));
|
||||
var groupData = [];
|
||||
this.hass.callApi('GET', 'zwave/groups/' + this.nodes[selectedNode].attributes.node_id).then(function (groups) {
|
||||
Object.entries(groups).forEach(([key, value]) => {
|
||||
groupData.push({ key, value });
|
||||
});
|
||||
this.groups = groupData;
|
||||
}.bind(this));
|
||||
var userCodes = [];
|
||||
this.hasNodeUserCodes = false;
|
||||
this.notifyPath('hasNodeUserCodes');
|
||||
this.hass.callApi('GET', 'zwave/usercodes/' + this.nodes[selectedNode].attributes.node_id).then(function (usercodes) {
|
||||
Object.entries(usercodes).forEach(([key, value]) => {
|
||||
userCodes.push({ key, value });
|
||||
});
|
||||
this.userCodes = userCodes;
|
||||
if (Object.keys(userCodes).length === 0) {
|
||||
this.hasNodeUserCodes = false;
|
||||
} else {
|
||||
this.hasNodeUserCodes = true;
|
||||
}
|
||||
this.notifyPath('hasNodeUserCodes');
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
computeSelectedEntityAttrs: function (selectedEntity) {
|
||||
if (selectedEntity === -1) return 'No entity selected';
|
||||
var entityAttrs = this.entities[selectedEntity].attributes;
|
||||
var att = [];
|
||||
Object.entries(entityAttrs).forEach(([key, value]) => {
|
||||
att.push(key + ': ' + value);
|
||||
});
|
||||
return att.sort();
|
||||
},
|
||||
|
||||
computeSelectCaption: function (stateObj) {
|
||||
return window.hassUtil.computeStateName(stateObj) + ' (Node:' +
|
||||
stateObj.attributes.node_id + ' ' +
|
||||
stateObj.attributes.query_stage + ')';
|
||||
},
|
||||
|
||||
computeSelectCaptionEnt: function (stateObj) {
|
||||
return (window.hassUtil.computeDomain(stateObj) + '.'
|
||||
+ window.hassUtil.computeStateName(stateObj));
|
||||
},
|
||||
|
||||
computeIsNodeSelected: function () {
|
||||
return (!this.nodes || this.selectedNode === -1);
|
||||
},
|
||||
|
||||
computeIsEntitySelected: function (selectedEntity) {
|
||||
return (selectedEntity === -1);
|
||||
},
|
||||
|
||||
computeNodeServiceData: function (selectedNode) {
|
||||
return { node_id: this.nodes[selectedNode].attributes.node_id };
|
||||
},
|
||||
|
||||
computeGetNodeName: function (selectedNode) {
|
||||
if (this.selectedNode === -1 ||
|
||||
!this.nodes[selectedNode].entity_id) return -1;
|
||||
var str = (this.nodes[selectedNode].entity_id);
|
||||
var name = str.replace('zwave.', '');
|
||||
return name;
|
||||
},
|
||||
|
||||
computeNodeNameServiceData: function (newNodeNameInput) {
|
||||
return { node_id: this.nodes[this.selectedNode].attributes.node_id,
|
||||
name: newNodeNameInput };
|
||||
},
|
||||
|
||||
computeRefreshEntityServiceData: function (selectedEntity) {
|
||||
if (selectedEntity === -1) return -1;
|
||||
return { entity_id: this.entities[selectedEntity].entity_id };
|
||||
},
|
||||
});</script></body></html>
|
||||
Binary file not shown.
Reference in new issue
Block a user