diff --git a/test/api_test.http b/test/api_test.http index 8af1807e8..71012060a 100755 --- a/test/api_test.http +++ b/test/api_test.http @@ -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}} diff --git a/test/api_test.sh b/test/api_test.sh new file mode 100755 index 000000000..c6e464831 --- /dev/null +++ b/test/api_test.sh @@ -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" \