add HA API test

This commit is contained in:
proddy
2024-07-18 15:00:38 +02:00
parent 3af3d3f0d8
commit 7826f3b873
2 changed files with 36 additions and 0 deletions

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" \