From d9dbe39a529f72798eaddf90c07144b2eb8091ce Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sat, 19 Jul 2025 09:16:53 -0500 Subject: [PATCH] update --- defaults.inc | 2 +- inc/power.inc.sh | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/defaults.inc b/defaults.inc index b98e045f..2ee7c831 100755 --- a/defaults.inc +++ b/defaults.inc @@ -1,6 +1,6 @@ #!/usr/bin/env bash -PW_VERS='2.11.20-07132025' +PW_VERS='2.12.1a-07192025' noheader=' update service dailytemp confsync -r -report test ' diff --git a/inc/power.inc.sh b/inc/power.inc.sh index 7ef34cf7..6cb2e6f1 100644 --- a/inc/power.inc.sh +++ b/inc/power.inc.sh @@ -486,7 +486,7 @@ CHECKPOWER(){ declare -A OFFSITE_MISC for mSENSOR in "${PW_POWERSENSOR_MISC[@]}"; do - OFFSITE_MISC[${mSENSOR}]=$(GET_TUYA_POWER ${mSENSOR}) + OFFSITE_MISC[${mSENSOR}]=$(GET_KASA_POWER ${mSENSOR}) done fi @@ -1702,6 +1702,15 @@ GET_TUYA_POWER(){ fi } +GET_KASA_POWER(){ + INFO=$(/usr/local/bin/kasa --type strip --json --verbose --host ${PW_REMOTE_SENSORS[${1}]} energy --child-index ${PW_SENSOR_DEVICEID[${1}]}) + if [ "${INFO}" != "" ]; then + AMP=$(echo $(echo "scale=2; $(echo ${INFO} | jq '.current_ma')/1000" | tr -d $'\r' | bc -l)) + WATT=$(echo $(echo "scale=2; $(echo ${INFO} | jq '.power_mw')/1000" | tr -d $'\r' | bc -l)) + VOLT=$(echo $(echo "scale=2; $(echo ${INFO} | jq '.voltage_mv')/1000" | tr -d $'\r' | bc -l)) + echo "${AMP}:${WATT}:${VOLT}" + fi +}