Light.turn_off in on_shutdown is erroring - or is my ESP32-S3 faulty?

UPDATE: As per post #6 I think my ESP32-S3 is faulty - it is not executing all the code in on_boot: and on_shutdown:

I’m starting to try out deep sleep.
My ESP32-S3 dev board has a programmable LED on board, and I can turn it on, off, change colour etc through yaml code.

I thought to turn the LED on when the ESP32 wakes up (in esphome: on_boot:) and turn it off in the on_shutdown: routine - an easy way to tell whether the ESP is awake.

# To control the greenhouse I have an ESP32-S3-DevKitC-1 (v1) board with ESP32-S3-WROOM-1-N16R8 chip
# THIS IS SERIOUSLY CUT BACK TO MINIMUM FOR TESTING

substitutions:
  devicename:     "greenhouse"
  deviceIP:       "97"                     # last octet of the IP Address
  update_interval_sensor:  "3 min"        # How often to measure and report sensor values

logger:
  level: VERBOSE

esp32:
  board: esp32-s3-devkitc-1
  variant: esp32s3
  flash_size: 16MB
  framework:
    type: esp-idf
    version: recommended

esphome:
  name: $devicename
  platformio_options:
    board_build.flash_mode: dio 
  on_boot: 
    then:
    - light.turn_on:
        id: rgb_led
        red: 0%
        green: 100%
        blue: 0%
        brightness: 20%
    - logger.log: "##### on_boot finished" 
  on_shutdown:                #Includes deep sleep
    - priority: -100          # before everything else
      then:
        - light.turn_off: rgb_led
        - delay: 2s
    - priority: 900          # before everything else
      then:
        - logger.log: "##### on_shutdown finished" 

deep_sleep: 
  id: deep_sleep_1
  run_duration:   5 min   # how long to run (be awake)
  sleep_duration: 5 min   # how long to sleep for

light:
  - platform: esp32_rmt_led_strip
    name: $devicename RGB LED
    id: rgb_led
    rgb_order: GRB
    pin: GPIO48
    num_leds: 1
    rmt_channel: 0
    chipset: ws2812

sensor:
  - platform: dht
    model: DHT22
    pin: GPIO6
    temperature:
      name: $devicename Control box Temperature
    humidity:
      name: $devicename Control box Humidity
    update_interval: $update_interval_sensor

Except that is NOT what is happening.
The LED is turning on green when the ESP32 starts up, and “[D][main:506]: ##### on_boot finished” shows in the log - but this appears to be before wi-fi is connected.

Then in the on_shutdown the log shows the LED being turned off before “[D][main:525]: ##### on_shutdown finished”. However the LED is still on when the ESP goes to sleep.

The Log shown in ESPHome Builder does not show my logger.log messages, so to get more detailed information I have connected to the USB log; which shows

[D][esphome.ota:293]: Progress: 54.1%
[D][esphome.ota:293]: Progress: 73.0%
[D][esphome.ota:293]: Progress: 92.1%
[V][esp-idf:000]: I (18692) esp_image: segment 0: paddr=001d0020 vaddr=3c0b0020 size=3235ch (205660) map

[V][esp-idf:000]: I (18716) esp_image: segment 1: paddr=00202384 vaddr=3fc99700 size=044cch ( 17612) 

[V][esp-idf:000]: I (18719) esp_image: segment 2: paddr=00206858 vaddr=40374000 size=097c0h ( 38848) 

[V][esp-idf:000]: I (18724) esp_image: segment 3: paddr=00210020 vaddr=42000020 size=ab808h (702472) map

[V][esp-idf:000]: I (18802) esp_image: segment 4: paddr=002bb830 vaddr=4037d7c0 size=0bea8h ( 48808) 

[V][esp-idf:000]: I (18809) esp_image: segment 5: paddr=002c76e0 vaddr=600fe000 size=0005ch (    92) 

[V][esp-idf:000]: I (18810) esp_image: segment 6: paddr=002c7744 vaddr=600fe05c size=00008h (     8) 

[V][esp-idf:000]: I (18811) esp_image: segment 0: paddr=001d0020 vaddr=3c0b0020 size=3235ch (205660) map

[V][esp-idf:000]: I (18834) esp_image: segment 1: paddr=00202384 vaddr=3fc99700 size=044cch ( 17612) 

[V][esp-idf:000]: I (18838) esp_image: segment 2: paddr=00206858 vaddr=40374000 size=097c0h ( 38848) 

[V][esp-idf:000]: I (18843) esp_image: segment 3: paddr=00210020 vaddr=42000020 size=ab808h (702472) map

[V][esp-idf:000]: I (18920) esp_image: segment 4: paddr=002bb830 vaddr=4037d7c0 size=0bea8h ( 48808) 

[V][esp-idf:000]: I (18927) esp_image: segment 5: paddr=002c76e0 vaddr=600fe000 size=0005ch (    92) 

[V][esp-idf:000]: I (18928) esp_image: segment 6: paddr=002c7744 vaddr=600fe05c size=00008h (     8) 

[I][esphome.ota:326]: Update complete
[W][component:170]: Component esphome.ota cleared Warning flag
[I][app:132]: Rebooting safely...
[D][esp32.preferences:114]: Saving 1 preferences to flash...
[V][esp32.preferences:126]: sync: key: 233825507, len: 4
[D][esp32.preferences:142]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[D][light:036]: 'greenhouse RGB LED' Setting:
[D][light:047]:   State: OFF
[D][light:085]:   Transition length: 1.0s
[D][main:641]: ##### on_shutdown finished
[V][esp-idf:000][wifi]: I (19168) wifi:
[V][esp-idf:000][wifi]: state: run -> init (0)
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (19170) wifi:
[V][esp-idf:000][wifi]: pm stop, total sleep time: 8512981 us / 17647993 us

[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (19171) wifi:
[V][esp-idf:000][wifi]: <ba-del>idx:0, tid:0
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (19172) wifi:
[V][esp-idf:000][wifi]: new:<13,0>, old:<13,0>, ap:<255,255>, sta:<13,0>, prof:1
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (19205) wifi:
[V][esp-idf:000][wifi]: flush txq
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (19206) wifi:
[V][esp-idf:000][wifi]: stop sw txq
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (19207) wifi:
[V][esp-idf:000][wifi]: lmac stop hw txq
[V][esp-idf:000][wifi]: 

ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x40377e4b
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x43c
load:0x403c9700,len:0xbec
load:0x403cc700,len:0x2a3c
entry 0x403c98d8
I (197) cpu_start: Multicore app
I (197) cpu_start: Pro cpu up.
I (198) cpu_start: Starting app cpu, entry point is 0x40377450
I (0) cpu_start: App cpu up.
I (208) cpu_start: Pro cpu start user code
I (208) cpu_start: cpu freq: 160000000 Hz
I (208) cpu_start: Application information:
I (209) cpu_start: Project name:     greenhouse
I (209) cpu_start: App version:      2024.12.4
I (209) cpu_start: Compile time:     Feb 18 2025 11:20:12
I (209) cpu_start: ELF file SHA256:  f850eb98e9e7b106...
I (210) cpu_start: ESP-IDF:          5.1.5
I (210) cpu_start: Min chip rev:     v0.0
I (210) cpu_start: Max chip rev:     v0.99 
I (210) cpu_start: Chip rev:         v0.2
I (210) heap_init: Initializing. RAM available for dynamic allocation:
I (211) heap_init: At 3FCA19F0 len 00047D20 (287 KiB): DRAM
I (211) heap_init: At 3FCE9710 len 00005724 (21 KiB): STACK/DRAM
I (211) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (212) heap_init: At 600FE064 len 00001F84 (7 KiB): RTCRAM
I (213) spi_flash: detected chip: generic
I (213) spi_flash: flash io: dio
W (213) spi_flash: Detected size(16384k) larger than the size in the binary image header(4096k). Using the size in th.
W (214) rmt(legacy): legacy driver is deprecated, please migrate to `driver/rmt_tx.h` and/or `driver/rmt_rx.h`
I (214) sleep: Configure to isolate all GPIO pins in sleep state
I (215) sleep: Enable automatic switching of GPIO sleep configuration
I (215) app_start: Starting scheduler on CPU0
I (215) app_start: Starting scheduler on CPU1
I (215) main_task: Started on CPU0
I (216) main_task: Calling app_main()
I (297) main_task: Returned from app_main()
[I][logger:171]: Log initialized
[C][safe_mode:079]: There have been 0 suspected unsuccessful boot attempts
[D][esp32.preferences:114]: Saving 1 preferences to flash...
[V][esp32.preferences:126]: sync: key: 233825507, len: 4
[D][esp32.preferences:142]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[I][app:029]: Running through setup()...
[V][app:030]: Sorting components by setup priority...
[C][esp32_rmt_led_strip:021]: Setting up ESP32 LED Strip...
[C][light:021]: Setting up light 'greenhouse RGB LED'...
[D][light:036]: 'greenhouse RGB LED' Setting:
[D][light:041]:   Color mode: RGB
[D][light:085]:   Transition length: 1.0s
[D][light:036]: 'greenhouse RGB LED' Setting:
[D][light:047]:   State: ON
[D][light:051]:   Brightness: 20%
[D][light:058]:   Red: 0%, Green: 100%, Blue: 0%
[D][light:085]:   Transition length: 1.0s
[D][main:506]: ##### on_boot finished
[C][dht:011]: Setting up DHT...
[V][esp-idf:000]: I (328) gpio: GPIO[6]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 

[V][text_sensor:013]: 'greenhouse ESPHome Version': Received new state 2024.12.4 Feb 18 2025, 11:20:05
[D][text_sensor:064]: 'greenhouse ESPHome Version': Sending state '2024.12.4 Feb 18 2025, 11:20:05'
[C][wifi:048]: Setting up WiFi...
[V][esp-idf:000]: I (331) pp: pp rom version: e7ae62f

[V][esp-idf:000]: I (332) net80211: net80211 rom version: e7ae62f

[V][esp-idf:000]: I (334) wifi:
[V][esp-idf:000]: wifi driver task: 3fcaf168, prio:23, stack:6656, core=0
[V][esp-idf:000]: 

[V][esp-idf:000][wifi]: I (339) wifi:
[V][esp-idf:000][wifi]: wifi firmware version: bbd58fc31
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (340) wifi:
[V][esp-idf:000][wifi]: wifi certification version: v7.0
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (341) wifi:
[V][esp-idf:000][wifi]: config NVS flash: enabled
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (342) wifi:
[V][esp-idf:000][wifi]: config nano formating: disabled
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (343) wifi:
[V][esp-idf:000][wifi]: Init data frame dynamic rx buffer num: 32
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (345) wifi:
[V][esp-idf:000][wifi]: Init static rx mgmt buffer num: 5
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (346) wifi:
[V][esp-idf:000][wifi]: Init management short buffer num: 32
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (347) wifi:
[V][esp-idf:000][wifi]: Init dynamic tx buffer num: 32
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (348) wifi:
[V][esp-idf:000][wifi]: Init static tx FG buffer num: 2
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (349) wifi:
[V][esp-idf:000][wifi]: Init static rx buffer size: 1600
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (350) wifi:
[V][esp-idf:000][wifi]: Init static rx buffer num: 10
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (351) wifi:
[V][esp-idf:000][wifi]: Init dynamic rx buffer num: 32
[V][esp-idf:000][wifi]: 

[V][esp-idf:000]: I (353) wifi_init: rx ba win: 6

[V][esp-idf:000]: I (353) wifi_init: tcpip mbox: 32

[V][esp-idf:000]: I (354) wifi_init: udp mbox: 6

[V][esp-idf:000]: I (354) wifi_init: tcp mbox: 6

[V][esp-idf:000]: I (355) wifi_init: tcp tx win: 5760

[V][esp-idf:000]: I (355) wifi_init: tcp rx win: 5760

[V][esp-idf:000]: I (355) wifi_init: tcp mss: 1440

[V][esp-idf:000]: I (356) wifi_init: WiFi IRAM OP enabled

[V][esp-idf:000]: I (356) wifi_init: WiFi RX IRAM OP enabled

[C][wifi:061]: Starting WiFi...
[C][wifi:062]:   Local MAC: 98:3D:AE:EB:24:F4
[V][esp32.preferences:059]: nvs_get_blob('2623382305'): ESP_ERR_NVS_NOT_FOUND - the key might not be set yet
[V][wifi_esp32:222]: Enabling STA.
[V][esp-idf:000][wifi]: I (359) phy_init: phy_version 680,a6008b2,Jun  4 2024,16:41:10

[V][esp-idf:000][wifi]: W (396) phy_init: saving new calibration data because of checksum failure, mode(0)

[V][esp-idf:000][wifi]: I (552) wifi:
[V][esp-idf:000][wifi]: mode : sta (98:3d:ae:eb:24:f4)
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (553) wifi:
[V][esp-idf:000][wifi]: enable tsf
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (555) wifi:
[V][esp-idf:000][wifi]: Set ps type: 1, coexist: 0

[V][esp-idf:000][wifi]: 

[V][esp32.preferences:059]: nvs_get_blob('2623382305'): ESP_ERR_NVS_NOT_FOUND - the key might not be set yet
[I][wifi:313]: WiFi Connecting to 'dagoba'...
[V][wifi:315]: Connection Params:
[V][wifi:316]:   SSID: 'dagoba'
[V][wifi:321]:   BSSID: Not Set
[V][wifi:349]:   Password: 'gt49lkxyzzy'
[V][wifi:356]:   Channel: Not Set
[V][wifi:360]:   Manual IP: Static IP=192.168.1.97 Gateway=192.168.1.1 Subnet=255.255.255.0 DNS1=0.0.0.0 DNS2=0.0.0.0
[V][wifi:365]:   Hidden: NO
[V][esp-idf:000][wifi]: W (561) wifi:
[V][esp-idf:000][wifi]: Password length matches WPA2 standards, authmode threshold changes from OPEN to WPA2
[V][esp-idf:000][wifi]: 

[V][sensor:043]: 'greenhouse Uptime': Received new state 0.565000
[D][sensor:093]: 'greenhouse Uptime': Sending state 0.56500 s with 0 decimals of accuracy
[D][dht:048]: Got Temperature=24.7°C Humidity=52.5%
[V][sensor:043]: 'greenhouse Control box Temperature': Received new state 24.700001
[D][sensor:093]: 'greenhouse Control box Temperature': Sending state 24.70000 °C with 1 decimals of accuracy
[V][sensor:043]: 'greenhouse Control box Humidity': Received new state 52.500000
[D][sensor:093]: 'greenhouse Control box Humidity': Sending state 52.50000 % with 0 decimals of accuracy
[V][wifi_esp32:668]: Event: WiFi STA start
[V][esp-idf:000][wifi]: I (574) wifi:
[V][esp-idf:000][wifi]: Set ps type: 1, coexist: 0

[V][esp-idf:000][wifi]: 

[W][component:157]: Component wifi set Warning flag: associating to network
[V][esp-idf:000][wifi]: I (3454) wifi:
[V][esp-idf:000][wifi]: new:<13,0>, old:<1,0>, ap:<255,255>, sta:<13,0>, prof:1
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (3456) wifi:
[V][esp-idf:000][wifi]: state: init -> auth (b0)
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (3459) wifi:
[V][esp-idf:000][wifi]: state: auth -> assoc (0)
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (3465) wifi:
[V][esp-idf:000][wifi]: state: assoc -> run (10)
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (3479) wifi:
[V][esp-idf:000][wifi]: connected with dagoba, aid = 2, channel 13, BW20, bssid = 64:66:b3:ed:08:c4
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (3480) wifi:
[V][esp-idf:000][wifi]: security: WPA2-PSK, phy: bgn, rssi: -58
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (3482) wifi:
[V][esp-idf:000][wifi]: pm start, type: 1

[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (3483) wifi:
[V][esp-idf:000][wifi]: dp: 1, bi: 102400, li: 3, scale listen interval from 307200 us to 307200 us
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][wifi]: I (3484) wifi:
[V][esp-idf:000][wifi]: set rx beacon pti, rx_bcn_pti: 0, bcn_timeout: 25000, mt_pti: 0, mt_time: 10000
[V][esp-idf:000][wifi]: 

[V][esp-idf:000][sys_evt]: I (3486) esp_netif_handlers: sta ip: 192.168.1.97, mask: 255.255.255.0, gw: 192.168.1.1

[V][wifi_esp32:694]: Event: Connected ssid='dagoba' bssid=64:66:B3:ED:08:C4 channel=13, authmode=WPA2 PSK
[V][wifi_esp32:724]: Event: Got IP static_ip=192.168.1.97 gateway=192.168.1.1
[I][wifi:617]: WiFi Connected!
[C][wifi:428]:   Local MAC: 98:3D:AE:EB:24:F4
[C][wifi:433]:   SSID: 'dagoba'
[C][wifi:436]:   IP Address: 192.168.1.97
[C][wifi:439]:   BSSID: 64:66:B3:ED:08:C4
[C][wifi:441]:   Hostname: 'greenhouse'
[C][wifi:443]:   Signal strength: -58 dB ▂▄▆█
[C][wifi:447]:   Channel: 13
[C][wifi:448]:   Subnet: 255.255.255.0
[C][wifi:449]:   Gateway: 192.168.1.1
[C][wifi:450]:   DNS1: 0.0.0.0
[C][wifi:451]:   DNS2: 0.0.0.0
[D][wifi:626]: Disabling AP...
[D][wifi:776]: Saved fast_connect wifi settings
[C][web_server:100]: Setting up web server...
[C][api:026]: Setting up Home Assistant API server...
[C][deep_sleep:013]: Setting up Deep Sleep...
[I][deep_sleep:018]: Scheduling Deep Sleep to start in 300000 ms
[I][app:062]: setup() finished successfully!
[V][sensor:043]: 'greenhouse Wifi signal': Received new state -58.000000
[D][sensor:093]: 'greenhouse Wifi signal': Sending state -58.00000 dBm with 0 decimals of accuracy
[W][component:170]: Component wifi cleared Warning flag
[W][component:157]: Component api set Warning flag: unspecified
[I][app:100]: ESPHome version 2024.12.4 compiled on Feb 18 2025, 11:20:05
[C][wifi:600]: WiFi:
[C][wifi:428]:   Local MAC: 98:3D:AE:EB:24:F4
[C][wifi:433]:   SSID: 'dagoba'
[C][wifi:436]:   IP Address: 192.168.1.97
[C][wifi:439]:   BSSID: 64:66:B3:ED:08:C4
[C][wifi:441]:   Hostname: 'greenhouse'
[C][wifi:443]:   Signal strength: -58 dB ▂▄▆█
[C][wifi:447]:   Channel: 13
[C][wifi:448]:   Subnet: 255.255.255.0
[C][wifi:449]:   Gateway: 192.168.1.1
[C][wifi:450]:   DNS1: 0.0.0.0
[C][wifi:451]:   DNS2: 0.0.0.0
[C][logger:185]: Logger:
[C][logger:186]:   Level: VERBOSE
[C][logger:188]:   Log Baud Rate: 115200
[C][logger:189]:   Hardware UART: USB_SERIAL_JTAG
[C][uptime.sensor:033]: Uptime Sensor 'greenhouse Uptime'
[C][uptime.sensor:033]:   Device Class: 'duration'
[C][uptime.sensor:033]:   State Class: 'total_increasing'
[C][uptime.sensor:033]:   Unit of Measurement: 's'
[C][uptime.sensor:033]:   Accuracy Decimals: 0
[C][uptime.sensor:033]:   Icon: 'mdi:timer-outline'
[V][uptime.sensor:033]:   Unique ID: '983daeeb24f4-uptime'
[C][uptime.sensor:034]:   Type: Seconds
[V][esp-idf:000][wifi]: I (3568) wifi:
[V][esp-idf:000][wifi]: AP's beacon interval = 102400 us, DTIM period = 1
[V][esp-idf:000][wifi]: 

[C][template.text_sensor:020]: Template Sensor 'greenhouse Uptime Human Readable'
[C][template.text_sensor:020]:   Icon: 'mdi:clock-start'
[C][esp32_rmt_led_strip:187]: ESP32 RMT LED Strip:
[C][esp32_rmt_led_strip:188]:   Pin: 48
[C][esp32_rmt_led_strip:189]:   Channel: 0
[C][esp32_rmt_led_strip:214]:   RGB Order: GRB
[C][esp32_rmt_led_strip:215]:   Max refresh rate: 0
[C][esp32_rmt_led_strip:216]:   Number of LEDs: 1
[C][light:092]: Light 'greenhouse RGB LED'
[C][light:094]:   Default Transition Length: 1.0s
[C][light:095]:   Gamma Correct: 2.80
[C][dht:017]: DHT:
[C][dht:018]:   Pin: GPIO6
[C][dht:024]:   Model: DHT22 (or equivalent)
[C][dht:027]:   Update Interval: 180.0s
[C][dht:029]:   Temperature 'greenhouse Control box Temperature'
[C][dht:029]:     Device Class: 'temperature'
[C][dht:029]:     State Class: 'measurement'
[C][dht:029]:     Unit of Measurement: '°C'
[C][dht:029]:     Accuracy Decimals: 1
[C][dht:030]:   Humidity 'greenhouse Control box Humidity'
[C][dht:030]:     Device Class: 'humidity'
[C][dht:030]:     State Class: 'measurement'
[C][dht:030]:     Unit of Measurement: '%'
[C][dht:030]:     Accuracy Decimals: 0
[C][version.text_sensor:021]: Version Text Sensor 'greenhouse ESPHome Version'
[C][version.text_sensor:021]:   Icon: 'mdi:new-box'
[V][version.text_sensor:021]:   Unique ID: '983daeeb24f4-version'
[C][captive_portal:089]: Captive Portal:
[C][web_server:153]: Web Server:
[C][web_server:154]:   Address: 192.168.1.97:80
[C][mdns:116]: mDNS:
[C][mdns:117]:   Hostname: greenhouse
[V][mdns:118]:   Services:
[V][mdns:120]:   - _esphomelib, _tcp, 6053
[V][mdns:122]:     TXT: version = 2024.12.4
[V][mdns:122]:     TXT: mac = 983daeeb24f4
[V][mdns:122]:     TXT: platform = ESP32
[V][mdns:122]:     TXT: board = esp32-s3-devkitc-1
[V][mdns:122]:     TXT: network = wifi
[V][mdns:122]:     TXT: api_encryption = Noise_NNpsk0_25519_ChaChaPoly_SHA256
[V][mdns:120]:   - _http, _tcp, 80
[C][esphome.ota:073]: Over-The-Air updates:
[C][esphome.ota:074]:   Address: 192.168.1.97:3232
[C][esphome.ota:075]:   Version: 2
[C][safe_mode:018]: Safe Mode:
[C][safe_mode:019]:   Boot considered successful after 60 seconds
[C][safe_mode:021]:   Invoke after 10 boot attempts
[C][safe_mode:022]:   Remain in safe mode for 300 seconds
[C][api:140]: API Server:
[C][api:141]:   Address: 192.168.1.97:6053
[C][api:143]:   Using noise encryption: YES
[C][wifi_signal.sensor:010]: WiFi Signal 'greenhouse Wifi signal'
[C][wifi_signal.sensor:010]:   Device Class: 'signal_strength'
[C][wifi_signal.sensor:010]:   State Class: 'measurement'
[C][wifi_signal.sensor:010]:   Unit of Measurement: 'dBm'
[C][wifi_signal.sensor:010]:   Accuracy Decimals: 0
[V][wifi_signal.sensor:010]:   Unique ID: '983daeeb24f4-wifisignal'
[C][deep_sleep:026]: Setting up Deep Sleep...
[C][deep_sleep:029]:   Sleep Duration: 300000 ms
[C][deep_sleep:032]:   Run Duration: 300000 ms
[V][esp-idf:000][wifi]: I (4045) wifi:
[V][esp-idf:000][wifi]: <ba-add>idx:0 (ifx:0, 64:66:b3:ed:08:c4), tid:0, ssn:0, winSize:64
[V][esp-idf:000][wifi]: 

[D][api:103]: Accepted 192.168.1.98
[W][component:170]: Component api cleared Warning flag
[V][api.connection:1427]: Hello from client: 'ESPHome Logs 2024.12.4' | 192.168.1.98 | API Version 1.10
[D][api.connection:1446]: ESPHome Logs 2024.12.4 (192.168.1.98): Connected successfully
[I][app:100]: ESPHome version 2024.12.4 compiled on Feb 18 2025, 11:20:05
[C][wifi:600]: WiFi:
[C][wifi:428]:   Local MAC: 98:3D:AE:EB:24:F4
[C][wifi:433]:   SSID: 'dagoba'
[C][wifi:436]:   IP Address: 192.168.1.97
[C][wifi:439]:   BSSID: 64:66:B3:ED:08:C4
[C][wifi:441]:   Hostname: 'greenhouse'
[C][wifi:443]:   Signal strength: -63 dB ▂▄▆█
[C][wifi:447]:   Channel: 13
[C][wifi:448]:   Subnet: 255.255.255.0
[C][wifi:449]:   Gateway: 192.168.1.1
[C][wifi:450]:   DNS1: 0.0.0.0
[C][wifi:451]:   DNS2: 0.0.0.0
[C][logger:185]: Logger:
[C][logger:186]:   Level: VERBOSE
[C][logger:188]:   Log Baud Rate: 115200
[C][logger:189]:   Hardware UART: USB_SERIAL_JTAG
[C][uptime.sensor:033]: Uptime Sensor 'greenhouse Uptime'
[C][uptime.sensor:033]:   Device Class: 'duration'
[C][uptime.sensor:033]:   State Class: 'total_increasing'
[C][uptime.sensor:033]:   Unit of Measurement: 's'
[C][uptime.sensor:033]:   Accuracy Decimals: 0
[C][uptime.sensor:033]:   Icon: 'mdi:timer-outline'
[V][uptime.sensor:033]:   Unique ID: '983daeeb24f4-uptime'
[C][uptime.sensor:034]:   Type: Seconds
[C][template.text_sensor:020]: Template Sensor 'greenhouse Uptime Human Readable'
[C][template.text_sensor:020]:   Icon: 'mdi:clock-start'
[C][esp32_rmt_led_strip:187]: ESP32 RMT LED Strip:
[C][esp32_rmt_led_strip:188]:   Pin: 48
[C][esp32_rmt_led_strip:189]:   Channel: 0
[C][esp32_rmt_led_strip:214]:   RGB Order: GRB
[C][esp32_rmt_led_strip:215]:   Max refresh rate: 0
[C][esp32_rmt_led_strip:216]:   Number of LEDs: 1
[C][light:092]: Light 'greenhouse RGB LED'
[C][light:094]:   Default Transition Length: 1.0s
[C][light:095]:   Gamma Correct: 2.80
[C][dht:017]: DHT:
[C][dht:018]:   Pin: GPIO6
[C][dht:024]:   Model: DHT22 (or equivalent)
[C][dht:027]:   Update Interval: 180.0s
[C][dht:029]:   Temperature 'greenhouse Control box Temperature'
[C][dht:029]:     Device Class: 'temperature'
[C][dht:029]:     State Class: 'measurement'
[C][dht:029]:     Unit of Measurement: '°C'
[C][dht:029]:     Accuracy Decimals: 1
[C][dht:030]:   Humidity 'greenhouse Control box Humidity'
[C][dht:030]:     Device Class: 'humidity'
[C][dht:030]:     State Class: 'measurement'
[C][dht:030]:     Unit of Measurement: '%'
[C][dht:030]:     Accuracy Decimals: 0
[C][version.text_sensor:021]: Version Text Sensor 'greenhouse ESPHome Version'
[C][version.text_sensor:021]:   Icon: 'mdi:new-box'
[V][version.text_sensor:021]:   Unique ID: '983daeeb24f4-version'
[C][captive_portal:089]: Captive Portal:
[C][web_server:153]: Web Server:
[C][web_server:154]:   Address: 192.168.1.97:80
[C][mdns:116]: mDNS:
[C][mdns:117]:   Hostname: greenhouse
[V][mdns:118]:   Services:
[V][mdns:120]:   - _esphomelib, _tcp, 6053
[V][mdns:122]:     TXT: version = 2024.12.4
[V][mdns:122]:     TXT: mac = 983daeeb24f4
[V][mdns:122]:     TXT: platform = ESP32
[V][mdns:122]:     TXT: board = esp32-s3-devkitc-1
[V][mdns:122]:     TXT: network = wifi
[V][mdns:122]:     TXT: api_encryption = Noise_NNpsk0_25519_ChaChaPoly_SHA256
[V][mdns:120]:   - _http, _tcp, 80
[C][esphome.ota:073]: Over-The-Air updates:
[C][esphome.ota:074]:   Address: 192.168.1.97:3232
[C][esphome.ota:075]:   Version: 2
[C][safe_mode:018]: Safe Mode:
[C][safe_mode:019]:   Boot considered successful after 60 seconds
[C][safe_mode:021]:   Invoke after 10 boot attempts
[C][safe_mode:022]:   Remain in safe mode for 300 seconds
[C][api:140]: API Server:
[C][api:141]:   Address: 192.168.1.97:6053                                 
[C][api:143]:   Using noise encryption: YES                                
[C][wifi_signal.sensor:010]: WiFi Signal 'greenhouse Wifi signal'          
[C][wifi_signal.sensor:010]:   Device Class: 'signal_strength'             
[C][wifi_signal.sensor:010]:   State Class: 'measurement'                  
[C][wifi_signal.sensor:010]:   Unit of Measurement: 'dBm'
[C][wifi_signal.sensor:010]:   Accuracy Decimals: 0
[V][wifi_signal.sensor:010]:   Unique ID: '983daeeb24f4-wifisignal'
[C][deep_sleep:026]: Setting up Deep Sleep...
[C][deep_sleep:029]:   Sleep Duration: 300000 ms
[C][deep_sleep:032]:   Run Duration: 300000 ms
[D][api:103]: Accepted 192.168.1.98
[V][api.connection:1427]: Hello from client: 'Home Assistant 2025.2.4' | 192.168.1.98 | API Version 1.10
[D][api.connection:1446]: Home Assistant 2025.2.4 (192.168.1.98): Connected successfully
[D][esp32.preferences:114]: Saving 1 preferences to flash...
[V][esp32.preferences:163]: nvs_get_blob('2623382305'): ESP_ERR_NVS_NOT_FOUND - the key might not be set yet
[V][esp32.preferences:126]: sync: key: 2623382305, len: 7
[D][esp32.preferences:142]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[I][safe_mode:041]: Boot seems successful; resetting boot loop counter
[D][esp32.preferences:114]: Saving 1 preferences to flash...
[V][esp32.preferences:126]: sync: key: 233825507, len: 4
[D][esp32.preferences:142]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[D][dht:048]: Got Temperature=24.7°C Humidity=52.3%
[V][sensor:043]: 'greenhouse Control box Temperature': Received new state 24.700001
[D][sensor:093]: 'greenhouse Control box Temperature': Sending state 24.70000 °C with 1 decimals of accuracy
[V][sensor:043]: 'greenhouse Control box Humidity': Received new state 52.299999
[D][sensor:093]: 'greenhouse Control box Humidity': Sending state 52.30000 % with 0 decimals of accuracy
[I][deep_sleep:060]: Beginning Deep Sleep
[I][deep_sleep:062]: Sleeping for 300000000us
[D][esp32.preferences:114]: Saving 1 preferences to flash...
[V][esp32.preferences:137]: NVS data not changed skipping 233825507  len=4
[D][esp32.preferences:142]: Saving 1 preferences to flash: 1 cached, 0 written, 0 failed
[D][light:036]: 'greenhouse RGB LED' Setting:
[D][light:047]:   State: OFF
[D][light:085]:   Transition length: 1.0s
[D][main:525]: ##### on_shutdown finished
eferences to flash: 0 cached, 1 written, 0 failed
[I][app:029]: Running through setup()...
[V][app:030]: Sorting components by setup priority...
[C][esp32_rmt_led_strip:021]: Setting up ESP32 LED Strip...
[C][D][text_sensor:064]: 'greenhouse ESPHome Version': Sendi[C][uptime.sensor:033]: Uptime Sensor 'greenhouse Uptime'
[C][uptime.sensor:033]:   Device Class: 'duration'
[C][uptime.sensor:033]:   State Class: 'total_increasing'
[C][uptime.sensor:033]:   Unit of Measurement: 's'
[C][uptime.sensor:033]:   Accuracy Decimals: 0
[C][uptime.sensor:033]:   Icon: 'mdi:timer-outline'
[V][uptime.sensor:033]:   Unique ID: '983daeeb24f4-uptime'
[C][uptime.sensor:034]:   Type: Seconds
[C][template.text_sensor:020]: Template Sensor 'greenhouse Uptime Human Readable'
[C][template.text_sensor:020]:   Icon: 'mdi:clock-start'
[C][esp32_rmt_led_strip:187]: ESP32 RMT LED Strip:
[C][esp32_rmt_led_strip:188]:   Pin: 48
[C][esp32_rmt_led_strip:189]:   Channel: 0
[C][esp32_rmt_led_strip:214]:   RGB Order: GRB
[C][esp32_rmt_led_strip:215]:   Max refresh rate: 0
[C][esp32_rmt_led_strip:216]:   Number of LEDs: 1
[C][light:092]: Light 'greenhouse RGB LED'
[C][light:094]:   Default Transition Length: 1.0s
[C][light:095]:   Gamma Correct: 2.80
[C][dht:017]: DHT:
[C][dht:018]:   Pin: GPIO6
[C][dht:024]:   Model: DHT22 (or equivalent)
[C][dht:027]:   Update Interval: 180.0s
[C][dht:029]:   Temperature 'greenhouse Control box Temperature'
[C][dht:029]:     Device Class: 'temperature'
[C][dht:029]:     State Class: 'measurement'
[C][dht:029]:     Unit of Measurement: '°C'
[C][dht:029]:     Accuracy Decimals: 1
[C][dht:030]:   Humidity 'greenhouse Control box Humidity'
[C][dht:030]:     Device Class: 'humidity'
[C][dht:030]:     State Class: 'measurement'
[C][dht:030]:     Unit of Measurement: '%'
[C][dht:030]:     Accuracy Decimals: 0
[C][version.text_sensor:021]: Version Text Sensor 'greenhouse ESPHome Version'
[C][version.text_sensor:021]:   Icon: 'mdi:new-box'
[V][version.text_sensor:021]:   Unique ID: '983daeeb24f4-version'
[C][captive_portal:089]: Captive Portal:
[C][web_server:153]: Web Server:
[C][web_server:154]:   Address: 192.168.1.97:80
[C][mdns:116]: mDNS:
[C][mdns:117]:   Hostname: greenhouse
[V][mdns:118]:   Services:
[V][mdns:120]:   - _esphomelib, _tcp, 6053
[V][mdns:122]:     TXT: version = 2024.12.4
[V][mdns:122]:     TXT: mac = 983daeeb24f4
[V][mdns:122]:     TXT: platform = ESP32
[V][mdns:122]:     TXT: board = esp32-s3-devkitc-1
[V][mdns:122]:     TXT: network = wifi
[V][mdns:122]:     TXT: api_encryption = Noise_NNpsk0_25519_ChaChaPoly_SHA256
[V][mdns:120]:   - _http, _tcp, 80
[C][esphome.ota:073]: Over-The-Air updates:
[C][esphome.ota:074]:   Address: 192.168.1.97:3232
[C][esphome.ota:075]:   Version: 2
[C][safe_mode:018]: Safe Mode:
[C][safe_mode:019]:   Boot considered successful after 60 seconds
[C][safe_mode:021]:   Invoke after 10 boot attempts
[C][safe_mode:022]:   Remain in safe mode for 300 seconds
[C][api:140]: API Server:
[C][api:141]:   Address: 192.168.1.97:6053
[C][api:143]:   Using noise encryption: YES
[C][wifi_signal.sensor:010]: WiFi Signal 'greenhouse Wifi signal'
[C][wifi_signal.sensor:010]:   Device Class: 'signal_strength'
[C][wifi_signal.sensor:010]:   State Class: 'measurement'
[C][wifi_signal.sensor:010]:   Unit of Measurement: 'dBm'
[C][wifi_signal.sensor:010]:   Accuracy Decimals: 0
[V][wifi_signal.sensor:010]:   Unique ID: '983daeeb24f4-wifisignal'
[C][deep_sleep:026]: Setting up Deep Sleep...
[C][deep_sleep:029]:   Sleep Duration: 300000 ms
[C][deep_sleep:032]:   Run Duration: 300000 ms
[V][esp-idf:000][wifi]: I (2144) wifi:
[V][esp-idf:000][wifi]: <ba-add>idx:0 (ifx:0, 64:66:b3:ed:08:c4), tid:0, ssn:0, winSize:64
[V][esp-idf:000][wifi]: 

[D][api:103]: Accepted 192.168.1.98
[D][api:103]: Accepted 192.168.1.98
[W][component:170]: Component api cleared Warning flag
[W][component:237]: Component api took a long time for an operation (77 ms).
[W][component:238]: Components should block for at most 30 ms.
[V][api.connection:1427]: Hello from client: 'Home Assistant 2025.2.4' | 192.168.1.98 | API Version 1.10
[D][api.connection:1446]: Home Assistant 2025.2.4 (192.168.1.98): Connected successfully
[V][api.connection:1427]: Hello from client: 'ESPHome Logs 2024.12.4' | 192.168.1.98 | API Version 1.10
[D][api.connection:1446]: ESPHome Logs 2024.12.4 (192.168.1.98): Connected successfully
[I][safe_mode:041]: Boot seems successful; resetting boot loop counter
[D][esp32.preferences:114]: Saving 1 preferences to flash...
[V][esp32.preferences:126]: sync: key: 233825507, len: 4
[D][esp32.preferences:142]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[D][dht:048]: Got Temperature=24.8°C Humidity=51.7%
[V][sensor:043]: 'greenhouse Control box Temperature': Received new state 24.800001
[D][sensor:093]: 'greenhouse Control box Temperature': Sending state 24.80000 °C with 1 decimals of accuracy
[V][sensor:043]: 'greenhouse Control box Humidity': Received new state 51.700001
[D][sensor:093]: 'greenhouse Control box Humidity': Sending state 51.70000 % with 0 decimals of accuracy


I think delays are not considered on shutdown. And you have default transition for your led. Try like this.

on_shutdown:                #Includes deep sleep
    - priority: -100          # before everything else
      then:
        - light.turn_off:
            id: rgb_led
            transition_length: 0s
    - priority: 900          # before everything else
      then:
        - logger.log: "##### on_shutdown finished" 
on_shutdown:
  - priority: -100  
    then:
      - light.addressable_set:
          id: rgb_led
          red: 0%
          green: 0%
          blue: 0%
      - delay: 50ms  # Signal processing delay
      - light.turn_off: rgb_led
      - delay: 2s
  - priority: 900  
    then:
      - logger.log: "##### on_shutdown finished"

A couple more thoughts…

Changing the ESP32 framework

esp32:
  framework:
#    type: esp-idf
    type: arduino

doesn’t make any difference.

Splitting the on_shutdown to use priority:

  on_shutdown:                #Includes deep sleep
    - priority: -100          # before everything else
      then:
        - light.turn_off: 
            id: rgb_led
            transition_length: 0s
        - delay: 2s
        - logger.log: "##### on_shutdown -100 finished" 
    - priority: 900          # before everything else
      then:
        - logger.log: "##### on_shutdown 900 finished" 

shows

[D][esp32.preferences:143]: Saving 1 preferences to flash: 1 cached, 0 written, 0 failed
[D][light:036]: 'greenhouse RGB LED' Setting:
[D][light:047]:   State: OFF
[D][main:538]: ##### on_shutdown 900 finished
[  1020][V][WiFiGeneric.cpp:353] _arduino_event_cb(): STA Connected: SSID: dagoba, BSSID: 64:66:b3:ed:08:c4, Channel:K
[  1021][D][WiF[i G 1en0e2r2i]c[.V]cp[pW:9i2F9iG] en_eerviecnt.caplpl:3ba67ck] (_):ar Adrudinuio_noev eEvnten_ct:b( 4:
192.[V][wifi_esp32:529][arduino_events]: Ev1 Connected ssid='dagoba' bssid=64:66:B3:ED:08:C4 channel=13, authmode=WPAK
68.1.97
[  1030][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
[  1037][D][WiFiGeneric.cpp:991] _eventCallback(): STA IP: 192.168.1.97, MASK: 255.255.255.0, GW: 192.168.1.1
[V][wifi_esp32:583][arduino_events]: Event: Got IP static_ip=192.168.1.97 gateway=192.168.1.1
[I][wifi:617]: WiFi Connected!
[C][wifi:428]:   Local MAC: 98:3D:AE:EB:24:F4
[C][wifi:433]:   SSID: 'dagoba'
[C][wifi:436]:   IP Address: 192.168.1.97
[C][wifi:440]:   BSSID: 64:66:B3:ED:08:C4
[C][wifi:441]:   Hostname: 'greenhouse'
[C][wifi:443]:   Signal strength: -62 dB ▂▄▆█
[V][wifi:445]:   Priority: 0.0
[C][wifi:447]:   Channel: 13
[C][wifi:448]:   Subnet: 255.255.255.0
[C][wifi:449]:   Gateway: 192.168.1.1
[C][wifi:450]:   DNS1: 0.0.0.0
[C][wifi:451]:   DNS2: 0.0.0.0
[D][wifi:626]: Disabling AP...
[C][web_server:100]: Setting up web server...
[C][api:026]: Setting up Home Assistant API server...
[C][deep_sleep:013]: Setting up Deep Sleep...
[I][deep_sleep:018]: Scheduling Deep Sleep to start in 300000 ms
[I][app:062]: setup() finished successfully!
[V][sensor:043]: 'greenhouse Wifi signal': Received new state -62.000000
[D][sensor:094]: 'greenhouse Wifi signal': Sending state -62.00000 dBm with 0 decimals of accuracy
[W][component:170]: Component wifi cleared Warning flag
[W][component:157]: Component api set Warning flag: unspecified
[I][app:100]: ESPHome version 2024.12.4 compiled on Feb 19 2025, 09:50:01
[C][wifi:600]: WiFi:
[C][wifi:428]:   Local MAC: 98:3D:AE:EB:24:F4
[C][wifi:433]:   SSID: 'dagoba'
[C][wifi:436]:   IP Address: 192.168.1.97
...

which implies that the priority -100 is running and (failing to) turn off the LED then ignoring the “##### on_shutdown -100” message; before the priority 900 is displaying its message.

Did i mention also that the “##### on_boot finished” message only appears the first time the ESP32 starts - not each time it wakes up. However there are several other threads about doing all the sensor updating in the on_boot so that the ESP32 can be sent back to sleep as soon as processing has finished. Hmmm.

I am curious why you suggest both light.turn_off and light.addressable_set. Light.addressable_set action seems designed to set a range in a LED strip, whereas my dev board only has one of these LEDs. I’ll try it anyway. Nope, no difference.

Curiouser and curiouser …

I have added some more logger.log debugging statements and changed all the wording slightly to make sure each is unique; cleaned build files, and uploaded. It all seems successful, and RAM and Flash are nowhere near full.

Dependency Graph
|-- noise-c @ 0.1.6
|-- ArduinoJson @ 6.18.5
Compiling .pioenvs/greenhouse/src/main.cpp.o
Linking .pioenvs/greenhouse/firmware.elf
RAM:   [=         ]  10.2% (used 33572 bytes from 327680 bytes)
Flash: [=         ]  12.5% (used 1019681 bytes from 8126464 bytes)
Building .pioenvs/greenhouse/firmware.bin
Creating esp32s3 image...
Successfully created esp32s3 image.
esp32_create_combined_bin([".pioenvs/greenhouse/firmware.bin"], [".pioenvs/greenhouse/firmware.elf"])
Wrote 0x109100 bytes to file /data/build/greenhouse/.pioenvs/greenhouse/firmware.factory.bin, ready to flash to offset 0x0
esp32_copy_ota_bin([".pioenvs/greenhouse/firmware.bin"], [".pioenvs/greenhouse/firmware.elf"])
========================= [SUCCESS] Took 13.32 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 192.168.1.97 port 3232...
INFO Connected to 192.168.1.97
INFO Uploading /data/build/greenhouse/.pioenvs/greenhouse/firmware.bin (1020160 bytes)
Uploading: [============================================================] 100% Done...

INFO Upload took 10.15 seconds, waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from 192.168.1.97 using esphome API
INFO Successfully connected to greenhouse @ 192.168.1.97 in 3.089s
INFO Successful handshake with greenhouse @ 192.168.1.97 in 0.091s
[12:12:55][I][app:100]: ESPHome version 2025.2.0 compiled on Feb 20 2025, 12:12:30
[12:12:55][C][wifi:600]: WiFi:
[12:12:55][C][wifi:428]:   Local MAC: 98:3D:AE:EB:24:F4
[12:12:55][C][wifi:433]:   SSID: [redacted]
[12:12:55][C][wifi:436]:   IP Address: 192.168.1.97
[12:12:55][C][wifi:439]:   BSSID: [redacted]
[12:12:55][C][wifi:441]:   Hostname: 'greenhouse'
[12:12:55][C][wifi:443]:   Signal strength: -63 dB ▂▄▆█

However looking more closely at the log files produced (both the OTA log and USB log) the compile datetime is correct “[I][app:100]: ESPHome version 2025.2.0 compiled on Feb 20 2025, 12:12:30” … but the messages getting into the log are not from the current version of the yaml configuration.

Since I seem to be the only person experiencing this … I guess it means my ESP32-S3 chip is faulty.

FYI, my current yaml, loaded with debugging logger.log statements

# To control the greenhouse I have an ESP32-S3-DevKitC-1 (v1) board with ESP32-S3-WROOM-1-N16R8 chip
# THIS IS SERIOUSLY CUT BACK TO MINIMUM FOR TESTING

substitutions:
  devicename:     "greenhouse"
  deviceIP:       "97"                     # last octet of the IP Address
  wifi_ssid:      !secret upstairs_ssid     ### which wi-fi to connect to
  wifi_password:  !secret upstairs_password 
  update_interval_network: "30 min"       # How often to measure and report network values
  update_interval_sensor:  "3 min"        # How often to measure and report sensor values

logger:
  level: DEBUG          # VERBOSE

esp32:
  board: esp32-s3-devkitc-1
  variant: esp32s3
  flash_size: 16MB
  framework:
    type: esp-idf
    version: recommended

packages:
  wi-fi: !include _common_wifi.yaml   # uses static $deviceIP

esphome:
  name: $devicename
  platformio_options:
    board_build.flash_mode: dio 
  on_boot: 
    then:
#    - lambda: |-
#          id(wake_up_reason) = esp_sleep_get_wakeup_cause();
#          id(num_wake_cycles) += 1;
    - lambda: ESP_LOGD("testing", " >>>>>> on_boot wake_up_reason=%d", esp_sleep_get_wakeup_cause() );
    - logger.log: 
        format: " >>>>>> on_boot: wake_up_reason=%d, num_wake_cycles=%d"
        args: [ id(wake_up_reason), id(num_wake_cycles) ]
    - light.turn_on:
        id: rgb_led
        red: 0%
        green: 100%           # change colour green when awake
        blue: 0%
        brightness: 20%
    - logger.log: "##### on_boot finished" 
  on_shutdown:
    - priority: -100
      then:
      - light.addressable_set:
          id: rgb_led
          red: 100%           # change colour to red on shhutdown
          green: 0%
          blue: 0%
          color_brightness: 20%
      - delay: 2s  # Signal processing delay
      - light.turn_off: 
            id: rgb_led
            transition_length: 0s
      - delay: 2s
      - logger.log: "##### on_shutdown -100 finished" 
    - priority: 600
      then:
        - if:
            condition:
              - light.is_on: rgb_led
            then:
              - logger.log: ">>>>> light still on at on_shutdown 600" 
              - light.turn_off: 
                    id: rgb_led
                    transition_length: 0s
              - delay: 5s
              - logger.log: "##### on_shutdown 600 turned light off" 
              - delay: 5s
    - priority: 900
      then:
        - if:
            condition:
              - light.is_on: rgb_led
            then:
              - logger.log: ">>>>> light still on at on_shutdown 900" 
        - logger.log: "##### on_shutdown 900 finished" 
        - delay: 10s

globals:
  - id: num_wake_cycles
    type: int
    restore_value: yes
    initial_value: '0'

deep_sleep: 
  id: deep_sleep_1
  run_duration:   5 min   # how long to run (be awake)
  sleep_duration: 5 min   # how long to sleep for

light:
  - platform: esp32_rmt_led_strip
    name: $devicename RGB LED
    id: rgb_led
    rgb_order: GRB
    pin: GPIO48
    num_leds: 1
#    rmt_channel: 0     # not allowed by ESPHome 2025.02 upgrade
    chipset: ws2812

sensor:
  - platform: dht
    model: DHT22
    pin: GPIO6
    update_interval: $update_interval_sensor
    temperature:
      name: $devicename Control box Temperature
    humidity:
      name: $devicename Control box Humidity

  - platform: template
    id: wake_up_reason
    name: $devicename Wakeup reason
    update_interval: $update_interval_sensor
    accuracy_decimals: 0
    lambda: return esp_sleep_get_wakeup_cause();
    on_value:
      then:
        - light.turn_on:
            id: rgb_led
            red: 0%
            green: 0% 
            blue: 100%          # change colour blue when sensor read
            brightness: 20%
        - logger.log: 
            format: " >>>>>> sensor: wake_up_reason=%d, num_wake_cycles=%d"
            args: [ id(wake_up_reason), id(num_wake_cycles) ]

produced this USB log (far too big for a forum post). My logger.log messages (prefixed with ### or >>>) are not the new wording in the yaml which it claims to be running.

To top it off this last run started getting errors
[12:25:22][E][esp32.preferences:146]: Error saving 2 preferences to flash. Last error=ESP_ERR_NVS_NOT_ENOUGH_SPACE for key=4194432769

A few more debugging logger.log statements, erase-flash then install esphome on my desktop PC to reinstall ESPHome on my ESP32-S3 … and voila, I think i’ve isolated the problem to a possible bug in ESPHome where some actions (specifically light.turn_off) fail and the rest of the actions in that section are skipped.

Please have a look and see if i have missed something …

 To control the greenhouse I have an ESP32-S3-DevKitC-1 (v1) board with ESP32-S3-WROOM-1-N16R8 chip
# THIS IS SERIOUSLY CUT BACK TO MINIMUM FOR TESTING

substitutions:
  devicename:     "greenhouse"
  deviceIP:       "97"                     # last octet of the IP Address
  wifi_ssid:      !secret upstairs_ssid     ### which wi-fi to connect to
  wifi_password:  !secret upstairs_password 
  update_interval_network: "30 min"       # How often to measure and report network values
  update_interval_sensor:  "3 min"        # How often to measure and report sensor values

logger:
  level: DEBUG          # VERBOSE

esp32:
  board: esp32-s3-devkitc-1
  variant: esp32s3
  flash_size: 16MB
  framework:
    type: esp-idf
    version: recommended

psram:
  mode: octal
  speed: 80MHz

packages:
  wi-fi: !include _common_wifi.yaml   # uses static $deviceIP

esphome:
  name: $devicename
  platformio_options:
    board_build.flash_mode: dio 
  on_boot: 
    then:
#    - lambda: |-
#          id(wake_up_reason) = esp_sleep_get_wakeup_cause();
#          id(num_wake_cycles) += 1;
    - lambda: ESP_LOGD("testing", " >>>>>> on_boot wake_up_reason=%d", esp_sleep_get_wakeup_cause() );
    - logger.log: 
        format: " >>>>>> on_boot: wake_up_reason=%d, num_wake_cycles=%d"
        args: [ id(wake_up_reason), id(num_wake_cycles) ]
    - light.turn_on:
        id: rgb_led
        red: 0%
        green: 100%           # change colour green when awake
        blue: 0%
        brightness: 20%
    - logger.log: "##### on_boot finished" 
  on_shutdown:
    - priority: -100
      then:
      - logger.log: "##### on_shutdown -100 start" 
      - light.addressable_set:
          id: rgb_led
          red: 100%           # change colour to red on shutdown
          green: 0%
          blue: 0%
          color_brightness: 20%
      - delay: 2s  # Signal processing delay
      - light.turn_off: 
            id: rgb_led
            transition_length: 0s
      - delay: 2s
      - logger.log: "##### on_shutdown -100 finished" 
    - priority: 600
      then:
        - logger.log: "##### on_shutdown 600 start" 
        - if:
            condition:
              - light.is_on: rgb_led
            then:
              - logger.log: ">>>>> light still on at on_shutdown 600" 
              - light.turn_off: 
                    id: rgb_led
                    transition_length: 0s
              - delay: 5s
              - logger.log: "##### on_shutdown 600 turned light off" 
              - delay: 5s
        - logger.log: "##### on_shutdown 600 finished" 
    - priority: 900
      then:
        - logger.log: "##### on_shutdown 900 start" 
        - if:
            condition:
              - light.is_on: rgb_led
            then:
              - logger.log: ">>>>> light still on at on_shutdown 900" 
            else:
              - logger.log: ">>>>> light is off at on_shutdown 900" 
        - logger.log: "##### on_shutdown 900 finished" 
        - delay: 10s

globals:
  - id: num_wake_cycles
    type: int
    restore_value: yes
    initial_value: '0'

deep_sleep: 
  id: deep_sleep_1
  run_duration:   5 min   # how long to run (be awake)
  sleep_duration: 5 min   # how long to sleep for

light:
  - platform: esp32_rmt_led_strip
    name: $devicename RGB LED
    id: rgb_led
    rgb_order: GRB
    pin: GPIO48
    num_leds: 1
#    rmt_channel: 0     # not allowed by ESPHome 2025.02
    chipset: ws2812

sensor:
  - platform: dht
    model: DHT22
    pin: GPIO6
    update_interval: $update_interval_sensor
    temperature:
      name: $devicename Control box Temperature
    humidity:
      name: $devicename Control box Humidity

  - platform: template
    id: wake_up_reason
    name: $devicename Wakeup reason
    update_interval: $update_interval_sensor
    accuracy_decimals: 0
    lambda: return esp_sleep_get_wakeup_cause();
    on_value:
      then:
        - logger.log: "##### sensor on_value started" 
        - light.turn_on:
            id: rgb_led
            red: 0%
            green: 0% 
            blue: 100%          # change colour blue when sensor read
            brightness: 20%
#        - logger.log: "##### sensor on_value turning light off" 
#        - light.turn_off:
#            id: rgb_led
        - logger.log: 
            format: " >>>>>> sensor: wake_up_reason=%d, num_wake_cycles=%d"
            args: [ id(wake_up_reason), id(num_wake_cycles) ]

I won’t bore you with the entire USB log, but the on_boot section shows:

[I][app:029]: Running through setup()...
[C][esp32_rmt_led_strip:025]: Setting up ESP32 LED Strip...
[D][esp-idf:000]: I (995) gpio: GPIO[48]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 

[C][light:021]: Setting up light 'greenhouse RGB LED'...
[D][light:036]: 'greenhouse RGB LED' Setting:
[D][light:041]:   Color mode: RGB
[D][light:085]:   Transition length: 1.0s
[D][testing:040]:  >>>>>> on_boot wake_up_reason=0
[D][main:376]:  >>>>>> on_boot: wake_up_reason=1070230608, num_wake_cycles=0
[D][light:036]: 'greenhouse RGB LED' Setting:
[D][light:047]:   State: ON
[D][light:051]:   Brightness: 20%
[D][light:058]:   Red: 0%, Green: 100%, Blue: 0%
[D][light:085]:   Transition length: 1.0s
[D][main:385]: ##### on_boot finished
[C][dht:011]: Setting up DHT...

This appears to work correctly, turning the light on green - though almost immediately the sensor wake_up_reason is executed (as part of boot) and LED turns blue.
Curiously the on_boot now seems to be executed every wakeup from deep_sleep … which it wasn’t before.

The wake_up_reason sensor is checked and shows as expected:

[D][sensor:093]: 'greenhouse Wakeup reason': Sending state 4.00000  with 0 decimals of accuracy
[D][main:243]: ##### sensor on_value started
[D][light:036]: 'greenhouse RGB LED' Setting:
[D][light:051]:   Brightness: 20%
[D][light:058]:   Red: 0%, Green: 0%, Blue: 100%
[D][light:085]:   Transition length: 1.0s
[D][main:474]:  >>>>>> sensor: wake_up_reason=1070230200, num_wake_cycles=0
[I][deep_sleep:060]: Beginning Deep Sleep

When going into deep_sleep: on the HA ESPHome Builder log I see only the on_shutdown -100 start message but …

On the USB log you can clearly see that all the on_shutdown priorities were started - but the -100 and 600 failed to get to the actions after the light.turn_off. At priority 900 the if: condition indicates that ESPHome believes the light is already off - despite it physically still being on blue.

[I][deep_sleep:060]: Beginning Deep Sleep
[I][deep_sleep:062]: Sleeping for 300000000us
[D][esp32.preferences:114]: Saving 1 preferences to flash...
[D][esp32.preferences:142]: Saving 1 preferences to flash: 1 cached, 0 written, 0 failed
[D][main:393]: ##### on_shutdown -100 start
[D][main:420]: ##### on_shutdown 600 start
[D][main:426]: >>>>> light still on at on_shutdown 600
[D][light:036]: 'greenhouse RGB LED' Setting:
[D][light:047]:   State: OFF
[D][main:452]: ##### on_shutdown 900 start
[D][main:462]: >>>>> light is off at on_shutdown 900
[D][main:466]: ##### on_shutdown 900 finished
I (302) esp_image: segment 4: paddr=008c2a54 vaddr=4037c6[I][logger:171]: Log initialized
[C][safe_mode:079]: There have been 0 suspected unsuccessful boot attempts

Update: In another thread and in Discord I have been advised that lights with a transition_length option (which for my single LED esp32_rmt_led_strip defaults to 1s) create a loop, and the on_shutdown: doesn’t wait for multiple iteration of the loop.

In my case I found that setting transition_length to 0ms worked.

      - light.turn_off: 
            id: rgb_led
            transition_length: 0ms

… though that doesn’t help with seeing the logger.log statements in on_boot:

Well, there must have been something else going on, because I still have the same 0ms transition, yet it is back to the log saying the light is turned off BUT IT DOES NOT HAPPEN (thus using more power during deep_sleep than I want).

[11:37:17][D][main:073]: ##### on_shutdown -100 start
[11:37:17][D][light:036]: 's3-mini RGB LED' Setting:
[11:37:17][D][light:047]:   State: OFF
[11:37:17][D][main:079]: ##### on_shutdown -100 turned light off, finished

Maybe because I have gone back to powering from my power manager instead of from my PC (to get the full log) ?