-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
pc-switch.yaml
116 lines (95 loc) · 2.1 KB
/
pc-switch.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
substitutions:
name: "pc"
uppercase_name: "PC"
esphome:
name: "${name}"
platform: ESP8266
board: nodemcuv2
project:
name: "ajfriesen.pc-switch"
version: "1.0.1"
# Enable logging
logger:
# Enable Home Assistant API
api:
dashboard_import:
package_import_url: github://ajfriesen/pc-switch/pc-switch.yaml@main
# Put ota password here
ota:
# Your wifi config
wifi:
# ssid: ""
# password: ""
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "PC-Switch Fallback Hotspot"
password: "fallback-wifi"
captive_portal:
web_server:
port: 80
sensor:
- platform: wifi_signal
name: "pc-switch WiFi Signal"
update_interval: 60s
switch:
- platform: gpio
pin: D6
id: power_pin
internal: true
- platform: template
name: "Power Switch"
id: power_switch
internal: true
turn_on_action:
- switch.turn_on: power_pin
- delay: 300ms
- switch.turn_off: power_pin
- platform: template
name: "Power Switch Force"
id: power_switch_force
internal: true
turn_on_action:
- switch.turn_on: power_pin
- delay: 5000ms
- switch.turn_off: power_pin
- platform: gpio
pin: D7
id: reset_pin
internal: true
- platform: template
name: "Reset Switch"
id: reset_switch
internal: true
turn_on_action:
- switch.turn_on: reset_pin
- delay: 300ms
- switch.turn_off: reset_pin
binary_sensor:
- platform: gpio
pin: D0
id: pc_power_sensor
name: "${name} Power State"
device_class: power
icon: "mdi:desktop-classic"
button:
- platform: template
name: "${name} Power Button"
id: power_button
icon: "mdi:power-standby"
on_press:
then:
- switch.toggle: power_switch
- platform: template
name: "${name} Force Power Off"
id: force_power_off
icon: "mdi:power-plug-off"
on_press:
then:
- switch.toggle: power_switch_force
- platform: template
name: "${name} Reset Button"
id: reset_button
icon: "mdi:restart"
on_press:
then:
- switch.toggle: reset_switch