Fix bug where zones would not be opened/closed when turning on system.
Added -F zonename:temp option to provide fake current zone temperatures for testing.
This commit is contained in:
parent
9a6043f72b
commit
c002091d0e
30
aircon.sh
30
aircon.sh
|
@ -68,6 +68,7 @@ function usage() {
|
||||||
echo " bottoken"
|
echo " bottoken"
|
||||||
echo " chatid"
|
echo " chatid"
|
||||||
echo " -f file Specify an alternate config file."
|
echo " -f file Specify an alternate config file."
|
||||||
|
echo " -F zonename:temp Forcibly provide current zone temperature (for testing)"
|
||||||
echo " -h Show this text."
|
echo " -h Show this text."
|
||||||
echo " -i x.x.x.x Specify IP address for aircon (default is $DEFAULT_AIRCON_IP)"
|
echo " -i x.x.x.x Specify IP address for aircon (default is $DEFAULT_AIRCON_IP)"
|
||||||
echo " -I db Log all zone temperatures to given influxdb database, then exit (see -o)."
|
echo " -I db Log all zone temperatures to given influxdb database, then exit (see -o)."
|
||||||
|
@ -225,7 +226,7 @@ function getzoneaction() { # populates zproblem[] and zaction[]
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if we couldnt turn the system on, there's nothing else to do
|
# if we couldnt turn the system on, there's nothing else to do
|
||||||
if [[ $airconmode == "heat" ]]; then
|
if [[ $airconmode == "heat" || $thisaction == *set_mode:heat* ]]; then
|
||||||
# adjust set temperature, if required
|
# adjust set temperature, if required
|
||||||
if [[ $(echo "${zsettemp[$idx]} > ${zwantmax[$idx]}" | bc) -eq 1 || $(echo "${zsettemp[$idx]} < ${zwantmin[$idx]}" | bc) -eq 1 ]]; then
|
if [[ $(echo "${zsettemp[$idx]} > ${zwantmax[$idx]}" | bc) -eq 1 || $(echo "${zsettemp[$idx]} < ${zwantmin[$idx]}" | bc) -eq 1 ]]; then
|
||||||
# set temperature to midpoint of acceptable range
|
# set temperature to midpoint of acceptable range
|
||||||
|
@ -264,7 +265,7 @@ function getzoneaction() { # populates zproblem[] and zaction[]
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if we couldnt turn the system on, there's nothing else to do
|
# if we couldnt turn the system on, there's nothing else to do
|
||||||
if [[ $airconmode == "cool" ]]; then
|
if [[ $airconmode == "cool" || $thisaction == *set_mode:cool* ]]; then
|
||||||
# adjust set temperature, if required
|
# adjust set temperature, if required
|
||||||
if [[ $(echo "${zsettemp[$idx]} > ${zwantmax[$idx]}" | bc) -eq 1 || $(echo "${zsettemp[$idx]} < ${zwantmin[$idx]}" | bc) -eq 1 ]]; then
|
if [[ $(echo "${zsettemp[$idx]} > ${zwantmax[$idx]}" | bc) -eq 1 || $(echo "${zsettemp[$idx]} < ${zwantmin[$idx]}" | bc) -eq 1 ]]; then
|
||||||
# set temperature to midpoint of acceptable range
|
# set temperature to midpoint of acceptable range
|
||||||
|
@ -2081,8 +2082,9 @@ ALLARGS="$ALLARGS $*"
|
||||||
|
|
||||||
expirenotifyfile=""
|
expirenotifyfile=""
|
||||||
expirenotifytext=""
|
expirenotifytext=""
|
||||||
|
FAKESTRING=""
|
||||||
|
|
||||||
optstring="aA:bcD:e:E:f:g:hHi:I:k:l:Lo:pmRsSt:T:wWy"
|
optstring="aA:bcD:e:E:f:F:g:hHi:I:k:l:Lo:pmRsSt:T:wWy"
|
||||||
while getopts "$optstring" i $ALLARGS; do
|
while getopts "$optstring" i $ALLARGS; do
|
||||||
case "$i" in
|
case "$i" in
|
||||||
a)
|
a)
|
||||||
|
@ -2109,6 +2111,9 @@ while getopts "$optstring" i $ALLARGS; do
|
||||||
f)
|
f)
|
||||||
CONFIGFILE=${OPTARG}
|
CONFIGFILE=${OPTARG}
|
||||||
;;
|
;;
|
||||||
|
F)
|
||||||
|
FAKESTRING="${FAKESTRING} ${OPTARG}"
|
||||||
|
;;
|
||||||
g)
|
g)
|
||||||
USETELEGRAM=1
|
USETELEGRAM=1
|
||||||
TELEGRAM_FILE=${OPTARG}
|
TELEGRAM_FILE=${OPTARG}
|
||||||
|
@ -2244,6 +2249,25 @@ else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# fake input for testing
|
||||||
|
for x in ${FAKESTRING}; do
|
||||||
|
fake_name="${x%%:*}"
|
||||||
|
fake_wanttemp="${x##*:}"
|
||||||
|
fake_idx=-1
|
||||||
|
for zi in ${!zname[@]}; do
|
||||||
|
if [[ ${zname[zi]^^} == ${fake_name^^} ]]; then
|
||||||
|
fake_idx=$zi
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [[ ${fake_idx} -eq -1 ]]; then
|
||||||
|
error "Unknown zone '${fake_name}' in -f argument '${x}'"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
ztemp[$fake_idx]="$fake_wanttemp"
|
||||||
|
info "Faking zone '${fake_name}' temp to ${fake_wanttemp}"
|
||||||
|
done
|
||||||
|
|
||||||
# ping all hosts in background to populate arp table
|
# ping all hosts in background to populate arp table
|
||||||
#for x in ${devices}; do
|
#for x in ${devices}; do
|
||||||
# ping -c1 -w1 -n -q $ip >/dev/null 2>&1 &
|
# ping -c1 -w1 -n -q $ip >/dev/null 2>&1 &
|
||||||
|
|
Loading…
Reference in New Issue