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

Expose more information to Home Assistant and the hosted website #148

Open
wants to merge 2 commits 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
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ ota:
web_server:
port: 80

#Exposes this data to Home Assistant, and displayed on the website
text_sensor:
# Expose ESPHome version as sensor
- platform: version
name: ${name} ESPHome Version
# Expose the friendly uptime as a sensor
- platform: template
name: ${name} Uptime
id: uptime_human
icon: mdi:clock-start
# Expose the IP Address as a sensor
- platform: ethernet_info
ip_address:
name: ${name} IP Address

script:
- id: fw_update_mode
Expand Down Expand Up @@ -115,6 +129,32 @@ binary_sensor:
stream_server: ss
name: "TubesZB Serial Connected"

#converts uptime in seconds to a more human friendly format
sensor:
- platform: "uptime"
name: "Uptime Sensor"
id: "uptime_sensor"
internal: true
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();

mdns:
services:
- service: "_tubeszb"
Expand Down