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