用esp32s3和tft显示天气,原来一直很正常,这几天就是解析不出数据了,请问大家遇到没有?
log:
web能看到json数据:
{
"code": "200",
"updateTime": "2023-04-15T21:07+08:00",
"fxLink": "https://www.qweather.com/weather/lixia-101120107.html",
"now": {
"obsTime": "2023-04-15T20:58+08:00",
"temp": "15",
"feelsLike": "11",
"icon": "151",
"text": "多云",
"wind360": "70",
"windDir": "东北风",
"windScale": "2",
"windSpeed": "8",
"humidity": "35",
"precip": "0.0",
"pressure": "985",
"vis": "20",
"cloud": "91",
"dew": "1"
},
"refer": {
"sources": [
"QWeather",
"NMC",
"ECMWF"
],
"license": [
"CC BY-SA 4.0"
]
}
}
yaml文件代码:
esphome:
name: out-display-weather
friendly_name: out-display
on_boot: #断电启动时,先获取一次实时天气
priority: -200
then:
- http_request.get:
# 和风天气 实时
url: https://devapi.qweather.com/v7/weather/now?location=******&key=*******************&gzip=n
verify_ssl: false
headers:
Content-Type: application/json
on_response:
then:
- lambda: |-
json::parse_json(id(http_request_data).get_string(), [](JsonObject root) {
JsonObject now2 = root["now"];
const char* now_temp2 = now2["temp"];
id(weather_now_temp).publish_state(now_temp2);
});
哪里出了问题?请大家给出提示。
|