Aggiunto prima implementazione del driver sonoff_tesmota_http, aggiunto implementazione parametro EVx_MONOSTABLE per potere definire singolarmente le elettrovamvole monostabili, corretto alcuni commenti

This commit is contained in:
lejubila
2018-05-20 17:14:58 +02:00
parent 7c96a6afd1
commit 3eb45fd1e9
13 changed files with 215 additions and 5 deletions

View File

@@ -0,0 +1,42 @@
#
# Funzioni comuni utilizzate dal driver
#
#
# Invia un comando al modulo sonoff tramite http
#
# $1 identificativo modulo sonoff
# $2 comando da eseguire
#
function drv_sonoff_tasmota_http_command {
local remote="$1"
local command="$2"
local remote_ip_var=$remote"_IP"
local remote_user_var=$remote"_USER"
local remote_pwd_var=$remote"_PWD"
local remote_ip="${!remote_ip_var}"
local remote_user="${!remote_user_var}"
local remote_pwd="${!remote_pwd_var}"
local url="http://$remore_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"
#$CURL -LI $url -o /dev/null -w '%{http_code}\n' -s
}