The Mifi address is 192.168.1.1. I enabled the built in GPS stream on port 10110. Below is the shell command that an automation calls every 30 minutes when the camper is away from home.
#!/bin/bash
GPSLOC="` curl -s --http0.9 192.168.1.1:10110 --output - | grep -a GPGGA -m 1 | cut -d, -f 3-10 `"
GPSLAT="` echo $GPSLOC | cut -d, -f 1 `"
GPSNS="` echo $GPSLOC | cut -d, -f 2 `"
GPSLON="` echo $GPSLOC | cut -d, -f 3 `"
GPSEW="` echo $GPSLOC | cut -d, -f 4 `"
GPSALT="` echo $GPSLOC | cut -d, -f 8 `"
if [[ $GPSNS =~ "S" ]]; then GPSLAT=`echo "0-$GPSLAT" | bc`; fi
if [[ $GPSEW =~ "W" ]]; then GPSLON=`echo "0-$GPSLON" | bc`; fi
GPSLAT=`echo "($GPSLAT/100)+(($GPSLAT%100)*.016666667)" | bc`
GPSLON=`echo "($GPSLON/100)+(($GPSLON%100)*.016666667)" | bc`
GPSALT=`echo "($GPSALT-1.8)/1" | bc`
printf '{"latitude":"%s","longitude":"%s","altitude":"%s"}\n' "$GPSLAT" "$GPSLON" "$GPSALT"
The automation runs this command with a response variable “gps_response”:
The next step of the automation is a set_location action using this response variable:
Edit: The shell script above subtracts 1.8m from the altitude because that’s approximately how high the Mifi is typically above ground level.