Hi.
I’m unable to make on_boot work no matter what I do. Even for the copy/paste yaml examples from various websites the validation fails. That seems very strange to me.
Example
Validation fails:
Any ideas on what am I doing wrong?
Thank you
Hi.
I’m unable to make on_boot work no matter what I do. Even for the copy/paste yaml examples from various websites the validation fails. That seems very strange to me.
Example
Validation fails:
Any ideas on what am I doing wrong?
Thank you
Please read section 11 here:
And why wait for WiFi and then wait for MQTT when MQTT will not be available if WiFi is not?
The red lines also indicate a problem, so reading up on the first red line might be a good idea.
As a further hint, yaml indentation and ensuring each yaml node is nested under the correct parent node is critical.
Red squiggles indicate errors so no point validating yaml. Search the documentation but on_boot: needs to be under esphome: and then fix your indentation.
Thank you guys for your replies.
It seems I’m relying on chatgpt a bit too much
I’ve been placing this on_boot code in different places for a while and it does not seem to be working, but now I think I got a breaktrhrough.
esphome:
name: soil
friendly_name: "DIY MORE ESP32 DHT11 Soil Sensor"
# On boot, send an MQTT message and go to deep sleep
on_boot:
priority: -100 # Execute early in the boot sequence
then:
- logger.log: "Device booting up..."
- wait_until:
condition: # any condition here
wifi.connected:
timeout: 8s
- wait_until:
condition: # any condition here
mqtt.connected:
timeout: 8s
# - mqtt.wait_for_connection: # Wait until MQTT is connected
- mqtt.publish:
topic: "my_esp_device/status"
payload: "Device has booted"
- delay: 1s # Ensure the MQTT message is sent before sleeping
esp32:
board: esp32dev
framework:
type: arduino
this works nicely.
Thank you very much