diff options
author | tomsmeding <tom.smeding@gmail.com> | 2016-01-13 22:22:51 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2016-01-13 22:22:51 +0100 |
commit | 394acb2a3c198dfa678153b2cad064af3f1fc810 (patch) | |
tree | 40468ebdb4b51e2f036ab03d30e7c7439fa9b1b4 | |
parent | 150f751aba6fb7b6697a65441d10ba29b96df021 (diff) |
get state, get graph data
-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 |