-
Notifications
You must be signed in to change notification settings - Fork 1
/
device_base_all.yaml
76 lines (67 loc) · 1.79 KB
/
device_base_all.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
esphome:
name: $friendly_name
# esp8266:
# board: nodemcuv2
# restore_from_flash: true
# framework:
# version: recommended
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
#fast_connect: on
logger:
api:
ota:
captive_portal:
switch:
- platform: restart
id: restart1
name: $friendly_name ESP32 Restart
time:
- platform: homeassistant
on_time:
# Every morning at 12:30am
- seconds: 0
minutes: 30
hours: 0
then:
- switch.turn_on: restart1
text_sensor:
# Send IP Address
- platform: wifi_info
ip_address:
name: "$friendly_name IP Address"
# Send Uptime in raw seconds
- platform: template
name: $friendly_name Uptime
id: uptime_human
update_interval: 24h
icon: mdi:clock-start
# Sensors that the ESPhome unit is capable of reporting
sensor:
- platform: wifi_signal
name: "$friendly_name WiFi Signal"
update_interval: 10min
- platform: uptime
internal: true
id: uptime_sensor
update_interval: 10min
on_raw_value:
then:
- text_sensor.template.publish:
id: uptime_human
# Custom C++ code to generate the result
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();