Skip to content

Commit

Permalink
Add state attribute translations
Browse files Browse the repository at this point in the history
  • Loading branch information
dscao authored Apr 6, 2023
1 parent da4add7 commit 440ff08
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 8 deletions.
2 changes: 1 addition & 1 deletion custom_components/autoamap/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@
ATTR_RUNORSTOP = "runorstop"
ATTR_LASTSTOPTIME = "laststoptime"
ATTR_UPDATE_TIME = "update_time"
ATTR_QUERYTIME = "querytime"
ATTR_QUERYTIME = "query_time"
ATTR_PARKING_TIME = "parking_time"
9 changes: 5 additions & 4 deletions custom_components/autoamap/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
class autoamapEntity(TrackerEntity):
"""Representation of a tracker condition."""
_attr_has_entity_name = True
_attr_name = None
#_attr_name = None
_attr_translation_key = "autoamap_device_tracker"
def __init__(self, name, gps_conver, attr_show, coordinator):

self.coordinator = coordinator
Expand All @@ -73,9 +74,9 @@ def __init__(self, name, gps_conver, attr_show, coordinator):
else:
self._coords = [self.coordinator.data["thislon"], self.coordinator.data["thislat"]]

@property
def name(self):
return self._name
# @property
# def name(self):
# return self._name


@property
Expand Down
71 changes: 68 additions & 3 deletions custom_components/autoamap/translations/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"already_configured": "请勿重复配置."
}
},
"options": {
"options": {
"step": {
"user":{
"data": {
Expand All @@ -33,6 +33,71 @@
"description": "设置实体属性是否显示,不显示更简洁,显示内容更丰富。"
}
}
}

},
"entity": {
"device_tracker": {
"autoamap_device_tracker": {
"name": "高德地图车机版",
"state_attributes": {
"speed": {
"name": "当前车速"
},
"course": {
"name": "行车方向"
},
"status": {
"name": "当前状态"
},
"navistatus": {
"name": "导航状态"
},
"macaddr": {
"name": "网卡地址"
},
"lastofflinetime": {
"name": "上次离线时间"
},
"lastonlinetime": {
"name": "上次上线时间"
},
"update_time": {
"name": "更新时间"
},
"query_time": {
"name": "查询时间"
},
"runorstop": {
"name": "运动状态"
},
"laststoptime": {
"name": "上次停止时间"
},
"parking_time": {
"name": "停车时长"
},
"battery": {
"name": "电池电量"
},
"gps_accuracy": {
"name": "GPS精度"
},
"latitude": {
"name": "纬度"
},
"longitude": {
"name": "经度"
},
"source_type": {
"name": "数据源",
"state": {
"bluetooth_le": "低功耗蓝牙",
"bluetooth": "蓝牙",
"gps": "GPS定位",
"router": "路由器"
}
}
}
}
}
}
}

0 comments on commit 440ff08

Please sign in to comment.