Ich verwende jetzt das unten stehende Script "warp" zum testen
warp -h zeigt die usage
Usage: warp [options]
Options:
-h, --help Show this help message
-i, --info show API info
-u, --update [value] Update meter value
warp -i
warp -i
see https://docs.warp-charger.com/docs/api_reference
version: 2.7.8+67efdb29
meter1: Netz
meter1 value: 74 - Summe der Phasenwirkleistungen (Bezug - Einspeisung)
warp -u 1200 setzt z.B. die aktuelle Leistung auf 1200 Watt der Zähler zeigt das dann auch an
warp -u 1200
✅:1200
Fehler werden angezeigt z.B.
warp -u 1200a
❌:Failed to deserialize: JSON payload could not be parsed
#!/bin/bash
# WF 2025-04-18
docs=https://docs.warp-charger.com/docs/api_reference
wallbox=http://wallbox.bitplan.com
#ansi colors
#http://www.csc.uvic.ca/~sae/seng265/fall04/tips/s265s047-tips/bash-using-colors.html
blue='\033[0;34m'
red='\033[0;31m'
green='\033[0;32m' # '\e[1;32m' is too bright for white bg.
endColor='\033[0m'
#
# a colored message
# params:
# 1: l_color - the color of the message
# 2: l_msg - the message to display
#
color_msg() {
local l_color="$1"
local l_msg="$2"
echo -e "${l_color}$l_msg${endColor}"
}
# Function to display negative messages
negative() {
local l_msg="$1"
color_msg $red "❌:$l_msg"
}
# Function to display positive messages
positive() {
local l_msg="$1"
color_msg $green "✅:$l_msg"
}
# call the wallbox API with the given command
# and filter the json result with given jq filter
# params
# #1: cmd - the api command
# #2: filter - the jq filter
api() {
local l_cmd="$1"
local l_filter="$2"
curl -s $wallbox/$l_cmd | jq -r "$l_filter"
}
# call the wallbox API with the given command
# and filter the json result with given jq filter
# show result with the given label
# params
# #1: label - the title label
# #2: cmd - the api command
# #3: filter - the jq filter
show_api() {
local l_label="$1"
local l_cmd="$2"
local l_filter="$3"
printf "%s: " "$l_label"
api "$l_cmd" "$l_filter"
}
# explain what a value_id means
explain_value_id() {
local l_value_id=$1
local l_explanation=""
case $l_value_id in
1) l_explanation="Spannung L1-N" ;;
2) l_explanation="Spannung L2-N" ;;
3) l_explanation="Spannung L3-N" ;;
4) l_explanation="Spannung L1-L2" ;;
5) l_explanation="Spannung L2-L3" ;;
6) l_explanation="Spannung L3-L1" ;;
7) l_explanation="Durchschnittliche Phasenspannung" ;;
8) l_explanation="Durchschnitt Spannung L1-L2, L2-L3, L3-L1" ;;
13|17|21) l_explanation="Strom (Bezug + Einspeisung)" ;;
25) l_explanation="Neutralleiterstrom" ;;
29) l_explanation="Durchschnitt der Phasenströme" ;;
33) l_explanation="Summe der Phasenströme" ;;
39|48|57) l_explanation="Wirkleistung (Bezug - Einspeisung)" ;;
74) l_explanation="Summe der Phasenwirkleistungen (Bezug - Einspeisung)" ;;
83|91|99) l_explanation="Blindleistung (induktiv - kapazitiv)" ;;
115) l_explanation="Summe der Phasenblindleistungen" ;;
122|130|138) l_explanation="Scheinleistung (Bezug + Einspeisung)" ;;
154) l_explanation="Summe der Phasenscheinleistungen" ;;
209) l_explanation="Wirkenergie Bezug (seit Herstellung)" ;;
210) l_explanation="Wirkenergie Bezug (seit letztem Zurücksetzen)" ;;
211) l_explanation="Wirkenergie Einspeisung (seit Herstellung)" ;;
212) l_explanation="Wirkenergie Einspeisung (seit letztem Zurücksetzen)" ;;
213) l_explanation="Wirkenergie Bezug + Einspeisung (seit Herstellung)" ;;
214) l_explanation="Wirkenergie Bezug + Einspeisung (seit letztem Zurücksetzen)" ;;
277) l_explanation="Blindenergie induktiv + kapazitiv (seit Herstellung)" ;;
353|354|355) l_explanation="Leistungsfaktor (gerichtet)" ;;
356) l_explanation="Summe der gerichteten Leistungsfaktoren" ;;
364) l_explanation="Netzfrequenz" ;;
*) l_explanation="Unknown value_id" ;;
esac
echo "$l_explanation"
}
# print usage information
usage() {
echo "Usage: $(basename $0) [options]"
echo "Options:"
echo " -h, --help Show this help message"
echo " -i, --info show API info"
echo " -u, --update [value] Update meter value"
exit 1
}
#
# show API infos
#
info() {
echo "see $docs"
show_api version info/version '.firmware'
show_api meter1 meters/1/config '.[1].display_name'
first_value_id=$(api meters/1/config '.[1].value_ids[0]')
first_value=$(explain_value_id $first_value_id)
printf "meter1 value: %s - %s\n" "$first_value_id" "$first_value"
}
# Update meter values function
# params
# #1: value - the value to set (should be an array of values)
update_meter() {
local l_value="$1"
local l_result=$(curl -s -X POST "$wallbox/meters/1/update" \
-d "[$l_value]")
if [ -z "$l_result" ]; then
positive "$l_value Watt set"
else
negative "$l_result"
fi
}
# handle command line options
while [ "$1" != "" ]; do
option="$1"
case $option in
-h|--help)
usage
;;
-u|--update)
shift
value="$1"
if [ "$value" = "" ]; then
echo "Error: Missing value for update"
usage
fi
# Update meter value
update_meter "$value"
# Add update functionality here
;;
-i|--info)
info
;;
*)
echo "Unknown option: $option"
usage
;;
esac
shift
done