Skip to content

Commit 514ed67

Browse files
authored
Refactored UART output
Disabled presence and target messages from sensor as they were unused and to reduce load on the software UART on the D1 Mini
1 parent 4c64abc commit 514ed67

File tree

3 files changed

+13
-26
lines changed

3 files changed

+13
-26
lines changed

header/leapmmw_sensor.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,8 @@ class leapmmw : public Component, public UARTDevice {
6969
if(readline(read(), buffer, max_line_length) >= 4) {
7070
std::string line = buffer;
7171

72-
if (line.substr(0, 6) == "$JYRPO" && id(mmwave_sensor).state == 0) {
73-
publishSwitch("mmwave_sensor", 1);
74-
}
75-
7672
// compare last line
7773
if (line.substr(0, 8) == "Response") {
78-
// ESP_LOGD("custom", "Found Response - line is: %s", line.c_str());
79-
// ESP_LOGD("custom", "Found Response - lastline is: %s", getline.c_str());
8074

8175
// leapMMW:/>getSensitivity
8276
if (getline.substr(0, 24) == "leapMMW:/>getSensitivity" || getline.substr(0, 14) == "getSensitivity") {
@@ -130,8 +124,6 @@ class leapmmw : public Component, public UARTDevice {
130124
}
131125
}
132126
if (line.substr(0, 4) == "Done") {
133-
// ESP_LOGD("custom", "Found Done - line is: %s", line.c_str());
134-
// ESP_LOGD("custom", "Found Done - lastline is: %s", getline.c_str());
135127
// leapMMW:/>sensorStop
136128
if (getline.substr(0, 20) == "leapMMW:/>sensorStop") {
137129
// ESP_LOGD("custom", "sensorStop completed successfully");

packages/leapmmw_sensor.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
substitutions:
2-
device_name: mmwave
3-
## FIXME: To be removed later. Would cause a breaking change.
4-
uart_tx_pin: GPIO19
5-
uart_rx_pin: GPIO18
6-
##
7-
gpio_pin: GPIO23
8-
header_file: leapmmw_sensor.h
2+
# include the header file with the UART parsing logic
3+
header_file: header/leapmmw_sensor.h
94

105
esphome:
116
name: ${device_name}
@@ -16,14 +11,14 @@ logger:
1611
logs:
1712
sensor: INFO # reduced logging to minimize web_server target overload..
1813

19-
## FIXME: To be removed later. Would cause a breaking change
2014
uart:
2115
id: uart_bus
2216
tx_pin: ${uart_tx_pin}
2317
rx_pin: ${uart_rx_pin}
2418
baud_rate: 115200
2519

26-
##
20+
21+
## sensor definitions
2722

2823
binary_sensor:
2924
- platform: gpio
@@ -33,6 +28,13 @@ binary_sensor:
3328
pin:
3429
number: ${gpio_pin}
3530
mode: INPUT_PULLDOWN
31+
# when motion is detected, the radar sensor is on so publish radar state to HA
32+
on_press:
33+
then:
34+
lambda: !lambda |-
35+
if (!id(mmwave_sensor).state) {
36+
id(mmwave_sensor).publish_state(true);
37+
}
3638
3739
sensor:
3840
- platform: custom
@@ -53,11 +55,9 @@ switch:
5355
optimistic: true
5456
turn_on_action:
5557
- uart.write: "setUartOutput 1 0"
56-
- delay: 2s
57-
- uart.write: "setUartOutput 2 1 1 2"
58-
- delay: 2s
58+
- delay: 1s
5959
- uart.write: "saveConfig"
60-
- delay: 5s
60+
- delay: 4s
6161
- uart.write: "sensorStart"
6262
turn_off_action:
6363
- uart.write: "sensorStop"

sensor.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ substitutions:
1313
uart_rx_pin: GPIO5
1414
# RX Pin configured for a D1 Mini stacked setup
1515
gpio_pin: GPIO16
16-
# include the header file with the UART parsing logic
17-
header_file: header/leapmmw_sensor.h
1816

1917
# include the yml file with the sensor configuration
2018
packages:
@@ -26,9 +24,6 @@ esphome:
2624
esp8266:
2725
board: d1_mini
2826

29-
# Enable logging
30-
logger:
31-
3227
# Enable Home Assistant API
3328
api:
3429
password: ""

0 commit comments

Comments
 (0)