Hmmm, I think this is the wrong position, the sensor should be vertical.
I configure the sensor as follows:
- Flash the sensor without inversion of coordinates and without entry points
- Make a widget with the plane x[-600, 600] and y[-600, 600]
- Stand in front of the sensor at a distance of 1 meter
- Rotate the coordinates with the rotate parameter until your position is in the required plane, for example x:100 y:-100
- Set the y coordinate inversion parameter
- Set the coordinate of the entry point relative to the new coordinates, for example (0, 150) because my sensor is to the right of the entrance at a distance of 150 cm
- (Additional) I added additional entry points at (0,0) and (0,100) because the sensor sometimes shows ghosts at these coordinates when I exit
Basically, this approach works, but there are some problems:
- If there are two persons in the room and the first person disappears, then the second person becomes the first person, this confuses the algorithm.
- When leaving the room, ghosts sometimes appear in random coordinates.
Both of these problems are difficult to solve on the esphome side, maybe the sensor firmware will improve later.
I also added custom zones with a binary sensor to detect presence.
Configuration Widget
type: custom:plotly-graph
title: LD2450
refresh_interval: 10
hours_to_show: current_day
ha_theme: true
layout:
legend:
'y': 600
orientation: h
autosize: true
margin:
autoexpand: true
l: 50
r: 20
t: 20
b: 40
showlegend: true
xaxis:
dtick: 100
gridcolor: RGBA(200,200,200,0.15)
zerolinecolor: RGBA(200,200,200,0.15)
type: number
fixedrange: true
range:
- 600
- -600
yaxis:
dtick: 100
gridcolor: RGBA(200,200,200,0.15)
zerolinecolor: RGBA(200,200,200,0.15)
scaleanchor: x
scaleratio: 1
fixedrange: true
range:
- 600
- -600
entities:
- entity: ''
name: Person1
show_value: true
unit_of_measurement: cm
marker:
size: 12
line:
shape: spline
width: 5
x:
- $ex hass.states["sensor.hlk_presenсe_p0x"].state
'y':
- $ex hass.states["sensor.hlk_presenсe_p0y"].state
- entity: ''
name: Person2
show_value: true
unit_of_measurement: cm
marker:
size: 12
line:
shape: spline
width: 5
x:
- $ex hass.states["sensor.hlk_presenсe_p1x"].state
'y':
- $ex hass.states["sensor.hlk_presenсe_p1y"].state
- entity: ''
name: Person3
show_value: true
unit_of_measurement: cm
marker:
size: 12
line:
shape: spline
width: 5
x:
- $ex hass.states["sensor.hlk_presenсe_p2x"].state
'y':
- $ex hass.states["sensor.hlk_presenсe_p2y"].state
- entity: ''
name: Zone1
mode: lines
fill: toself
fillcolor: RGBA(20,200,0,0.1)
line:
color: RGBA(20,200,0,0.2)
shape: line
width: 2
x:
- $ex hass.states["number.hlk_presenсe_r0x0"].state
- $ex hass.states["number.hlk_presenсe_r0x0"].state
- $ex hass.states["number.hlk_presenсe_r0x1"].state
- $ex hass.states["number.hlk_presenсe_r0x1"].state
- $ex hass.states["number.hlk_presenсe_r0x0"].state
'y':
- $ex hass.states["number.hlk_presenсe_r0y0"].state
- $ex hass.states["number.hlk_presenсe_r0y1"].state
- $ex hass.states["number.hlk_presenсe_r0y1"].state
- $ex hass.states["number.hlk_presenсe_r0y0"].state
- $ex hass.states["number.hlk_presenсe_r0y0"].state
- entity: ''
name: Zone2
mode: lines
fill: toself
fillcolor: RGBA(200,0,255,0.1)
line:
color: RGBA(200,0,255,0.2)
shape: line
width: 2
x:
- $ex hass.states["number.hlk_presenсe_r1x0"].state
- $ex hass.states["number.hlk_presenсe_r1x0"].state
- $ex hass.states["number.hlk_presenсe_r1x1"].state
- $ex hass.states["number.hlk_presenсe_r1x1"].state
- $ex hass.states["number.hlk_presenсe_r1x0"].state
'y':
- $ex hass.states["number.hlk_presenсe_r1y0"].state
- $ex hass.states["number.hlk_presenсe_r1y1"].state
- $ex hass.states["number.hlk_presenсe_r1y1"].state
- $ex hass.states["number.hlk_presenсe_r1y0"].state
- $ex hass.states["number.hlk_presenсe_r1y0"].state
- entity: ''
name: Zone3
mode: lines
fill: toself
fillcolor: RGBA(200,120,55,0.1)
line:
color: RGBA(200,120,55,0.2)
shape: line
width: 2
x:
- $ex hass.states["number.hlk_presenсe_r2x0"].state
- $ex hass.states["number.hlk_presenсe_r2x0"].state
- $ex hass.states["number.hlk_presenсe_r2x1"].state
- $ex hass.states["number.hlk_presenсe_r2x1"].state
- $ex hass.states["number.hlk_presenсe_r2x0"].state
'y':
- $ex hass.states["number.hlk_presenсe_r2y0"].state
- $ex hass.states["number.hlk_presenсe_r2y1"].state
- $ex hass.states["number.hlk_presenсe_r2y1"].state
- $ex hass.states["number.hlk_presenсe_r2y0"].state
- $ex hass.states["number.hlk_presenсe_r2y0"].state
- entity: ''
name: Coverage
mode: lines
fill: tonexty
fillcolor: rgba(168, 216, 234, 0.08)
line:
shape: line
width: 1
dash: dot
x:
- 0
- $ex 600 * Math.sin((2 * Math.PI)/360 * 60)
- 450
- 400
- 300
- 200
- 100
- 0
- -100
- -200
- -300
- -400
- -450
- $ex -600 * Math.sin((2 * Math.PI)/360 * 60)
- 0
'y':
- 0
- $ex 600 * Math.cos((2 * Math.PI)/360 * 60)
- $ex Math.sqrt( 600**2 - 450**2 )
- $ex Math.sqrt( 600**2 - 400**2 )
- $ex Math.sqrt( 600**2 - 300**2 )
- $ex Math.sqrt( 600**2 - 200**2 )
- $ex Math.sqrt( 600**2 - 100**2 )
- 600
- $ex Math.sqrt( 600**2 - 100**2 )
- $ex Math.sqrt( 600**2 - 200**2 )
- $ex Math.sqrt( 600**2 - 300**2 )
- $ex Math.sqrt( 600**2 - 400**2 )
- $ex Math.sqrt( 600**2 - 450**2 )
- $ex 600 * Math.cos((2 * Math.PI)/360 * 60)
- 0
raw_plotly_config: true
Widget
type: custom:plotly-graph
title: LD2450
refresh_interval: 0.5
hours_to_show: current_day
ha_theme: true
layout:
legend:
orientation: h
autosize: true
margin:
autoexpand: true
l: 50
r: 20
t: 20
b: 40
showlegend: true
xaxis:
dtick: 50
gridcolor: RGBA(200,200,200,0.15)
zerolinecolor: RGBA(200,200,200,0.15)
type: number
fixedrange: true
range:
- -50
- 450
yaxis:
dtick: 50
gridcolor: RGBA(200,200,200,0.15)
zerolinecolor: RGBA(200,200,200,0.15)
scaleanchor: x
scaleratio: 1
fixedrange: true
range:
- -50
- 350
entities:
- entity: ''
name: Room
mode: lines
line:
color: RGBA(200,200,200,0.7)
shape: line
width: 2
x:
- 0
- 0
- 400
- 400
- 0
'y':
- 300
- 0
- 0
- 300
- 300
- entity: ''
name: Sensor
mode: lines
fill: toself
fillcolor: RGBA(200,200,0,1)
line:
color: RGBA(200,200,0,0.7)
shape: line
width: 2
x:
- 0
- 0
- 30
- 0
'y':
- 30
- 0
- 0
- 30
- entity: ''
name: Person1
show_value: true
unit_of_measurement: cm
marker:
size: 12
line:
shape: spline
width: 5
x:
- $ex hass.states["sensor.hlk_presenсe_p0x"].state
'y':
- $ex hass.states["sensor.hlk_presenсe_p0y"].state
- entity: ''
name: Person2
show_value: true
unit_of_measurement: cm
marker:
size: 12
line:
shape: spline
width: 5
x:
- $ex hass.states["sensor.hlk_presenсe_p1x"].state
'y':
- $ex hass.states["sensor.hlk_presenсe_p1y"].state
- entity: ''
name: Person3
show_value: true
unit_of_measurement: cm
marker:
size: 12
line:
shape: spline
width: 5
x:
- $ex hass.states["sensor.hlk_presenсe_p2x"].state
'y':
- $ex hass.states["sensor.hlk_presenсe_p2y"].state
raw_plotly_config: true