我终于学会这个了
esphome:
name: "test"
friendly_name: "test"
esp8266:
board: esp12e
captive_portal:
logger:
mqtt:
broker: !secret mqtt_ip
username: !secret mqtt_username
password: !secret mqtt_password
ota:
password: "xxxxxxxxxxxxxxx"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: "test Fallback Hotspot"
password: ""
http_request:
id: http_request_data
timeout: 20s
text_sensor:
- platform: template
name: "IP"
id: ip
lambda: |-
return {"正在获取..."};
update_interval: never
interval:
- interval: 5min
then:
- http_request.get:
url: "https://myip.ipip.net/json"
verify_ssl: false
on_response:
then:
- lambda: |-
json::parse_json(id(http_request_data).get_string(), [](JsonObject root) {
id(ip).publish_state(root["data"]["ip"]);
});
显示效果:
|