本帖最后由 dscao 于 2021-1-28 00:10 编辑
直接在rest中处理的,不知如何来替换。
sensor:
- platform: rest
name: youjia
resource: http://restcore.gooddriver.cn/API/Values/HudDeviceDetail/XXXXX
scan_interval: 60
headers:
Host: restcore.gooddriver.cn
SDF: XXXXXXXXXXXXXXXXXXXXX
Accept: \*/\*
User-Agent: gooddriver/.7.1 CFNetwork/1209 Darwin/20.2.0
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
Connection: keep-alive
# json_attributes_path: "$.MESSAGE.HD_RECENT_LOCATION"
# json_attributes:
# - \Lng
# - \Lat
# - \Course
# - \Speed
value_template: >-
{% if value_json.ERROR_CODE == 0 %}
有效
{% else %}
无效
{% endif %}
json_attributes:
- MESSAGE
- platform: template
sensors:
car_time:
value_template: '{{ states.sensor.youjia.attributes.MESSAGE.HD_RECENT_LOCATION.Time }}' #取不到值
|