-
Notifications
You must be signed in to change notification settings - Fork 20
/
pc-power.yaml
72 lines (62 loc) · 1.47 KB
/
pc-power.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: pc-power
# ESP8266 board
esp8266:
board: nodemcuv2
# Or: ESP32 board (comment out esp8266)
# esp32:
# lolin_d32
# WiFi connection to base station
wifi:
ssid: !secret esphome_wifi_ssid
password: !secret esphome_wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "PC Power Fallback Hotspot"
password: !secret esphome_ap_password
# captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
password: !secret esphome_api_password
# Enable OTA update via WiFi
ota:
- platform: esphome
password: !secret esphome_ota_password
switch:
- platform: gpio
id: power_short_press
name: "PC Power Toggle"
icon: "mdi:electric-switch"
pin:
number: D2 # Power button output pin
inverted: false
allow_other_uses: true
mode:
output: true
on_turn_on:
- delay: 150ms
- switch.turn_off: power_short_press
- platform: gpio
id: power_long_press
name: "PC HARD POWER OFF"
icon: "mdi:electric-switch"
pin:
number: D2 # Power button output pin
inverted: false
allow_other_uses: true
mode:
output: true
on_turn_on:
- delay: 3500ms
- switch.turn_off: power_long_press
binary_sensor:
- platform: gpio
name: "PC Power State"
device_class: power
pin:
number: D1 # Power detect input pin (readback from Reset button)
inverted: false
mode:
input: true