96 lines
2.2 KiB
YAML
96 lines
2.2 KiB
YAML
esphome:
|
|
name: heart
|
|
|
|
esp8266:
|
|
board: esp01_1m
|
|
|
|
# Enable logging
|
|
logger:
|
|
|
|
# Enable Home Assistant API
|
|
api:
|
|
encryption:
|
|
key: "+N0FoP/8Iai5hBYZv5EEd2/uZypPe1nvQSskIOo8aeA="
|
|
|
|
ota:
|
|
- platform: esphome
|
|
password: "cf4259c67a56c86316e14d48ff6e867f"
|
|
|
|
wifi:
|
|
ssid: "SmartHome"
|
|
password: ""
|
|
|
|
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
|
ap:
|
|
# ssid: "Gas-Kitchen Fallback Hotspot"
|
|
# password: "0n8oXqMAAFPU"
|
|
|
|
use_address: 192.168.88.32
|
|
|
|
manual_ip:
|
|
static_ip: 192.168.88.32
|
|
gateway: 192.168.88.1
|
|
subnet: 255.255.255.0
|
|
|
|
captive_portal:
|
|
|
|
switch:
|
|
- platform: gpio
|
|
pin: GPIO0
|
|
name: "Heart switch"
|
|
inverted: true
|
|
|
|
# The following can be omitted
|
|
- platform: restart
|
|
name: ${devicename} restart
|
|
|
|
sensor:
|
|
- platform: wifi_signal
|
|
name: ${devicename} wifi signal
|
|
update_interval: 600s
|
|
|
|
# human readable uptime sensor output to the text sensor above
|
|
- platform: uptime
|
|
name: ${devicename} Uptime in Days
|
|
id: uptime_sensor_days
|
|
update_interval: 60s
|
|
on_raw_value:
|
|
then:
|
|
- text_sensor.template.publish:
|
|
id: uptime_human
|
|
state: !lambda |-
|
|
int seconds = round(id(uptime_sensor_days).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 ? String(days) + "d " : "") +
|
|
(hours ? String(hours) + "h " : "") +
|
|
(minutes ? String(minutes) + "m " : "") +
|
|
(String(seconds) + "s")
|
|
).c_str();
|
|
|
|
time:
|
|
- platform: homeassistant
|
|
id: homeassistant_time
|
|
|
|
# Text sensors with general information.
|
|
text_sensor:
|
|
# Expose ESPHome version as sensor.
|
|
- platform: version
|
|
name: $devicename Version
|
|
# Expose WiFi information as sensors.
|
|
- platform: wifi_info
|
|
ip_address:
|
|
name: $devicename IP
|
|
bssid:
|
|
name: $devicename BSSID
|
|
|
|
# human readable update text sensor from sensor:uptime
|
|
- platform: template
|
|
name: Uptime Human Readable
|
|
id: uptime_human
|
|
icon: mdi:clock-start |