Skip to content

修复新版 Home Assistant 下车辆定位属性缺失 - #6

Open
shigella520 wants to merge 1 commit into
hasscc:mainfrom
shigella520:codex/fix-device-tracker-gps
Open

修复新版 Home Assistant 下车辆定位属性缺失#6
shigella520 wants to merge 1 commit into
hasscc:mainfrom
shigella520:codex/fix-device-tracker-gps

Conversation

@shigella520

Copy link
Copy Markdown

改动

  • 将车辆定位实体改为写入 Home Assistant 标准的 _attr_latitude_attr_longitude_attr_location_accuracy
  • 保留九号接口返回的 loc.acc,用于填充定位精度。

原因

新版 Home Assistant 不再可靠地从自定义 property 推导 GPS 属性,导致 device_tracker 看不到 source_type: gpslatitudelongitude 等属性,只显示离家状态。

验证

  • python3 -m py_compile custom_components/ninebot/*.py
  • git diff --check origin/main..HEAD

新版 Home Assistant 的 TrackerEntity 在生成状态属性时依赖实体缓存字段。原实现通过动态 property 从 coordinator 数据里读取 latitude/longitude,在部分新版 HA 环境中会导致 device_tracker 状态里缺少 latitude、longitude、source_type 等定位属性。

现在改为在 coordinator 更新时写入 _attr_latitude、_attr_longitude 和 _attr_location_accuracy,让 Home Assistant 按标准 TrackerEntity 逻辑生成 GPS 状态属性。
@shigella520
shigella520 marked this pull request as ready for review June 30, 2026 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant