Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e2fdd04
Refactor uptime calculation and string formatting for ESPHome 2026.1.0
Roving-Ronin Jan 21, 2026
91c77db
Refactor uptime calculation and string formatting for ESPHome 2026.1.0
Roving-Ronin Jan 21, 2026
39f420b
Refactor uptime calculation and string formatting
Roving-Ronin Jan 21, 2026
c1d5133
Refactor uptime calculation and return types
Roving-Ronin Jan 21, 2026
95d6c24
Refactor uptime sensor to use std::string
Roving-Ronin Jan 21, 2026
29a6fbb
Refactor uptime calculation and string formatting
Roving-Ronin Jan 21, 2026
3cd2c4f
Refactor uptime sensor to use std::string
Roving-Ronin Jan 21, 2026
b7227d7
Refactor uptime calculation to use std::string
Roving-Ronin Jan 21, 2026
c2f9b54
Refactor uptime calculation to use std::string
Roving-Ronin Jan 21, 2026
332d7e0
Refactor uptime calculation to use std::string
Roving-Ronin Jan 21, 2026
679ebe9
Update athom-relay-board-x8.yaml
Roving-Ronin Jan 21, 2026
fe478e8
Update athom-rgb-light.yaml
Roving-Ronin Jan 21, 2026
7c0a3ea
Refactor uptime sensor lambda for better clarity
Roving-Ronin Jan 21, 2026
4200b53
Refactor uptime sensor lambda for better clarity
Roving-Ronin Jan 21, 2026
fe14693
Refactor uptime sensor logic for better clarity
Roving-Ronin Jan 21, 2026
24ca70e
Refactor uptime display logic in athom-sw01.yaml
Roving-Ronin Jan 21, 2026
645ad2d
Refactor uptime calculation and string formatting
Roving-Ronin Jan 21, 2026
98641c5
Refactor uptime calculation to use std::string
Roving-Ronin Jan 21, 2026
2060450
Refactor uptime calculation and output formatting
Roving-Ronin Jan 21, 2026
068c528
Update athom-sw04.yaml
Roving-Ronin Jan 21, 2026
1fcd5ef
Refactor uptime calculation to use std::string
Roving-Ronin Jan 21, 2026
0fe9ca6
Refactor uptime calculation and string formatting
Roving-Ronin Jan 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 30 additions & 15 deletions athom-cb02.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -230,24 +230,39 @@ text_sensor:
name: "Uptime"
entity_category: diagnostic
lambda: |-
int seconds = (id(uptime_sensor).state);
int seconds = (int) id(uptime_seconds).state;
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
seconds %= (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
if ( days > 3650 ) {
return { "Starting up" };
} else if ( days ) {
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( hours ) {
return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( minutes ) {
return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
seconds %= 3600;
int minutes = seconds / 60;
seconds %= 60;

if (days > 3650) {
return std::string("Starting up");
} else if (days) {
return std::string(
std::to_string(days) + "d " +
std::to_string(hours) + "h " +
std::to_string(minutes) + "m " +
std::to_string(seconds) + "s"
);
} else if (hours) {
return std::string(
std::to_string(hours) + "h " +
std::to_string(minutes) + "m " +
std::to_string(seconds) + "s"
);
} else if (minutes) {
return std::string(
std::to_string(minutes) + "m " +
std::to_string(seconds) + "s"
);
} else {
return { (String(seconds) +"s").c_str() };
}
return std::string(
std::to_string(seconds) + "s"
);
}
icon: mdi:clock-start

time:
Expand Down
45 changes: 30 additions & 15 deletions athom-garage-door.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -217,24 +217,39 @@ text_sensor:
name: "Uptime"
entity_category: diagnostic
lambda: |-
int seconds = (id(uptime_sensor).state);
int seconds = (int) id(uptime_seconds).state;
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
seconds %= (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
if ( days > 3650 ) {
return { "Starting up" };
} else if ( days ) {
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( hours ) {
return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( minutes ) {
return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
seconds %= 3600;
int minutes = seconds / 60;
seconds %= 60;

if (days > 3650) {
return std::string("Starting up");
} else if (days) {
return std::string(
std::to_string(days) + "d " +
std::to_string(hours) + "h " +
std::to_string(minutes) + "m " +
std::to_string(seconds) + "s"
);
} else if (hours) {
return std::string(
std::to_string(hours) + "h " +
std::to_string(minutes) + "m " +
std::to_string(seconds) + "s"
);
} else if (minutes) {
return std::string(
std::to_string(minutes) + "m " +
std::to_string(seconds) + "s"
);
} else {
return { (String(seconds) +"s").c_str() };
}
return std::string(
std::to_string(seconds) + "s"
);
}
icon: mdi:clock-start

time:
Expand Down
45 changes: 30 additions & 15 deletions athom-mini-switch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,24 +258,39 @@ text_sensor:
name: "Uptime"
entity_category: diagnostic
lambda: |-
int seconds = (id(uptime_sensor).state);
int seconds = (int) id(uptime_seconds).state;
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
seconds %= (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
if ( days > 3650 ) {
return { "Starting up" };
} else if ( days ) {
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( hours ) {
return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( minutes ) {
return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
seconds %= 3600;
int minutes = seconds / 60;
seconds %= 60;

if (days > 3650) {
return std::string("Starting up");
} else if (days) {
return std::string(
std::to_string(days) + "d " +
std::to_string(hours) + "h " +
std::to_string(minutes) + "m " +
std::to_string(seconds) + "s"
);
} else if (hours) {
return std::string(
std::to_string(hours) + "h " +
std::to_string(minutes) + "m " +
std::to_string(seconds) + "s"
);
} else if (minutes) {
return std::string(
std::to_string(minutes) + "m " +
std::to_string(seconds) + "s"
);
} else {
return { (String(seconds) +"s").c_str() };
}
return std::string(
std::to_string(seconds) + "s"
);
}
icon: mdi:clock-start

time:
Expand Down
45 changes: 30 additions & 15 deletions athom-presence-sensor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -436,24 +436,39 @@ text_sensor:
name: "Uptime"
entity_category: diagnostic
lambda: |-
int seconds = (id(uptime_sensor).state);
int seconds = (int) id(uptime_seconds).state;
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
seconds %= (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
if ( days > 3650 ) {
return { "Starting up" };
} else if ( days ) {
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( hours ) {
return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( minutes ) {
return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
seconds %= 3600;
int minutes = seconds / 60;
seconds %= 60;

if (days > 3650) {
return std::string("Starting up");
} else if (days) {
return std::string(
std::to_string(days) + "d " +
std::to_string(hours) + "h " +
std::to_string(minutes) + "m " +
std::to_string(seconds) + "s"
);
} else if (hours) {
return std::string(
std::to_string(hours) + "h " +
std::to_string(minutes) + "m " +
std::to_string(seconds) + "s"
);
} else if (minutes) {
return std::string(
std::to_string(minutes) + "m " +
std::to_string(seconds) + "s"
);
} else {
return { (String(seconds) +"s").c_str() };
}
return std::string(
std::to_string(seconds) + "s"
);
}
icon: mdi:clock-start

time:
Expand Down
45 changes: 30 additions & 15 deletions athom-relay-board-x1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,24 +166,39 @@ text_sensor:
name: "Uptime"
entity_category: diagnostic
lambda: |-
int seconds = (id(uptime_sensor).state);
int seconds = (int) id(uptime_seconds).state;
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
seconds %= (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
if ( days > 3650 ) {
return { "Starting up" };
} else if ( days ) {
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( hours ) {
return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( minutes ) {
return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
seconds %= 3600;
int minutes = seconds / 60;
seconds %= 60;

if (days > 3650) {
return std::string("Starting up");
} else if (days) {
return std::string(
std::to_string(days) + "d " +
std::to_string(hours) + "h " +
std::to_string(minutes) + "m " +
std::to_string(seconds) + "s"
);
} else if (hours) {
return std::string(
std::to_string(hours) + "h " +
std::to_string(minutes) + "m " +
std::to_string(seconds) + "s"
);
} else if (minutes) {
return std::string(
std::to_string(minutes) + "m " +
std::to_string(seconds) + "s"
);
} else {
return { (String(seconds) +"s").c_str() };
}
return std::string(
std::to_string(seconds) + "s"
);
}
icon: mdi:clock-start

time:
Expand Down
45 changes: 30 additions & 15 deletions athom-relay-board-x2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -173,24 +173,39 @@ text_sensor:
name: "Uptime"
entity_category: diagnostic
lambda: |-
int seconds = (id(uptime_sensor).state);
int seconds = (int) id(uptime_seconds).state;
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
seconds %= (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
if ( days > 3650 ) {
return { "Starting up" };
} else if ( days ) {
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( hours ) {
return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( minutes ) {
return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
seconds %= 3600;
int minutes = seconds / 60;
seconds %= 60;

if (days > 3650) {
return std::string("Starting up");
} else if (days) {
return std::string(
std::to_string(days) + "d " +
std::to_string(hours) + "h " +
std::to_string(minutes) + "m " +
std::to_string(seconds) + "s"
);
} else if (hours) {
return std::string(
std::to_string(hours) + "h " +
std::to_string(minutes) + "m " +
std::to_string(seconds) + "s"
);
} else if (minutes) {
return std::string(
std::to_string(minutes) + "m " +
std::to_string(seconds) + "s"
);
} else {
return { (String(seconds) +"s").c_str() };
}
return std::string(
std::to_string(seconds) + "s"
);
}
icon: mdi:clock-start

time:
Expand Down
45 changes: 30 additions & 15 deletions athom-relay-board-x4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,24 +186,39 @@ text_sensor:
name: "Uptime"
entity_category: diagnostic
lambda: |-
int seconds = (id(uptime_sensor).state);
int seconds = (int) id(uptime_seconds).state;
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
seconds %= (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
if ( days > 3650 ) {
return { "Starting up" };
} else if ( days ) {
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( hours ) {
return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( minutes ) {
return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
seconds %= 3600;
int minutes = seconds / 60;
seconds %= 60;

if (days > 3650) {
return std::string("Starting up");
} else if (days) {
return std::string(
std::to_string(days) + "d " +
std::to_string(hours) + "h " +
std::to_string(minutes) + "m " +
std::to_string(seconds) + "s"
);
} else if (hours) {
return std::string(
std::to_string(hours) + "h " +
std::to_string(minutes) + "m " +
std::to_string(seconds) + "s"
);
} else if (minutes) {
return std::string(
std::to_string(minutes) + "m " +
std::to_string(seconds) + "s"
);
} else {
return { (String(seconds) +"s").c_str() };
}
return std::string(
std::to_string(seconds) + "s"
);
}
icon: mdi:clock-start

time:
Expand Down
Loading
Loading