Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor changes #2388

Merged
merged 9 commits into from
Feb 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-icons": "^5.4.0",
"react-router": "^7.1.3",
"react-router": "^7.1.5",
"react-toastify": "^11.0.3",
"typesafe-i18n": "^5.26.2",
"typescript": "^5.7.3"
Expand All @@ -47,7 +47,7 @@
"@preact/preset-vite": "^2.10.0",
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
"@types/formidable": "^3",
"@types/node": "^22.12.0",
"@types/node": "^22.13.0",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"concurrently": "^9.1.2",
Expand Down
4 changes: 2 additions & 2 deletions interface/src/app/main/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const Dashboard = () => {
send: fetchDashboard,
error
} = useRequest(readDashboard, {
initialData: { connected: false, nodes: [] }
initialData: { connected: true, nodes: [] }
}).onSuccess((event) => {
if (event.data.nodes.length !== parentNodes) {
setParentNodes(event.data.nodes.length); // count number of parents/devices
Expand Down Expand Up @@ -238,7 +238,7 @@ const Dashboard = () => {
<MessageBox mb={2} level="error" message={LL.EMS_BUS_WARNING()} />
)}

{data.connected && !hasFavEntities && (
{data.connected && data.nodes.length > 0 && !hasFavEntities && (
<MessageBox mb={2} level="warning">
<Typography>
{LL.NO_DATA_1()}&nbsp;
Expand Down
24 changes: 0 additions & 24 deletions interface/src/app/main/Help.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,6 @@ const Help = () => {
}
});

// const { send: sendExportAllValues } = useRequest(
// () => callAction({ action: 'export', param: 'allvalues' }),
// {
// immediate: false
// }
// )
// .onSuccess((event) => {
// saveFile(event.data, 'allvalues', '.txt');
// toast.info(LL.DOWNLOAD_SUCCESSFUL());
// })
// .onError((error) => {
// toast.error(error.message);
// });

const { send: sendAPI } = useRequest((data: APIcall) => API(data), {
immediate: false
})
Expand Down Expand Up @@ -165,16 +151,6 @@ const Help = () => {
</Button>
</Box>

{/* <Button
sx={{ ml: 2 }}
startIcon={<DownloadIcon />}
variant="outlined"
color="primary"
onClick={() => sendExportAllValues()}
>
{LL.DOWNLOAD(1)}&nbsp;{LL.ALLVALUES()}
</Button> */}

<Divider sx={{ mt: 4 }} />

<Typography color="white" variant="subtitle1" align="center" mt={1}>
Expand Down
9 changes: 9 additions & 0 deletions interface/src/app/settings/DownloadUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ const DownloadUpload = () => {
{LL.SCHEDULE(0)}
</Button>
</Grid>
<Button
sx={{ ml: 2, mt: 2 }}
startIcon={<DownloadIcon />}
variant="outlined"
color="primary"
onClick={() => sendExportData('allvalues')}
>
{LL.ALLVALUES()}
</Button>

<Typography sx={{ pt: 2, pb: 2 }} variant="h6" color="primary">
{LL.UPLOAD()}
Expand Down
1 change: 1 addition & 0 deletions interface/src/components/loading/FormLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const FormLoader = ({ errorMessage, onRetry }: FormLoaderProps) => {
<MessageBox my={2} level="error" message={errorMessage}>
{onRetry && (
<Button
sx={{ ml: 2 }}
startIcon={<RefreshIcon />}
variant="contained"
color="error"
Expand Down
20 changes: 10 additions & 10 deletions interface/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1408,12 +1408,12 @@ __metadata:
languageName: node
linkType: hard

"@types/node@npm:^22.12.0":
version: 22.12.0
resolution: "@types/node@npm:22.12.0"
"@types/node@npm:^22.13.0":
version: 22.13.0
resolution: "@types/node@npm:22.13.0"
dependencies:
undici-types: "npm:~6.20.0"
checksum: 10c0/be220706732d95db2ed1c441c1e64cab90bf9a47519ce6f4c79cc5a9ec9d5c517131a149a9ac30afac1a30103e67e3a00d453ba7c1b0141608a3a7ba6397c303
checksum: 10c0/9cf6358b2863ae7bf9588ca1cc3d87f6a6289c3880e95a046a188760666870e2c12502df8b0a473bec8aa8ffee85e025d60382a6104b10f197120793235b2c22
languageName: node
linkType: hard

Expand Down Expand Up @@ -1604,7 +1604,7 @@ __metadata:
"@table-library/react-table-library": "npm:4.1.7"
"@trivago/prettier-plugin-sort-imports": "npm:^5.2.2"
"@types/formidable": "npm:^3"
"@types/node": "npm:^22.12.0"
"@types/node": "npm:^22.13.0"
"@types/react": "npm:^19.0.8"
"@types/react-dom": "npm:^19.0.3"
alova: "npm:3.2.8"
Expand All @@ -1620,7 +1620,7 @@ __metadata:
react: "npm:^19.0.0"
react-dom: "npm:^19.0.0"
react-icons: "npm:^5.4.0"
react-router: "npm:^7.1.3"
react-router: "npm:^7.1.5"
react-toastify: "npm:^11.0.3"
rollup-plugin-visualizer: "npm:^5.14.0"
terser: "npm:^5.37.0"
Expand Down Expand Up @@ -5612,9 +5612,9 @@ __metadata:
languageName: node
linkType: hard

"react-router@npm:^7.1.3":
version: 7.1.3
resolution: "react-router@npm:7.1.3"
"react-router@npm:^7.1.5":
version: 7.1.5
resolution: "react-router@npm:7.1.5"
dependencies:
"@types/cookie": "npm:^0.6.0"
cookie: "npm:^1.0.1"
Expand All @@ -5626,7 +5626,7 @@ __metadata:
peerDependenciesMeta:
react-dom:
optional: true
checksum: 10c0/f42f7b245533d1adaa00779a0287993a836d5b56039d97a6643a8b3a721ffb92ff47c97cfb36409fec8794ac3c8a884339f588cf21fcd7f6dccdfc834520c76f
checksum: 10c0/c0013102c7a02d26cd2353fa3749bd229fbcfedd291710540be1765d703861f96a34ef0114dd5ee8d9a728e87f3a5698387058f9539b39604f331505f507d912
languageName: node
linkType: hard

Expand Down
7 changes: 7 additions & 0 deletions pio_local.ini_example
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ custom_password = admin
; upload_protocol = custom
; custom_emsesp_ip = 10.10.10.93

; example override for lib_deps and using locally built modules
;lib_deps =
; bblanchon/ArduinoJson @ 7.3.0
; ESP32Async/AsyncTCP @ 3.3.2
; ESP32Async/ESPAsyncWebServer @ 3.6.2
; file://${PROJECT_DIR}/../modules/EMS-ESP-Modules

; ** debug settings **
; to be used with esp-prog/JTAG hardware device like https://docs.espressif.com/projects/esp-dev-kits/en/latest/other/esp-prog/user_guide.html
; pio run -e debug
Expand Down
2 changes: 1 addition & 1 deletion src/core/emsesp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ uint8_t EMSESP::publish_all_idx_ = 0;
uint8_t EMSESP::unique_id_count_ = 0;
bool EMSESP::trace_raw_ = false;
uint16_t EMSESP::wait_validate_ = 0;
bool EMSESP::wait_km_ = true;
bool EMSESP::wait_km_ = false;
uint32_t EMSESP::last_fetch_ = 0;

AsyncWebServer webServer(80);
Expand Down
8 changes: 5 additions & 3 deletions src/web/WebStatusService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,14 @@ void WebStatusService::action(AsyncWebServerRequest * request, JsonVariant json)
Serial.println(COLOR_RESET);
#endif

// send response
// check for error
if (!ok) {
request->send(400);
emsesp::EMSESP::logger().err("Action '%s' failed", action.c_str());
request->send(400); // bad request
return;
}

// send response
response->setLength();
request->send(response);
}
Expand Down Expand Up @@ -256,7 +258,7 @@ bool WebStatusService::checkUpgrade(JsonObject root, std::string & versions) {
}

// action = allvalues
// output all the devices and the values
// output all the devices and their values, including custom entities, scheduler and sensors
void WebStatusService::allvalues(JsonObject output) {
JsonObject device_output;
auto value = F_(values);
Expand Down
2 changes: 1 addition & 1 deletion test/test_api/api_test.http
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# The response will be shown in the right panel

# @host = http://ems-esp.local
@host = http://192.168.1.206
@host = http://192.168.1.225
@host_dev = http://10.10.10.175
@host_standalone = http://localhost:3080
@host_standalone2 = http://localhost:3082
Expand Down
26 changes: 19 additions & 7 deletions test/test_api/api_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
# Command line test for the API
#

# EMS_ESP API
emsesp_url="http://192.168.1.225"

emsesp_url="http://192.168.1.206"
# get the token from the Security page. This is the token for the admin user, unless changed it'll always be the same
emsesp_token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiYWRtaW4iOnRydWV9.2bHpWya2C7Q12WjNUBD6_7N3RCD7CMl-EGhyQVzFdDg"

# This example will get the system info, via a GET request
curl -X GET ${emsesp_url}/api/system/info
echo "\n"

# This example will execute a read command on product ID 8 and type ID 1
curl -X POST \
-H "Authorization: Bearer ${emsesp_token}" \
-H "Content-Type: application/json" \
Expand All @@ -20,12 +22,22 @@ curl -X POST \

echo "\n"

# HA API
# This example will export all values to a json file, including custom entities, sensors and schedules
curl -X POST \
-H "Authorization: Bearer ${emsesp_token}" \
-H "Content-Type: application/json" \
-d '{"action":"export", "param":"allvalues"}' \
${emsesp_url}/rest/action

echo "\n"

# This example is how to call a service in Home Assistant via the API
# Which can be added to an EMS-EPS schedule

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"
curl -X POST \
${ha_url}/api/services/script/test_notify \
-H "Authorization: Bearer ${ha_token}" \
-H "Content-Type: application/json"