diff --git a/panels/config/ha-panel-config.html b/panels/config/ha-panel-config.html index 4cdfb3131b..4d09489840 100644 --- a/panels/config/ha-panel-config.html +++ b/panels/config/ha-panel-config.html @@ -109,11 +109,11 @@ Polymer({ return isWide ? 'content' : 'content narrow'; }, - computeIsHassbianLoaded(hass) { + computeIsHassbianLoaded: function (hass) { return window.hassUtil.isComponentLoaded(hass, 'config.hassbian'); }, - computeIsZwaveLoaded(hass) { + computeIsZwaveLoaded: function (hass) { return window.hassUtil.isComponentLoaded(hass, 'config.zwave'); }, }); diff --git a/panels/map/ha-panel-map.html b/panels/map/ha-panel-map.html index 699c5f6d96..bd09088f67 100644 --- a/panels/map/ha-panel-map.html +++ b/panels/map/ha-panel-map.html @@ -132,7 +132,7 @@ Polymer({ mapItems.push(window.L.marker( [entity.attributes.latitude, entity.attributes.longitude], { - icon, + icon: icon, interactive: false, title: title, } @@ -167,7 +167,7 @@ Polymer({ mapItems.push(window.L.marker( [entity.attributes.latitude, entity.attributes.longitude], { - icon, + icon: icon, title: window.hassUtil.computeStateName(entity), } ).addTo(map)); diff --git a/panels/zwave/ha-panel-zwave.html b/panels/zwave/ha-panel-zwave.html index 8f1e60a57b..baa8c4d05b 100644 --- a/panels/zwave/ha-panel-zwave.html +++ b/panels/zwave/ha-panel-zwave.html @@ -370,50 +370,38 @@ Polymer({ 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 valueData = []; - this.hass.callApi('GET', 'zwave/values/' + this.nodes[selectedNode].attributes.node_id).then(function (values) { - Object.entries(values).forEach(([key, value]) => { - valueData.push({ key, value }); - }); - this.values = valueData; - }.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.hass.callApi('GET', 'zwave/config/' + this.nodes[selectedNode].attributes.node_id).then( + function (configs) { + this.config = this._objToArray(configs); + }.bind(this)); + + this.hass.callApi('GET', 'zwave/values/' + this.nodes[selectedNode].attributes.node_id).then( + function (values) { + this.values = this._objToArray(values); + }.bind(this)); + + this.hass.callApi('GET', 'zwave/groups/' + this.nodes[selectedNode].attributes.node_id).then( + function (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) { - 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)); + this.hass.callApi('GET', 'zwave/usercodes/' + this.nodes[selectedNode].attributes.node_id).then( + function (usercodes) { + this.userCodes = this._objToArray(usercodes); + this.hasNodeUserCodes = this.userCodes.length > 0; + 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); + Object.keys(entityAttrs).forEach(function (key) { + att.push(key + ': ' + entityAttrs[key]); }); return att.sort(); }, @@ -460,5 +448,16 @@ Polymer({ toggleHelp: function () { this.showHelp = !this.showHelp; }, + + _objToArray: function (obj) { + var array = []; + Object.keys(obj).forEach(function (key) { + array.push({ + key: key, + value: obj[key], + }); + }); + return array; + }, }); diff --git a/panels/zwave/zwave-groups.html b/panels/zwave/zwave-groups.html index 7f25d793f5..5a6dbdf3e9 100644 --- a/panels/zwave/zwave-groups.html +++ b/panels/zwave/zwave-groups.html @@ -203,13 +203,17 @@ Polymer({ 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)); + this.hass.callApi('GET', 'zwave/groups/' + this.nodes[selectedNode].attributes.node_id).then( + function (groups) { + Object.keys(groups).forEach(function (key) { + groupData.push({ + key: key, + value: groups[key], + }); + }); + this.groups = groupData; + this.selectedGroupChanged(this.selectedGroup); + }.bind(this)); }, selectedGroupChanged: function (selectedGroup) { diff --git a/panels/zwave/zwave-node-config.html b/panels/zwave/zwave-node-config.html index 4dcc5717b5..d50b66613f 100644 --- a/panels/zwave/zwave-node-config.html +++ b/panels/zwave/zwave-node-config.html @@ -300,13 +300,17 @@ Polymer({ 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)); + this.hass.callApi('GET', 'zwave/config/' + this.nodes[selectedNode].attributes.node_id).then( + function (config) { + Object.keys(config).forEach(function (key) { + configData.push({ + key: key, + value: config[key], + }); + }); + this.config = configData; + this.selectedConfigParameterChanged(this.selectedConfigParameter); + }.bind(this)); }, }); diff --git a/panels/zwave/zwave-node-information.html b/panels/zwave/zwave-node-information.html index a42b22beb9..5bab298bb0 100644 --- a/panels/zwave/zwave-node-information.html +++ b/panels/zwave/zwave-node-information.html @@ -71,8 +71,8 @@ Polymer({ 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); + Object.keys(nodeAttrs).forEach(function (key) { + att.push(key + ': ' + nodeAttrs[key]); }); this.selectedNodeAttrs = att.sort(); }, diff --git a/panels/zwave/zwave-usercodes.html b/panels/zwave/zwave-usercodes.html index 3e0c580017..d5ab68a901 100644 --- a/panels/zwave/zwave-usercodes.html +++ b/panels/zwave/zwave-usercodes.html @@ -159,13 +159,17 @@ Polymer({ 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)); + this.hass.callApi('GET', 'zwave/usercodes/' + this.nodes[selectedNode].attributes.node_id).then( + function (usercodes) { + Object.keys(usercodes).forEach(function (key) { + userCodes.push({ + key: key, + value: usercodes[key], + }); + }); + this.userCodes = userCodes; + this.selectedUserCodeChanged(this.selectedUserCode); + }.bind(this)); }, }); diff --git a/panels/zwave/zwave-values.html b/panels/zwave/zwave-values.html index b8f4ef2908..2168a9fad9 100644 --- a/panels/zwave/zwave-values.html +++ b/panels/zwave/zwave-values.html @@ -120,13 +120,17 @@ Polymer({ refreshValues: function (selectedNode) { var valueData = []; - this.hass.callApi('GET', 'zwave/values/' + this.nodes[selectedNode].attributes.node_id).then(function (values) { - Object.entries(values).forEach(([key, value]) => { - valueData.push({ key, value }); - }); - this.values = valueData; - this.selectedValueChanged(this.selectedValue); - }.bind(this)); + this.hass.callApi('GET', 'zwave/values/' + this.nodes[selectedNode].attributes.node_id).then( + function (values) { + Object.keys(values).forEach(function (key) { + valueData.push({ + key: key, + value: values[key], + }); + }); + this.values = valueData; + this.selectedValueChanged(this.selectedValue); + }.bind(this)); }, computeValueNameServiceData: function (newValueNameInput) {