diff options
| -rwxr-xr-x | functions.sh | 24 | 
1 files changed, 24 insertions, 0 deletions
diff --git a/functions.sh b/functions.sh index 857ae55..b24f80b 100755 --- a/functions.sh +++ b/functions.sh @@ -90,6 +90,30 @@ function finctemp() {  	fcurlwithtoken -d "increment=$1" 'https://www.e-thermostaat.nl/processing/temperature' >/dev/null  } +#returns number in [1-4], the selected state +function fgetstate() { +	local page linklist selectedstate +	page="$(fgetthermpage)" +	linklist="$(grep -m 1 -C 4 '<div id="termostat-states">' <<<"$page" | tail -n 4)" +	selectedstate="$(sed 's/.*class="\([^"]*\)".*/\1/' <<<"$linklist" | grep -nm 1 selected | cut -d: -f1)" +	echo $selectedstate +} + +#returns 4 words, the names of the 4 states +function fgetstatenames() { +	local page linklist statenames +	page="$(fgetthermpage)" +	linklist="$(grep -m 1 -C 4 '<div id="termostat-states">' <<<"$page" | tail -n 4)" +	statenames="$(sed 's/.*setState(\("\)\?\([^)&]*\)\("\)\?).*/\2/' <<<"$linklist")" +	echo $statenames +} + +function fgetprogress() { +	fensurelogin +	json="$(fcurlwithtoken 'https://www.e-thermostaat.nl/pages/temperature_progress' | grep -m 1 'var json_data =' | sed 's/[^=]*= *\({.*}\);.*/\1/')" +	echo $json +} +  function fissourced() {  	test ${BASH_SOURCE[0]} != $0  | 
