From 06b259cb1b4f6e9a2c1aeb549abadd14bf225d9b Mon Sep 17 00:00:00 2001 From: MangaValk Date: Mon, 9 Nov 2026 01:17:11 +0100 Subject: [PATCH] Restart when the MCU stops reporting After about 2.5 days the chip stopped receiving MCU replies while writes still went out, so switches looked stuck. Restart after 5 quiet minutes, but only if the link worked earlier in that boot. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 1 + server-example.yaml | 2 +- wake-up-light-ii.yaml | 11 ++++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index e17fc7a..2f2bca1 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -70,6 +70,7 @@ From Tuya's definition for a sibling product (tuya-local issue #3821). See the R - Keep `default_transition_length` at 0. A transition sends about 50 MCU writes a second. - LibreTiny before v1.14.0 can hang after a software restart or OTA until powered off for about 30 seconds (LibreTiny issue #396). The config pins v1.14.0. Drop the pin once ESPHome defaults to it or newer. - "Last Restart Reason" reports Power-On even after software restarts. +- On 2026-11-08, after about 2.5 days of uptime, the chip stopped receiving anything from the MCU while its own writes still went out. The owner saw Ambient Light turn on but not off, and MCU Link was OFF. A software restart fixed it. Since v1.0.4 the firmware restarts itself after 5 minutes without an MCU report, but only if the link worked earlier in that boot. The cause isn't known; suspects are the patched UART0 on PA13/PA14 or a LibreTiny serial issue. ## Status diff --git a/server-example.yaml b/server-example.yaml index 19c211f..cd85b9e 100644 --- a/server-example.yaml +++ b/server-example.yaml @@ -7,6 +7,6 @@ substitutions: packages: lamp: url: https://mangavalk.com/mangavalk/esphome-wake-up-light-ii.git - ref: v1.0.3 + ref: v1.0.4 files: [wake-up-light-ii.yaml] refresh: 1d diff --git a/wake-up-light-ii.yaml b/wake-up-light-ii.yaml index 103c2c3..decbabe 100644 --- a/wake-up-light-ii.yaml +++ b/wake-up-light-ii.yaml @@ -22,7 +22,7 @@ external_components: - source: type: git url: https://mangavalk.com/mangavalk/esphome-wake-up-light-ii.git - ref: v1.0.3 + ref: v1.0.4 components: [uart] refresh: 1d @@ -187,6 +187,15 @@ interval: - interval: 60s then: - script.execute: apply_display_schedule + # After about 2.5 days the chip once stopped receiving the MCU's replies, + # while sending still worked. A restart fixed it, so restart after 5 quiet + # minutes. Only if the link worked earlier this boot, to avoid a restart loop. + - lambda: |- + uint32_t last = id(last_mcu_report); + if (last != 0 && millis() - last > 300000) { + ESP_LOGW("mcu", "No report from the MCU for %u s, restarting", (unsigned) ((millis() - last) / 1000)); + App.safe_reboot(); + } ############################################################################### # Tuya MCU