我的水平也就能对付esphome,没有时间精力折腾mqtt了,不过我分析了一下,原因可能处在:
我的两个wifi接入点上
wifi:
networks:
- ssid: !secret wifi_ssid1
password: !secret wifi_password
- ssid: !secret wifi_ssid2
password: !secret wifi_password
manual_ip:
static_ip: 192.168.123.XXX
gateway: 192.168.123.1
subnet: 255.255.255.0
reboot_timeout: 180s
但我也不想删除,目前使用api断联触发来处理:
api:
reboot_timeout: 300s
on_client_disconnected:
then:
- lambda: |-
if (id(my_dis_int) < 10) {
id(my_dis_int) += 1;
} else {
id(my_dis_int) += 0;
id(rest).press();
}
ESP_LOGD("tag", "%s: %d", id(my_dis_int));
- script.stop: reset_num
# - logger.log: "API client disconnected!"
on_client_connected:
script.execute: reset_num
globals:
- id: my_dis_int
type: int
restore_value: no
initial_value: '0'
script:
- id: reset_num
then:
- delay: 60s
- if:
condition:
for:
time: 60s
condition:
- api.connected:
then:
- globals.set:
id: my_dis_int
value: '0'
设置全局变量,初始值为0,每次断联加1,直到10次断联自动复位esp32,不知道这样行不行,刚刷上,还没试过行不行 |