From 927380b278d99f436e194ed1279a23bc898b7cd6 Mon Sep 17 00:00:00 2001 From: kernelpanic85 <80057019+kernelpanic85@users.noreply.github.com> Date: Fri, 18 Sep 2026 23:33:10 -0400 Subject: [PATCH 1/2] Make uptime sensor human-readable Updates the R-PRO-1 uptime reporting to display uptime in days, hours, minutes, and seconds format instead of raw seconds. --- Integrations/ESPHome/Core.yaml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Integrations/ESPHome/Core.yaml b/Integrations/ESPHome/Core.yaml index 3f194d4..09d5c63 100644 --- a/Integrations/ESPHome/Core.yaml +++ b/Integrations/ESPHome/Core.yaml @@ -393,9 +393,9 @@ sensor: disabled_by_default: true - platform: uptime - name: Uptime - id: sys_uptime + id: sys_uptime_seconds update_interval: 60s + internal: true - platform: scd4x id: scd40 @@ -776,6 +776,20 @@ text_sensor: id: apollo_firmware_version update_interval: never entity_category: "diagnostic" + - platform: template + name: Uptime + id: sys_uptime + update_interval: 60s + lambda: |- + const uint32_t total_seconds = static_cast(id(sys_uptime_seconds).state); + const uint32_t days = total_seconds / 86400; + const uint32_t hours = (total_seconds % 86400) / 3600; + const uint32_t minutes = (total_seconds % 3600) / 60; + const uint32_t seconds = total_seconds % 60; + + char buffer[32]; + snprintf(buffer, sizeof(buffer), "%ud %02uh %02um %02us", days, hours, minutes, seconds); + return {buffer}; light: - platform: esp32_rmt_led_strip From 417526e450728889414b72f2a981a9741de3d5e0 Mon Sep 17 00:00:00 2001 From: kernelpanic85 <80057019+kernelpanic85@users.noreply.github.com> Date: Sun, 20 Sep 2026 14:59:19 -0400 Subject: [PATCH 2/2] Refactor uptime handling in Core.yaml Refactored uptime calculation logic to use on_raw_value event and removed previous lambda implementation. --- Integrations/ESPHome/Core.yaml | 35 +++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/Integrations/ESPHome/Core.yaml b/Integrations/ESPHome/Core.yaml index 09d5c63..87b0751 100644 --- a/Integrations/ESPHome/Core.yaml +++ b/Integrations/ESPHome/Core.yaml @@ -396,6 +396,29 @@ sensor: id: sys_uptime_seconds update_interval: 60s internal: true + on_raw_value: + then: + - text_sensor.template.publish: + id: sys_uptime + state: !lambda |- + const uint32_t total_seconds = static_cast(x); + const uint32_t days = total_seconds / 86400; + const uint32_t hours = (total_seconds % 86400) / 3600; + const uint32_t minutes = (total_seconds % 3600) / 60; + const uint32_t seconds = total_seconds % 60; + + std::string uptime; + if (days > 0) { + uptime += to_string(days) + "d "; + } + if (hours > 0) { + uptime += to_string(hours) + "h "; + } + if (minutes > 0) { + uptime += to_string(minutes) + "m "; + } + uptime += to_string(seconds) + "s"; + return uptime; - platform: scd4x id: scd40 @@ -779,17 +802,7 @@ text_sensor: - platform: template name: Uptime id: sys_uptime - update_interval: 60s - lambda: |- - const uint32_t total_seconds = static_cast(id(sys_uptime_seconds).state); - const uint32_t days = total_seconds / 86400; - const uint32_t hours = (total_seconds % 86400) / 3600; - const uint32_t minutes = (total_seconds % 3600) / 60; - const uint32_t seconds = total_seconds % 60; - - char buffer[32]; - snprintf(buffer, sizeof(buffer), "%ud %02uh %02um %02us", days, hours, minutes, seconds); - return {buffer}; + update_interval: never light: - platform: esp32_rmt_led_strip