-
Notifications
You must be signed in to change notification settings - Fork 1
/
th0_mini_d1_ant.yaml
185 lines (148 loc) · 3.6 KB
/
th0_mini_d1_ant.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
#zf210514.0831
# Configuration ESPhome
esphome:
name: th0_mini_d1_ant
platform: ESP8266
board: d1_mini
on_boot:
- switch.turn_on: led
- delay: 30s
- logger.log: Y'a un problème, je dois dormir !
- mqtt.publish:
topic: th0_mini_d1_ant/ota/state
payload: 'OFF'
retain: true
- delay: 0.5s
- deep_sleep.enter: deep_sleep_1
# Configuration WIFI
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "th0_mini_d1_ant Fallback"
password: !secret ap_wifi_password
captive_portal:
# Enable logging
logger:
level: DEBUG
logs:
logger: INFO
adc: INFO
captive_portal: INFO
deep_sleep: INFO
htu21d: INFO
i2c: INFO
ota: INFO
restart: INFO
sensor: INFO
switch: INFO
switch.gpio: INFO
uptime.sensor: INFO
web_server: INFO
wifi_signal.sensor: INFO
mqtt: INFO
mqtt.component: INFO
mqtt.client: INFO
mqtt.switch: INFO
mqtt.sensor: INFO
# Enable Home Assistant API
#api:
# password: !secret api_password
ota:
password: !secret ota_password
globals:
- id: ota_state
type: int
initial_value: '0'
interval:
- interval: 1s
then:
if:
condition:
mqtt.connected:
then:
- logger.log: MQTT est connecté !
- if:
condition:
lambda: 'return id(ota_state) == 1;'
then:
- logger.log: OTA est demandé !
- mqtt.publish:
topic: th0_mini_d1_ant/ota/command
payload: 'OFF'
retain: true
- mqtt.publish:
topic: th0_mini_d1_ant/ota/state
payload: 'ON'
retain: true
- logger.log: J'arrête le desleep !
- deep_sleep.prevent: deep_sleep_1
else:
- logger.log: Je suis connected et envoie la sauce !
- delay: 1.5s
- logger.log: Je vais dormir !
- mqtt.publish:
topic: th0_mini_d1_ant/ota/state
payload: 'OFF'
retain: true
- delay: 0.5s
- deep_sleep.enter: deep_sleep_1
else:
- logger.log: MQTT en attente d'être connecté !
# Définition des Switch's
switch:
- platform: gpio
name: "th0_mini_d1_ant LED"
inverted: True
id: led
pin: GPIO2
- platform: restart
name: "th0_mini_d1_ant Restart"
# WEB Server
web_server:
port: 80
# MQTT server
mqtt:
broker: !secret mqtt_server_dev
port: !secret mqtt_port_dev
username: !secret mqtt_user_dev
password: !secret mqtt_password_dev
birth_message:
will_message:
on_message:
- topic: th0_mini_d1_ant/ota/command
payload: 'ON'
then:
- logger.log: Receive OTA command !
- globals.set:
id: ota_state
value: '1'
# I2C conf
i2c:
sda: GPIO4
scl: GPIO14
# Sensors
sensor:
- platform: wifi_signal
name: "th0_mini_d1_ant Signal Wi-Fi"
update_interval: 3s
- platform: uptime
name: "th0_mini_d1_ant uptime"
update_interval: 3s
- platform: htu21d
temperature:
name: "th0_mini_d1_ant Température"
humidity:
name: "th0_mini_d1_ant Humidité"
update_interval: 3s
- platform: adc
pin: VCC
name: "th0_mini_d1_ant VCC Voltage"
update_interval: 3s
# Deep Sleep
deep_sleep:
run_duration: 10s
sleep_duration: 300s
id: deep_sleep_1