Update temp.inc.sh
This commit is contained in:
@@ -352,11 +352,21 @@ CHECKTEMPSENSOR(){
|
||||
|
||||
TIMEOUT=0
|
||||
temp_h=0
|
||||
temp_f=''
|
||||
if [ "${PW_SENSOR_TYPE[${1}]}" == "mqtt" ]; then
|
||||
if ! mqtt_message=`${mqtt_conn} -t tele/${1}/SENSOR -C 1` ; then TIMEOUT=1; fi
|
||||
echo ${mqtt_message} | cut -d':' -f 6 | cut -d',' -f 1 | read temp_c
|
||||
echo ${mqtt_message} | cut -d':' -f 7 | cut -d',' -f 1 | read temp_h
|
||||
|
||||
elif [ "${PW_SENSOR_TYPE[${1}]}" == "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[${1}]}_temperature) ; 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[${1}]}_humidity) 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
|
||||
|
||||
@@ -415,7 +425,7 @@ CHECKTEMPSENSOR(){
|
||||
temp_f=$(echo "scale=2; $temp_c/1" | bc -l)
|
||||
elif [ "${PW_SENSOR_TYPE[${1}]}" == "system" ] && [[ "${1}" = *"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}"
|
||||
|
||||
Reference in New Issue
Block a user