update
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
VERS='2.161-08122023'
|
VERS='2.162-08122023'
|
||||||
|
|
||||||
noheader=' update service dailytemp '
|
noheader=' update service dailytemp '
|
||||||
|
|
||||||
|
|||||||
40
powerwall.sh
40
powerwall.sh
@@ -59,11 +59,14 @@ CHECKTEMPSENSOR(){
|
|||||||
temp_c=${temp_c%\'*}; temp_c=${temp_c#*=}
|
temp_c=${temp_c%\'*}; temp_c=${temp_c#*=}
|
||||||
|
|
||||||
elif [ "${SENSOR_TYPE[${1}]}" == "remotesystem" ]; then
|
elif [ "${SENSOR_TYPE[${1}]}" == "remotesystem" ]; then
|
||||||
|
if [ "$(CHECK_HOST ${REMOTE_SENSORS[${1}]})" != "false" ]; then
|
||||||
temp_c=$(ssh root@${REMOTE_SENSORS[${1}]} vcgencmd measure_temp)
|
temp_c=$(ssh root@${REMOTE_SENSORS[${1}]} vcgencmd measure_temp)
|
||||||
temp_c=${temp_c%\'*}; temp_c=${temp_c#*=}
|
temp_c=${temp_c%\'*}; temp_c=${temp_c#*=}
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$temp_c" != "null" ] && [ "$temp_c" != "" ]; then
|
if [ "$temp_c" != "null" ] && [ "$temp_c" != "" ]; then
|
||||||
temp_f=`echo "scale=2; $temp_c*1.8 + 32" | bc`
|
temp_f=`echo "scale=2; $temp_c*1.8 + 32" | bc`
|
||||||
#echo "$temp_c -> $temp_f"
|
#echo "$temp_c -> $temp_f"
|
||||||
@@ -117,6 +120,14 @@ CHECKTEMP_SERVICE(){
|
|||||||
errtime=$(expr `date +%s` - $(stat -c %Y ${logtemp}))
|
errtime=$(expr `date +%s` - $(stat -c %Y ${logtemp}))
|
||||||
[ $errtime -ge 3600 ] && relog=1 || relog=0
|
[ $errtime -ge 3600 ] && relog=1 || relog=0
|
||||||
|
|
||||||
|
if [ "$(CHECK_HOST ${REMOTE_SENSORS[${1}]})" != "false" ]; then
|
||||||
|
if [ -f ${TMPFOLDER}/${SENSOR}.down ]; then
|
||||||
|
SENDNOTICE "${SENSOR} Online" "${SENSOR} is back online"
|
||||||
|
echo "($datetime) - ${SENSOR} - ${SENSOR} is back onlione" >> ${logtemp}
|
||||||
|
rm -f ${TMPFOLDER}/${SENSOR}.down
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "${SENSOR_TYPE[${SENSOR}]}" == "mqtt" ]; then
|
if [ "${SENSOR_TYPE[${SENSOR}]}" == "mqtt" ]; then
|
||||||
mqtt_message=`${mqtt_conn} -t tele/${SENSOR}/SENSOR -C 1`
|
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 7 | cut -d',' -f 1 | read temp_h
|
||||||
@@ -126,10 +137,22 @@ CHECKTEMP_SERVICE(){
|
|||||||
temp_c=$(vcgencmd measure_temp)
|
temp_c=$(vcgencmd measure_temp)
|
||||||
temp_c=${temp_c%\'*}; temp_c=${temp_c#*=}
|
temp_c=${temp_c%\'*}; temp_c=${temp_c#*=}
|
||||||
temp_h=''
|
temp_h=''
|
||||||
|
|
||||||
|
elif [ "${SENSOR_TYPE[${SENSOR}]}" == "remotesystem" ]; then
|
||||||
|
temp_c=$(ssh root@${REMOTE_SENSORS[${1}]} vcgencmd measure_temp)
|
||||||
|
temp_c=${temp_c%\'*}; temp_c=${temp_c#*=}
|
||||||
|
temp_h=''
|
||||||
|
|
||||||
fi
|
fi
|
||||||
datetime=`date +'%Y-%m-%d %H:%M:%S'`
|
datetime=`date +'%Y-%m-%d %H:%M:%S'`
|
||||||
|
|
||||||
if [ "$temp_c" != "null" ] && [ "$temp_c" != "" ]; then
|
if [ "$temp_c" != "null" ] && [ "$temp_c" != "" ]; then
|
||||||
|
if [ -f ${TMPFOLDER}/${SENSOR}-error.reading ]; then
|
||||||
|
SENDNOTICE "${SENSOR} Data" "${SENSOR} is reporting data again"
|
||||||
|
echo "($datetime) - ${SENSOR} - ${SENSOR} is reporting data again" >> ${logtemp}
|
||||||
|
rm -f ${TMPFOLDER}/${SENSOR}-error.reading
|
||||||
|
|
||||||
|
fi
|
||||||
temp_f=`echo "scale=2; $temp_c*1.8 + 32" | bc`
|
temp_f=`echo "scale=2; $temp_c*1.8 + 32" | bc`
|
||||||
|
|
||||||
echo ${TEMP_THRESHOLDS[${SENSOR}]} | cut -d',' -f 1 | read temp_warn
|
echo ${TEMP_THRESHOLDS[${SENSOR}]} | cut -d',' -f 1 | read temp_warn
|
||||||
@@ -221,8 +244,21 @@ NORMAL TEMP: ${temp_f}'F"
|
|||||||
touch ${TMPFOLDER}/${SENSOR}.insert
|
touch ${TMPFOLDER}/${SENSOR}.insert
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
SENDNOTICE "${SENSOR} ERROR" "($datetime) ERROR reading temperature" 1
|
if [ ! -f ${TMPFOLDER}/${SENSOR}-error.reading ] || [ $(expr `date +%s` - $(stat -c %Y ${TMPFOLDER}/${SENSOR}-error.reading)) -ge 1800 ]; then
|
||||||
echo "($datetime) - alert sent" >> ${logtemp}
|
SENDNOTICE "${SENSOR} ERROR" "($datetime) ERROR reading sensor data" 1
|
||||||
|
echo "($datetime) - ${SENSOR} - ERROR reading sensor data" >> ${logtemp}
|
||||||
|
touch ${TMPFOLDER}/${SENSOR}-error.reading
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
if [ ! -f ${TMPFOLDER}/${SENSOR}.down ] || [ $(expr `date +%s` - $(stat -c %Y ${TMPFOLDER}/${SENSOR}.down)) -ge 1800 ]; then
|
||||||
|
SENDNOTICE "${SENSOR} ERROR" "${SENSOR} is down" 1
|
||||||
|
echo "($datetime) - ${SENSOR} - ${SENSOR} is down" >> ${logtemp}
|
||||||
|
touch ${TMPFOLDER}/${SENSOR}.down
|
||||||
|
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user