192 lines
4.6 KiB
YAML
192 lines
4.6 KiB
YAML
# https://github.com/Chreece/LD2450-ESPHome.git
|
|
#
|
|
substitutions:
|
|
devicename: mw25
|
|
upper_devicename: "Hi-Link LD2450"
|
|
|
|
esphome:
|
|
name: ${devicename}
|
|
comment: ${upper_devicename}
|
|
includes:
|
|
- ld2450_uart.h
|
|
platformio_options:
|
|
board_build.flash_mode: dio
|
|
board_build.extra_flags:
|
|
- "-DARDUINO_USB_CDC_ON_BOOT=0"
|
|
|
|
esp32:
|
|
board: seeed_xiao_esp32c3
|
|
framework:
|
|
type: arduino
|
|
|
|
|
|
wifi:
|
|
ssid: !secret wifi_ssid
|
|
password: !secret wifi_password
|
|
# reboot_timeout: 0s
|
|
ap:
|
|
password: "admin1234"
|
|
ap_timeout: 30s
|
|
|
|
# Enable logging
|
|
logger:
|
|
baud_rate: 0
|
|
|
|
# Enable Home Assistant API
|
|
api:
|
|
|
|
ota:
|
|
password: !secret ota
|
|
|
|
web_server:
|
|
port: 80
|
|
|
|
mqtt:
|
|
broker: 192.168.10.102
|
|
|
|
uart:
|
|
id: uart_ld2450
|
|
tx_pin:
|
|
number: GPIO21
|
|
mode:
|
|
input: true
|
|
pullup: true
|
|
rx_pin:
|
|
number: GPIO20
|
|
mode:
|
|
input: true
|
|
pullup: true
|
|
baud_rate: 256000
|
|
parity: NONE
|
|
stop_bits: 1
|
|
# debug:
|
|
# direction: BOTH
|
|
# dummy_receiver: false
|
|
|
|
custom_component:
|
|
- lambda: |-
|
|
return {new LD2450(id(uart_ld2450))};
|
|
components:
|
|
- id: ld2450
|
|
|
|
binary_sensor:
|
|
- platform: template
|
|
name: "Presence Detected"
|
|
device_class: occupancy
|
|
lambda: |-
|
|
if (id(target1).state > 0
|
|
or id(target2).state > 0
|
|
or id(target3).state > 0) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
|
|
sensor:
|
|
- platform: custom
|
|
lambda: |-
|
|
auto uart_component = static_cast<LD2450 *>(ld2450);
|
|
return {uart_component->target1Resolution, uart_component->target1Speed, uart_component->target1X, uart_component->target1Y,
|
|
uart_component->target2Resolution, uart_component->target2Speed, uart_component->target2X, uart_component->target2Y,
|
|
uart_component->target3Resolution, uart_component->target3Speed, uart_component->target3X, uart_component->target3Y,
|
|
};
|
|
sensors:
|
|
- name: "Target1 Resolution"
|
|
unit_of_measurement: "nm"
|
|
accuracy_decimals: 0
|
|
icon: mdi:artboard
|
|
id: target1
|
|
- name: "Target1 Speed"
|
|
unit_of_measurement: "cm/s"
|
|
accuracy_decimals: 0
|
|
icon: mdi:speedometer
|
|
- name: "Target1 X"
|
|
unit_of_measurement: "cm"
|
|
accuracy_decimals: 0
|
|
icon: mdi:map-marker-right
|
|
- name: "Target1 Y"
|
|
unit_of_measurement: "cm"
|
|
accuracy_decimals: 0
|
|
icon: mdi:map-marker-down
|
|
- name: "Target2 Resolution"
|
|
unit_of_measurement: "nm"
|
|
accuracy_decimals: 0
|
|
icon: mdi:artboard
|
|
id: target2
|
|
- name: "Target2 Speed"
|
|
unit_of_measurement: "cm/s"
|
|
accuracy_decimals: 0
|
|
icon: mdi:speedometer
|
|
- name: "Target2 X"
|
|
unit_of_measurement: "cm"
|
|
accuracy_decimals: 0
|
|
icon: mdi:map-marker-right
|
|
- name: "Target2 Y"
|
|
unit_of_measurement: "cm"
|
|
accuracy_decimals: 0
|
|
icon: mdi:map-marker-down
|
|
- name: "Target3 Resolution"
|
|
unit_of_measurement: "nm"
|
|
accuracy_decimals: 0
|
|
icon: mdi:artboard
|
|
id: target3
|
|
- name: "Target3 Speed"
|
|
unit_of_measurement: "cm/s"
|
|
accuracy_decimals: 0
|
|
icon: mdi:speedometer
|
|
- name: "Target3 X"
|
|
unit_of_measurement: "cm"
|
|
accuracy_decimals: 0
|
|
icon: mdi:map-marker-right
|
|
- name: "Target3 Y"
|
|
unit_of_measurement: "cm"
|
|
accuracy_decimals: 0
|
|
icon: mdi:map-marker-down
|
|
- platform: template
|
|
name: "Targets Detected"
|
|
update_interval: 1s
|
|
lambda: |-
|
|
int num = 0;
|
|
if (id(target1).state > 0) {
|
|
num += 1;
|
|
}
|
|
if (id(target2).state > 0) {
|
|
num += 1;
|
|
}
|
|
if (id(target3).state > 0) {
|
|
num += 1;
|
|
}
|
|
return num;
|
|
- platform: wifi_signal
|
|
name: WiFi Signal
|
|
id: wifi_signal_db
|
|
update_interval: 60s
|
|
entity_category: "diagnostic"
|
|
- platform: copy # Reports the WiFi signal strength in %
|
|
source_id: wifi_signal_db
|
|
name: "WiFi Signal Percent"
|
|
filters:
|
|
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
|
|
unit_of_measurement: "%"
|
|
entity_category: "diagnostic"
|
|
- platform: uptime
|
|
name: Uptime
|
|
- platform: template
|
|
id: sys_esp_temperature
|
|
name: MW25 ESP Temperature
|
|
lambda: return temperatureRead();
|
|
unit_of_measurement: °C
|
|
device_class: TEMPERATURE
|
|
update_interval: 45s
|
|
entity_category: "diagnostic"
|
|
- platform: template
|
|
id: esp_memory
|
|
icon: mdi:memory
|
|
name: MW25 ESP Free Memory
|
|
lambda: return heap_caps_get_free_size(MALLOC_CAP_INTERNAL) / 1024;
|
|
unit_of_measurement: 'kB'
|
|
state_class: measurement
|
|
entity_category: "diagnostic"
|
|
update_interval: 60s
|
|
|