add 'nomyzone' config option to prevent a zone from ever becoming the "myzone".

This commit is contained in:
Rob Pearce 2021-07-01 16:24:15 +10:00
parent 407af3f3e6
commit 6ff51f038e
1 changed files with 45 additions and 27 deletions

View File

@ -432,13 +432,21 @@ function generate_actions() { # populates global: nairconcommands & airconcmd
if [[ -z $powerchange ]]; then if [[ -z $powerchange ]]; then
if [[ $airconmode != "off" ]]; then if [[ $airconmode != "off" ]]; then
mzmustmove=0 mzmustmove=0
# get list of all zones which can't be myzone
nomyzone="" nomyzone=""
for x in ${!zname[@]}; do
if [[ ${znomyzone[$x]} -eq 1 ]]; then
nomyzone="$nomyzone ${zname[$x]} "
fi
done
for x in ${!zname[@]}; do for x in ${!zname[@]}; do
if [[ $airconmyzoneid == ${zid[$x]} || ${zaction[$x]} == *set_myzone* ]]; then if [[ $airconmyzoneid == ${zid[$x]} || ${zaction[$x]} == *set_myzone* ]]; then
if [[ ${zstate[$x]} == "close" || ${zaction[$x]} == *close_vent* ]]; then if [[ ${zstate[$x]} == "close" || ${zaction[$x]} == *close_vent* ]]; then
mzmustmove=1 mzmustmove=1
elif [[ ${zaction[@]} == *close:${zname[$x]}* ]]; then elif [[ ${zaction[@]} == *close:${zname[$x]}* ]]; then
mzmustmove=1 mzmustmove=1
elif [[ ${znomyzone[$x]} -eq 1 ]]; then
mzmustmove=1
fi fi
if [[ $mzmustmove -eq 1 ]]; then if [[ $mzmustmove -eq 1 ]]; then
[[ $db -eq 1 ]] && info "myzone must move away from ${zname[$x]}" [[ $db -eq 1 ]] && info "myzone must move away from ${zname[$x]}"
@ -633,6 +641,13 @@ function addnoop() {
zignore[$idx]=1 zignore[$idx]=1
} }
function addnomyzone() {
local idx
idx=$(getidxfromname "$1")
znomyzone[$idx]=1
}
function addforcevent() { function addforcevent() {
local x idx local x idx
idx=$nforcevents idx=$nforcevents
@ -905,6 +920,8 @@ function load_config() {
fi fi
elif [[ ${tok[0]} == "adj" ]]; then elif [[ ${tok[0]} == "adj" ]]; then
addadj ${tok[1]} ${tok[@]:2} addadj ${tok[1]} ${tok[@]:2}
elif [[ ${tok[0]} == "nomyzone" || ${tok[0]} == "nomy" ]]; then
addnnomyzone ${tok[1]}
elif [[ ${tok[0]} == "noop" || ${tok[0]} == "ignore" ]]; then elif [[ ${tok[0]} == "noop" || ${tok[0]} == "ignore" ]]; then
addnoop ${tok[1]} addnoop ${tok[1]}
elif [[ ${tok[0]} == "force" ]]; then elif [[ ${tok[0]} == "force" ]]; then
@ -981,6 +998,7 @@ function addzone() {
zownerperson[$nzones]=$(getownerperson "$name") zownerperson[$nzones]=$(getownerperson "$name")
#info "zone $name owner is [${zowner[$nzones]}]" #info "zone $name owner is [${zowner[$nzones]}]"
zignore[$nzones]=0 zignore[$nzones]=0
znomyzone[$nzones]=0
zpri[$nzones]=0 zpri[$nzones]=0
wanttemp=$(gettemprange "$name") wanttemp=$(gettemprange "$name")
if [[ $wanttemp == "n/a" ]]; then if [[ $wanttemp == "n/a" ]]; then