Added lots of things
This commit is contained in:
27
switchcontrol
Executable file
27
switchcontrol
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
# A program that maps the paramaters [1 -> length - 1] to a variable P[1 -> length - 1] and then sends it in a HTTP post requset to HomeAssistant web hook automation.
|
||||
|
||||
WEBHOOK_ID="3Rvdb4qZDgcKD2EiZgV328xdhWLVkjn8dVgSKr13JkIb5eP0RFNPQjgYDey16R64"
|
||||
WEBHOOK_URL="http://0.hassio.local/api/webhook/$WEBHOOK_ID"
|
||||
|
||||
CURL_REQ="curl -X POST $WEBHOOK_URL"
|
||||
|
||||
#CURL_REQ=("curl" "-X" "POST" "$WEBHOOK_URL")
|
||||
|
||||
declare -a params_array
|
||||
|
||||
i=0
|
||||
j=0
|
||||
for var in "$@"
|
||||
do
|
||||
params_array[$i]='-d'
|
||||
((i++))
|
||||
params_array[$((i))]="P$((i-1+j))=$var"
|
||||
((i++))
|
||||
|
||||
((j-=1))
|
||||
|
||||
done
|
||||
|
||||
$CURL_REQ "${params_array[@]}"
|
Reference in New Issue
Block a user