#!/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://NTFY_SERVER_IP/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