Killfile can now contain a unixtime, after which it expires.
This commit is contained in:
parent
7dc7a660e3
commit
091aa8aa17
24
aircon.sh
24
aircon.sh
|
@ -66,7 +66,9 @@ function usage() {
|
||||||
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)."
|
||||||
echo " -k file If file exists, never change aircon settings (default: $DEFAULT_KILLFILE)."
|
echo " -k file If file exists and is empty, never change aircon settings (default: $DEFAULT_KILLFILE)."
|
||||||
|
echo " If file is non-empty, never change aircon settings if current unixtime < file contents."
|
||||||
|
echo " File will be removed if current unixtime >= file contents."
|
||||||
echo " -l num Set number of too hot/cold zones at which to taking action."
|
echo " -l num Set number of too hot/cold zones at which to taking action."
|
||||||
echo " -L Log all zone temperatures to CSV file, then exit (see -o)."
|
echo " -L Log all zone temperatures to CSV file, then exit (see -o)."
|
||||||
echo " -m Generate a config file based on current aircon setup."
|
echo " -m Generate a config file based on current aircon setup."
|
||||||
|
@ -1698,13 +1700,29 @@ function show_analysis() {
|
||||||
[[ $count -eq 0 ]] && echo -e "${GREEN}All is good!${PLAIN}"
|
[[ $count -eq 0 ]] && echo -e "${GREEN}All is good!${PLAIN}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function killfile_active() { # returns true if killfile swill stop us
|
||||||
|
local val now
|
||||||
|
if [[ ! -f ${KILLFILE} ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
val=$(cat "${KILLFILE}")
|
||||||
|
[[ -z $val ]] && return 1
|
||||||
|
now=$(date +%s)
|
||||||
|
if [[ $val -le $now ]]; then
|
||||||
|
# killfile expired
|
||||||
|
rm -f "${KILLFILE}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
function show_proposed_commands() {
|
function show_proposed_commands() {
|
||||||
local str x maxlen count cmdformat fullcmd
|
local str x maxlen count cmdformat fullcmd
|
||||||
str="Proposed commands"
|
str="Proposed commands"
|
||||||
echo -e "${UNDERLINE}${str}:${PLAIN}"
|
echo -e "${UNDERLINE}${str}:${PLAIN}"
|
||||||
|
|
||||||
if [[ $nairconcommands -gt 0 ]]; then
|
if [[ $nairconcommands -gt 0 ]]; then
|
||||||
if [[ -f ${KILLFILE} ]]; then
|
if killfile_active; then
|
||||||
echo -e "${RED}Not running commands because killfile exists ($KILLFILE)${PLAIN}"
|
echo -e "${RED}Not running commands because killfile exists ($KILLFILE)${PLAIN}"
|
||||||
elif [[ $DOIT -ne 1 ]]; then
|
elif [[ $DOIT -ne 1 ]]; then
|
||||||
echo -e "${RED}Not running commands because -y not specified${PLAIN}"
|
echo -e "${RED}Not running commands because -y not specified${PLAIN}"
|
||||||
|
@ -2197,7 +2215,7 @@ fi
|
||||||
|
|
||||||
# Actually run the commands
|
# Actually run the commands
|
||||||
if [[ $DOIT -eq 1 ]]; then
|
if [[ $DOIT -eq 1 ]]; then
|
||||||
if [[ ! -f ${KILLFILE} ]]; then
|
if ! killfile_active; then
|
||||||
run_commands
|
run_commands
|
||||||
[[ $cronmode -ne 1 ]] && echo
|
[[ $cronmode -ne 1 ]] && echo
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue