diff --git a/drv/sonoff_tasmota_http/common.include.sh b/drv/sonoff_tasmota_http/common.include.sh index 916738e..56f8b1b 100644 --- a/drv/sonoff_tasmota_http/common.include.sh +++ b/drv/sonoff_tasmota_http/common.include.sh @@ -21,21 +21,28 @@ function drv_sonoff_tasmota_http_command { local remote_user="${!remote_user_var}" local remote_pwd="${!remote_pwd_var}" - local url="http://$remore_ip/cm" + local url="http://$remote_ip/cm" local credentials="" local response="" - #$CURL -LI http://$remote_ip/ -o /dev/null -w '%{http_code}\n' -s - if [[ ! -z $remote_user ]] && [[ ! -z $remote_pwd ]]; then credentials="user=$remote_user&password=$remote_pwd&" fi 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 } diff --git a/drv/sonoff_tasmota_http/init.include.sh b/drv/sonoff_tasmota_http/init.include.sh index 991dda6..57ba16d 100644 --- a/drv/sonoff_tasmota_http/init.include.sh +++ b/drv/sonoff_tasmota_http/init.include.sh @@ -1,7 +1,7 @@ # # 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 diff --git a/drv/sonoff_tasmota_http/rele.include.sh b/drv/sonoff_tasmota_http/rele.include.sh index b9c5f9b..b9961bd 100644 --- a/drv/sonoff_tasmota_http/rele.include.sh +++ b/drv/sonoff_tasmota_http/rele.include.sh @@ -28,10 +28,10 @@ function drv_sonoff_tasmota_http_rele_open { echo "response=$response" - local result=$(echo $response|$JQ -M ".$remore_alias") + local result=$(echo $response|$JQ -M ".$remote_alias") echo "result=$result" - if [[ "$result" != "\"Off\"" ]]; then - local error="Command error: $result" + if [[ "$result" != "\"OFF\"" ]]; then + local error="Command error: $response" error="${error%\"}" error="${error#\"}" echo "error=$error" @@ -61,10 +61,10 @@ function drv_sonoff_tasmota_http_rele_close { echo "response=$response" - local result=$(echo $response|$JQ -M ".$remore_alias") + local result=$(echo $response|$JQ -M ".$remote_alias") echo "result=$result" - if [[ "$result" != "\"On\"" ]]; then - local error="Command error: $result" + if [[ "$result" != "\"ON\"" ]]; then + local error="Command error: $response" error="${error%\"}" error="${error#\"}" echo "error=$error"