Version 0.9.1

Datei 'scripts/_get/set_device.sh' Zurück zur Übersicht
#!/bin/ksh
device=${1:?'$1 No Device!'}
value=${2:?'$2 No Values!'}

#get base dir
BASEDIR=$(dirname "$0")
if [ -L $0 ] ; then
    BASEDIR=$(dirname $(readlink -f "$0"))
fi

#config
if [ -e "$BASEDIR/../config.conf" ]; then
	. "$BASEDIR/../config.conf"
else
	echo "No config found at: $BASEDIR/../config.conf"
fi

function wLog {
	log="${logdir}/set_device.log"
	date=$(date "+%Y-%m-%d_%H:%M:%S.%N")
	
	echo "$date $USER $1 $2 $3 $4 $5 $6 $7 $8 $9" >> "$log"
}

. $shdir/synonyms $device

if [[ "$type" = "Thermostat" ]]; then
	curl -v $userNpassword "${gatewayAPI}devices/${device}/command/exact?level=$value"
	wLog "'${device}'" "Thermostat" "$value"
elif [[ "$type" = "Binary Power Switch" ]]; then
	curl -v $userNpassword "${gatewayAPI}devices/${device}/command/$value"
	wLog "'${device}'" "Binary_Power_Switch" "$value"

elif [[ "$type" = "Routing Multilevel Switch" ]]; then
	wLog "'${device}'" "Routing_Multilevel_Switch" "$value"
	if [ $value = "off" -o $value = "on" ]; then
		curl -v "${gatewayAPI}devices/${device}/command/$value"
	else
		curl -v $userNpassword "${gatewayAPI}devices/${device}/command/on"
		curl -v $userNpassword "${gatewayAPI}devices/${device}/command/exact?level=$value"
	fi
	
elif [[ "$type" = "RXV779" ]]; then
	"${shdir}/_get/set_rxv779.sh" "power" "$value";
	wLog "'${device}'" "RXV779" "$value"

else
	echo "Unknown device"
	wLog "'Unknown_device'" "${device}" "$value"
	exit 1
fi