GPS altitude gets (really) wrong when moving

Hi,
I’d like to record the altitude of my smartphone used as a device_tracker.
For some reason, the gps altitude looks ok when the phone is not moving. However, when in the car, the altitude gets very wrong (like several kilometers high wrong).
The vertical_accuracy gets to 0 or 1.

I tried to run a GPS app at the same time. The altitude reported by the app is correct and at the same time, the altitude in the hass companion app is wrong.

I enabled high accuracy location, location permissions are set. I cleared the app’s cache and even updated A-GPS info. No change.

My phone is a oneplus 8t.

Does anyone see the same behavior? Is there a way to force to read the altitude in a more precise way?

Thanks!

from the source code of the companion app: the send location update function contains:
</s> <s>altitude = location.altitude.toInt()</s> <s>
which should give a int value.
Interestingly enough, when the altitude value is wrong, I get something like 15766.45 (which is not an int…).

Maybe it gets wrong wly converted when being received by home assistant?

Checked again and it’s an integer as expected.

Generally, the Z or height axis of most GNSS / GPSr is the least accurate measurement, so a bad height measurement is not that surprising when moving in a car. Many outdoors GPSr include a barometer for this very reason (e.g Garmin Oregon, etc). Early GPSr had firmware limits on altitude and speed to prevent certain applications under ITAR, but that’s largely gone these days.

That two Android software programs report different positions is a little more surprising. I was going to suggest checking the “Use precise location” permission but you’ve done that.

My guess is many people use zones more than absolute position so altitude might not be well tested. Android dev is not my thing, but an Integer truncation does seem a bit suspicious - several km out sound like a bad type conversion thrown in.

GitHub issue on the Android app with your debug perhaps?

Interestingly, I checked the person.me state attributes but didn’t see altitude from a Pixel 8:

latitude: 55.*
longitude: -1.*
gps_accuracy: 100

Thanks for the ideas FloatingBoater!
I just found out there is a x100 factor.

when speed=0 → altitude is reported in meter but when speed>0, altitude somehow is reported in centimeter.
Looks strange. I’ll report a bug.

I got the altitude information from a device_tracker.
Like this:
{{state_attr("device_tracker.myphone","altitude")}}
and
{{state_attr("device_tracker.myphone","vertical_accuracy")}}

Ah - that works here too:

device_tracker.pixel_8 state gives...

source_type: gps
latitude: 55.*
longitude: -1.*
gps_accuracy: 100
altitude: 100
course: 0
speed: 0
vertical_accuracy: 100
friendly_name: Pixel 8

A GPSr map app gives my altitude as 51m.