Code Monkey home page Code Monkey logo

esphome-hlk-ld2450's People

Contributors

bsell93 avatar tillfleisch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

esphome-hlk-ld2450's Issues

[Feature Request] Add sensitivity configuration

Hi,

First of all, thank you for your amazing work!

I'd like to ask if it is possible to add a "Sensitivity" parameter because the sensor is currently too sensitive (it triggers simply when the curtain moves due to the wind).

EDIT:
Hi again,
just to add one more parameters: I'd like to have the "update_interval" parameter to reduce the power usage if possible

Thanks again!

LD2450 Sensor stops detecting occupancy on "static" (non-moving) objects

Hi,
Thank you for the really good work.
I have noticed something while using my sensors across my home.
In rooms where moovement occurs frequently I have almost no issue.
However, in room where I might have really few moovement (for exemple while watching tv) the Esp Home stops returning my occupancy. I have checked with the HKtool app the sensor can see my position.

It looks like than when position is not changing, the sensor stop publishing information and esphome clears occupancy.

Thank you for the help or the explication

Stuck in repeated "Clearing RX buffer."

Hey @TillFleisch ,

I've got a weird one - I keep getting the following in my logs

[LD2450:276]: Clearing RX buffer. - repeated
[LD2450:258]: Sensor is not sending updates, attempting to leave config mode. - occasionally
[LD2450:131]: Sending command timed out! Is the sensor connected? - occasionally

The weird thing is the sensor was working perfectly and then after a while (not being touched) it starts failing and giving all ZERO values for my sensors, which aligns with the logs.

I thought perhaps I'm running out of ram so I added this to my sensors

  - platform: debug
    free:
      name: "Heap Free"

to see if I'm running out of ram and I consistently have 10s of thousands of Bytes of ram
image

Is it possible there is a memory leak somewhere that is causing LD2450 get stuck in this loop?

Things I've tried,

  • Rebooting esp32 device (power off and on)
  • Updating firmware
  • Increase uart -> rx_buffer_size to 512
  • Set logger -> baud_rate to 0

Things I've verified:

  • I'm getting 5v from GND -> VCC on the LD2450 and between my ESP32
  • I'm getting 3.3v from GND -> TX as well as GND -> RX and GND -> 3v3
  • I'm getting 3.3v from GND on LD2450 to TX as well as RX on ESP32

Here is my config: https://github.com/bsell93/esphome/blob/main/bedroom-thermostat.common.yaml

Any assistance is appreciated 😄

Bluetooth/Multi-Target switch unreliable

Nice work ! I really like the clean design and area definitions.
I am using new sensors with latest build fw in combination with a ESP32C3 board.

I have following problems:
I noticed in the log, that the data is not continously flowing.
I can switch the buttons multitarget or BT to off, but not back on. The logs show the error, that the sensor can't be switched into config mode. I than reduced the yaml to only those buttons to recover the seonsor, but it still didn't work.

After that I used the project https://github.com/uncle-yura/esphome-ld2450 and was able to recover the sensor.

Any idea ?

Is it possible to use multiple sensors?

Hello,
I am trying to use two LD2450 sensors on the same ESP32.
I correctly configured the UARTs, and the section for the LD2450s in my code looks like this:

external_components:
  - source: github://TillFleisch/ESPHome-HLK-LD2450@main

uart:
  - id: uart_bus_internal
    rx_pin: 
      number: GPIO25
      mode:
        input: true
        pullup: true
    tx_pin: 
      number: GPIO22
      mode:
        input: true
        pullup: true
    baud_rate: 256000
    parity: NONE
    stop_bits: 1
    data_bits: 8
  - id: uart_bus_external
    rx_pin: 
      number: GPIO19
      mode:
        input: true
        pullup: true
    tx_pin: 
      number: GPIO18
      mode:
        input: true
        pullup: true
    baud_rate: 256000
    parity: NONE
    stop_bits: 1
    data_bits: 8

LD2450:
  - id: ld2410_internal
    uart_id: uart_bus_internal
    targets:
      - target:
          debug: true
          x_position:
            id: t1_xpos
          y_position:
            id: t1_ypos
          speed:
            id: t1_speed
          distance_resolution:
            id: t1_res
          angle:
            id: t1_angle
          distance:
            id: t1_distance
  - id: ld2410_external
    uart_id: uart_bus_external
    targets:
      - target:
          debug: true
          x_position:
            id: t1_xpos
          y_position:
            id: t1_ypos
          speed:
            id: t1_speed
          distance_resolution:
            id: t1_res
          angle:
            id: t1_angle
          distance:
            id: t1_distance

When I try to compile it, the error message is as follows:

INFO ESPHome 2023.12.9
INFO Reading configuration /config/esphome/mmwavetest-d1mini32-02.yaml...
Failed config

LD2450: [source <unicode string>:67]
  
  expected a dictionary.
  - id: ld2410_internal
    uart_id: uart_bus_internal
    targets: 
      - target: 
          debug: True
          x_position: 
            id: t1_xpos
          y_position: 
            id: t1_ypos
          speed: 
            id: t1_speed
          distance_resolution: 
            id: t1_res
          angle: 
            id: t1_angle
          distance: 
            id: t1_distance
  - id: ld2410_external
    uart_id: uart_bus_external
    targets: 
      - target: 
          debug: True
          x_position: 
            id: t1_xpos
          y_position: 
            id: t1_ypos
          speed: 
            id: t1_speed
          distance_resolution: 
            id: t1_res
          angle: 
            id: t1_angle
          distance: 
            id: t1_distance

Is it possible to use two LD2450 sensors on the same ESP32? If yes, how would the code look like?

Best regards
Aaron

filters on "occupancy" doesn't seem to work

Hi,

I'm trying to add a small delay before the occupancy sensor goes off. Below, I have posted my configuration, but the delay_off filter doesn't seem to work.

Can I get some help?

Thanks!

LD2450:
  uart_id: uart_bus
  flip_x_axis: true
  fast_off_detection: true
  max_detection_tilt_angle:
    name: "Max Tilt Angle"
    initial_value: 40°
  min_detection_tilt_angle:
    name: "Min Tilt Angle"
    initial_value: -40°
  max_detection_distance:
    name: "Max Distance"
    initial_value: 4m
  max_distance_margin: 30cm
  tracking_mode_switch:
    name: "Multiple Target Tracking"
  occupancy:
    name: Occupancy
    filters:
      - delayed_off: 45s
  target_count:
    name: Target Count
  targets:
    - target:
        name: "T1"
        id: t1
        debug: true
        x_position:
            id: t1_xpos
        y_position:
            id: t1_ypos
        speed:
            id: t1_speed
        distance_resolution:
            id: t1_res
        angle:
            id: t1_angle
        distance:
            id: t1_distance
    - target:
        id: t2
        x_position:
            id: t2_xpos
        y_position:
            id: t2_ypos
        speed:
            id: t2_speed
        distance_resolution:
            id: t2_res
        angle:
            id: t2_angle
        distance:
            id: t2_distance

Compilation Error - format '%i' expects argument of type 'int', but argument 5 has type 'double' [-Werror=format=]

In file included from src/esphome/components/uart/uart.h:6,
                 from src/esphome/components/LD2450/LD2450.h:4,
                 from src/esphome/components/LD2450/LD2450.cpp:1:
src/esphome/components/LD2450/LD2450.cpp: In member function 'virtual void esphome::ld2450::LD2450::dump_config()':
src/esphome/components/LD2450/LD2450.cpp:55:28: error: format '%i' expects argument of type 'int', but argument 5 has type 'double' [-Werror=format=]
   55 |         ESP_LOGCONFIG(TAG, "  max_detection_tilt_angle: %i °", max_detection_tilt_angle_);
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/core/log.h:72:36: note: in definition of macro 'ESPHOME_LOG_FORMAT'
   72 | #define ESPHOME_LOG_FORMAT(format) format
      |                                    ^~~~~~
src/esphome/core/log.h:153:33: note: in expansion of macro 'esph_log_config'
  153 | #define ESP_LOGCONFIG(tag, ...) esph_log_config(tag, __VA_ARGS__)
      |                                 ^~~~~~~~~~~~~~~
src/esphome/components/LD2450/LD2450.cpp:55:9: note: in expansion of macro 'ESP_LOGCONFIG'
   55 |         ESP_LOGCONFIG(TAG, "  max_detection_tilt_angle: %i °", max_detection_tilt_angle_);
      |         ^~~~~~~~~~~~~
src/esphome/components/LD2450/LD2450.cpp:55:58: note: format string is defined here
   55 |         ESP_LOGCONFIG(TAG, "  max_detection_tilt_angle: %i °", max_detection_tilt_angle_);
      |                                                         ~^
      |                                                          |
      |                                                          int
      |                                                         %f
src/esphome/components/LD2450/LD2450.cpp:56:28: error: format '%i' expects argument of type 'int', but argument 5 has type 'double' [-Werror=format=]
   56 |         ESP_LOGCONFIG(TAG, "  min_detection_tilt_angle: %i °", min_detection_tilt_angle_);
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/core/log.h:72:36: note: in definition of macro 'ESPHOME_LOG_FORMAT'
   72 | #define ESPHOME_LOG_FORMAT(format) format
      |                                    ^~~~~~
src/esphome/core/log.h:153:33: note: in expansion of macro 'esph_log_config'
  153 | #define ESP_LOGCONFIG(tag, ...) esph_log_config(tag, __VA_ARGS__)
      |                                 ^~~~~~~~~~~~~~~
src/esphome/components/LD2450/LD2450.cpp:56:9: note: in expansion of macro 'ESP_LOGCONFIG'
   56 |         ESP_LOGCONFIG(TAG, "  min_detection_tilt_angle: %i °", min_detection_tilt_angle_);
      |         ^~~~~~~~~~~~~
src/esphome/components/LD2450/LD2450.cpp:56:58: note: format string is defined here
   56 |         ESP_LOGCONFIG(TAG, "  min_detection_tilt_angle: %i °", min_detection_tilt_angle_);
      |                                                         ~^
      |                                                          |
      |                                                          int
      |                                                         %f
src/esphome/components/LD2450/LD2450.cpp:59:28: error: format '%i' expects argument of type 'int', but argument 5 has type 'double' [-Werror=format=]
   59 |         ESP_LOGCONFIG(TAG, "  tilt_angle_margin: %i °", tilt_angle_margin_);
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/core/log.h:72:36: note: in definition of macro 'ESPHOME_LOG_FORMAT'
   72 | #define ESPHOME_LOG_FORMAT(format) format
      |                                    ^~~~~~
src/esphome/core/log.h:153:33: note: in expansion of macro 'esph_log_config'
  153 | #define ESP_LOGCONFIG(tag, ...) esph_log_config(tag, __VA_ARGS__)
      |                                 ^~~~~~~~~~~~~~~
src/esphome/components/LD2450/LD2450.cpp:59:9: note: in expansion of macro 'ESP_LOGCONFIG'
   59 |         ESP_LOGCONFIG(TAG, "  tilt_angle_margin: %i °", tilt_angle_margin_);
      |         ^~~~~~~~~~~~~
src/esphome/components/LD2450/LD2450.cpp:59:51: note: format string is defined here
   59 |         ESP_LOGCONFIG(TAG, "  tilt_angle_margin: %i °", tilt_angle_margin_);
      |                                                  ~^
      |                                                   |
      |                                                   int
      |                                                  %f
Compiling .pioenvs/esphome_living_room_sensor1/src/esphome/components/api/api_frame_helper.o
Compiling .pioenvs/esphome_living_room_sensor1/src/esphome/components/api/api_pb2.o
cc1plus: some warnings being treated as errors
*** [.pioenvs/esphome_living_room_sensor1/src/esphome/components/LD2450/LD2450.o] Error 1
In file included from src/esphome/components/sensor/sensor.h:3,
                 from src/esphome/components/LD2450/polling_sensor.h:4,
                 from src/esphome/components/LD2450/target.h:5,
                 from src/esphome/components/LD2450/zone.h:3,
                 from src/esphome/components/LD2450/zone.cpp:1:
src/esphome/components/LD2450/zone.cpp: In member function 'void esphome::ld2450::Zone::dump_config()':
src/esphome/components/LD2450/zone.cpp:41:32: error: format '%i' expects argument of type 'int', but argument 5 has type 'uint32_t' {aka 'long unsigned int'} [-Werror=format=]
   41 |             ESP_LOGCONFIG(TAG, "  template polygon update interval: %i", template_evaluation_interval_);
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/core/log.h:72:36: note: in definition of macro 'ESPHOME_LOG_FORMAT'
   72 | #define ESPHOME_LOG_FORMAT(format) format
      |                                    ^~~~~~
src/esphome/core/log.h:153:33: note: in expansion of macro 'esph_log_config'
  153 | #define ESP_LOGCONFIG(tag, ...) esph_log_config(tag, __VA_ARGS__)
      |                                 ^~~~~~~~~~~~~~~
src/esphome/components/LD2450/zone.cpp:41:13: note: in expansion of macro 'ESP_LOGCONFIG'
   41 |             ESP_LOGCONFIG(TAG, "  template polygon update interval: %i", template_evaluation_interval_);
      |             ^~~~~~~~~~~~~
src/esphome/components/LD2450/zone.cpp:41:70: note: format string is defined here
   41 |             ESP_LOGCONFIG(TAG, "  template polygon update interval: %i", template_evaluation_interval_);
      |                                                                     ~^
      |                                                                      |
      |                                                                      int
      |                                                                     %li
cc1plus: some warnings being treated as errors
*** [.pioenvs/esphome_living_room_sensor1/src/esphome/components/LD2450/zone.o] Error 1
========================= [FAILED] Took 48.97 seconds =========================

ESP32-C6 compilation issue

There is an error in zone.cpp:41:70

The last changes, framework: type: esp-idf

should be

ESP_LOGCONFIG(TAG, " template polygon update interval: %lu", template_evaluation_interval_);

The log

|-- ArduinoJson @ 6.18.5
Compiling .pioenvs/esphome_living_room_sensor1/src/esphome/components/LD2450/LD2450.o
Compiling .pioenvs/esphome_living_room_sensor1/src/esphome/components/LD2450/zone.o
Compiling .pioenvs/esphome_living_room_sensor1/src/esphome/components/api/api_pb2_service.o
Compiling .pioenvs/esphome_living_room_sensor1/src/esphome/components/api/api_server.o
Compiling .pioenvs/esphome_living_room_sensor1/src/esphome/components/api/list_entities.o
Compiling .pioenvs/esphome_living_room_sensor1/src/esphome/components/api/proto.o
Compiling .pioenvs/esphome_living_room_sensor1/src/esphome/components/api/subscribe_state.o
Compiling .pioenvs/esphome_living_room_sensor1/src/esphome/components/api/user_services.o
In file included from src/esphome/components/uart/uart.h:6,
                 from src/esphome/components/LD2450/LD2450.h:4,
                 from src/esphome/components/LD2450/LD2450.cpp:1:
src/esphome/components/LD2450/LD2450.cpp: In member function 'virtual void esphome::ld2450::LD2450::dump_config()':
src/esphome/components/LD2450/LD2450.cpp:55:28: error: format '%i' expects argument of type 'int', but argument 5 has type 'double' [-Werror=format=]
   55 |         ESP_LOGCONFIG(TAG, "  max_detection_tilt_angle: %i °", max_detection_tilt_angle_);
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/core/log.h:72:36: note: in definition of macro 'ESPHOME_LOG_FORMAT'
   72 | #define ESPHOME_LOG_FORMAT(format) format
      |                                    ^~~~~~
src/esphome/core/log.h:153:33: note: in expansion of macro 'esph_log_config'
  153 | #define ESP_LOGCONFIG(tag, ...) esph_log_config(tag, __VA_ARGS__)
      |                                 ^~~~~~~~~~~~~~~
src/esphome/components/LD2450/LD2450.cpp:55:9: note: in expansion of macro 'ESP_LOGCONFIG'
   55 |         ESP_LOGCONFIG(TAG, "  max_detection_tilt_angle: %i °", max_detection_tilt_angle_);
      |         ^~~~~~~~~~~~~
src/esphome/components/LD2450/LD2450.cpp:55:58: note: format string is defined here
   55 |         ESP_LOGCONFIG(TAG, "  max_detection_tilt_angle: %i °", max_detection_tilt_angle_);
      |                                                         ~^
      |                                                          |
      |                                                          int
      |                                                         %f
src/esphome/components/LD2450/LD2450.cpp:56:28: error: format '%i' expects argument of type 'int', but argument 5 has type 'double' [-Werror=format=]
   56 |         ESP_LOGCONFIG(TAG, "  min_detection_tilt_angle: %i °", min_detection_tilt_angle_);
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/core/log.h:72:36: note: in definition of macro 'ESPHOME_LOG_FORMAT'
   72 | #define ESPHOME_LOG_FORMAT(format) format
      |                                    ^~~~~~
src/esphome/core/log.h:153:33: note: in expansion of macro 'esph_log_config'
  153 | #define ESP_LOGCONFIG(tag, ...) esph_log_config(tag, __VA_ARGS__)
      |                                 ^~~~~~~~~~~~~~~
src/esphome/components/LD2450/LD2450.cpp:56:9: note: in expansion of macro 'ESP_LOGCONFIG'
   56 |         ESP_LOGCONFIG(TAG, "  min_detection_tilt_angle: %i °", min_detection_tilt_angle_);
      |         ^~~~~~~~~~~~~
src/esphome/components/LD2450/LD2450.cpp:56:58: note: format string is defined here
   56 |         ESP_LOGCONFIG(TAG, "  min_detection_tilt_angle: %i °", min_detection_tilt_angle_);
      |                                                         ~^
      |                                                          |
      |                                                          int
      |                                                         %f
src/esphome/components/LD2450/LD2450.cpp:59:28: error: format '%i' expects argument of type 'int', but argument 5 has type 'double' [-Werror=format=]
   59 |         ESP_LOGCONFIG(TAG, "  tilt_angle_margin: %i °", tilt_angle_margin_);
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/core/log.h:72:36: note: in definition of macro 'ESPHOME_LOG_FORMAT'
   72 | #define ESPHOME_LOG_FORMAT(format) format
      |                                    ^~~~~~
src/esphome/core/log.h:153:33: note: in expansion of macro 'esph_log_config'
  153 | #define ESP_LOGCONFIG(tag, ...) esph_log_config(tag, __VA_ARGS__)
      |                                 ^~~~~~~~~~~~~~~
src/esphome/components/LD2450/LD2450.cpp:59:9: note: in expansion of macro 'ESP_LOGCONFIG'
   59 |         ESP_LOGCONFIG(TAG, "  tilt_angle_margin: %i °", tilt_angle_margin_);
      |         ^~~~~~~~~~~~~
src/esphome/components/LD2450/LD2450.cpp:59:51: note: format string is defined here
   59 |         ESP_LOGCONFIG(TAG, "  tilt_angle_margin: %i °", tilt_angle_margin_);
      |                                                  ~^
      |                                                   |
      |                                                   int
      |                                                  %f
Compiling .pioenvs/esphome_living_room_sensor1/src/esphome/components/binary_sensor/automation.o
In file included from src/esphome/components/sensor/sensor.h:3,
                 from src/esphome/components/LD2450/polling_sensor.h:4,
                 from src/esphome/components/LD2450/target.h:5,
                 from src/esphome/components/LD2450/zone.h:3,
                 from src/esphome/components/LD2450/zone.cpp:1:
src/esphome/components/LD2450/zone.cpp: In member function 'void esphome::ld2450::Zone::dump_config()':
src/esphome/components/LD2450/zone.cpp:41:32: error: format '%i' expects argument of type 'int', but argument 5 has type 'uint32_t' {aka 'long unsigned int'} [-Werror=format=]
   41 |             ESP_LOGCONFIG(TAG, "  template polygon update interval: %i", template_evaluation_interval_);
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/core/log.h:72:36: note: in definition of macro 'ESPHOME_LOG_FORMAT'
   72 | #define ESPHOME_LOG_FORMAT(format) format
      |                                    ^~~~~~
src/esphome/core/log.h:153:33: note: in expansion of macro 'esph_log_config'
  153 | #define ESP_LOGCONFIG(tag, ...) esph_log_config(tag, __VA_ARGS__)
      |                                 ^~~~~~~~~~~~~~~
src/esphome/components/LD2450/zone.cpp:41:13: note: in expansion of macro 'ESP_LOGCONFIG'
   41 |             ESP_LOGCONFIG(TAG, "  template polygon update interval: %i", template_evaluation_interval_);
      |             ^~~~~~~~~~~~~
src/esphome/components/LD2450/zone.cpp:41:70: note: format string is defined here
   41 |             ESP_LOGCONFIG(TAG, "  template polygon update interval: %i", template_evaluation_interval_);
      |                                                                     ~^
      |                                                                      |
      |                                                                      int
      |                                                                     %li
cc1plus: some warnings being treated as errors
*** [.pioenvs/esphome_living_room_sensor1/src/esphome/components/LD2450/LD2450.o] Error 1
cc1plus: some warnings being treated as errors
*** [.pioenvs/esphome_living_room_sensor1/src/esphome/components/LD2450/zone.o] Error 1
========================= [FAILED] Took 10.81 seconds =========================

Setting delayed_off filter results two state changes at the end of the delay period

TLDR: if occupancy detected → cleared → detected inside a time window defined by delayed_off the sensor will publish two state changes - OFF immediately followed by ON at the end of the delayed_off window.

Using the following configuration

LD2450:
  uart_id: uart_bus
  flip_x_axis: true
  fast_off_detection: true
  max_detection_tilt_angle:
    name: "Max Tilt Angle"
    initial_value: 40°
  min_detection_tilt_angle:
    name: "Min Tilt Angle"
    initial_value: -40°
  max_detection_distance:
    name: "Max Distance"
    initial_value: 4m
  max_distance_margin: 30cm

  occupancy:
    name: Occupancy
    filters:
      delayed_off: 10s
    #   delayed_on: 500ms
    #   settle: 10s
  target_count:
    name: Target Count

In the case below, I am sitting in front of the sensor holding very still so the sensor state clears. As you can see from the logs, 10s after the sensor initially detects 0 targets, the OFF state is sent.

[13:05:10][D][sensor:093]: 'Target Count': Sending state 0.00000  with 0 decimals of accuracy
[13:05:19][D][binary_sensor:036]: 'Occupancy': Sending state OFF

11s later, I move into the detection area triggering an ON state - so far so good

[13:05:10][D][sensor:093]: 'Target Count': Sending state 0.00000  with 0 decimals of accuracy
[13:05:19][D][binary_sensor:036]: 'Occupancy': Sending state OFF
[13:05:30][D][binary_sensor:036]: 'Occupancy': Sending state ON
[13:05:30][D][sensor:093]: 'Target Count': Sending state 1.00000  with 0 decimals of accuracy

Next, I hold very still to clear the presence detection 13:05:37, after which I move again 13:05:38.

[13:05:10][D][sensor:093]: 'Target Count': Sending state 0.00000  with 0 decimals of accuracy
[13:05:19][D][binary_sensor:036]: 'Occupancy': Sending state OFF
[13:05:30][D][binary_sensor:036]: 'Occupancy': Sending state ON
[13:05:30][D][sensor:093]: 'Target Count': Sending state 1.00000  with 0 decimals of accuracy
[13:05:37][D][sensor:093]: 'Target Count': Sending state 0.00000  with 0 decimals of accuracy
[13:05:38][D][sensor:093]: 'Target Count': Sending state 1.00000  with 0 decimals of accuracy
[13:05:47][D][binary_sensor:036]: 'Occupancy': Sending state OFF
[13:05:47][D][binary_sensor:036]: 'Occupancy': Sending state ON

The problem: notice how at 13:05:47 the Occupancy state rapidly flips from OFF to ON. The net result of the occupancy state is ON, but I have the occupancy tied to an automation watching for both states. Since this happens so fast, the first automation is not complete by the time the second state change again triggers the automation - this means the second execution is ignored and the end result is that the OFF automation is fired even though the current state is ON. My current bandaid to the rapid state change is to put a 3 minute duration check on the OFF state change.

It is totally possible that I don't understand how filters are supposed to work; to me, it seems that with delayed_off: 10s in the above configuration the ON state change would only fire if the sensor detected presence after 10s of no presence detection. Or put in context of my example above: I am surprised to see the last two log messages where any state change is published.

Problem with Polygon being not convex

Hello,
I have successfully set up your component, but I'm now struggling with the creation of zones, especially with the polygons not being convex. Is there a way to make this polygon convex with minimal changes to the coordinates? If yes, could you please let me know how to do it so I can create that zone?
The values are based on testing (walking to where the zone points should later be and taking notes of the X and Y) and should not be varied much.

zones:
      - zone:
          name: "Tür aussen"
          margin: 10cm
          target_timeout: 0s
          polygon:
            - point: 
                x: 1.42m
                y: 3m
            - point:
                x: 0.66m
                y: 3m
            - point:
                x: 0.66m
                y: 3.2m
            - point: 
                x: 1.42m
                y: 3.2m

Best regards
Aaron Eisele

Is there a possibility for delayed initialization and startup of the LD2450?

Is it possible to delay the initialization and startup of the LD2450?

Currently, the initialization of the LD2450 conflicts with the initialization of 4 I2C sensors.

If I disable the LD2450, everything works fine, but when everything is together, the sensors are scanned but marked as FAILED. I suspect that the ESP32 is trying to handle everything at once, which it can't manage.

Sensor unreliable when using long wires

Hello,
I have two LD2450 Sensors on the same ESP32 board.
Both detect presence well, but one of them (S2 or ld2450_external in the config) doesn't allow me to switch on the Bluetooth or the Multi-Target mode.
When I flip the switch to ON, it resets to OFF after approximately 2 seconds.
Power cycling the sensor and/or ESP32 doesn't help.
It could be a similar problem to this Issue: #5

I also get this message in the logs after startup:

[14:52:31][W][LD2450:119]: Entering config mode failed, clearing command queue.
[14:52:31][W][LD2450:126]: Sending command timed out! Is the sensor connected?
[14:52:33][D][LD2450:271]: Clearing RX buffer.

Here's my config:

esphome:
  name: mmwavetest-d1mini32-02
  friendly_name: mmwavetest_d1mini32-02

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:
  logs:
    sensor: ERROR
    binary_sensor: ERROR

# Enable Home Assistant API
api:
  encryption:
    key: "8a/INyAsUXFGEf/4HuU2oXGTLKI0m+ddBEOYJbH4Cqw="

ota:
  password: "bf09a8dda9090dbe7040bed6da345672"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Mmwavetest-D1Mini32-02"
    password: "xxeHosZcLSnu"

captive_portal:

#begin customisation (non-default things)
external_components:
  - source: github://TillFleisch/ESPHome-HLK-LD2450@main
    refresh: always

uart:
  - id: uart_bus_internal
    rx_pin: GPIO19
    tx_pin: GPIO18
    baud_rate: 256000
    parity: NONE
    stop_bits: 1
    data_bits: 8
    rx_buffer_size: 1024
  - id: uart_bus_external
    rx_pin: GPIO21 
    tx_pin:  GPIO22
    baud_rate: 256000
    parity: NONE
    stop_bits: 1
    rx_buffer_size: 1024
LD2450:
  - id: ld2410_internal
    uart_id: uart_bus_internal
    targets:
      - target:
          name: "S1 T1"
          x_position:
            id: t1_xpos_s1
          y_position:
            id: t1_ypos_s1
          distance: 
            id: t1_dist_s1
      - target:
          name: "S1 T2"
          x_position:
            id: t2_xpos_s1
          y_position:
            id: t2_ypos_s1
          distance: 
            id: t2_dist_s1
      - target:
          name: "S1 T3"
          x_position:
            id: t3_xpos_s1
          y_position:
            id: t3_ypos_s1
          distance: 
            id: t3_dist_s1
    flip_x_axis: false
    fast_off_detection: false
    max_detection_distance:
      name: "Max Distance S1"
      initial_value: "6m"
    restart_button:
      name: "Restart Sensor S1"
    tracking_mode_switch:
      name: "Multiple Target Tracking S1"
      restore_mode: ALWAYS_ON
    bluetooth_switch:
      name: "Sensor Bluetooth S1"
      restore_mode: ALWAYS_ON
    occupancy:
      name: "Occupancy S1"
      id: occupancy_s1
    target_count:
      name: "Target Count S1"
    zones:
      - zone:
          name: "Tür aussen"
          margin: 10cm
          target_timeout: 0s
          polygon:
            - point: 
                x: 1.42m
                y: 3m
            - point:
                x: 0.66m
                y: 3m
            - point:
                x: 0.66m
                y: 3.2m
            - point: 
                x: 1.42m
                y: 3.2m
            

          occupancy:
            id: tuer_aussen
            name: Occupancy Tür aussen
      - zone:
          name: "Tür innen"
          margin: 10cm
          target_timeout: 0s
          polygon:
            - point:
                x: 0.6m
                y: 2.6m
            - point:
                x: 0.66m
                y: 3.1m
            - point:
                x: 1.42m
                y: 3.1m
            - point:
                x: 1.42m
                y: 2.6m
          occupancy:
            id: tuer_innen
            name: Occupancy Tür innen
  - id: ld2410_external
    uart_id: uart_bus_external
    targets:
      - target:
          name: "S2 T1"
          x_position:
            id: t1_xpos_s2
          y_position:
            id: t1_ypos_s2
          distance: 
            id: t1_dist_s2
      - target:
          name: "S2 T2"
          x_position:
            id: t2_xpos_s2
          y_position:
            id: t2_ypos_s2
          distance: 
            id: t2_dist_s2
      - target:
          name: "S2 T3"
          x_position:
            id: t3_xpos_s2
          y_position:
            id: t3_ypos_s2
          distance: 
            id: t3_dist_s2
    flip_x_axis: false
    fast_off_detection: false
    max_detection_distance:
      name: "Max Distance S2"
      initial_value: "6m"
    restart_button:
      name: "Restart Sensor S2"
    tracking_mode_switch:
      name: "Multiple Target Tracking S2"
      restore_mode: ALWAYS_ON
    bluetooth_switch:
      name: "Sensor Bluetooth S2"
      restore_mode: ALWAYS_ON
    occupancy:
      id: occupancy_s2
      name: "Occupancy S2"
    target_count:
      name: "Target Count S2"
binary_sensor:
    - id: occupancy_combined
      platform: template
      name: "Occupancy combined"
      lambda: |-
        return (id(occupancy_s1).state || id(occupancy_s2).state);
      filters:
        - delayed_off: 10s
    - name: Tuer innen korrigiert
      platform: template
      lambda: |-
        return (id(tuer_innen).state);
      filters:
        - delayed_off: 2s
    - name: Tuer aussen korrigiert
      platform: template
      lambda: |-
        return (id(tuer_aussen).state);
      filters:
        - delayed_off: 2s


button:
  - platform: restart
    name: Restart

How could I fix this issue?

Best regards
Aaron Eisele

[Feature] Make coordinates in zone definition templateable

Hello,
I have been using this component for about 2 months now and it has been rock solid!

However, as seems to be the case with mmWave, there is a lot of fine-tuning and calibration needed, which includes changing the coordinates of zone polygon points.

Could you please make those templatable so I could set them from e.g a text input field in HA?

This is not urgent in any way, I can still recompile every time I change the coordinates, but it would make fine-tuning and initial setup much easier especially for bugfixing (e.g sensor zone too big) so you can adjust it dynamically while testing.

Best regards
Aaron Eisele

Zone constantly detecting false positive occupancy when polygon area is 0

Hello,
I have recently changed my zones and now I'm getting constant occupancy detected obn both of my zones, veven though the coordinates are obviously not in the zone's range.
How could I fix this?
Here's my zone config like it was before the issue appeared:

zones:
      - zone:
          name: "Tür aussen"
          margin: 10cm
          target_timeout: 0s
          polygon:
            - point: 
                x: 1.5m
                y: 3m
            - point:
                x: 0.4m
                y: 3m
            - point:
                x: 0.6m
                y: 3.2m
            - point: 
                x: 1.42m
                y: 3.2m
            

          occupancy:
            id: tuer_aussen
            name: Occupancy Tür aussen
      - zone:
          name: "Tür innen"
          margin: 10cm
          target_timeout: 0s
          polygon:
            - point:
                x: 0.6m
                y: 2.6m
            - point:
                x: 0.6m
                y: 3.1m
            - point:
                x: 1.42m
                y: 3.1m
            - point:
                x: 1.42m
                y: 2.6m
          occupancy:
            id: tuer_innen
            name: Occupancy Tür innen

And here's my current config with the bug:

zones:
      - zone:
          name: "Tür aussen"
          margin: 0cm
          target_timeout: 0s
          polygon:
            - point: 
                x: 0.55m
                y: 2.82m
            - point:
                x: 0.55m
                y: 2.82m
            - point:
                x: 1.41m
                y: 3.2m
            - point: 
                x: 1.41m
                y: 3.2m
            

          occupancy:
            id: tuer_aussen
            name: Occupancy Tür aussen
      - zone:
          name: "Tür innen"
          margin: 0cm
          target_timeout: 0s
          polygon:
            - point:
                x: 0.57m
                y: 2.46m
            - point:
                x: 0.57m
                y: 2.46m
            - point:
                x: 1.54m
                y: 2.66m
            - point:
                x: 1.54m
                y: 2.66m
          occupancy:
            id: tuer_innen
            name: Occupancy Tür innen

How could I fix this?
I'll switch back to the original config in the meantime.

Best regards
Aaron Eisele

Sensor stops working after some time

Hi, awesome work and very nice to see fully polygon based zone support!

I'm having trouble with the sensor stopping to work after some time.

I first thought it might be a problem with the ESP but that seems to not be the case. Restarting only the ESP does not resolve the issue (I tried the ESPHome Restart functionality). So I assume the sensor itself stops working after some time.

I was wondering which Firmware Version you are running (mine is 2.04.23101915, but I've had the same issue with 2.02.23090617, 1.2.23051810 did not work at all)

Any hint is appreciated, thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.