Update powerwall.sh

This commit is contained in:
2023-05-14 17:04:41 -05:00
parent d33d7c612d
commit db928e6735

View File

@@ -16,31 +16,33 @@ VERBOSE=false
#ssh root@10.5.10.35 '/vmfs/volumes/NFS_ESXi-Vault/esxi-shutdown.sh > /dev/null 2>&1' & > /dev/null 2>&1
CHECKTEMP(){
[ "${1}" != "" ] && SENSORS=("${1}") || SENSORS=SENSOR_ID[@]
for x in "${!SENSOR_ID[@]}"; do printf "[%s]=%s\n" "$x" "${SENSOR_ID[$x]}" ; done
for x in "${!SENSORS[@]}"; do printf "[%s]=%s\n" "$x" "${SENSORS[$x]}" ; done
if [ "${1}" != "" ]; then
CHECKTEMPSENSOR ${1}
else
for SENSOR in ${!SENSOR_ID[@]}; do
echo "HERE: ${SENSOR}-${SENSORS[${SENSOR}]}"
done
fi
for SENSOR in ${!SENSORS}; do
echo "HERE: ${SENSOR}-${SENSORS[${SENSOR}]}"
done
# mqtt_message=`${mqtt_conn} -t tele/${1}/SENSOR -C 1`
# echo $mqtt_message | cut -d':' -f 6 | cut -d',' -f 1 | read temp_c
# if [ "$temp_c" != "null" ] && [ "$temp_c" != "" ]; then
# temp_f=`echo "scale=2; $temp_c*1.8 + 32" | bc`
# #echo "$temp_c -> $temp_f"
#
# echo ${TEMP_THRESHOLDS[${1}]} | cut -d',' -f 1 | read temp_warn
# echo ${TEMP_THRESHOLDS[${1}]} | cut -d',' -f 2 | read temp_crit
#
# if [ $(bc -l <<< "$temp_f >= $temp_warn") -eq 1 ] && [ $(bc -l <<< "$temp_f < $temp_crit") -eq 1 ]; then
# echo "WARNING: $temp_f°F"
# elif [ $(bc -l <<< "$temp_f >= $temp_crit") -eq 1 ]; then
# echo "CRITICAL: $temp_f°F"
# else
# echo "normal: $temp_f°F"
# fi
# fi
}
CHECKTEMPSENSOR()}{
mqtt_message=`${mqtt_conn} -t tele/${1}/SENSOR -C 1`
echo $mqtt_message | cut -d':' -f 6 | cut -d',' -f 1 | read temp_c
if [ "$temp_c" != "null" ] && [ "$temp_c" != "" ]; then
temp_f=`echo "scale=2; $temp_c*1.8 + 32" | bc`
#echo "$temp_c -> $temp_f"
echo ${TEMP_THRESHOLDS[${1}]} | cut -d',' -f 1 | read temp_warn
echo ${TEMP_THRESHOLDS[${1}]} | cut -d',' -f 2 | read temp_crit
if [ $(bc -l <<< "$temp_f >= $temp_warn") -eq 1 ] && [ $(bc -l <<< "$temp_f < $temp_crit") -eq 1 ]; then
echo "WARNING: $temp_f°F"
elif [ $(bc -l <<< "$temp_f >= $temp_crit") -eq 1 ]; then
echo "CRITICAL: $temp_f°F"
else
echo "normal: $temp_f°F"
fi
fi
}
CHECKTEMP_SERVICE(){