I've generated the script below to send values from halpi status to signalk via UDP
I'm wondering if this could be a feature built directly into the daemon? I might find time to attempt a PR in the next few weeks.... but failing that, feel free to implement if you think it is a good idea.
If you don't think this is appropriate for the daemon, then the other approach is to write a signalk-server plugin that does the same (or goes directly to the RESTful API).
#!/usr/bin/env bash
# sk-halpi-delta.sh — push HALPI status as a Signal K delta over UDP
# Usage: ./sk-halpi-delta.sh [host] [port]
# Defaults: host=127.0.0.1 port=55557 (adjust to your Signal K UDP input)
HOST="${1:-127.0.0.1}"
PORT="${2:-10111}"
# Holders
VIN=""; IIN=""; VSC=""; TMCU_K=""; TPCB_K=""
# Parse `halpi status` output (keys are single tokens)
# Example keys include: V_in, I_in, V_supercap, T_mcu, T_pcb, etc.
# (Matches HALPI daemon value names). :contentReference[oaicite:2]{index=2}
while read -r key val unit _; do
# strip possible UTF-8 degree char from unit and spaces
unit_clean=$(echo -n "$unit" | tr -d '[:space:]' | sed 's/°//g')
case "$key" in
V_in) VIN="$val" ;;
I_in) IIN="$val" ;;
V_supercap) VSC="$val" ;;
T_mcu)
# status shows °C; convert to Kelvin for Signal K
TMCU_K=$(awk -v c="$val" 'BEGIN{ printf("%.2f", c + 273.15) }')
;;
T_pcb)
TPCB_K=$(awk -v c="$val" 'BEGIN{ printf("%.2f", c + 273.15) }')
;;
esac
done < <(halpi status)
# Build the Signal K delta JSON
ts=$(date -Is)
src='{"label":"halpi2"}'
values=()
# Map V_in to house battery voltage (volts)
# (Boat battery is your "house" bank here)
if [[ -n "$VIN" ]]; then
values+=("{\"path\":\"electrical.batteries.house.voltage\",\"value\":$VIN}")
fi
# Map I_in to house battery current (amps).
# Note: sign convention depends on install; adjust if you prefer charge/discharge sign flip.
if [[ -n "$IIN" ]]; then
values+=("{\"path\":\"electrical.batteries.house.current\",\"value\":$IIN}")
fi
# Supercap voltage — no standard path; publish under a vendor-ish namespace
if [[ -n "$VSC" ]]; then
values+=("{\"path\":\"electrical.halpi2.supercap.voltage\",\"value\":$VSC}")
fi
# Board temperatures in Kelvin (Signal K uses SI)
if [[ -n "$TMCU_K" ]]; then
values+=("{\"path\":\"electrical.halpi2.temperatures.mcu\",\"value\":$TMCU_K}")
fi
if [[ -n "$TPCB_K" ]]; then
values+=("{\"path\":\"electrical.halpi2.temperatures.pcb\",\"value\":$TPCB_K}")
fi
# Join the values array
vals_json=$(IFS=, ; echo "${values[*]}")
delta=$(cat <<EOF
{"context":"vessels.self",
"updates":[
{"source":$src,
"timestamp":"$ts",
"values":[$vals_json]
}
]
}
EOF
)
# Send over UDP to your Signal K server's UDP input
# (Default UDP input commonly 55557; adjust for your config.)
printf '%s' "$delta" | nc -u -w1 "$HOST" "$PORT"
I've generated the script below to send values from
halpi statusto signalk via UDPI'm wondering if this could be a feature built directly into the daemon? I might find time to attempt a PR in the next few weeks.... but failing that, feel free to implement if you think it is a good idea.
If you don't think this is appropriate for the daemon, then the other approach is to write a signalk-server plugin that does the same (or goes directly to the RESTful API).