I live in an RV, would love to be able to track the home on map, trigger on locations and whatnot. I have 15 minute updates based on reading location from the Android App, but that thing feels ‘glitchy’, works sometimes and then suddenly not - regardless of settings.
now I found a way to get a “NMEA 0183” stream coming through a serial port, (not Bluetooth though, but USB)
So now, next step:
Is there any NMEA parsing helpers, or whatever?
A search for “NMEA”, “GPS” - or anything else I can think of - turns up nothing.
This entity (‘sensor.bt_gps_02’) does not have a unique ID, therefore its settings cannot be managed from the UI. See the documentation for more detail.
" id: ‘BT_GPS_02’ " is apparently not the way to go there…
Here, simple python to read such lines (via stdin) and print the corresponding text that makes google maps accept the lat/lon.
import sys
header,utc,status,lat,latdir,lon,londir,speedKn,tracktrue, \
date,magvar,vardir,modeind,chksum=range(13+1)
for line in sys.stdin:
line=line.split(',')
lat=line[lat]
lon=line[lon]
lat=float(lat[:2])+float(lat[2:])/60
lon=float(lon[:3])+float(lon[3:])/60
print(lat,line[latdir],lon,line[londir])
Hmm… second portion of lat and lon are floats, so all “int” → “float” likely required.
Now i have this set in “automations.yaml” with sensor.bt_gps_02 for sensor.YOUR_SERIAL_SENSOR - it is OK for CHECK CONFIGURATION - remains to see if it needs more amending
Note: there are other lines as well in the serial readout. The lines with $GPRMC,225446,A,4916.45,N,12311.12,W,000.5,054.7,191194,020.3,E*68
… are just part of it, but the actual ones having the lat/lon.
Will the above ignore those other lines, or might it be necessary to skip them?
I’ll try it out the following days and “report back” after that!
The serial port setup, connected physically to the Rpi4, a bluetooth capable GPS, which apparently also sends out NMEA 0183 -code via the USB-cable, in serial-port -form.:
sensor:
- platform: serial
serial_port: /dev/ttyUSB1
name: BT-GPS-01
baudrate: 9600
bytesize: 8
parity: N
stopbits: 1
xonxoff: false
xonxoff: false
Have had this running for a while.
It does it’s thing, and very well so… but with several updates per second.
What I’d change is to have it update only as either of lat or lon changes a suitable amount, e.g. corresponding to 15 meters (~45 feet).
That corresponds somewhat to lat value changing 0.00005, and/or lon value changing 0.0001 - for a simplistic check.
Now, this is growing in complexity; might it be a better approach to split it into parts, e.g. to make the GPS readout a more versatile separate sensor? Then a separate “movement sensor” using the simplistic approach (above). And finally use them for the home-movement?
What would be a reasonable approach?
in all this - I am in a process of attempting to build my understanding of home assistant infrastructure, which admittedly is very low still.
I get frustrated when simple things as naming an entity gets stopped with “Invalid Entity ID” even though I try very simple name(s), e.g. corresponding to a variable name in python, with no indication of WHAT the problem is.
Eh, and there I got stuck; where do I go (in HA) to get this done?
Clicking on Settings > Quick Search gives me nothing for ‘template’ or ‘sensor’, do I need to copy this into any of the .yaml files?
I have wandered over many places in the documentation and not caught it - basic stuff, heh?