File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,29 @@ 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();
77100
78101# Captive Portal is the portal created by this node when Wifi connection fails
79102captive_portal :
You can’t perform that action at this time.
0 commit comments