Edit esp-bedside-panel.yaml

This commit is contained in:
ESPHome Device Builder
2026-07-20 15:05:51 +12:00
parent 809f9ada66
commit a8b0990000
+37 -72
View File
@@ -6,6 +6,7 @@
# https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-bedside-panel.yaml
#:########################################################################################:#
# VERSIONS:
# V1.47 2026-07-20 Widened the alarm volume range while retaining 5-100% controls and the proven 6000 Hz tone
# V1.46 2026-07-20 Raised the alarm tone to 6000 Hz, limited volume to 5-100%, and remapped 100% to the previous displayed 30% level
# V1.45 2026-07-20 Shortened the project description to remain within ESPHome's 255-byte string limit
# V1.44 2026-07-20 Added a classic 4096 Hz digital-clock triplet alarm and remapped displayed 0-100% volume to a quieter 0-30% output ceiling
@@ -147,9 +148,9 @@
# - The Snooze duration is a persistent Home Assistant configuration entity.
# - Alarm speaker volume is persistent and adjustable from Home Assistant or the display.
# - The ES8311 remains at its 75% / 0 dB reference while local PCM amplitude
# follows a perceptual curve across the displayed 5-100% volume range.
# - Displayed 100% now matches approximately the previous displayed 30% level.
# - The previous displayed 5-30% loudness range is spread across the new 5-100% scale.
# follows a 42 dB perceptual curve across the displayed 5-100% range.
# - Displayed 100% retains the tested V1.46 maximum sound level.
# - Displayed 5% is about 42 dB below 100%, giving a much quieter bedside level.
# - Zero volume is unavailable so an alarm cannot be silenced accidentally.
# - The Alarm Clock page provides local Beep, repeating Alarm and Stop hardware tests.
# - Beep is a short 6000 Hz electronic tone.
@@ -173,7 +174,7 @@ substitutions:
# Device Naming
device_name: "esp-bedside-panel"
friendly_name: "ESP Bedside Panel"
description_comment: "Guition JC1060P470C_I_W_Y ESP32-P4 bedside panel with four alarms, a 6000 Hz triplet alarm, limited 5-100% volume and a 24-hour roller time editor. (Layout V1.1)"
description_comment: "Guition JC1060P470C_I_W_Y ESP32-P4 bedside panel with four alarms, 6000 Hz triplet sound, wide 5-100% volume range and 24-hour time editor. (Layout V1.1)"
device_area: "Bedroom"
# Project Naming
@@ -257,15 +258,13 @@ substitutions:
# The ES8311 uses 75% as its 0 dB reference. Keep the codec at that
# reference and apply the user volume to the generated PCM samples.
#
# The display and Home Assistant expose 5-100%. The previous displayed
# 5-30% loudness range is stretched across this complete user-facing range,
# so the new 100% is approximately equal to the old displayed 30%.
# The display and Home Assistant expose 5-100%. The maximum retains the
# tested V1.46 output level, while a direct 42 dB curve makes 5% roughly
# 126 times lower in PCM amplitude than 100%.
alarm_dac_reference_volume: "0.75"
alarm_pcm_max_amplitude: "28000"
alarm_output_ceiling_percent: "30"
alarm_volume_attenuation_db: "24"
alarm_previous_ui_min_percent: "5"
alarm_previous_ui_max_percent: "30"
alarm_pcm_amplitude_at_100_percent: "530"
alarm_pcm_minimum_amplitude: "4"
alarm_volume_range_db: "42"
# A 6000 Hz bipolar square wave gives a sharper bedside clock character.
alarm_beep_frequency_hz: "6000"
@@ -2470,36 +2469,20 @@ script:
}
ui_volume = fminf(fmaxf(ui_volume, 5.0f), 100.0f);
// Stretch the former displayed 5-30% loudness range across the
// new 5-100% control. New 100% therefore equals old 30%.
const float effective_ui_volume =
${alarm_previous_ui_min_percent}.0f +
((ui_volume - 5.0f) / 95.0f) *
(${alarm_previous_ui_max_percent}.0f -
${alarm_previous_ui_min_percent}.0f);
float peak_amplitude = 0.0f;
{
const float ceiling_position =
fminf(fmaxf(
(${alarm_output_ceiling_percent}.0f - 5.0f) / 95.0f,
0.0f
), 1.0f);
const float ceiling_attenuation_db =
-${alarm_volume_attenuation_db}.0f *
(1.0f - ceiling_position);
const float user_position =
effective_ui_volume / 100.0f;
const float user_attenuation_db =
-${alarm_volume_attenuation_db}.0f *
(1.0f - user_position);
peak_amplitude =
${alarm_pcm_max_amplitude}.0f *
powf(
10.0f,
(ceiling_attenuation_db + user_attenuation_db) / 20.0f
);
}
// Map displayed 5-100% directly over a wide logarithmic range.
// The 100% endpoint keeps the tested V1.46 maximum. At 5%, the
// generated PCM amplitude is approximately 42 dB below that level.
const float volume_position =
(ui_volume - 5.0f) / 95.0f;
const float attenuation_db =
-${alarm_volume_range_db}.0f * (1.0f - volume_position);
const float calculated_amplitude =
${alarm_pcm_amplitude_at_100_percent}.0f *
powf(10.0f, attenuation_db / 20.0f);
const float peak_amplitude = fmaxf(
calculated_amplitude,
${alarm_pcm_minimum_amplitude}.0f
);
std::vector<uint8_t> audio;
audio.reserve(sample_count * 2);
@@ -2630,36 +2613,18 @@ script:
}
ui_volume = fminf(fmaxf(ui_volume, 5.0f), 100.0f);
const float effective_ui_volume =
${alarm_previous_ui_min_percent}.0f +
((ui_volume - 5.0f) / 95.0f) *
(${alarm_previous_ui_max_percent}.0f -
${alarm_previous_ui_min_percent}.0f);
float peak_amplitude = 0.0f;
{
const float ceiling_position =
fminf(fmaxf(
(${alarm_output_ceiling_percent}.0f - 5.0f) /
95.0f,
0.0f
), 1.0f);
const float ceiling_attenuation_db =
-${alarm_volume_attenuation_db}.0f *
(1.0f - ceiling_position);
const float user_position =
effective_ui_volume / 100.0f;
const float user_attenuation_db =
-${alarm_volume_attenuation_db}.0f *
(1.0f - user_position);
peak_amplitude =
${alarm_pcm_max_amplitude}.0f *
powf(
10.0f,
(ceiling_attenuation_db +
user_attenuation_db) / 20.0f
);
}
const float volume_position =
(ui_volume - 5.0f) / 95.0f;
const float attenuation_db =
-${alarm_volume_range_db}.0f *
(1.0f - volume_position);
const float calculated_amplitude =
${alarm_pcm_amplitude_at_100_percent}.0f *
powf(10.0f, attenuation_db / 20.0f);
const float peak_amplitude = fmaxf(
calculated_amplitude,
${alarm_pcm_minimum_amplitude}.0f
);
std::vector<uint8_t> audio;
audio.reserve(sample_count * 2);