Eseguito correzioni su driver sonoff_tasmota_http

This commit is contained in:
lejubila
2018-05-21 22:21:27 +02:00
parent 3eb45fd1e9
commit 87edbbbe7a
3 changed files with 19 additions and 12 deletions

View File

@@ -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
}

View File

@@ -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

View File

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