-
Notifications
You must be signed in to change notification settings - Fork 1
/
device_base_esp32.yaml
72 lines (64 loc) · 1.84 KB
/
device_base_esp32.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
esphome:
name: $friendly_id
platform: ESP32
board: esp32dev
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
logger:
api:
ota:
# captive_portal:
switch:
- platform: restart
id: ${friendly_id}_restart
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: ${friendly_id}_restart
text_sensor:
# Send IP Address
- platform: wifi_info
ip_address:
id: ${friendly_id}_ip_address
name: "${friendly_name} IP Address"
# Send Uptime in raw seconds
- platform: template
name: ${friendly_name} Uptime
id: ${friendly_id}_uptime_human
icon: mdi:clock-start
# Sensors that the ESPhome unit is capable of reporting
sensor:
- platform: wifi_signal
id: ${friendly_id}_wifi_signal
name: "${friendly_name} WiFi Signal"
update_interval: 300s
- platform: uptime
internal: true
id: ${friendly_id}_uptime_sensor
update_interval: 60s
on_raw_value:
then:
- text_sensor.template.publish:
id: ${friendly_id}_uptime_human
# Custom C++ code to generate the result
state: !lambda |-
int seconds = round(id(${friendly_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();