Salut WarC0zes
Maintenant que j ai réussi a réaliser des capteurs de présences avec les LD2410 avec l esp32s2 mini ; je viens d essayer de compiler le code pour le LD2450 mais j ai pas mal d erreurs !?
INFO ESPHome 2024.11.3
INFO Reading configuration C:\ESPHome\esp32S2-presence-2450_test.yaml...
Failed config
esphome: None
name: esp32test
comment: esp32test
includes:
Could not find file 'C:\ESPHome\components/ld2450_uart.h'. Please make sure it exists (full path: C:\ESPHome\components\ld2450_uart.h).
- components/ld2450_uart.h
on_boot:
priority: -100
then:
- lambda: static_cast<LD2450 *>(ld2450)->getInfo();
- lambda: id(tracking_mode).publish_state("Multiple");
min_version: 2024.11.3
build_path: build\esp32test
J avais gardé le code avec mes données du LD 2410:
esphome:
name: esp32test
friendly_name: esp32test
esp32:
board: lolin_s2_mini
framework:
type: arduino
mqtt:
topic_prefix: ESPHOME_LD2450
discovery: false
broker: 192.168.1.12
port: 1883
username: jeedom
password: pw
discovery_prefix: homeassistant
# Enable logging
logger:
# Enable Home Assistant API
ota:
- platform: esphome
password: "b406952a7e07a8a5b57ceebcebca0fb5"
wifi:
ssid: Wifi_NyG_2.4
password: rachida.yacine89
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp32Test Fallback Hotspot"
password: "iRhAGW2x3LUg"
# Optional manual IP
manual_ip:
static_ip: 192.168.1.238
gateway: 192.168.1.1
subnet: 255.255.255.0
web_server:
port: 80
uart:
tx_pin: GPIO18
rx_pin: GPIO33
baud_rate: 256000
id: uart_1
parity: NONE
stop_bits: 1
Puis j ai copié le code pour le LD 2450 sur le lien que tu m avais envoyé !
light:
- platform: binary
name: "Led bleu"
output: light_output
output:
- id: light_output
platform: gpio
pin: GPIO02
# LD2450
substitutions:
devicename: ld2450
upper_devicename: "Hi-Link LD2450"
esphome:
name: ${devicename}
comment: ${upper_devicename}
includes:
- components/ld2450_uart.h
on_boot:
priority: -100
# ...
then:
- lambda: 'static_cast<LD2450 *>(ld2450)->getInfo();'
- lambda: id(tracking_mode).publish_state("Multiple");
# Enable logging
logger:
baud_rate: 0
ota:
uart:
id: uart_ld2450
tx_pin: GPIO17
rx_pin: GPIO16
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: custom
lambda: |-
auto uart_component = static_cast<LD2450 *>(ld2450);
return {uart_component->lastCommandSuccess, uart_component->configMode, uart_component->bluetoothState};
binary_sensors:
- name: "Last Command Success"
id: binary_sensor_command_state
internal: true
- name: "Config Mode"
icon: mdi:cog
id: binary_sensor_config_mode
- name: "Bluetooth State"
icon: mdi:bluetooth
id: binary_sensor_bluetooth_state
internal: true
button:
- platform: template
name: "Reboot LD2450"
on_press:
- lambda: 'static_cast<LD2450 *>(ld2450)->reboot();'
- platform: template
name: "Factory Reset LD2450"
on_press:
- lambda: 'static_cast<LD2450 *>(ld2450)->factoryReset();'
- platform: template
name: "Single Target Tracking"
on_press:
- lambda: 'static_cast<LD2450 *>(ld2450)->setSingle();'
- platform: template
name: "Multiple Targets Tracking"
on_press:
- lambda: 'static_cast<LD2450 *>(ld2450)->setMultiple();'
- platform: template
name: "Get Zones Information"
on_press:
- lambda: 'static_cast<LD2450 *>(ld2450)->getZone();'
- platform: template
name: "Set Zones Information"
on_press:
lambda: |-
int type = 0;
if (id(zone_type).state == "Disable Zone Filter") {
type = 0;
} else if (id(zone_type).state == "Only Detect Configured Zone") {
type = 1;
} else if (id(zone_type).state == "Not Detect Configured Zone") {
type = 2;
}
static_cast<LD2450 *>(ld2450)->setZone(type, id(zone1_x1).state * 10, id(zone1_y1).state * 10, id(zone1_x2).state * 10, id(zone1_y2).state * 10, id(zone2_x1).state * 10, id(zone2_y1).state * 10, id(zone2_x2).state * 10, id(zone2_y2).state * 10, id(zone2_x1).state * 10, id(zone2_y1).state * 10, id(zone2_x2).state * 10, id(zone2_y2).state * 10);
number:
- platform: template
name: "Zone1 X1"
id: zone1_x1
icon: mdi:align-horizontal-left
min_value: -100
max_value: 100
step: 1
optimistic: true
- platform: template
name: "Zone1 Y1"
id: zone1_y1
icon: mdi:align-horizontal-distribute
min_value: -100
max_value: 100
step: 1
optimistic: true
- platform: template
name: "Zone1 X2"
id: zone1_x2
icon: mdi:align-horizontal-right
min_value: -100
max_value: 100
step: 1
optimistic: true
- platform: template
name: "Zone1 Y2"
id: zone1_y2
icon: mdi:align-horizontal-distribute
min_value: -100
max_value: 100
step: 1
optimistic: true
- platform: template
name: "Zone2 X1"
id: zone2_x1
icon: mdi:align-horizontal-left
min_value: -100
max_value: 100
step: 1
optimistic: true
- platform: template
name: "Zone2 Y1"
id: zone2_y1
icon: mdi:align-horizontal-distribute
min_value: -100
max_value: 100
step: 1
optimistic: true
- platform: template
name: "Zone2 X2"
id: zone2_x2
icon: mdi:align-horizontal-right
min_value: -100
max_value: 100
step: 1
optimistic: true
- platform: template
name: "Zone2 Y2"
id: zone2_y2
icon: mdi:align-horizontal-distribute
min_value: -100
max_value: 100
step: 1
optimistic: true
- platform: template
name: "Zone3 X1"
id: zone3_x1
icon: mdi:align-horizontal-left
min_value: -100
max_value: 100
step: 1
optimistic: true
- platform: template
name: "Zone3 Y1"
id: zone3_y1
icon: mdi:align-horizontal-distribute
min_value: -100
max_value: 100
step: 1
optimistic: true
- platform: template
name: "Zone3 X2"
id: zone3_x2
icon: mdi:align-horizontal-right
min_value: -100
max_value: 100
step: 1
optimistic: true
- platform: template
name: "Zone3 Y2"
id: zone3_y2
icon: mdi:align-horizontal-distribute
min_value: -100
max_value: 100
step: 1
optimistic: true
select:
- platform: template
name: "Template select"
id: zone_type
optimistic: true
options:
- Disable Zone Filter
- Only Detect Configured Zone
- Not Detect Configured Zone
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, uart_component->targets, uart_component->zoneType, uart_component->zone1X1, uart_component->zone1Y1, uart_component->zone1X2, uart_component->zone1Y2, uart_component->zone2X1, uart_component->zone2Y1, uart_component->zone2X2, uart_component->zone2Y2, uart_component->zone3X1, uart_component->zone3Y1, uart_component->zone3X2, uart_component->zone3Y2
};
sensors:
- name: "Target1 Resolution"
unit_of_measurement: "nm"
accuracy_decimals: 0
icon: mdi:artboard
- 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
- 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
- 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
- name: "Targets"
- name: "Zone Type"
id: zonetype
icon: mdi:tangram
internal: true
on_value:
then:
lambda: |-
if (id(zonetype).state == 0) {
id(zone_type).publish_state("Disable Zone Filter");
} else if (id(zonetype).state == 1) {
id(zone_type).publish_state("Only Detect Configured Zone");
} else if (id(zonetype).state == 2) {
id(zone_type).publish_state("Not Detect Configured Zone");
}
- name: "Zone1 X1"
id: zone1x1
unit_of_measurement: "cm"
accuracy_decimals: 0
icon: mdi:align-horizontal-left
internal: true
on_value:
then:
- lambda: id(zone1_x1).publish_state(id(zone1x1).state);
- name: "Zone1 Y1"
id: zone1y1
unit_of_measurement: "cm"
accuracy_decimals: 0
icon: mdi:align-horizontal-distribute
internal: true
on_value:
then:
- lambda: id(zone1_y1).publish_state(id(zone1y1).state);
- name: "Zone1 X2"
id: zone1x2
unit_of_measurement: "cm"
accuracy_decimals: 0
icon: mdi:align-horizontal-right
internal: true
on_value:
then:
- lambda: id(zone1_x2).publish_state(id(zone1x2).state);
- name: "Zone1 Y2"
id: zone1y2
unit_of_measurement: "cm"
accuracy_decimals: 0
icon: mdi:align-horizontal-distribute
internal: true
on_value:
then:
- lambda: id(zone1_y2).publish_state(id(zone1y2).state);
- name: "Zone2 X1"
id: zone2x1
unit_of_measurement: "cm"
accuracy_decimals: 0
icon: mdi:align-horizontal-left
internal: true
on_value:
then:
- lambda: id(zone2_x1).publish_state(id(zone2x1).state);
- name: "Zone2 Y1"
id: zone2y1
unit_of_measurement: "cm"
accuracy_decimals: 0
icon: mdi:align-horizontal-distribute
internal: true
on_value:
then:
- lambda: id(zone2_y1).publish_state(id(zone2y1).state);
- name: "Zone2 X2"
id: zone2x2
unit_of_measurement: "cm"
accuracy_decimals: 0
icon: mdi:align-horizontal-right
internal: true
on_value:
then:
- lambda: id(zone2_x2).publish_state(id(zone2x2).state);
- name: "Zone2 Y2"
id: zone2y2
unit_of_measurement: "cm"
accuracy_decimals: 0
icon: mdi:align-horizontal-distribute
internal: true
on_value:
then:
- lambda: id(zone2_y2).publish_state(id(zone2y2).state);
- name: "Zone3 X1"
id: zone3x1
unit_of_measurement: "cm"
accuracy_decimals: 0
icon: mdi:align-horizontal-left
internal: true
on_value:
then:
- lambda: id(zone3_x1).publish_state(id(zone3x1).state);
- name: "Zone3 Y1"
id: zone3y1
unit_of_measurement: "cm"
accuracy_decimals: 0
icon: mdi:align-horizontal-distribute
internal: true
on_value:
then:
- lambda: id(zone3_y1).publish_state(id(zone3y1).state);
- name: "Zone3 X2"
id: zone3x2
unit_of_measurement: "cm"
accuracy_decimals: 0
icon: mdi:align-horizontal-right
internal: true
on_value:
then:
- lambda: id(zone3_x2).publish_state(id(zone3x2).state);
- name: "Zone3 Y2"
id: zone3y2
unit_of_measurement: "cm"
accuracy_decimals: 0
icon: mdi:align-horizontal-distribute
internal: true
on_value:
then:
- lambda: id(zone3_y2).publish_state(id(zone3y2).state);
switch:
- platform: template
name: "Config Mode"
lambda: |-
if (id(binary_sensor_config_mode).state) {
return true;
} else {
return false;
}
turn_on_action:
- lambda: 'static_cast<LD2450 *>(ld2450)->setConfigMode(true);'
turn_off_action:
- lambda: 'static_cast<LD2450 *>(ld2450)->setConfigMode(false);'
- platform: template
name: "Bluetooth Function"
lambda: |-
if (id(binary_sensor_bluetooth_state).state) {
return true;
} else {
return false;
}
icon: mdi:bluetooth
turn_on_action:
- lambda: 'static_cast<LD2450 *>(ld2450)->setBluetooth(true);'
turn_off_action:
- lambda: 'static_cast<LD2450 *>(ld2450)->setBluetooth(false);'
text_sensor:
- platform: custom
lambda: |-
auto uart_component = static_cast<LD2450 *>(ld2450);
return { uart_component->macAddress, uart_component->fwVersion, uart_component->trackingMode
};
text_sensors:
- name: "Mac Address"
icon: mdi:puzzle
- name: "Firmware Versoin"
icon: mdi:new-box
- name: "Tracking Mode"
icon: mdi:radar
id: tracking_mode
Dois je modifier quelques paramètres ?