mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
add HA API test
This commit is contained in:
@@ -146,3 +146,23 @@ Content-Type: application/json
|
|||||||
< ./standalone_file_export/emsesp_settings.json
|
< ./standalone_file_export/emsesp_settings.json
|
||||||
------WebKitFormBoundary7MA4YWxkTrZu0gW--
|
------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
16
test/api_test.sh
Executable 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" \
|
||||||
Reference in New Issue
Block a user