Skip to content

Commit

Permalink
Some tweak to hs server uptime
Browse files Browse the repository at this point in the history
  • Loading branch information
rhoriguchi committed Nov 15, 2023
1 parent 6583dd0 commit 0ae61ed
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,12 @@ in {
type = "entities";
title = "Info";
entities = [
{
name = "Last rebooted";
entity = "sensor.last_rebooted";
}
{
name = "Uptime";
icon = "mdi:clock";
entity = "sensor.uptime";
}
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ in {
]);
}];

template = [{
sensor = [
{
name = "Uptime";
icon = "mdi:clock";
state = "{{ states('sensor.last_boot') | as_datetime | relative_time }}";
}
{
name = "Last rebooted";
icon = "mdi:clock";
state = "{{ states('sensor.last_boot') | as_timestamp | timestamp_custom('%d.%m.%Y %H:%M:%S') }}";
}
];
}];

command_line = [
{
sensor = {
Expand All @@ -41,14 +56,6 @@ in {
command = "${pkgs.coreutils}/bin/uname -r";
};
}
{
sensor = {
name = "Uptime";
scan_interval = 60;
command =
"${pkgs.coreutils}/bin/uptime | ${pkgs.gawk}/bin/awk -F '( |,|:)+' '{d=h=m=0; if ($7==\"min\") m=$6; else {if ($7~/^day/) {d=$6;h=$8;m=$9} else {h=$6;m=$7}}} {print d+0,\"days\",h+0,\"hours\",m+0,\"minutes\"}'";
};
}
];
};
}

0 comments on commit 0ae61ed

Please sign in to comment.