| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 This in an HTML Import-able file that contains the definition | 2 This in an HTML Import-able file that contains the definition |
| 3 of the following elements: | 3 of the following elements: |
| 4 | 4 |
| 5 <device-summary> | 5 <device-summary> |
| 6 | 6 |
| 7 Usage: | 7 Usage: |
| 8 | 8 |
| 9 <device-summary></device-summary> | 9 <device-summary></device-summary> |
| 10 | 10 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 _getDevices() { | 94 _getDevices() { |
| 95 var arr = []; | 95 var arr = []; |
| 96 if (!this.state || !this.state.devices) { | 96 if (!this.state || !this.state.devices) { |
| 97 return arr; | 97 return arr; |
| 98 } | 98 } |
| 99 for (var id in this.state.devices) { | 99 for (var id in this.state.devices) { |
| 100 if (this.state.devices.hasOwnProperty(id)) { | 100 if (this.state.devices.hasOwnProperty(id)) { |
| 101 var d = this.state.devices[id]; | 101 var d = this.state.devices[id]; |
| 102 var device = { | 102 var device = { |
| 103 id: id, | 103 id: id, |
| 104 battery: d.battery.level, | 104 state: d.state || "???", |
| 105 state: d.state, | |
| 106 }; | 105 }; |
| 106 device.battery = (d.battery && d.battery.level) || "???" |
| 107 var count = 0; | 107 var count = 0; |
| 108 var totalTemp = 0; | 108 var totalTemp = 0; |
| 109 d.temp = d.temp || []; |
| 109 for (var t in d.temp) { | 110 for (var t in d.temp) { |
| 110 totalTemp += parseFloat(d.temp[t]); | 111 totalTemp += parseFloat(d.temp[t]); |
| 111 count++; | 112 count++; |
| 112 } | 113 } |
| 113 // Report the average temperature of all sensors. | 114 // Report the average temperature of all sensors. |
| 114 if (count) { | 115 if (count) { |
| 115 device.temp = (totalTemp/count).toFixed(1); | 116 device.temp = (totalTemp/count).toFixed(1); |
| 117 } else { |
| 118 device.temp == "???"; |
| 116 } | 119 } |
| 117 arr.push(device); | 120 arr.push(device); |
| 118 } | 121 } |
| 119 } | 122 } |
| 120 return arr; | 123 return arr; |
| 121 } | 124 } |
| 122 }); | 125 }); |
| 123 </script> | 126 </script> |
| 124 </dom-module> | 127 </dom-module> |
| OLD | NEW |