Merge pull request #1685 from proddy/dev

fix test data (wrong icons in web)
This commit is contained in:
Proddy
2024-04-02 21:09:28 +02:00
committed by GitHub
5 changed files with 165 additions and 162 deletions

View File

@@ -33,7 +33,7 @@
"@types/imagemin": "^8.0.5", "@types/imagemin": "^8.0.5",
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@types/node": "^20.12.2", "@types/node": "^20.12.2",
"@types/react": "^18.2.73", "@types/react": "^18.2.74",
"@types/react-dom": "^18.2.23", "@types/react-dom": "^18.2.23",
"@types/react-router-dom": "^5.3.3", "@types/react-router-dom": "^5.3.3",
"alova": "^2.18.2", "alova": "^2.18.2",
@@ -55,8 +55,8 @@
"devDependencies": { "devDependencies": {
"@preact/compat": "^17.1.2", "@preact/compat": "^17.1.2",
"@preact/preset-vite": "^2.8.2", "@preact/preset-vite": "^2.8.2",
"@typescript-eslint/eslint-plugin": "^7.4.0", "@typescript-eslint/eslint-plugin": "^7.5.0",
"@typescript-eslint/parser": "^7.4.0", "@typescript-eslint/parser": "^7.5.0",
"concurrently": "^8.2.2", "concurrently": "^8.2.2",
"eslint": "^8.57.0", "eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
@@ -68,7 +68,7 @@
"preact": "^10.20.1", "preact": "^10.20.1",
"prettier": "^3.2.5", "prettier": "^3.2.5",
"rollup-plugin-visualizer": "^5.12.0", "rollup-plugin-visualizer": "^5.12.0",
"terser": "^5.30.0", "terser": "^5.30.2",
"vite": "^5.2.7", "vite": "^5.2.7",
"vite-plugin-imagemin": "^0.6.1", "vite-plugin-imagemin": "^0.6.1",
"vite-tsconfig-paths": "^4.3.2" "vite-tsconfig-paths": "^4.3.2"

View File

@@ -1492,13 +1492,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@types/react@npm:^18.2.73": "@types/react@npm:^18.2.74":
version: 18.2.73 version: 18.2.74
resolution: "@types/react@npm:18.2.73" resolution: "@types/react@npm:18.2.74"
dependencies: dependencies:
"@types/prop-types": "npm:*" "@types/prop-types": "npm:*"
csstype: "npm:^3.0.2" csstype: "npm:^3.0.2"
checksum: 10/799e30e73464dff40e04f4eb7499ebc31f99b1711a69263b9af340af738e35c9cdf53084e3dacc3b21c031aaa0cba1b51f4ba60490204b7abb75f115b841583f checksum: 10/4057aa7d082d434f8e580e5aebd4007e5dbe7f8e9ae5e506a34a629e382070694a0401bf3f0d38fe8d64f4b38622e5794341e634b9739784deae19b037ae43fa
languageName: node languageName: node
linkType: hard linkType: hard
@@ -1534,15 +1534,15 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@typescript-eslint/eslint-plugin@npm:^7.4.0": "@typescript-eslint/eslint-plugin@npm:^7.5.0":
version: 7.4.0 version: 7.5.0
resolution: "@typescript-eslint/eslint-plugin@npm:7.4.0" resolution: "@typescript-eslint/eslint-plugin@npm:7.5.0"
dependencies: dependencies:
"@eslint-community/regexpp": "npm:^4.5.1" "@eslint-community/regexpp": "npm:^4.5.1"
"@typescript-eslint/scope-manager": "npm:7.4.0" "@typescript-eslint/scope-manager": "npm:7.5.0"
"@typescript-eslint/type-utils": "npm:7.4.0" "@typescript-eslint/type-utils": "npm:7.5.0"
"@typescript-eslint/utils": "npm:7.4.0" "@typescript-eslint/utils": "npm:7.5.0"
"@typescript-eslint/visitor-keys": "npm:7.4.0" "@typescript-eslint/visitor-keys": "npm:7.5.0"
debug: "npm:^4.3.4" debug: "npm:^4.3.4"
graphemer: "npm:^1.4.0" graphemer: "npm:^1.4.0"
ignore: "npm:^5.2.4" ignore: "npm:^5.2.4"
@@ -1555,44 +1555,44 @@ __metadata:
peerDependenciesMeta: peerDependenciesMeta:
typescript: typescript:
optional: true optional: true
checksum: 10/9bd8852c7e4e9608c3fded94f7c60506cc7d2b6d8a8c1cad6d48969a7363751b20282874e55ccdf180635cf204cb10b3e1e5c3d1cff34d4fcd07762be3fc138e checksum: 10/5469900a0c2f485dcae10fc8509e2e1d981538d4c90a13330672fbd10cb7b9bb6d55445d6edea876e2c1719f1f0e25f6af0eb2d413e0c458a8930a371481b9e6
languageName: node languageName: node
linkType: hard linkType: hard
"@typescript-eslint/parser@npm:^7.4.0": "@typescript-eslint/parser@npm:^7.5.0":
version: 7.4.0 version: 7.5.0
resolution: "@typescript-eslint/parser@npm:7.4.0" resolution: "@typescript-eslint/parser@npm:7.5.0"
dependencies: dependencies:
"@typescript-eslint/scope-manager": "npm:7.4.0" "@typescript-eslint/scope-manager": "npm:7.5.0"
"@typescript-eslint/types": "npm:7.4.0" "@typescript-eslint/types": "npm:7.5.0"
"@typescript-eslint/typescript-estree": "npm:7.4.0" "@typescript-eslint/typescript-estree": "npm:7.5.0"
"@typescript-eslint/visitor-keys": "npm:7.4.0" "@typescript-eslint/visitor-keys": "npm:7.5.0"
debug: "npm:^4.3.4" debug: "npm:^4.3.4"
peerDependencies: peerDependencies:
eslint: ^8.56.0 eslint: ^8.56.0
peerDependenciesMeta: peerDependenciesMeta:
typescript: typescript:
optional: true optional: true
checksum: 10/142a9e1187d305ed43b4fef659c36fa4e28359467198c986f0955c70b4067c9799f4c85d9881fbf099c55dfb265e30666e28b3ef290520e242b45ca7cb8e4ca9 checksum: 10/a5414fb2fbd78bf7337125f4a3040318bdffa996a94e27b4f791d51535d5d9286c3e0ae43652b251c48549bbfece0e3a33553b30ed986af6b4f715d76361d6bb
languageName: node languageName: node
linkType: hard linkType: hard
"@typescript-eslint/scope-manager@npm:7.4.0": "@typescript-eslint/scope-manager@npm:7.5.0":
version: 7.4.0 version: 7.5.0
resolution: "@typescript-eslint/scope-manager@npm:7.4.0" resolution: "@typescript-eslint/scope-manager@npm:7.5.0"
dependencies: dependencies:
"@typescript-eslint/types": "npm:7.4.0" "@typescript-eslint/types": "npm:7.5.0"
"@typescript-eslint/visitor-keys": "npm:7.4.0" "@typescript-eslint/visitor-keys": "npm:7.5.0"
checksum: 10/8cf9292444f9731017a707cac34bef5ae0eb33b5cd42ed07fcd046e981d97889d9201d48e02f470f2315123f53771435e10b1dc81642af28a11df5352a8e8be2 checksum: 10/9446c07290a7f7f539a0bdaaf2fb97ae57095a01cd0baad9ecac532da88e7d0d207e5180131c0608542aee2fd1270caf700a2788fa460ffc6e65e966baf34135
languageName: node languageName: node
linkType: hard linkType: hard
"@typescript-eslint/type-utils@npm:7.4.0": "@typescript-eslint/type-utils@npm:7.5.0":
version: 7.4.0 version: 7.5.0
resolution: "@typescript-eslint/type-utils@npm:7.4.0" resolution: "@typescript-eslint/type-utils@npm:7.5.0"
dependencies: dependencies:
"@typescript-eslint/typescript-estree": "npm:7.4.0" "@typescript-eslint/typescript-estree": "npm:7.5.0"
"@typescript-eslint/utils": "npm:7.4.0" "@typescript-eslint/utils": "npm:7.5.0"
debug: "npm:^4.3.4" debug: "npm:^4.3.4"
ts-api-utils: "npm:^1.0.1" ts-api-utils: "npm:^1.0.1"
peerDependencies: peerDependencies:
@@ -1600,23 +1600,23 @@ __metadata:
peerDependenciesMeta: peerDependenciesMeta:
typescript: typescript:
optional: true optional: true
checksum: 10/a8bd0929d8237679b2b8a7817f070a4b9658ee976882fba8ff37e4a70dd33f87793e1b157771104111fe8054eaa8ad437a010b6aa465072fbdb932647125db2d checksum: 10/257730553760fa943538db9648a11f4253efb722ab3394cd325bd775ee0c9d93af84c62540dee9377d4a669eb1cd801faed5e1bcb673d1606c9225eee82b420a
languageName: node languageName: node
linkType: hard linkType: hard
"@typescript-eslint/types@npm:7.4.0": "@typescript-eslint/types@npm:7.5.0":
version: 7.4.0 version: 7.5.0
resolution: "@typescript-eslint/types@npm:7.4.0" resolution: "@typescript-eslint/types@npm:7.5.0"
checksum: 10/2782c5bf65cd3dfa9cd32bc3023676bbca22144987c3f6c6b67fd96c73d4a60b85a57458c49fd11b9971ac6531824bb3ae0664491e7a6de25d80c523c9be92b7 checksum: 10/12eac46d0dfbbeb1db7d0658b841d554d38365420f42b699dea531e0c475b77d6fd838ac4046b7672e53d9bb76a021eaf6198cf3210fe1ecf1056ea44b6699a9
languageName: node languageName: node
linkType: hard linkType: hard
"@typescript-eslint/typescript-estree@npm:7.4.0": "@typescript-eslint/typescript-estree@npm:7.5.0":
version: 7.4.0 version: 7.5.0
resolution: "@typescript-eslint/typescript-estree@npm:7.4.0" resolution: "@typescript-eslint/typescript-estree@npm:7.5.0"
dependencies: dependencies:
"@typescript-eslint/types": "npm:7.4.0" "@typescript-eslint/types": "npm:7.5.0"
"@typescript-eslint/visitor-keys": "npm:7.4.0" "@typescript-eslint/visitor-keys": "npm:7.5.0"
debug: "npm:^4.3.4" debug: "npm:^4.3.4"
globby: "npm:^11.1.0" globby: "npm:^11.1.0"
is-glob: "npm:^4.0.3" is-glob: "npm:^4.0.3"
@@ -1626,34 +1626,34 @@ __metadata:
peerDependenciesMeta: peerDependenciesMeta:
typescript: typescript:
optional: true optional: true
checksum: 10/162ec9d7582f45588342e1be36fdb60e41f50bbdfbc3035c91b517ff5d45244f776921c88d88e543e1c7d0f1e6ada5474a8316b78f1b0e6d2233b101bc45b166 checksum: 10/7487293a9ab9459b133322e695435b4540ffcad89f2bea917c3389676d68283297a663c77d6bda298144d3581361733ae4af632213fa7ef48be67e9aa792b4cc
languageName: node languageName: node
linkType: hard linkType: hard
"@typescript-eslint/utils@npm:7.4.0": "@typescript-eslint/utils@npm:7.5.0":
version: 7.4.0 version: 7.5.0
resolution: "@typescript-eslint/utils@npm:7.4.0" resolution: "@typescript-eslint/utils@npm:7.5.0"
dependencies: dependencies:
"@eslint-community/eslint-utils": "npm:^4.4.0" "@eslint-community/eslint-utils": "npm:^4.4.0"
"@types/json-schema": "npm:^7.0.12" "@types/json-schema": "npm:^7.0.12"
"@types/semver": "npm:^7.5.0" "@types/semver": "npm:^7.5.0"
"@typescript-eslint/scope-manager": "npm:7.4.0" "@typescript-eslint/scope-manager": "npm:7.5.0"
"@typescript-eslint/types": "npm:7.4.0" "@typescript-eslint/types": "npm:7.5.0"
"@typescript-eslint/typescript-estree": "npm:7.4.0" "@typescript-eslint/typescript-estree": "npm:7.5.0"
semver: "npm:^7.5.4" semver: "npm:^7.5.4"
peerDependencies: peerDependencies:
eslint: ^8.56.0 eslint: ^8.56.0
checksum: 10/ffed27e770c486cd000ff892d9049b0afe8b9d6318452a5355b78a37436cbb414bceacae413a2ac813f3e584684825d5e0baa2e6376b7ad6013a108ac91bc19d checksum: 10/a0b2f206a1c35dd77b292d1cd385443f42d00ccf8a5151811fe6bdd6b5f3a450372bf99b8757c307988d14d99587424c59ed59e78cf56c17b43c9c3fd8932871
languageName: node languageName: node
linkType: hard linkType: hard
"@typescript-eslint/visitor-keys@npm:7.4.0": "@typescript-eslint/visitor-keys@npm:7.5.0":
version: 7.4.0 version: 7.5.0
resolution: "@typescript-eslint/visitor-keys@npm:7.4.0" resolution: "@typescript-eslint/visitor-keys@npm:7.5.0"
dependencies: dependencies:
"@typescript-eslint/types": "npm:7.4.0" "@typescript-eslint/types": "npm:7.5.0"
eslint-visitor-keys: "npm:^3.4.1" eslint-visitor-keys: "npm:^3.4.1"
checksum: 10/70dc99f2ad116c6e2d9e55af249e4453e06bba2ceea515adef2d2e86e97e557865bb1b1d467667462443eb0d624baba36f7442fd1082f3874339bbc381c26e93 checksum: 10/ba83113110b13bc65120ea3d1e21e1dcea6010b0a1a3d07da2fd274bb0feb552a92276b6052e659d2fe40178938b17368ede64752c4937f41685c53bdf9d2634
languageName: node languageName: node
linkType: hard linkType: hard
@@ -1680,11 +1680,11 @@ __metadata:
"@types/imagemin": "npm:^8.0.5" "@types/imagemin": "npm:^8.0.5"
"@types/lodash-es": "npm:^4.17.12" "@types/lodash-es": "npm:^4.17.12"
"@types/node": "npm:^20.12.2" "@types/node": "npm:^20.12.2"
"@types/react": "npm:^18.2.73" "@types/react": "npm:^18.2.74"
"@types/react-dom": "npm:^18.2.23" "@types/react-dom": "npm:^18.2.23"
"@types/react-router-dom": "npm:^5.3.3" "@types/react-router-dom": "npm:^5.3.3"
"@typescript-eslint/eslint-plugin": "npm:^7.4.0" "@typescript-eslint/eslint-plugin": "npm:^7.5.0"
"@typescript-eslint/parser": "npm:^7.4.0" "@typescript-eslint/parser": "npm:^7.5.0"
alova: "npm:^2.18.2" alova: "npm:^2.18.2"
async-validator: "npm:^4.2.5" async-validator: "npm:^4.2.5"
concurrently: "npm:^8.2.2" concurrently: "npm:^8.2.2"
@@ -1709,7 +1709,7 @@ __metadata:
react-router-dom: "npm:^6.22.3" react-router-dom: "npm:^6.22.3"
react-toastify: "npm:^10.0.5" react-toastify: "npm:^10.0.5"
rollup-plugin-visualizer: "npm:^5.12.0" rollup-plugin-visualizer: "npm:^5.12.0"
terser: "npm:^5.30.0" terser: "npm:^5.30.2"
typesafe-i18n: "npm:^5.26.2" typesafe-i18n: "npm:^5.26.2"
typescript: "npm:^5.4.3" typescript: "npm:^5.4.3"
vite: "npm:^5.2.7" vite: "npm:^5.2.7"
@@ -7861,9 +7861,9 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"terser@npm:^5.30.0": "terser@npm:^5.30.2":
version: 5.30.0 version: 5.30.2
resolution: "terser@npm:5.30.0" resolution: "terser@npm:5.30.2"
dependencies: dependencies:
"@jridgewell/source-map": "npm:^0.3.3" "@jridgewell/source-map": "npm:^0.3.3"
acorn: "npm:^8.8.2" acorn: "npm:^8.8.2"
@@ -7871,7 +7871,7 @@ __metadata:
source-map-support: "npm:~0.5.20" source-map-support: "npm:~0.5.20"
bin: bin:
terser: bin/terser terser: bin/terser
checksum: 10/78e6ce9e95ec7fc40e694da2e749fa80c3a99c916626349361c22d4cf2e510e8e6e49859c955416088e40688f99115cd595cb033fd5a8a7f0fc03c527ed8efe3 checksum: 10/df671714eb9160cc61d340ddbe6e54f66060bc893c2d420090e10df7f1a2e459725a56dc2e547e992c021ad4523b81eabc8f5a551c53505def80b7320a72506a
languageName: node languageName: node
linkType: hard linkType: hard

View File

@@ -12,7 +12,7 @@
"@msgpack/msgpack": "^2.8.0", "@msgpack/msgpack": "^2.8.0",
"compression": "^1.7.4", "compression": "^1.7.4",
"express": "^4.19.2", "express": "^4.19.2",
"itty-router": "^5.0.4", "itty-router": "^5.0.5",
"multer": "^1.4.5-lts.1" "multer": "^1.4.5-lts.1"
}, },
"packageManager": "yarn@4.1.1", "packageManager": "yarn@4.1.1",

View File

@@ -21,26 +21,19 @@ const headers = {
'Content-type': 'application/json' 'Content-type': 'application/json'
}; };
const ESheaders = {
'Access-Control-Allow-Origin': '*',
'Content-type': 'text/event-stream',
'Cache-Control': 'no-cache',
Connection: 'keep-alive'
};
// GLOBAL VARIABLES // GLOBAL VARIABLES
let countWifiScanPoll = 0; // wifi network scan let countWifiScanPoll = 0; // wifi network scan
// FUNCTIONS // FUNCTIONS
const delay = (ms) => new Promise((res) => setTimeout(res, ms)); // const delay = (ms) => new Promise((res) => setTimeout(res, ms));
function delay_blocking(milliseconds) { // function delay_blocking(milliseconds) {
var start = new Date().getTime(); // var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) { // for (var i = 0; i < 1e7; i++) {
if (new Date().getTime() - start > milliseconds) { // if (new Date().getTime() - start > milliseconds) {
break; // break;
} // }
} // }
} // }
function updateMask(entity: any, de: any, dd: any) { function updateMask(entity: any, de: any, dd: any) {
const current_mask = parseInt(entity.slice(0, 2), 16); const current_mask = parseInt(entity.slice(0, 2), 16);
@@ -449,11 +442,12 @@ const EMSESP_CORE_DATA_ENDPOINT = REST_ENDPOINT_ROOT + 'coreData';
const EMSESP_SENSOR_DATA_ENDPOINT = REST_ENDPOINT_ROOT + 'sensorData'; const EMSESP_SENSOR_DATA_ENDPOINT = REST_ENDPOINT_ROOT + 'sensorData';
const EMSESP_DEVICES_ENDPOINT = REST_ENDPOINT_ROOT + 'devices'; const EMSESP_DEVICES_ENDPOINT = REST_ENDPOINT_ROOT + 'devices';
const EMSESP_SCANDEVICES_ENDPOINT = REST_ENDPOINT_ROOT + 'scanDevices'; const EMSESP_SCANDEVICES_ENDPOINT = REST_ENDPOINT_ROOT + 'scanDevices';
// for later
// const EMSESP_DEVICEDATA_ENDPOINT = REST_ENDPOINT_ROOT + 'deviceData/:id'; const EMSESP_DEVICEDATA_ENDPOINT1 = REST_ENDPOINT_ROOT + 'deviceData';
// const EMSESP_DEVICEENTITIES_ENDPOINT = REST_ENDPOINT_ROOT + 'deviceEntities/:id'; const EMSESP_DEVICEDATA_ENDPOINT2 = REST_ENDPOINT_ROOT + 'deviceData/:id?';
const EMSESP_DEVICEDATA_ENDPOINT = REST_ENDPOINT_ROOT + 'deviceData'; const EMSESP_DEVICEENTITIES_ENDPOINT1 = REST_ENDPOINT_ROOT + 'deviceEntities';
const EMSESP_DEVICEENTITIES_ENDPOINT = REST_ENDPOINT_ROOT + 'deviceEntities'; const EMSESP_DEVICEENTITIES_ENDPOINT2 = REST_ENDPOINT_ROOT + 'deviceEntities/:id?';
const EMSESP_BOARDPROFILE_ENDPOINT = REST_ENDPOINT_ROOT + 'boardProfile'; const EMSESP_BOARDPROFILE_ENDPOINT = REST_ENDPOINT_ROOT + 'boardProfile';
const EMSESP_WRITE_DEVICEVALUE_ENDPOINT = REST_ENDPOINT_ROOT + 'writeDeviceValue'; const EMSESP_WRITE_DEVICEVALUE_ENDPOINT = REST_ENDPOINT_ROOT + 'writeDeviceValue';
const EMSESP_WRITE_TEMPSENSOR_ENDPOINT = REST_ENDPOINT_ROOT + 'writeTemperatureSensor'; const EMSESP_WRITE_TEMPSENSOR_ENDPOINT = REST_ENDPOINT_ROOT + 'writeTemperatureSensor';
@@ -663,18 +657,18 @@ let settings = {
const emsesp_devices = { const emsesp_devices = {
devices: [ devices: [
{
i: 2,
s: 'Thermostat (RC20/Moduline 300)',
t: 5,
tn: 'thermostat'
},
{ {
i: 7, i: 7,
s: 'Boiler (GBx72/Trendline/Cerapur/Greenstar Si/27i)', s: 'Boiler (GBx72/Trendline/Cerapur/Greenstar Si/27i)',
t: 4, t: 4,
tn: 'boiler' tn: 'boiler'
}, },
{
i: 2,
s: 'Thermostat (RC20/Moduline 300)',
t: 5,
tn: 'thermostat'
},
{ {
i: 4, i: 4,
s: 'Thermostat (RC100/Moduline 1000/1010)', s: 'Thermostat (RC100/Moduline 1000/1010)',
@@ -691,7 +685,7 @@ const emsesp_coredata = {
devices: [ devices: [
{ {
id: 7, id: 7,
t: 4, t: 5,
tn: 'Boiler', tn: 'Boiler',
b: 'Nefit', b: 'Nefit',
n: 'GBx72/Trendline/Cerapur/Greenstar Si/27i', n: 'GBx72/Trendline/Cerapur/Greenstar Si/27i',
@@ -703,7 +697,7 @@ const emsesp_coredata = {
}, },
{ {
id: 3, id: 3,
t: 4, t: 5,
tn: 'Boiler', tn: 'Boiler',
b: 'Buderus', b: 'Buderus',
n: 'GB125/GB135/MC10', n: 'GB125/GB135/MC10',
@@ -714,7 +708,7 @@ const emsesp_coredata = {
}, },
{ {
id: 1, id: 1,
t: 5, t: 6,
tn: 'Thermostat', tn: 'Thermostat',
b: 'Buderus', b: 'Buderus',
n: 'RC35', n: 'RC35',
@@ -725,7 +719,7 @@ const emsesp_coredata = {
}, },
{ {
id: 2, id: 2,
t: 5, t: 6,
tn: 'Thermostat', tn: 'Thermostat',
b: '', b: '',
n: 'RC20/Moduline 300', n: 'RC20/Moduline 300',
@@ -736,7 +730,7 @@ const emsesp_coredata = {
}, },
{ {
id: 4, id: 4,
t: 5, t: 6,
tn: 'Thermostat', tn: 'Thermostat',
b: 'Buderus', b: 'Buderus',
n: 'RC100/Moduline 1000/1010', n: 'RC100/Moduline 1000/1010',
@@ -747,7 +741,7 @@ const emsesp_coredata = {
}, },
{ {
id: 5, id: 5,
t: 6, t: 7,
tn: 'Mixer Module', tn: 'Mixer Module',
b: 'Buderus', b: 'Buderus',
n: 'MM10', n: 'MM10',
@@ -758,7 +752,7 @@ const emsesp_coredata = {
}, },
{ {
id: 6, id: 6,
t: 7, t: 8,
tn: 'Solar Module', tn: 'Solar Module',
b: 'Buderus', b: 'Buderus',
n: 'SM10', n: 'SM10',
@@ -769,7 +763,7 @@ const emsesp_coredata = {
}, },
{ {
id: 99, id: 99,
t: 17, t: 4,
tn: 'Custom', tn: 'Custom',
b: '', b: '',
n: 'Custom Entities', n: 'Custom Entities',
@@ -2504,25 +2498,8 @@ router
// //
// EMS-ESP Project stuff // EMS-ESP Project stuff
// //
router
// EMS-ESP Settings
.get(EMSESP_SETTINGS_ENDPOINT, () => settings)
.post(EMSESP_SETTINGS_ENDPOINT, async (request: any) => {
settings = await request.json();
status(200); // no restart needed
status(205); // restart needed
})
// Device Dashboard Data
.get(EMSESP_CORE_DATA_ENDPOINT, () => emsesp_coredata)
.get(EMSESP_SENSOR_DATA_ENDPOINT, () => emsesp_sensordata)
.get(EMSESP_DEVICES_ENDPOINT, () => emsesp_devices)
.post(EMSESP_SCANDEVICES_ENDPOINT, () => status(200))
.get(EMSESP_DEVICEDATA_ENDPOINT, (request) => {
// const id = Number(request.params.id); // TODO when using :id
const id = Number(request.query.id);
function deviceData(id: number) {
if (id == 1) { if (id == 1) {
return new Response(encoder.encode(emsesp_devicedata_1), { headers }); return new Response(encoder.encode(emsesp_devicedata_1), { headers });
} }
@@ -2547,11 +2524,9 @@ router
if (id == 99) { if (id == 99) {
return new Response(encoder.encode(emsesp_devicedata_99), { headers }); return new Response(encoder.encode(emsesp_devicedata_99), { headers });
} }
}) }
.get(EMSESP_DEVICEENTITIES_ENDPOINT, (request) => {
// const id = Number(request.params.id); // TODO when using :id
const id = Number(request.query.id);
function deviceEntities(id: number) {
if (id == 1) { if (id == 1) {
return new Response(encoder.encode(emsesp_deviceentities_1), { headers }); return new Response(encoder.encode(emsesp_deviceentities_1), { headers });
} }
@@ -2573,8 +2548,33 @@ router
if (id == 7) { if (id == 7) {
return new Response(encoder.encode(emsesp_deviceentities_7), { headers }); return new Response(encoder.encode(emsesp_deviceentities_7), { headers });
} }
}
router
// EMS-ESP Settings
.get(EMSESP_SETTINGS_ENDPOINT, () => settings)
.post(EMSESP_SETTINGS_ENDPOINT, async (request: any) => {
settings = await request.json();
status(200); // no restart needed
status(205); // restart needed
}) })
// Device Dashboard Data
.get(EMSESP_CORE_DATA_ENDPOINT, () => emsesp_coredata)
.get(EMSESP_SENSOR_DATA_ENDPOINT, () => emsesp_sensordata)
.get(EMSESP_DEVICES_ENDPOINT, () => emsesp_devices)
.post(EMSESP_SCANDEVICES_ENDPOINT, () => status(200))
.get(EMSESP_DEVICEDATA_ENDPOINT1, (request) =>
request.query.id ? deviceData(Number(request.query.id)) : status(404)
)
.get(EMSESP_DEVICEDATA_ENDPOINT2, ({ params }) => (params.id ? deviceData(Number(params.id)) : status(404)))
.get(EMSESP_DEVICEENTITIES_ENDPOINT1, (request) =>
request.query.id ? deviceEntities(Number(request.query.id)) : status(404)
)
.get(EMSESP_DEVICEENTITIES_ENDPOINT2, ({ params }) => (params.id ? deviceEntities(Number(params.id)) : status(404)))
// Customization // Customization
.post(EMSESP_CUSTOMIZATION_ENTITIES_ENDPOINT, async (request: any) => { .post(EMSESP_CUSTOMIZATION_ENTITIES_ENDPOINT, async (request: any) => {
const content = await request.json(); const content = await request.json();
@@ -2660,7 +2660,7 @@ router
emsesp_devicedata_99.data[objIndex].v = value; emsesp_devicedata_99.data[objIndex].v = value;
} }
await delay(1000); // wait to show spinner // await delay(1000); // wait to show spinner
return status(200); return status(200);
}) })
@@ -2864,3 +2864,6 @@ router
}); });
export default router; export default router;
// use this with cloudflare workers instead
// export default { ...router };

View File

@@ -140,7 +140,7 @@ __metadata:
"@types/multer": "npm:^1.4.11" "@types/multer": "npm:^1.4.11"
compression: "npm:^1.7.4" compression: "npm:^1.7.4"
express: "npm:^4.19.2" express: "npm:^4.19.2"
itty-router: "npm:^5.0.4" itty-router: "npm:^5.0.5"
multer: "npm:^1.4.5-lts.1" multer: "npm:^1.4.5-lts.1"
languageName: unknown languageName: unknown
linkType: soft linkType: soft
@@ -526,10 +526,10 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"itty-router@npm:^5.0.4": "itty-router@npm:^5.0.5":
version: 5.0.4 version: 5.0.5
resolution: "itty-router@npm:5.0.4" resolution: "itty-router@npm:5.0.5"
checksum: 10/61c5c12b57e592ae9689782ca59d7b77154909eb52fc019c38f34e03fdce3d7fb50aad930bde0b31ef8d9131d2101141517823416886b36b81ba3ec6a0ff819e checksum: 10/b10ddeb65568e4ed5eb5a99b5e5e660bae62d53ab88ffdf56a9045d6323a87f561a000f3d8835dcd15451c565fd01083e049122e46d55ffd24fa675f9446971c
languageName: node languageName: node
linkType: hard linkType: hard