@@ -74,29 +74,11 @@ text_sensor:
7474 icon : mdi:network-outline
7575 - platform : version
7676 name : " ESPHome Version"
77- # Uptime Sensor
78- - platform : uptime
79- name : " Uptime"
80- id : uptime_sensor
81- update_interval : 360s
82- on_raw_value :
83- then :
84- - text_sensor.template.publish :
85- id : uptime_human
86- state : !lambda |-
87- int seconds = round(id(uptime_sensor).raw_state);
88- int days = seconds / (24 * 3600);
89- seconds = seconds % (24 * 3600);
90- int hours = seconds / 3600;
91- seconds = seconds % 3600;
92- int minutes = seconds / 60;
93- seconds = seconds % 60;
94- return (
95- (days ? to_string(days) + "d " : "") +
96- (hours ? to_string(hours) + "h " : "") +
97- (minutes ? to_string(minutes) + "m " : "") +
98- (to_string(seconds) + "s")
99- ).c_str();
77+ # Expose Uptime
78+ - platform : template
79+ name : " Uptime Human Readable"
80+ id : uptime_human
81+ icon : mdi:clock-start
10082
10183# Captive Portal is the portal created by this node when Wifi connection fails
10284captive_portal :
@@ -141,6 +123,30 @@ sensor:
141123 name : " Ambient Humidity"
142124 update_interval : 60s
143125
126+ # Uptime Sensor
127+ - platform : uptime
128+ name : " Uptime"
129+ id : uptime_sensor
130+ update_interval : 360s
131+ on_raw_value :
132+ then :
133+ - text_sensor.template.publish :
134+ id : uptime_human
135+ state : !lambda |-
136+ int seconds = round(id(uptime_sensor).raw_state);
137+ int days = seconds / (24 * 3600);
138+ seconds = seconds % (24 * 3600);
139+ int hours = seconds / 3600;
140+ seconds = seconds % 3600;
141+ int minutes = seconds / 60;
142+ seconds = seconds % 60;
143+ return (
144+ (days ? to_string(days) + "d " : "") +
145+ (hours ? to_string(hours) + "h " : "") +
146+ (minutes ? to_string(minutes) + "m " : "") +
147+ (to_string(seconds) + "s")
148+ ).c_str();
149+
144150# Status LED: indicates WiFi/API connection status
145151# GPIO23 LED will be ON when connected, blinking when disconnected
146152status_led :
0 commit comments