From b00ba8f34dbc2a943b1943f7193bd32cb9e80d44 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Wed, 10 Apr 2024 10:48:49 -0500 Subject: [PATCH] update --- defaults.inc | 2 +- inc/temp.inc.sh | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/defaults.inc b/defaults.inc index 5171fde8..a90e2fc0 100755 --- a/defaults.inc +++ b/defaults.inc @@ -1,6 +1,6 @@ #!/usr/bin/env bash -VERS='2.6.76-04092024' +VERS='2.6.77-04102024' noheader=' update service dailytemp confsync -r -report ' diff --git a/inc/temp.inc.sh b/inc/temp.inc.sh index 5ba335a6..1404be47 100644 --- a/inc/temp.inc.sh +++ b/inc/temp.inc.sh @@ -612,12 +612,22 @@ CHECKTEMP_SERVICE_RUNSENSOR(){ echo ${PW_THRESHOLDS[${SENSORa}]} | cut -d',' -f 2 | read temp_crit [ "$(echo ${PW_THRESHOLDS[${SENSORa}]} | cut -d',' -f 3)" != "" ] && echo ${PW_THRESHOLDS[${SENSORa}]} | cut -d',' -f 3 | read temp_crit_sys || temp_crit_sys=${temp_crit} fi - + + temp_f='' if [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "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 + elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "esphome" ]; then + if ! temp_c=$(curl -m 8 -s GET -H "Authorization: Bearer ${PW_ESPHOME_API}" http://10.10.1.180:8123/api/states/sensor.${PW_SENSOR_DEVICEID[${SENSORa}]}_temperature | jq -r '.state') ; then TIMEOUT=1; fi + if [ "${temp_c}" != "" ]; then + temp_f=`IDS_NUMBER_FORMAT ${temp_c} 2 yes` + temp_h=`IDS_NUMBER_FORMAT $(curl -m 8 -s GET -H "Authorization: Bearer ${PW_ESPHOME_API}" http://10.10.1.180:8123/api/states/sensor.${PW_SENSOR_DEVICEID[${SENSORa}]}_humidity | jq -r '.state') 2 yes` + else + temp_c='' + fi + elif [ "${PW_SENSOR_TYPE[${1}]}" == "tuya" ]; then IFS=: read -r temp_c temp_h <<< $(GET_TUYA_TEMP ${1}); unset IFS @@ -714,7 +724,7 @@ CHECKTEMP_SERVICE_RUNSENSOR(){ temp_f=$(echo "scale=2; $temp_c/1" | bc -l) elif [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "system" ] && [[ "${SENSOR}" = *"FAN"* ]]; then temp_f=${temp_c} - else + elif [ "${temp_f}" == "" ]; then temp_f=$(bc <<< "scale=2; (${temp_c}*(9/5))+32") fi (( $(bc <<<"${temp_f} < 1") )) && [[ "${temp_f}" = *"."* ]] && temp_f="0${temp_f}"