Merge pull request #1872 from proddy/dev

more minor changes
This commit is contained in:
Proddy
2024-07-19 13:51:37 +02:00
committed by GitHub
11 changed files with 148 additions and 71 deletions

View File

@@ -24,8 +24,8 @@
"dependencies": {
"@alova/adapter-xhr": "^1.0.6",
"@alova/scene-react": "^1.6.1",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@emotion/react": "^11.12.0",
"@emotion/styled": "^11.12.0",
"@mui/icons-material": "^5.16.4",
"@mui/material": "^5.16.4",
"@table-library/react-table-library": "4.1.7",

View File

@@ -314,16 +314,6 @@ const SystemStatus: FC = () => {
return (
<>
<List>
<ListItem>
<ListItemAvatar>
<Avatar sx={{ bgcolor: busStatusHighlight(), color: 'white' }}>
<DirectionsBusIcon />
</Avatar>
</ListItemAvatar>
<ListItemText primary={LL.EMS_BUS_STATUS()} secondary={busStatus()} />
</ListItem>
<Divider variant="inset" component="li" />
<ListItem>
<ListItemAvatar>
<Avatar sx={{ bgcolor: '#c5572c', color: 'white' }}>
@@ -347,7 +337,6 @@ const SystemStatus: FC = () => {
</ListItem>
<Divider variant="inset" component="li" />
<ListItem>
<ListItemAvatar>
<Avatar sx={{ bgcolor: '#5d89f7', color: 'white' }}>
@@ -375,8 +364,8 @@ const SystemStatus: FC = () => {
</Button>
)}
</ListItem>
<Divider variant="inset" component="li" />
<Divider variant="inset" component="li" />
<ListMenuItem
disabled={!me.admin}
icon={BuildIcon}
@@ -385,8 +374,18 @@ const SystemStatus: FC = () => {
text={data.emsesp_version}
to="/settings/upload"
/>
<Divider variant="inset" component="li" />
<Divider variant="inset" component="li" />
<ListMenuItem
disabled={!me.admin}
icon={DirectionsBusIcon}
bgcolor={busStatusHighlight()}
label={LL.EMS_BUS_STATUS()}
text={busStatus()}
to="/system/activity"
/>
<Divider variant="inset" component="li" />
<ListMenuItem
disabled={!me.admin}
icon={MemoryIcon}
@@ -395,8 +394,8 @@ const SystemStatus: FC = () => {
text={formatNumber(data.free_heap) + ' KB' + ' ' + LL.FREE_MEMORY()}
to="/system/espsystemstatus"
/>
<Divider variant="inset" component="li" />
<Divider variant="inset" component="li" />
<ListMenuItem
disabled={!me.admin}
icon={
@@ -409,8 +408,8 @@ const SystemStatus: FC = () => {
text={networkStatus()}
to="/settings/network/status"
/>
<Divider variant="inset" component="li" />
<Divider variant="inset" component="li" />
<ListMenuItem
disabled={!me.admin}
icon={DeviceHubIcon}
@@ -419,8 +418,8 @@ const SystemStatus: FC = () => {
text={data.mqtt_status ? LL.ACTIVE() : LL.INACTIVE(0)}
to="/settings/mqtt/status"
/>
<Divider variant="inset" component="li" />
<Divider variant="inset" component="li" />
<ListMenuItem
disabled={!me.admin}
icon={AccessTimeIcon}
@@ -429,8 +428,8 @@ const SystemStatus: FC = () => {
text={ntpStatus()}
to="/settings/ntp/status"
/>
<Divider variant="inset" component="li" />
<Divider variant="inset" component="li" />
<ListMenuItem
disabled={!me.admin}
icon={SettingsInputAntennaIcon}

View File

@@ -665,22 +665,22 @@ __metadata:
languageName: node
linkType: hard
"@emotion/babel-plugin@npm:^11.11.0":
version: 11.11.0
resolution: "@emotion/babel-plugin@npm:11.11.0"
"@emotion/babel-plugin@npm:^11.12.0":
version: 11.12.0
resolution: "@emotion/babel-plugin@npm:11.12.0"
dependencies:
"@babel/helper-module-imports": "npm:^7.16.7"
"@babel/runtime": "npm:^7.18.3"
"@emotion/hash": "npm:^0.9.1"
"@emotion/memoize": "npm:^0.8.1"
"@emotion/serialize": "npm:^1.1.2"
"@emotion/hash": "npm:^0.9.2"
"@emotion/memoize": "npm:^0.9.0"
"@emotion/serialize": "npm:^1.2.0"
babel-plugin-macros: "npm:^3.1.0"
convert-source-map: "npm:^1.5.0"
escape-string-regexp: "npm:^4.0.0"
find-root: "npm:^1.1.0"
source-map: "npm:^0.5.7"
stylis: "npm:4.2.0"
checksum: 10c0/89cbb6ec0e52c8ee9c2a4b9889ccd4fc3a75d28091d835bfac6d7c4565d3338621e23af0a85f3bcd133e1cae795c692e1dadada015784d4b0554aa5bb111df43
checksum: 10c0/930ff6f8768b0c24d05896ad696be20e1c65f32ed61fb5c1488f571120a947ef0a2cf69187b17114cc76e7886f771fac150876ed7b5341324fec2377185d6573
languageName: node
linkType: hard
@@ -697,19 +697,32 @@ __metadata:
languageName: node
linkType: hard
"@emotion/hash@npm:^0.9.1":
version: 0.9.1
resolution: "@emotion/hash@npm:0.9.1"
checksum: 10c0/cdafe5da63fc1137f3db6e232fdcde9188b2b47ee66c56c29137199642a4086f42382d866911cfb4833cae2cc00271ab45cad3946b024f67b527bb7fac7f4c9d
"@emotion/cache@npm:^11.12.0":
version: 11.12.0
resolution: "@emotion/cache@npm:11.12.0"
dependencies:
"@emotion/memoize": "npm:^0.9.0"
"@emotion/sheet": "npm:^1.3.0"
"@emotion/utils": "npm:^1.3.0"
"@emotion/weak-memoize": "npm:^0.4.0"
stylis: "npm:4.2.0"
checksum: 10c0/b6909597a41dfc1d07ada1b8a719697d2c0155a8f71c14079b7a089e281093a4c0710933592c864185e9176621ce6eff96e5ce2eb6774ba7959235232892d3c8
languageName: node
linkType: hard
"@emotion/is-prop-valid@npm:^1.2.2":
version: 1.2.2
resolution: "@emotion/is-prop-valid@npm:1.2.2"
"@emotion/hash@npm:^0.9.2":
version: 0.9.2
resolution: "@emotion/hash@npm:0.9.2"
checksum: 10c0/0dc254561a3cc0a06a10bbce7f6a997883fd240c8c1928b93713f803a2e9153a257a488537012efe89dbe1246f2abfe2add62cdb3471a13d67137fcb808e81c2
languageName: node
linkType: hard
"@emotion/is-prop-valid@npm:^1.3.0":
version: 1.3.0
resolution: "@emotion/is-prop-valid@npm:1.3.0"
dependencies:
"@emotion/memoize": "npm:^0.8.1"
checksum: 10c0/bb1530dcb4e0e5a4fabb219279f2d0bc35796baf66f6241f98b0d03db1985c890a8cafbea268e0edefd5eeda143dbd5c09a54b5fba74cee8c69b98b13194af50
"@emotion/memoize": "npm:^0.9.0"
checksum: 10c0/4620b62aaca4b3b610202513652872756d7f4a8b84b2cea6b798dd6e8ccdfe43944b956c6a6a8cb5da0b0fe61bef6caca273d198ba32b5c658df22a6c7371b1b
languageName: node
linkType: hard
@@ -720,37 +733,44 @@ __metadata:
languageName: node
linkType: hard
"@emotion/react@npm:^11.11.4":
version: 11.11.4
resolution: "@emotion/react@npm:11.11.4"
"@emotion/memoize@npm:^0.9.0":
version: 0.9.0
resolution: "@emotion/memoize@npm:0.9.0"
checksum: 10c0/13f474a9201c7f88b543e6ea42f55c04fb2fdc05e6c5a3108aced2f7e7aa7eda7794c56bba02985a46d8aaa914fcdde238727a98341a96e2aec750d372dadd15
languageName: node
linkType: hard
"@emotion/react@npm:^11.12.0":
version: 11.12.0
resolution: "@emotion/react@npm:11.12.0"
dependencies:
"@babel/runtime": "npm:^7.18.3"
"@emotion/babel-plugin": "npm:^11.11.0"
"@emotion/cache": "npm:^11.11.0"
"@emotion/serialize": "npm:^1.1.3"
"@emotion/babel-plugin": "npm:^11.12.0"
"@emotion/cache": "npm:^11.12.0"
"@emotion/serialize": "npm:^1.2.0"
"@emotion/use-insertion-effect-with-fallbacks": "npm:^1.0.1"
"@emotion/utils": "npm:^1.2.1"
"@emotion/weak-memoize": "npm:^0.3.1"
"@emotion/utils": "npm:^1.3.0"
"@emotion/weak-memoize": "npm:^0.4.0"
hoist-non-react-statics: "npm:^3.3.1"
peerDependencies:
react: ">=16.8.0"
peerDependenciesMeta:
"@types/react":
optional: true
checksum: 10c0/6df892fd9e04b5c8c37aacfd7f461631e04e00e845edc3c5b2955ab8ad681abf5cd49584101f579427e08b82f2f88369c78d37ae2fe9360a8f68fd4e51b8e448
checksum: 10c0/a2035e0a5788ec6748b595ae898732aa845515dea52657fcf2661288d01c7da16133588fdaa4288c05175dc4c39938546af265bb039065efca20a729c486da9b
languageName: node
linkType: hard
"@emotion/serialize@npm:^1.1.2, @emotion/serialize@npm:^1.1.3, @emotion/serialize@npm:^1.1.4":
version: 1.1.4
resolution: "@emotion/serialize@npm:1.1.4"
"@emotion/serialize@npm:^1.2.0":
version: 1.2.0
resolution: "@emotion/serialize@npm:1.2.0"
dependencies:
"@emotion/hash": "npm:^0.9.1"
"@emotion/memoize": "npm:^0.8.1"
"@emotion/unitless": "npm:^0.8.1"
"@emotion/utils": "npm:^1.2.1"
"@emotion/hash": "npm:^0.9.2"
"@emotion/memoize": "npm:^0.9.0"
"@emotion/unitless": "npm:^0.9.0"
"@emotion/utils": "npm:^1.3.0"
csstype: "npm:^3.0.2"
checksum: 10c0/164d936f72382594c47b9c24e67a51c7fc16b83d9a36b84eec5e4cb9bf7be029218a490ef4b44233a1b53423bdb3905d65b597cde3ebba759d40dab7a4c99121
checksum: 10c0/bac56ccc42b4842bbb55139296bfef812ec6d26cf92db1a7adfc90dcab8d2b717706828ff474feff227ef1a5f611020c5a2443ba600ed01d28095f0201b352e2
languageName: node
linkType: hard
@@ -761,30 +781,37 @@ __metadata:
languageName: node
linkType: hard
"@emotion/styled@npm:^11.11.5":
version: 11.11.5
resolution: "@emotion/styled@npm:11.11.5"
"@emotion/sheet@npm:^1.3.0":
version: 1.3.0
resolution: "@emotion/sheet@npm:1.3.0"
checksum: 10c0/99ce618d426e0646f58591200619cf3cd6f452e829c0b0339f66b3e4bfd7d51773f49d0200e14334861bee9db1dfb5d46328b20eafbfdd28f857584688fad8f4
languageName: node
linkType: hard
"@emotion/styled@npm:^11.12.0":
version: 11.12.0
resolution: "@emotion/styled@npm:11.12.0"
dependencies:
"@babel/runtime": "npm:^7.18.3"
"@emotion/babel-plugin": "npm:^11.11.0"
"@emotion/is-prop-valid": "npm:^1.2.2"
"@emotion/serialize": "npm:^1.1.4"
"@emotion/babel-plugin": "npm:^11.12.0"
"@emotion/is-prop-valid": "npm:^1.3.0"
"@emotion/serialize": "npm:^1.2.0"
"@emotion/use-insertion-effect-with-fallbacks": "npm:^1.0.1"
"@emotion/utils": "npm:^1.2.1"
"@emotion/utils": "npm:^1.3.0"
peerDependencies:
"@emotion/react": ^11.0.0-rc.0
react: ">=16.8.0"
peerDependenciesMeta:
"@types/react":
optional: true
checksum: 10c0/27da6ad7f5b374d61cfe6647cc2f93ee3ceb1139a51907050576ee30da0a50a27b0bbed45f76889d560d2a8ccf8bc4a4f7126cad3f00127e107c11093dc0a801
checksum: 10c0/f87466ade3c872c6452091969f2784b97dcec821f812f641088e1289ad039ddea7165e8b1221895911f199469d07a9ffc786434e496ae3cb62156f72a5686ad7
languageName: node
linkType: hard
"@emotion/unitless@npm:^0.8.1":
version: 0.8.1
resolution: "@emotion/unitless@npm:0.8.1"
checksum: 10c0/a1ed508628288f40bfe6dd17d431ed899c067a899fa293a13afe3aed1d70fac0412b8a215fafab0b42829360db687fecd763e5f01a64ddc4a4b58ec3112ff548
"@emotion/unitless@npm:^0.9.0":
version: 0.9.0
resolution: "@emotion/unitless@npm:0.9.0"
checksum: 10c0/f907d968a49315bb654b5734edf3315e52350f77c160a63f3437f14d80610dc78fd8295e759e7339055c45bd25c74c46363235c5971aae5587f7eeb969580c4c
languageName: node
linkType: hard
@@ -804,6 +831,13 @@ __metadata:
languageName: node
linkType: hard
"@emotion/utils@npm:^1.3.0":
version: 1.3.0
resolution: "@emotion/utils@npm:1.3.0"
checksum: 10c0/a42ec56b78e4fea16d120da31fb1d5ccffb9ad372e26c620eb6fe3ca5bb63f9d0d88497af01cd503e4baea9b1dd6d4fe04b897b7720c26a53eee8b993bc8000d
languageName: node
linkType: hard
"@emotion/weak-memoize@npm:^0.3.1":
version: 0.3.1
resolution: "@emotion/weak-memoize@npm:0.3.1"
@@ -811,6 +845,13 @@ __metadata:
languageName: node
linkType: hard
"@emotion/weak-memoize@npm:^0.4.0":
version: 0.4.0
resolution: "@emotion/weak-memoize@npm:0.4.0"
checksum: 10c0/64376af11f1266042d03b3305c30b7502e6084868e33327e944b539091a472f089db307af69240f7188f8bc6b319276fd7b141a36613f1160d73d12a60f6ca1a
languageName: node
linkType: hard
"@esbuild/aix-ppc64@npm:0.21.5":
version: 0.21.5
resolution: "@esbuild/aix-ppc64@npm:0.21.5"
@@ -2013,8 +2054,8 @@ __metadata:
"@alova/adapter-xhr": "npm:^1.0.6"
"@alova/scene-react": "npm:^1.6.1"
"@babel/core": "npm:^7.24.9"
"@emotion/react": "npm:^11.11.4"
"@emotion/styled": "npm:^11.11.5"
"@emotion/react": "npm:^11.12.0"
"@emotion/styled": "npm:^11.12.0"
"@eslint/js": "npm:^9.7.0"
"@mui/icons-material": "npm:^5.16.4"
"@mui/material": "npm:^5.16.4"

View File

@@ -41,7 +41,7 @@ class ChunkPrint : public Print {
}
};
// added msgPack by Proddy
// added msgPack by proddy for EMS-ESP
class AsyncJsonResponse : public AsyncAbstractResponse {
protected:
JsonDocument _jsonBuffer;

View File

@@ -329,9 +329,7 @@ class AsyncWebServerRequest {
AsyncResponseStream * beginResponseStream(const String & contentType, size_t bufferSize = 1460);
AsyncWebServerResponse * beginResponse_P(int code, const String & contentType, const uint8_t * content, size_t len, AwsTemplateProcessor callback = nullptr);
AsyncWebServerResponse * beginResponse_P(int code, const String & contentType, PGM_P content, AwsTemplateProcessor callback = nullptr);
// added by proddy for EMS-ESP
AsyncWebServerResponse * beginResponse(const String & contentType, const uint8_t * content, size_t len);
AsyncWebServerResponse * beginResponse(const String & contentType, const uint8_t * content, size_t len); // added by proddy for EMS-ESP
size_t headers() const; // get header count
bool hasHeader(const String & name) const; // check if header exists

Binary file not shown.

Binary file not shown.

View File

@@ -580,6 +580,7 @@ void Mqtt::ha_status() {
#endif
// These come from the heartbeat MQTT topic
// we don't use camelCase as it would change the HA entity_id and impact historic data
publish_system_ha_sensor_config(DeviceValueType::STRING, "EMS Bus", "bus_status", DeviceValueUOM::NONE);
publish_system_ha_sensor_config(DeviceValueType::STRING, "Uptime", "uptime", DeviceValueUOM::NONE);
publish_system_ha_sensor_config(DeviceValueType::INT8, "Uptime (sec)", "uptime_sec", DeviceValueUOM::SECONDS);

View File

@@ -1359,6 +1359,7 @@ bool System::get_value_info(JsonObject root, const char * command) {
// export status information including the device information
// http://ems-esp/api/system/info
// TODO camelCase - #1860
bool System::command_info(const char * value, const int8_t id, JsonObject output) {
JsonObject node;
@@ -1413,7 +1414,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject output
#endif
EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & settings) {
if (WiFi.status() == WL_CONNECTED && !settings.bssid.isEmpty()) {
node["BSSID"] = "set"; // TODO why is this not the actual value??
node["BSSID"] = "set"; // we don't disclose the name
}
node["TxPower setting"] = settings.tx_power;
node["static ip config"] = settings.staticIPConfig;
@@ -1591,6 +1592,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject output
obj["name"] = emsdevice->name(); // custom name
obj["device id"] = Helpers::hextoa(emsdevice->device_id());
obj["product id"] = emsdevice->product_id();
obj["brand"] = emsdevice->brand_to_char();
obj["version"] = emsdevice->version();
obj["entities"] = emsdevice->count_entities();
char result[500];

View File

@@ -146,3 +146,23 @@ Content-Type: application/json
< ./standalone_file_export/emsesp_settings.json
------WebKitFormBoundary7MA4YWxkTrZu0gW--
# test calling Home Assistant script
# https://developers.home-assistant.io/docs/api/rest/#post-apiservicesdomainservice
POST {{host_standalone}}/api
# HA
@ha = http://192.168.1.42:8123
@ha_token = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIwMzMyZjU1MjhlZmM0NGIyOTgyMjIxNThiODU1NDkyNSIsImlhdCI6MTcyMTMwNDg2NSwiZXhwIjoyMDM2NjY0ODY1fQ.Q-Y7E_i7clH3ff4Ma-OMmhZfbN7aMi_CahKwmoar
###
GET {{ha}}/api/services
Content-Type: application/json
Authorization: Bearer {{ha_token}}
###
POST {{ha}}/api/services/script/test_notify
Content-Type: application/json
Authorization: Bearer {{ha_token}}

16
test/api_test.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/sh
# API
curl -X GET http://ems-esp.local/api/system/info
echo "\n"
# HA
ha_url="http://192.168.1.42:8123"
ha_token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIwMzMyZjU1MjhlZmM0NGIyOTgyMjIxNThiODU1NDkyNSIsImlhdCI6MTcyMTMwNDg2NSwiZXhwIjoyMDM2NjY0ODY1fQ.Q-Y7E_i7clH3ff4Ma-OMmhZfbN7aMi_CahKwmoar"
curl -X POST \
${ha_url}/api/services/script/test_notify \
-H "Authorization: Bearer ${ha_token}" \
-H "Content-Type: application/json" \