diff --git a/Integrations/ESPHome/Core.yaml b/Integrations/ESPHome/Core.yaml index 3f194d4..87b0751 100644 --- a/Integrations/ESPHome/Core.yaml +++ b/Integrations/ESPHome/Core.yaml @@ -393,9 +393,32 @@ sensor: disabled_by_default: true - platform: uptime - name: Uptime - id: sys_uptime + 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 @@ -776,6 +799,10 @@ text_sensor: id: apollo_firmware_version update_interval: never entity_category: "diagnostic" + - platform: template + name: Uptime + id: sys_uptime + update_interval: never light: - platform: esp32_rmt_led_strip