From 5e214c836f61b3d65bb389b7cc7ca6a971fae3ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=2E=20=C3=81rkosi=20R=C3=B3bert?= Date: Tue, 25 Oct 2022 08:10:06 +0200 Subject: [PATCH] Remove human readable example from uptime (#2384) --- components/sensor/uptime.rst | 38 ------------------------------------ 1 file changed, 38 deletions(-) diff --git a/components/sensor/uptime.rst b/components/sensor/uptime.rst index c8ea1a9e6..c1f6db763 100644 --- a/components/sensor/uptime.rst +++ b/components/sensor/uptime.rst @@ -23,44 +23,6 @@ Configuration variables: - **id** (*Optional*, :ref:`config-id`): Set the ID of this sensor for use in lambdas. - All other options from :ref:`Sensor `. -Human readable sensor ---------------------- - -The sensor reports uptime in seconds which is good for automations -but is hard to read for humans, this example creates a text sensor -with human readable output. - -.. code-block:: yaml - - # Example configuration entry - text_sensor: - - platform: template - name: Uptime Human Readable - id: uptime_human - icon: mdi:clock-start - sensor: - - platform: uptime - name: Uptime Sensor - id: uptime_sensor - update_interval: 60s - on_raw_value: - then: - - text_sensor.template.publish: - id: uptime_human - state: !lambda |- - int seconds = round(id(uptime_sensor).raw_state); - int days = seconds / (24 * 3600); - seconds = seconds % (24 * 3600); - int hours = seconds / 3600; - seconds = seconds % 3600; - int minutes = seconds / 60; - seconds = seconds % 60; - return ( - (days ? to_string(days) + "d " : "") + - (hours ? to_string(hours) + "h " : "") + - (minutes ? to_string(minutes) + "m " : "") + - (to_string(seconds) + "s") - ).c_str(); See Also --------