-
Notifications
You must be signed in to change notification settings - Fork 3
/
esphome-fancontroller.yaml
201 lines (184 loc) · 4.34 KB
/
esphome-fancontroller.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
substitutions:
device_name: "ATI Ambiente Fan Controller"
device_name_low: "ati_ambient_fan_controller"
comment: "ATI Fan Controller"
version: "1.0.0"
speed_low: "10"
speed_med: "50"
speed_full: "100"
esphome:
name: "${device_name_low}"
comment: "${comment}"
platform: ESP8266
board: d1_mini
project:
name: "soloam.fan_controller"
version: "${version}"
on_boot:
then:
- delay: 10s
- fan.turn_on:
id: fan_speed
speed: "${speed_low}"
- delay: 5s
- fan.turn_on:
id: fan_speed
speed: "${speed_full}"
api:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
domain: .myhome
use_address: 192.168.7.200
ap:
ssid: "${device_name}"
password: !secret wifi_ap_password
captive_portal:
web_server:
port: 80
# Enable logging
#debug:
#logger:
# level: debug
ota:
mqtt:
broker: !secret mqtt_broker
discovery: false
topic_prefix: "esphome/${device_name_low}"
output:
- platform: esp8266_pwm
pin: D4
frequency: 15000 Hz
id: pwm_output
fan:
- platform: speed
id: fan_speed
output: pwm_output
speed_count: 100
name: "${device_name} Fan"
command_topic: "esphome/${device_name_low}/fan/command"
state_topic: "esphome/${device_name_low}/fan/state"
on_turn_on:
then:
- switch.turn_on: power
on_turn_off:
then:
- switch.turn_off: power
number:
- platform: template
icon: "mdi:fan"
id: speed_input
name: "${device_name} Fan Speed"
lambda: |-
return id(fan_speed).speed;
step: 1
min_value: 1
max_value: 100
unit_of_measurement: "%"
update_interval: 1s
set_action:
then:
- fan.turn_on:
id: fan_speed
speed: !lambda "return x;"
- component.update: fanmode
- component.update: sensor_fanspeed
select:
- platform: template
icon: "mdi:fan"
name: "${device_name} Fan Mode"
id: fanmode
update_interval: 1s
lambda: |-
if(id(fan_speed).speed <= ${speed_low})
return std::string("Low");
else if(id(fan_speed).speed == ${speed_med})
return std::string("Medium");
else if(id(fan_speed).speed >= ${speed_full})
return std::string("Full");
else
return std::string("Custom");
set_action:
then:
- lambda: |-
auto call = id(fan_speed).turn_on();
if(x == "Low")
call.set_speed(${speed_low});
else if(x == "Medium")
call.set_speed(${speed_med});
else if(x == "Full")
call.set_speed(${speed_full});
else
call.set_speed(id(speed_input).state);
call.perform();
- component.update: speed_input
- component.update: sensor_fanspeed
options:
- Low
- Medium
- Full
- Custom
switch:
- platform: gpio
name: "${device_name} Power"
pin: D1
id: power
restore_mode: RESTORE_DEFAULT_ON
internal: true
button:
- platform: template
icon: "mdi:fan-speed-1"
name: "${device_name} Set Low Speed"
id: fanlow
on_press:
- fan.turn_on:
id: fan_speed
speed: "${speed_low}"
- platform: template
icon: "mdi:fan-speed-2"
name: "${device_name} Set Medium Speed"
on_press:
- fan.turn_on:
id: fan_speed
speed: "${speed_med}"
- platform: template
icon: "mdi:fan-speed-3"
name: "${device_name} Set Full Speed"
on_press:
- fan.turn_on:
id: fan_speed
speed: "${speed_full}"
- platform: restart
name: "${device_name} Restart"
sensor:
- platform: template
id: sensor_fanspeed
icon: "mdi:fan"
name: "${device_name} Fan Seed"
lambda: |-
return id(fan_speed).speed;
update_interval: 1s
accuracy_decimals: 0
unit_of_measurement: "%"
- platform: dht
pin: D2
temperature:
name: "${device_name} Temperature"
humidity:
name: "${device_name} Humidity"
update_interval: 30s
model: DHT22
- platform: pulse_counter
icon: "mdi:fan"
pin:
number: D3
name: "${device_name} RPM"
unit_of_measurement: rpm
accuracy_decimals: 0
filters:
- multiply: 0.5
count_mode:
rising_edge: DISABLE
falling_edge: INCREMENT
update_interval: 1s