TillFleisch / ESPHome-HLK-LD2450

ESPHome support for the HI-Link HLK-LD2450 millimeter wave sensor (external component) with support for custom zones using convex polygons.
MIT License
105 stars 19 forks source link

Zone constantly detecting false positive occupancy when polygon area is 0 #10

Closed Aaroneisele55 closed 8 months ago

Aaroneisele55 commented 8 months ago

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

TillFleisch commented 8 months ago
         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

This (and the other example) is an invalid polygon. Since there are duplicate points and the "polygon" is essentially a line, it does not have a detection area. Therefore the output state of the zone is invalid. In theory, it should never be able to detect something. Please remove any duplicate points within a single polygon from your configuration.

I'll add some more input validation to catch such config issues, once I find some free time.