5 Commits
Author SHA1 Message Date
mangavalkandClaude Opus 5.5 bcc6b3a42b Keep the ambient colour when the light turns on
The MCU resets the colour to Cycle on every turn-on. Remember the chosen colour
across restarts and send it again just after the MCU reports the light on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 01:26:02 +01:00
mangavalkandClaude Opus 5.5 06b259cb1b 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 <noreply@anthropic.com>
2026-11-09 01:17:11 +01:00
mangavalkandClaude Opus 5.5 a355f64d1a Name the alarm sounds
Replace Sound 1 to 7 with the names identified by ear on this lamp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 19:19:54 +01:00
mangavalkandClaude Opus 5.5 5c29cdd52f Note the first alarm sound name
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 18:43:31 +01:00
mangavalkandClaude Opus 5.5 e772c1a351 Note confirmed ring duration and silent sound 0
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 18:28:30 +01:00
4 changed files with 104 additions and 31 deletions

No files matched your search

+6 -1
View File
@@ -8,6 +8,7 @@ ESPHome firmware for a Moes Wake Up Light II (Tuya PID `ya39qahrcdhvxowz`), runn
- `alarm_block.yaml`: controls for one alarm, included 4 times.
- `alarm_day.yaml`: one weekday switch, included 7 times per alarm.
- `components/uart`: ESPHome 2026.10.2's UART component with `patches/wbr3-pa13-pa14-uart.patch` applied. Recheck it when ESPHome updates.
- `server-example.yaml`: the short YAML that goes on an ESPHome server.
- `secrets.yaml`: local only, ignored by git. Needs `wifi_ssid`, `wifi_password`, `ap_password`, `api_encryption_key`.
@@ -62,11 +63,15 @@ From Tuya's definition for a sibling product (tuya-local issue #3821). See the R
- Byte 8 isn't per alarm. Every DP127 write sets all 4 to the current radio station, so there's no per-alarm station control.
- Byte 10 is forced to 0 without the light bit, and writing 0 clears the light bit.
- Byte 11: above 1 becomes 1.
- What byte 4 actually does to ring length isn't confirmed. A test ring wasn't observed stopping.
- Byte 4 is the ring length in minutes: set to 10, a ring ran from 18:16 to 18:26 and the owner saw it stop.
- Sound 0 is silent. In Sound + Light mode, the light still came on and no sound played.
- Alarm sounds, identified by ear: 1 birds chirping, 2 beach (water and birds), 3 galaxy twinkles, 4 piano and birds, 5 happy harp or high piano, 6 old mechanical alarm clock, 7 old digital alarm clock. Names are in `alarm_block.yaml`. Sunset's sounds 1 to 4 haven't been checked, so they keep their numbers.
- Radio Volume and station writes are ignored with the radio off. With it on, both work, and the station stays selected after turning it off.
- Every Ambient Light turn-on makes the MCU reset DP132 to Cycle (0), even if a colour was set while off. Since v1.0.5 the firmware remembers the chosen colour (kept across restarts) and sends it again 400 ms after the MCU reports the light on. Colour changes the MCU reports more than 1.5 s after turn-on count as user choices.
- 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
+18 -17
View File
@@ -117,13 +117,13 @@ select:
name: "Alarm ${n} Sound"
options:
- "Off"
- "Sound 1"
- "Sound 2"
- "Sound 3"
- "Sound 4"
- "Sound 5"
- "Sound 6"
- "Sound 7"
- "Birds"
- "Beach"
- "Galaxy Twinkles"
- "Piano and Birds"
- "Happy Harp"
- "Mechanical Alarm Clock"
- "Digital Alarm Clock"
update_interval: 2s
web_server:
sorting_group_id: group_alarm_${n}
@@ -131,20 +131,21 @@ select:
lambda: |-
if (!id(alarm_raw_valid)) return {};
uint8_t s = id(alarm_raw)[${o} + 6];
if (s == 0) return std::string("Off");
if (s >= 1 && s <= 7) return std::string("Sound ") + std::to_string(s);
return {};
static const char *const names[8] = {"Off", "Birds", "Beach", "Galaxy Twinkles", "Piano and Birds",
"Happy Harp", "Mechanical Alarm Clock", "Digital Alarm Clock"};
if (s > 7) return {};
return std::string(names[s]);
set_action:
- lambda: |-
if (!id(alarm_raw_valid)) return;
uint8_t value = 0;
if (x == "Sound 1") value = 1;
else if (x == "Sound 2") value = 2;
else if (x == "Sound 3") value = 3;
else if (x == "Sound 4") value = 4;
else if (x == "Sound 5") value = 5;
else if (x == "Sound 6") value = 6;
else if (x == "Sound 7") value = 7;
if (x == "Birds") value = 1;
else if (x == "Beach") value = 2;
else if (x == "Galaxy Twinkles") value = 3;
else if (x == "Piano and Birds") value = 4;
else if (x == "Happy Harp") value = 5;
else if (x == "Mechanical Alarm Clock") value = 6;
else if (x == "Digital Alarm Clock") value = 7;
id(alarm_raw)[${o} + 6] = value;
- script.execute: send_alarm_settings
+1 -1
View File
@@ -7,6 +7,6 @@ substitutions:
packages:
lamp:
url: https://mangavalk.com/mangavalk/esphome-wake-up-light-ii.git
ref: v1.0.2
ref: v1.0.5
files: [wake-up-light-ii.yaml]
refresh: 1d
+79 -12
View File
@@ -22,7 +22,7 @@ external_components:
- source:
type: git
url: https://mangavalk.com/mangavalk/esphome-wake-up-light-ii.git
ref: v1.0.2
ref: v1.0.5
components: [uart]
refresh: 1d
@@ -136,6 +136,23 @@ globals:
restore_value: no
initial_value: '0'
# Ambient colour (DP132). The MCU resets it to Cycle (0) whenever the ambient
# light turns on, so the chosen colour is kept here and sent again.
- id: ambient_color_saved
type: uint8_t
restore_value: yes
initial_value: '0'
- id: ambient_color_now
type: uint8_t
restore_value: no
initial_value: '0'
- id: ambient_on_ms
type: uint32_t
restore_value: no
initial_value: '0'
# When the MCU last sent its once-a-minute clock report.
- id: last_mcu_report
type: uint32_t
@@ -187,6 +204,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
@@ -268,7 +294,8 @@ tuya:
# [03] repeat days: bit 0 = Monday ... bit 6 = Sunday, 0 = one time
# [04] ring duration (Tuya says 10-20, this lamp reports 30; any value is kept)
# [05] mode bits: bit 0=light, bit 1=radio. Values above 3 are ignored.
# [06] sound 0..7. Writing 8 or more turns on the radio bit and resets it to 1.
# [06] sound 0..7, named in alarm_block.yaml. Writing 8 or more turns on the
# radio bit and resets it to 1.
# Locked at 1 in radio modes.
# [07] volume 1..16 (any value is kept)
# [08] radio station. Not per alarm: every write sets all 4 to the current
@@ -291,6 +318,24 @@ tuya:
id(alarm_raw_valid) = true;
id(publish_alarm_summaries).execute();
# DP129: ambient light. On every turn-on the MCU resets DP132 to Cycle.
- sensor_datapoint: 129
datapoint_type: bool
then:
- lambda: |-
if (!x) return;
id(ambient_on_ms) = millis();
id(restore_ambient_color).execute();
# DP132: ambient colour. A change reported while the light has been on for a
# moment came from the user (lamp buttons or here), so remember it.
- sensor_datapoint: 132
datapoint_type: enum
then:
- lambda: |-
id(ambient_color_now) = x;
if (millis() - id(ambient_on_ms) > 1500) id(ambient_color_saved) = x;
# DP128: sunset settings, 10 bytes, per Tuya's data model:
# [0] switch (unused) [1] mode: 0=sound, 1=sound+light, 2=radio, 3=radio+light
# [2] sound 1..4 [3] sound volume 1..16 [4] sound duration 10..120
@@ -390,6 +435,15 @@ script:
call.set_transition_length(0);
call.perform();
- id: restore_ambient_color
mode: restart
then:
- delay: 400ms
- lambda: |-
if (id(ambient_color_saved) == 0) return;
ESP_LOGI("ambient", "Restoring ambient colour %u", (unsigned) id(ambient_color_saved));
id(tuya_mcu).set_enum_datapoint_value(132, id(ambient_color_saved));
- id: radio_step
mode: queued
parameters:
@@ -672,19 +726,32 @@ select:
sorting_group_id: group_snooze
sorting_weight: 3
- platform: tuya
- platform: template
id: ambient_color
name: "Ambient Color"
enum_datapoint: 132
options:
0: "Cycle"
1: "Red"
2: "Orange"
3: "Yellow"
4: "Green"
5: "Cyan"
6: "Blue"
7: "Purple"
- "Cycle"
- "Red"
- "Orange"
- "Yellow"
- "Green"
- "Cyan"
- "Blue"
- "Purple"
update_interval: 1s
lambda: |-
static const char *const names[8] = {"Cycle", "Red", "Orange", "Yellow", "Green", "Cyan", "Blue", "Purple"};
if (id(ambient_color_now) > 7) return {};
return std::string(names[id(ambient_color_now)]);
set_action:
- lambda: |-
static const char *const names[8] = {"Cycle", "Red", "Orange", "Yellow", "Green", "Cyan", "Blue", "Purple"};
for (uint8_t i = 0; i < 8; i++) {
if (x == names[i]) {
id(ambient_color_saved) = i;
id(tuya_mcu).set_enum_datapoint_value(132, i);
}
}
web_server:
sorting_group_id: group_light
sorting_weight: 3