Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Uptime Sensors #142

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
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
28 changes: 27 additions & 1 deletion home_assistant_glow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ text_sensor:
ssid:
name: '${friendly_name} - Connected SSID'
icon: mdi:wifi-strength-2
- platform: template
name: Uptime Human Readable
id: uptime_human
icon: mdi:clock-start

sensor:
# WiFi signal
Expand Down Expand Up @@ -167,8 +171,30 @@ sensor:
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
- 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();

# Enable time component to reset energy at midnight
time:
- platform: sntp
id: my_time
id: my_time