Add additional check for API connectivity
This commit is contained in:
parent
cec8d27a4a
commit
b3b9fd7086
@ -249,7 +249,7 @@ script:
|
||||
}
|
||||
|
||||
interval:
|
||||
# Regular state reporting to HASS
|
||||
# Regular occupancy state reporting to HASS every 30s
|
||||
- interval: 30s
|
||||
then:
|
||||
- lambda: |-
|
||||
@ -258,7 +258,7 @@ interval:
|
||||
id(supersensor_occupancy).publish_state(current_state);
|
||||
|
||||
# API watchdog every 5 minutes
|
||||
- interval: 60s
|
||||
- interval: 300s
|
||||
then:
|
||||
- lambda: |-
|
||||
if (api::global_api_server->is_connected()) {
|
||||
@ -268,6 +268,31 @@ interval:
|
||||
App.safe_reboot();
|
||||
}
|
||||
|
||||
# API connectivity check every 5 seconds
|
||||
# Works around bugs in 2025.5.0+ that cause the api on_client_[dis]connect to not work reliably
|
||||
- interval: 5s
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
lambda: 'return api::global_api_server->is_connected();'
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
- switch.is_on: enable_voice_support
|
||||
- !micro_wake_word.is_running
|
||||
then:
|
||||
- micro_wake_word.start:
|
||||
- script.execute: light_off
|
||||
else:
|
||||
- light.turn_on:
|
||||
id: output_led
|
||||
effect: flash_white
|
||||
- if:
|
||||
condition:
|
||||
- switch.is_on: enable_voice_support
|
||||
then:
|
||||
- micro_wake_word.stop:
|
||||
|
||||
logger:
|
||||
level: DEBUG
|
||||
baud_rate: 115200
|
||||
@ -281,23 +306,22 @@ api:
|
||||
- if:
|
||||
condition:
|
||||
- switch.is_on: enable_voice_support
|
||||
- !micro_wake_word.is_running
|
||||
then:
|
||||
- micro_wake_word.start:
|
||||
- script.execute: light_off
|
||||
- delay: 1s
|
||||
- script.execute: light_off
|
||||
on_client_disconnected:
|
||||
- logger.log:
|
||||
format: "Client %s (IP %s) disconnected from API"
|
||||
args: ["client_info.c_str()", "client_address.c_str()"]
|
||||
- light.turn_on:
|
||||
id: output_led
|
||||
effect: flash_white
|
||||
- if:
|
||||
condition:
|
||||
- switch.is_on: enable_voice_support
|
||||
then:
|
||||
- micro_wake_word.stop:
|
||||
- light.turn_on:
|
||||
id: output_led
|
||||
effect: flash_white
|
||||
|
||||
ota:
|
||||
platform: esphome
|
||||
|
Loading…
x
Reference in New Issue
Block a user