From d189c2cc66c8de474c6e685b4b26f0ca31a9b7dd Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Thu, 22 Aug 2024 22:09:01 -0500 Subject: [PATCH] update --- defaults.inc | 2 +- inc/temp.inc.sh | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/defaults.inc b/defaults.inc index 882694eb..030e2c6a 100755 --- a/defaults.inc +++ b/defaults.inc @@ -1,6 +1,6 @@ #!/usr/bin/env bash -VERS='2.7.91-08222024' +VERS='2.7.92-08222024' noheader=' update service dailytemp confsync -r -report test ' diff --git a/inc/temp.inc.sh b/inc/temp.inc.sh index cf7fbd94..e9f2614e 100644 --- a/inc/temp.inc.sh +++ b/inc/temp.inc.sh @@ -914,21 +914,27 @@ CHECKTEMP_SERVICE_RUNSENSOR(){ fi temp_f='' - if [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "mqtt" ]; then + 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 - elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "esphome" ]; then - if ! temp_c=$(curl -m 5 -s GET -H "Authorization: Bearer ${PW_ESPHOME_API}" ${PW_HOMEASSISTANT_URL}/api/states/sensor.${PW_SENSOR_DEVICEID[${SENSORa}]}_temperature | jq -r '.state') ; then TIMEOUT=1; fi + elif [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "esphome" ]; then + if ! temp_c=$(curl -m 5 -s GET -H "Authorization: Bearer ${PW_ESPHOME_API}" ${PW_HOMEASSISTANT_URL}/api/states/sensor.${PW_SENSOR_DEVICEID[${SENSOR}]}_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 5 -s GET -H "Authorization: Bearer ${PW_ESPHOME_API}" ${PW_HOMEASSISTANT_URL}/api/states/sensor.${PW_SENSOR_DEVICEID[${SENSORa}]}_humidity | jq -r '.state') 2 yes` + temp_h=`IDS_NUMBER_FORMAT $(curl -m 5 -s GET -H "Authorization: Bearer ${PW_ESPHOME_API}" ${PW_HOMEASSISTANT_URL}/api/states/sensor.${PW_SENSOR_DEVICEID[${SENSOR}]}_humidity | jq -r '.state') 2 yes` else temp_c='' fi - - elif [ "${PW_SENSOR_TYPE[${1}]}" == "tuya" ]; then + + elif [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "espdev" ]; then + if ! temp_c=$(curl -m 8 -s http://${PW_REMOTE_SENSORS[${SENSOR}]}:8090/sensor/${PW_SENSOR_DEVICEID[${SENSOR}]} | jq '.value'); then TIMEOUT=1; fi + if [ "${temp_c}" != "" ]; then + temp_h=`IDS_NUMBER_FORMAT $(curl -m 8 -s http://${PW_REMOTE_SENSORS[${SENSOR}]}:8090/sensor/${PW_SENSOR_DEVICEID[${SENSOR}]/temperature/humidity} | jq '.value') 2 yes` + fi + + elif [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "tuya" ]; then IFS=: read -r temp_c temp_h <<< $(GET_TUYA_TEMP ${1}); unset IFS elif [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "lacrosse" ]; then @@ -940,7 +946,7 @@ CHECKTEMP_SERVICE_RUNSENSOR(){ temp_h=`IDS_NUMBER_FORMAT $(echo ${INFO} | jq -r '.device0 .obs[].humidity') 2 yes` fi - elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "system" ]; then + elif [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "system" ]; then if [[ "${SENSOR}" = *"CPU"* ]]; then temp_c=$(vcgencmd measure_temp) temp_c=${temp_c%\'*}; temp_c=${temp_c#*=} @@ -953,12 +959,12 @@ CHECKTEMP_SERVICE_RUNSENSOR(){ # fi fi - elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "remotesystem" ]; then + elif [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "remotesystem" ]; then temp_c=$(ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${PW_REMOTE_SENSORS[${SENSOR}]} vcgencmd measure_temp) temp_c=${temp_c%\'*}; temp_c=${temp_c#*=} temp_h='' - elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "esxi" ]; then + elif [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "esxi" ]; then temp_c=$(snmpwalk -v 1 -c public -t 2 ${PW_HOST_IDRACS[${SENSORa}]} .1.3.6.1.4.1.674.10892.5.4.700.20.1.6.1.${t} -O vq | sed -e 's/"//g') temp_c=`echo "scale=1; ${temp_c}/10" | bc` temp_warn=$(snmpwalk -v 1 -c public -t 2 ${PW_HOST_IDRACS[${SENSORa}]} .1.3.6.1.4.1.674.10892.5.4.700.20.1.11.1.${t} -O vq | sed -e 's/"//g')