added axpert inverter alert script

This commit is contained in:
andrea.noni 2024-04-16 17:35:42 +02:00
parent 20563bbd57
commit c9b45eb4a5
1 changed files with 25 additions and 0 deletions

25
axpert_grid_offline.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
### This script connects to a axpert inverter, using https://github.com/b48736/axpert-monitor
### It checks if the grid power is "on", and in case it's not alerts the server and informs about the battery percentage status and loads
topicurl=https://172.26.0.15/hangar_servers
GRID_STATUS=$(/usr/local/bin/axpert-query -c QPIGS | grep "gridVoltage" | awk '{print substr($2, 1, length($2)-1)}')
BATTERY_STATUS=$(/usr/local/bin/axpert-query -c QPIGS | grep "batteryCapacity" | awk '{print substr($2, 1, length($2)-1)}')
OUTPUT_LOAD=$(/usr/local/bin/axpert-query -c QPIGS | grep "outputLoadPercent" | awk '{print substr($2, 1, length($2)-1)}')
OUTPUT_APPARENT=$(/usr/local/bin/axpert-query -c QPIGS | grep "outputPowerApparent" | awk '{print substr($2, 1, length($2)-1)}')
OUTPUT_TRUE=$(/usr/local/bin/axpert-query -c QPIGS | grep "outputPowerActive" | awk '{print substr($2, 1, length($2)-1)}')
if [ ${GRID_STATUS} = 0 ]; then
curl -k --retry 3 \
-d "Grid power loss in Axpert Inverter, electrical problem! " \
-d "Lithium battery charge percentage: $BATTERY_STATUS % " \
-d "Output load percentage: $OUTPUT_LOAD % " \
-d "Output load apparent: $OUTPUT_APPARENT VA " \
-d "Output load true: $OUTPUT_TRUE P " \
-H "Title: grid power loss in Axpert Inverter" \
-H "Priority: urgent" \
-H "Tags: rotating_light,boar" \
$topicurl
fi