修复新版 Home Assistant 下车辆定位属性缺失 - #6
Open
shigella520 wants to merge 1 commit into
Open
Conversation
新版 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
marked this pull request as ready for review
June 30, 2026 06:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改动
_attr_latitude、_attr_longitude和_attr_location_accuracy。loc.acc,用于填充定位精度。原因
新版 Home Assistant 不再可靠地从自定义 property 推导 GPS 属性,导致
device_tracker看不到source_type: gps、latitude、longitude等属性,只显示离家状态。验证
python3 -m py_compile custom_components/ninebot/*.pygit diff --check origin/main..HEAD