mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-10-28 11:14:58 +00:00
optimize LED and fix some edge cases
This commit is contained in:
+65
-30
@@ -1,53 +1,88 @@
|
||||
#!/bin/sh
|
||||
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Command line test for the API
|
||||
#
|
||||
|
||||
emsesp_url="http://ems-esp.local"
|
||||
emsesp_url="http://ems-espT.local"
|
||||
|
||||
# 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"
|
||||
test0() {
|
||||
curl -X GET ${emsesp_url}/api/system/info
|
||||
}
|
||||
|
||||
# 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" \
|
||||
-d '{"data":"8 1"}' \
|
||||
${emsesp_url}/api/system/read
|
||||
|
||||
echo "\n"
|
||||
test1() {
|
||||
curl -X POST \
|
||||
-H "Authorization: Bearer ${emsesp_token}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"data":"8 1"}' \
|
||||
${emsesp_url}/api/system/read
|
||||
}
|
||||
|
||||
# This example will use the message command to get the locale (en)
|
||||
curl -X POST \
|
||||
-H "Authorization: Bearer ${emsesp_token}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"value":"system/settings/locale"}' \
|
||||
${emsesp_url}/api/system/message
|
||||
|
||||
echo "\n"
|
||||
test2() {
|
||||
curl -X POST \
|
||||
-H "Authorization: Bearer ${emsesp_token}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"value":"system/settings/locale"}' \
|
||||
${emsesp_url}/api/system/message
|
||||
}
|
||||
|
||||
# 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"
|
||||
test3() {
|
||||
curl -X POST \
|
||||
-H "Authorization: Bearer ${emsesp_token}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"action":"export", "param":"allvalues"}' \
|
||||
${emsesp_url}/rest/action
|
||||
}
|
||||
|
||||
# Get all versions
|
||||
curl -X POST \
|
||||
test4() {
|
||||
curl -X POST \
|
||||
-H "Authorization: Bearer ${emsesp_token}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"action":"getVersions"}' \
|
||||
${emsesp_url}/rest/action
|
||||
-d '{"action":"getVersions"}' \
|
||||
${emsesp_url}/rest/action
|
||||
}
|
||||
|
||||
# led tests
|
||||
test5() {
|
||||
curl -X POST \
|
||||
-H "Authorization: Bearer ${emsesp_token}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"data":"red:blink1"}' \
|
||||
${emsesp_url}/api/system/led
|
||||
}
|
||||
|
||||
test6() {
|
||||
curl -X POST \
|
||||
-H "Authorization: Bearer ${emsesp_token}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"data":"rgb"}' \
|
||||
${emsesp_url}/api/system/led
|
||||
}
|
||||
|
||||
# Create a list of test function names to run
|
||||
tests_to_run=(
|
||||
# test0
|
||||
# test1
|
||||
# test2
|
||||
# test3
|
||||
# test4
|
||||
test5
|
||||
test6
|
||||
)
|
||||
|
||||
for test_func in "${tests_to_run[@]}"; do
|
||||
echo "Running $test_func..."
|
||||
$test_func
|
||||
echo ""
|
||||
done
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user