Eseguito correzioni su driver sonoff_tasmota_http
This commit is contained in:
@@ -21,21 +21,28 @@ function drv_sonoff_tasmota_http_command {
|
|||||||
local remote_user="${!remote_user_var}"
|
local remote_user="${!remote_user_var}"
|
||||||
local remote_pwd="${!remote_pwd_var}"
|
local remote_pwd="${!remote_pwd_var}"
|
||||||
|
|
||||||
local url="http://$remore_ip/cm"
|
local url="http://$remote_ip/cm"
|
||||||
local credentials=""
|
local credentials=""
|
||||||
local response=""
|
local response=""
|
||||||
|
|
||||||
#$CURL -LI http://$remote_ip/ -o /dev/null -w '%{http_code}\n' -s
|
|
||||||
|
|
||||||
if [[ ! -z $remote_user ]] && [[ ! -z $remote_pwd ]]; then
|
if [[ ! -z $remote_user ]] && [[ ! -z $remote_pwd ]]; then
|
||||||
credentials="user=$remote_user&password=$remote_pwd&"
|
credentials="user=$remote_user&password=$remote_pwd&"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
url="$url?$credentials$command"
|
url="$url?$credentials$command"
|
||||||
|
|
||||||
$CURL -sb -H "$url"
|
echo "url api sonoff: $url" >> "$LOG_OUTPUT_DRV_FILE"
|
||||||
|
|
||||||
#$CURL -LI $url -o /dev/null -w '%{http_code}\n' -s
|
$CURL --connect-timeout 5 -sb -H "$url"
|
||||||
|
|
||||||
|
local res=$?
|
||||||
|
|
||||||
|
echo "curl code response: $res" >> "$LOG_OUTPUT_DRV_FILE"
|
||||||
|
|
||||||
|
if [ "$res" != "0" ]; then
|
||||||
|
#echo "The curl command failed with: $res - url: $url"
|
||||||
|
local FOO="bar"
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Questa funzione viene inviocata dalla funzione "init" di piGarden se sono presenti elettrovalvole o sensori che utilizzano questo driver
|
# Questa funzione viene inviocata dalla funzione "init" di piGarden se sono presenti elettrovalvole o sensori che utilizzano questo driver
|
||||||
#
|
#
|
||||||
function drv_sonoff_tasmota_http_init {
|
function drv_sonoff_tasmota_http_rele_init {
|
||||||
|
|
||||||
local FOO=bar
|
local FOO=bar
|
||||||
|
|
||||||
|
|||||||
@@ -28,10 +28,10 @@ function drv_sonoff_tasmota_http_rele_open {
|
|||||||
|
|
||||||
echo "response=$response"
|
echo "response=$response"
|
||||||
|
|
||||||
local result=$(echo $response|$JQ -M ".$remore_alias")
|
local result=$(echo $response|$JQ -M ".$remote_alias")
|
||||||
echo "result=$result"
|
echo "result=$result"
|
||||||
if [[ "$result" != "\"Off\"" ]]; then
|
if [[ "$result" != "\"OFF\"" ]]; then
|
||||||
local error="Command error: $result"
|
local error="Command error: $response"
|
||||||
error="${error%\"}"
|
error="${error%\"}"
|
||||||
error="${error#\"}"
|
error="${error#\"}"
|
||||||
echo "error=$error"
|
echo "error=$error"
|
||||||
@@ -61,10 +61,10 @@ function drv_sonoff_tasmota_http_rele_close {
|
|||||||
|
|
||||||
echo "response=$response"
|
echo "response=$response"
|
||||||
|
|
||||||
local result=$(echo $response|$JQ -M ".$remore_alias")
|
local result=$(echo $response|$JQ -M ".$remote_alias")
|
||||||
echo "result=$result"
|
echo "result=$result"
|
||||||
if [[ "$result" != "\"On\"" ]]; then
|
if [[ "$result" != "\"ON\"" ]]; then
|
||||||
local error="Command error: $result"
|
local error="Command error: $response"
|
||||||
error="${error%\"}"
|
error="${error%\"}"
|
||||||
error="${error#\"}"
|
error="${error#\"}"
|
||||||
echo "error=$error"
|
echo "error=$error"
|
||||||
|
|||||||
Reference in New Issue
Block a user