Powering off system when closing the last remaining zone and it being the constant zone now works correctly.
This commit is contained in:
parent
ac9addde30
commit
ee7751ffd5
33
aircon.sh
33
aircon.sh
|
@ -497,14 +497,17 @@ function generate_actions() { # populates global: nairconcommands & airconcmd
|
|||
# pass xx - if we're closing the constant zone, and it's NOT the myzone,
|
||||
# just turn the whole system off (since it will probably be opened.
|
||||
# again anyway).
|
||||
#
|
||||
if [[ -z $powerchange && $airconmode != "off" ]]; then
|
||||
for x in ${!zname[@]}; do
|
||||
if [[ ${zaction[$x]} == *close_vent* && $constant == ${zname[$x]} ]]; then
|
||||
if [[ ${zaction[$x]} == *close_vent* ]]; then
|
||||
if [[ $constant == ${zname[$x]} ]]; then
|
||||
if [[ $airconmyzoneid != ${zid[$x]} ]]; then
|
||||
zaction[$x]="power_off"
|
||||
[[ -z $powerchange ]] && powerchange="power_off"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
|
@ -619,9 +622,22 @@ function generate_actions() { # populates global: nairconcommands & airconcmd
|
|||
gen_aircon_command ${x} ${zaction[$x]}
|
||||
fi
|
||||
done
|
||||
|
||||
# if we are closing the constant zone and taking no other action,
|
||||
# just turn the system off.
|
||||
if [[ $nairconcommands -eq 1 ]]; then
|
||||
if [[ ${airconjcmd[0]} == *lose* ]]; then
|
||||
if [[ ${airconcmdzone[0]} == $constant ]]; then
|
||||
globprob="constant_close"
|
||||
globaction="power_off"
|
||||
[[ -z $powerchange ]] && powerchange="power_off"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [[ -n $globaction ]]; then
|
||||
gen_aircon_command -1 ${globaction}
|
||||
fi
|
||||
|
||||
[[ $cronmode -eq 0 && $logmode -eq 0 ]] && echo -e "${GREEN}${BOLD}ok${PLAIN}"
|
||||
}
|
||||
|
||||
|
@ -1542,6 +1558,15 @@ function get_aircon_info() {
|
|||
[[ $cronmode -eq 0 && $logmode -eq 0 ]] && echo -en "${GREEN}${BOLD}>> ${PLAIN}${GREEN}Querying aircon... ${PLAIN}"
|
||||
url="${AIRCON_URL}/getSystemData"
|
||||
jsoninfo=$(curl -s "$url" 2>/dev/null)
|
||||
if [[ $? -ne 0 ]]; then
|
||||
error "get_aircon_info() failed to reach ${AIRCON_URL}/getSystemData endpoint"
|
||||
exit 1;
|
||||
fi
|
||||
echo "$jsoninfo" | jq . &>/dev/null
|
||||
if [[ $? -ne 0 ]]; then
|
||||
error "${AIRCON_URL}/getSystemData returned bad json: $jsoninfo"
|
||||
exit 1;
|
||||
fi
|
||||
zones=$(echo "$jsoninfo" | $JQ -r '.aircons.ac1.zones[] | [ .name, .state, .setTemp, .measuredTemp, .number ] | @csv' | tr -d '" ')
|
||||
state=$(echo "$jsoninfo" | $JQ -r '.aircons.ac1.info.state' | tr -d '" ')
|
||||
if [[ $state == "off" ]]; then
|
||||
|
@ -1555,6 +1580,10 @@ url="${AIRCON_URL}/getSystemData"
|
|||
IFS=',' read -ra tok <<< "$line"
|
||||
addzone "${tok[0]}" "${tok[1]}" "${tok[2]}" "${tok[3]}" "${tok[4]}"
|
||||
done
|
||||
if [[ $nzones -eq 0 ]]; then
|
||||
error "get_aircon_info() found no zones"
|
||||
exit 1;
|
||||
fi
|
||||
airconmyzone=$(getnamefromid $airconmyzoneid)
|
||||
[[ $cronmode -eq 0 && $logmode -eq 0 ]] && echo -e "${GREEN}${BOLD}ok${PLAIN}"
|
||||
profile "query aircon"
|
||||
|
@ -1674,6 +1703,8 @@ function describe_globprob() {
|
|||
echo "$limit or more zones are ${globprob/_/ }"
|
||||
elif [[ $globprob == "not_needed" ]]; then
|
||||
echo "The system is on but all zones at optimal temperature"
|
||||
elif [[ $globprob == "constant_close" ]]; then
|
||||
echo "All other zones are already closed"
|
||||
else
|
||||
echo "_unknown_globprob_:$globprob"
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue