|
1 | | -//var hst = '192.168.1.208'; |
2 | | -var hst = '192.168.1.152'; |
3 | | -//var hst = '192.168.1.159'; |
| 1 | +/** |
| 2 | + * hst is a development convenience variable: it's a hardcoded IP address used when the HTML file is opened directly |
| 3 | + * from the filesystem (i.e., file:// protocol) rather than served from the ESP32. |
| 4 | + * Adapt the IP accordingly based on your router configuration. |
| 5 | +**/ |
| 6 | +var hst = '192.168.178.20'; |
4 | 7 | var _rooms = [{ roomId: 0, name: 'Home' }]; |
5 | 8 |
|
6 | 9 | var errors = [ |
@@ -1268,9 +1271,27 @@ class Security { |
1268 | 1271 | } |
1269 | 1272 | var security = new Security(); |
1270 | 1273 |
|
| 1274 | +// let appVersion = 'v3.0.11'; // Default placeholder |
| 1275 | +async function getAppVersion() { |
| 1276 | + try { |
| 1277 | + const response = await fetch('/appversion'); |
| 1278 | + if (!response.ok) throw new Error('File not found'); |
| 1279 | + |
| 1280 | + const data = await response.text(); |
| 1281 | + appVersion = `v${data.trim()}`; |
| 1282 | + |
| 1283 | + console.log("Loaded Version:", appVersion); |
| 1284 | + // Trigger any UI updates here |
| 1285 | + } catch (error) { |
| 1286 | + console.error("Error loading App version:", error); |
| 1287 | + appVersion = 'v3.0.11'; // Default placeholder |
| 1288 | + } |
| 1289 | + return appVersion; |
| 1290 | +} |
| 1291 | + |
1271 | 1292 | class General { |
1272 | 1293 | initialized = false; |
1273 | | - appVersion = 'v3.0.11'; |
| 1294 | + appVersion = getAppVersion(); |
1274 | 1295 | reloadApp = false; |
1275 | 1296 | init() { |
1276 | 1297 | if (this.initialized) return; |
@@ -2795,16 +2816,17 @@ class Somfy { |
2795 | 2816 | document.getElementById('divLinkedShadeList').innerHTML = divCfg; |
2796 | 2817 | } |
2797 | 2818 | pinMaps = [ |
2798 | | - { name: '', maxPins: 39, inputs: [0, 1, 6, 7, 8, 9, 10, 11, 37, 38], outputs: [3, 6, 7, 8, 9, 10, 11, 34, 35, 36, 37, 38, 39] }, |
| 2819 | + { name: '', maxPins: 39, inputs: [], outputs: [] }, |
2799 | 2820 | { name: 's2', maxPins: 46, inputs: [0, 19, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 45], outputs: [0, 19, 20, 26, 27, 28, 29, 30, 31, 32, 45, 46]}, |
2800 | 2821 | { name: 's3', maxPins: 48, inputs: [19, 20, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32], outputs: [19, 20, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32] }, |
2801 | | - { name: 'c3', maxPins: 21, inputs: [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], outputs: [11, 12, 13, 14, 15, 16, 17, 21] } |
| 2822 | + { name: 'c3', maxPins: 21, inputs: [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], outputs: [11, 12, 13, 14, 15, 16, 17, 21] }, |
| 2823 | + { name: 'c6', maxPins: 23, inputs: [], outputs: [] } |
2802 | 2824 | ]; |
2803 | 2825 |
|
2804 | 2826 | loadPins(type, sel, opt) { |
2805 | 2827 | while (sel.firstChild) sel.removeChild(sel.firstChild); |
2806 | 2828 | let cm = document.getElementById('divContainer').getAttribute('data-chipmodel'); |
2807 | | - let pm = this.pinMaps.find(x => x.name === cm) || { name: '', maxPins: 39, inputs: [0, 1, 6, 7, 8, 9, 10, 11, 37, 38], outputs: [3, 6, 7, 8, 9, 10, 11, 34, 35, 36, 37, 38, 39] }; |
| 2829 | + let pm = this.pinMaps.find(x => x.name === cm) || { name: '', maxPins: 39, inputs: [], outputs: [] }; |
2808 | 2830 | //console.log({ cm: cm, pm: pm }); |
2809 | 2831 | for (let i = 0; i <= pm.maxPins; i++) { |
2810 | 2832 | if (type.includes('in') && pm.inputs.includes(i)) continue; |
@@ -4815,3 +4837,15 @@ class Firmware { |
4815 | 4837 | } |
4816 | 4838 | var firmware = new Firmware(); |
4817 | 4839 |
|
| 4840 | +window.addEventListener('load', async () => { |
| 4841 | + // 1. Initialize your main application logic |
| 4842 | + // await init(); |
| 4843 | + |
| 4844 | + // 2. Fetch and display the app version |
| 4845 | + appVersion = await getAppVersion(); |
| 4846 | + const spanAppVersion = document.getElementById('spanAppVersion'); |
| 4847 | + spanAppVersion.innerText = `${appVersion.trim()}`; |
| 4848 | + |
| 4849 | + console.log("Application fully loaded and version updated."); |
| 4850 | +}); |
| 4851 | + |
0 commit comments