Update powerwall.sh
This commit is contained in:
16
powerwall.sh
16
powerwall.sh
@@ -163,10 +163,12 @@ CHECKTEMP_SERVICE(){
|
||||
|
||||
fi
|
||||
|
||||
SENSORS_CHECK=(${SENSOR})
|
||||
if [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "mqtt" ]; then
|
||||
mqtt_message=`${mqtt_conn} -t tele/${SENSOR}/SENSOR -C 1`
|
||||
echo $mqtt_message | cut -d':' -f 7 | cut -d',' -f 1 | read temp_h
|
||||
echo $mqtt_message | cut -d':' -f 6 | cut -d',' -f 1 | read temp_c
|
||||
SENSORS_CHECK=(${SENSOR})
|
||||
|
||||
elif [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "system" ]; then
|
||||
temp_c=$(vcgencmd measure_temp)
|
||||
@@ -178,8 +180,12 @@ CHECKTEMP_SERVICE(){
|
||||
temp_c=${temp_c%\'*}; temp_c=${temp_c#*=}
|
||||
temp_h=''
|
||||
|
||||
# elif [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "esxi" ]; then
|
||||
|
||||
|
||||
fi
|
||||
|
||||
for SENSOR in ${SENSORS_CHECK[@]}; do
|
||||
|
||||
datetime=`date +'%Y-%m-%d %H:%M:%S'`
|
||||
logtemp=${PW_LOGFOLDER}/log-temp-${SENSOR}
|
||||
@@ -258,8 +264,8 @@ CHECKTEMP_SERVICE(){
|
||||
[ "$(compgen -G "${PW_FOLDER}/shutdown.*")" != "" ] && rm -f ${PW_FOLDER}/shutdown.*
|
||||
|
||||
elif [ ${last_temp[${SENSOR}]} -eq 0 ]; then
|
||||
SENDNOTICE "${SENSOR} TEMP NORMAL" "($datetime) Service Startup
|
||||
NORMAL TEMP: ${temp_f}'F"
|
||||
# SENDNOTICE "${SENSOR} TEMP NORMAL" "($datetime) Service Startup
|
||||
# NORMAL TEMP: ${temp_f}'F"
|
||||
echo -e "($datetime) - ${temp_f}'F - Service Startup - NORMAL TEMP" >> ${logtemp}
|
||||
echo -e "($datetime) - ${temp_f}'F - ${SENSOR} - Service Startup" >> ${PW_LOGFILE}
|
||||
[ "$(compgen -G "${PW_FOLDER}/shutdown.*")" != "" ] && rm -f ${PW_FOLDER}/shutdown.*
|
||||
@@ -284,8 +290,8 @@ CHECKTEMP_SERVICE(){
|
||||
else
|
||||
QRY="USE servermonitor; INSERT INTO sensor_data (\`sensorid\`, \`date\`, \`temp\`) VALUES ('${PW_SENSOR_ID[${SENSOR}]}','${datetime}','${temp_f}')"
|
||||
fi
|
||||
${mysql_conn} -e "${QRY}"
|
||||
touch ${PW_TMPFOLDER}/${SENSOR}.insert
|
||||
# ${mysql_conn} -e "${QRY}"
|
||||
# touch ${PW_TMPFOLDER}/${SENSOR}.insert
|
||||
fi
|
||||
else
|
||||
if [ ! -f ${PW_TMPFOLDER}/${SENSOR}-error.reading ] || [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/${SENSOR}-error.reading)) -ge 1800 ]; then
|
||||
@@ -296,6 +302,8 @@ CHECKTEMP_SERVICE(){
|
||||
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
else #sensor down
|
||||
if [ ! -f ${PW_TMPFOLDER}/${SENSOR}.down ] || [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/${SENSOR}.down)) -ge 1800 ]; then
|
||||
SENDNOTICE "${SENSOR} ERROR" "${SENSOR} Sensor is down" 1
|
||||
|
||||
Reference in New Issue
Block a user