-
Notifications
You must be signed in to change notification settings - Fork 0
/
ttgo_t-call_sim800.yaml
196 lines (172 loc) · 4.03 KB
/
ttgo_t-call_sim800.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
esphome:
name: esp32_sim
platform: ESP32
board: esp-wrover-kit
#IP5306 Custom
includes:
- IP5306.h
wifi:
ssid: 'SSID'
password: 'PASSWORD'
# Disble auto reboot
reboot_timeout: 0s
logger:
ota:
web_server:
port: 80
# Home Assistant API
api:
# Disable API-reboot
reboot_timeout: 0s
# SMS service
services:
- service: send_sms
variables:
recipient: string
message: string
then:
- sim800l.send_sms:
recipient: !lambda 'return recipient;'
message: !lambda 'return message;'
# i2c for onboard IP5306
i2c:
sda: 21
scl: 22
scan: True
sensor:
# IP5306
- platform: custom
lambda: |-
auto battery_sensor = new IP5306();
App.register_component(battery_sensor);
return {battery_sensor->fully_charged, battery_sensor->battery_level};
sensors:
- name: "esp32_sim_ip5306_fully_charged"
accuracy_decimals: 0
- name: "esp32_sim_ip5306_battery_sensor"
accuracy_decimals: 0
# Pulse counter for sim led
- platform: pulse_counter
pin: 12
name: "esp32_sim_pulse_counter"
id: "esp32_sim_pulse_counter"
update_interval: 60s
# New SMS - Home Assistant Boolean
- platform: homeassistant
internal: true
name: "New SMS"
entity_id: input_boolean.sms
- platform: wifi_signal
name: "esp32_sim_wifi"
update_interval: 60s
- platform: uptime
name: "esp32_sim_uptime"
binary_sensor:
# Connected to API
- platform: status
name: "esp32_sim_connected"
id: "esp32_sim_connected"
filters:
- delayed_off: 60s
text_sensor:
- platform: template
name: "esp32_sim_status"
lambda: |-
if (id(esp32_sim_pulse_counter).state >= 18 && id(esp32_sim_pulse_counter).state <= 22) {
return {"Registered"};
}
else if (id(esp32_sim_pulse_counter).state > 22) {
return {"Registering"};
}
else if (id(esp32_sim_pulse_counter).state == 0) {
return {"Powered down"};
}
else {
return {"Unknown"};
}
update_interval: 10s
- platform: version
name: "esp32_sim_version"
- platform: template
id: sms_sender
name: "esp32_sim_sms_sender"
- platform: template
id: sms_message
name: "esp32_sim_sms_message"
time:
- platform: homeassistant
id: homeassistant_time
# Onboard SIM800L
# GPIO 27
# GPIO 26
uart:
baud_rate: 115200
tx_pin: 27
rx_pin: 26
sim800l:
on_sms_received:
- logger.log:
format: "Received '%s' from %s"
args: [ 'message.c_str()', 'sender.c_str()' ]
- lambda: |-
id(sms_sender).publish_state(sender);
id(sms_message).publish_state(message);
# SMS is a sensor reboot request
- if:
condition:
and:
- lambda: 'return id(sms_sender).state == "+47XXXXXXXX";'
- lambda: 'return id(sms_message).state == "REBOOT";'
then:
- sim800l.send_sms:
recipient: '+47XXXXXXXX'
message: Restarting...
- delay: 00:00:20
- switch.turn_on: restartswitch
# Also when receiving SMS
- light.turn_on:
id: led
- homeassistant.service:
service: input_boolean.turn_on
data:
entity_id: input_boolean.sms
- delay: 00:00:05
- homeassistant.service:
service: input_boolean.turn_off
data:
entity_id: input_boolean.sms
- delay: 00:00:55
- light.turn_off:
id: led
# Onboard SIM800L GPIO power/reset
# GPIO 23
# GPIO 4
# GPIO 5
switch:
- platform: gpio
pin: 23
name: "esp32_sim_sim800l_power"
restore_mode: ALWAYS_ON
- platform: gpio
pin: 4
name: "SIM800L PWRKEY"
restore_mode: ALWAYS_OFF
internal: true
- platform: gpio
pin: 5
name: "SIM800L RST"
restore_mode: ALWAYS_ON
internal: true
- platform: restart
id: restartswitch
name: "esp32_sim_restart"
output:
# GPIO 13
- platform: ledc
pin: 13
id: state_led
light:
- platform: monochromatic
name: "esp32_sim_led"
output: state_led
id: led