-
Notifications
You must be signed in to change notification settings - Fork 0
/
tpms-01.yaml
170 lines (151 loc) · 4.81 KB
/
tpms-01.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
esphome:
name: $devicename
substitutions:
devicename: "tpms-01"
esp32:
board: nodemcu-32s
framework:
type: arduino
logger:
level: DEBUG
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
api:
sensor:
- platform: template
name: "$devicename FL Temperature"
id: ble_fl_temp
unit_of_measurement: "°C"
icon: "mdi:thermometer"
device_class: "temperature"
state_class: "measurement"
- platform: template
name: "$devicename FL Pressure"
id: ble_fl_press
unit_of_measurement: "bar"
icon: "mdi:gauge"
device_class: "pressure"
state_class: "measurement"
- platform: template
name: "$devicename FL Voltage"
id: ble_fl_batt
unit_of_measurement: "V"
icon: "mdi:battery"
device_class: "voltage"
state_class: "measurement"
- platform: template
name: "$devicename FR Temperature"
id: ble_fr_temp
unit_of_measurement: "°C"
icon: "mdi:thermometer"
device_class: "temperature"
state_class: "measurement"
- platform: template
name: "$devicename FR Pressure"
id: ble_fr_press
unit_of_measurement: "bar"
icon: "mdi:gauge"
device_class: "pressure"
state_class: "measurement"
- platform: template
name: "$devicename FR Voltage"
id: ble_fr_batt
unit_of_measurement: "V"
icon: "mdi:battery"
device_class: "voltage"
state_class: "measurement"
- platform: template
name: "$devicename RL Temperature"
id: ble_rl_temp
unit_of_measurement: "°C"
icon: "mdi:thermometer"
device_class: "temperature"
state_class: "measurement"
- platform: template
name: "$devicename RL Pressure"
id: ble_rl_press
unit_of_measurement: "bar"
icon: "mdi:gauge"
device_class: "pressure"
state_class: "measurement"
- platform: template
name: "$devicename RL Voltage"
id: ble_rl_batt
unit_of_measurement: "V"
icon: "mdi:battery"
device_class: "voltage"
state_class: "measurement"
- platform: template
name: "$devicename RR Temperature"
id: ble_rr_temp
unit_of_measurement: "°C"
icon: "mdi:thermometer"
device_class: "temperature"
state_class: "measurement"
- platform: template
name: "$devicename RR Pressure"
id: ble_rr_press
unit_of_measurement: "bar"
icon: "mdi:gauge"
device_class: "pressure"
state_class: "measurement"
- platform: template
name: "$devicename RR Voltage"
id: ble_rr_batt
unit_of_measurement: "V"
icon: "mdi:battery"
device_class: "voltage"
state_class: "measurement"
esp32_ble_tracker:
scan_parameters:
active: false
on_ble_advertise:
# RR
- mac_address: !secret rr_mac
then:
- lambda: |-
for (auto data : x.get_manufacturer_datas()) {
const char *hexstring = data.uuid.to_string().substr(2,2).c_str();
const float voltage = (float) strtol(hexstring, NULL, 16) * 0.1;
const int pressure = data.data[1] << 8 | data.data[2];
id(ble_rr_temp).publish_state(data.data[0]);
id(ble_rr_press).publish_state((float) pressure * 0.001);
id(ble_rr_batt).publish_state(voltage);
}
# RL
- mac_address: !secret rl_mac
then:
- lambda: |-
for (auto data : x.get_manufacturer_datas()) {
const char *hexstring = data.uuid.to_string().substr(2,2).c_str();
const float voltage = (float) strtol(hexstring, NULL, 16) * 0.1;
const int pressure = data.data[1] << 8 | data.data[2];
id(ble_rl_temp).publish_state(data.data[0]);
id(ble_rl_press).publish_state((float) pressure * 0.001);
id(ble_rl_batt).publish_state(voltage);
}
# FR
- mac_address: !secret fr_mac
then:
- lambda: |-
for (auto data : x.get_manufacturer_datas()) {
const char *hexstring = data.uuid.to_string().substr(2,2).c_str();
const float voltage = (float) strtol(hexstring, NULL, 16) * 0.1;
const int pressure = data.data[1] << 8 | data.data[2];
id(ble_fr_temp).publish_state(data.data[0]);
id(ble_fr_press).publish_state((float) pressure * 0.001);
id(ble_fr_batt).publish_state(voltage);
}
# FL
- mac_address: !secret fl_mac
then:
- lambda: |-
for (auto data : x.get_manufacturer_datas()) {
const char *hexstring = data.uuid.to_string().substr(2,2).c_str();
const float voltage = (float) strtol(hexstring, NULL, 16) * 0.1;
const int pressure = data.data[1] << 8 | data.data[2];
id(ble_fl_temp).publish_state(data.data[0]);
id(ble_fl_press).publish_state((float) pressure * 0.001);
id(ble_fl_batt).publish_state(voltage);
}