Skip to content

Commit 8e1c403

Browse files
authored
Merge pull request #90 from CarsonF/config
Refactor configuration structure
2 parents d70c776 + 8062f84 commit 8e1c403

19 files changed

+914
-948
lines changed

README.md

Lines changed: 107 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ People counter working with any smart home system which supports ESPHome and the
1111
- [ESP32](#esp32)
1212
- [ESP8266](#esp8266)
1313
- [Configuration](#configuration)
14-
- [Configuration variables](#configuration-variables)
15-
- [Sensor](#sensor)
14+
- [Platform Setup](#platform-setup)
15+
- [Sensors](#sensors)
1616
- [Threshold distance](#threshold-distance)
1717
- [Algorithm](#algorithm)
1818
- [FAQ/Troubleshoot](#faqtroubleshoot)
@@ -66,61 +66,123 @@ Ps=0 (when connected to GND): In the IIC mode, the user can operate the chip by
6666

6767
## Configuration
6868

69+
## Platform Setup
70+
6971
Roode is provided as an external_component which means it is easy to setup in any ESPHome sensor configuration file.
7072

71-
Example configuration
73+
Other than base ESPHome configuration the only config that's needed for Roode is
74+
```yaml
75+
external_components:
76+
- source: github://Lyr3x/Roode
77+
refresh: always
7278

73-
```
7479
roode:
75-
id: roode_platform
76-
i2c_address: 0x29
77-
update_interval: 200ms
80+
```
81+
This uses the recommended default configuration.
82+
83+
However, we offer a lot of flexibility. Here's the full configuration spelled out.
84+
85+
```yml
86+
external_components:
87+
- source: github://Lyr3x/Roode
88+
refresh: always
89+
90+
# VL53L1X sensor configuration is separate from Roode people counting algorithm
91+
vl53l1x:
92+
# A non-standard I2C address
93+
address:
94+
95+
# Sensor calibration options
7896
calibration:
79-
max_threshold_percentage: 85
80-
min_threshold_percentage: 5
81-
roi_calibration: true
82-
# manual:
83-
# sensor_mode: 2
84-
# roi_height: 16
85-
# roi_width: 6
86-
# manual_threshold: 1300
87-
# timing_budget: 100
88-
invert_direction: true
97+
# The ranging mode is different based on how long the distance is that the sensor need to measure.
98+
# The longer the distance, the more time the sensor needs to take a measurement.
99+
# Available options are: auto, shortest, short, medium, long, longer, longest
100+
ranging: auto
101+
# The offset correction distance. See calibration section (WIP) for more details.
102+
offset: 8mm
103+
# The corrected photon count in counts per second. See calibration section (WIP) for more details.
104+
crosstalk: 53406cps
105+
106+
# Hardware pins
107+
pins:
108+
# Shutdown/Enable pin, which is needed to change the I2C address. Required with multiple sensors.
109+
xshut: GPIO3
110+
# Interrupt pin. Use to notify us when a measurement is ready. This feature is WIP.
111+
# This needs to be an internal pin.
112+
interrupt: GPIO1
113+
114+
# Roode people counting algorithm
115+
roode:
116+
# Smooth out measurements by using the minimum distance from this number of readings
117+
sampling: 2
118+
119+
# The orientation of the two sensor pads in relation to the entryway being tracked.
120+
# The advised orientation is parallel, but if needed this can be changed to perpendicular.
121+
orientation: parallel
122+
123+
# This controls the size of the Region of Interest the sensor should take readings in.
124+
# The current default is
125+
roi: { height: 16, width: 6 }
126+
# We have an experiential automatic mode that can be enabled with
127+
roi: auto
128+
# or only automatic for one dimension
129+
roi: { height: 16, width: auto }
130+
131+
# The detection thresholds for determining whether a measurement should count as a person crossing.
132+
# A reading must be greater than the minimum and less than the maximum to count as a crossing.
133+
# These can be given as absolute distances or as percentages.
134+
# Percentages are based on the automatically determined idle or resting distance.
135+
detection_thresholds:
136+
min: 0% # default minimum is any distance
137+
max: 85% # default maximum is 85%
138+
# an example of absolute units
139+
min: 50mm
140+
max: 234cm
141+
142+
# The people counting algorithm works by splitting the sensor's capability reading area into two zones.
143+
# This allows for detecting whether a crossing is an entry or exit based on which zones was crossed first.
144+
zones:
145+
# Flip the entry/exit zones. If Roode seems to be counting backwards, set this to true.
146+
invert: false
147+
148+
# Entry/Exit zones can set overrides for individual ROI & detection thresholds here.
149+
# If omitted, they use the options configured above.
150+
entry:
151+
# Entry zone will automatically configure ROI, regardless of ROI above.
152+
roi: auto
153+
exit:
154+
roi:
155+
# Exit zone will have a height of 8 and a width of number set above or default or auto
156+
height: 8
157+
# Additionally, zones can manually set their center point.
158+
# Usually though, this is left for Roode to automatically determine.
159+
center: 124
160+
161+
detection_thresholds:
162+
# Exit zone's min detection threshold will be 5% of idle/resting distance, regardless of setting above.
163+
min: 5%
164+
# Exit zone's max detection threshold will be 70% of idle/resting distance, regardless of setting above.
165+
max: 70%
166+
```
167+
168+
### Sensors
89169
170+
#### People Counter
171+
172+
The most important one is the people counter.
173+
```yaml
90174
number:
91175
- platform: roode
92176
people_counter:
93177
name: People Count
94178
```
179+
Regardless of how close we can get, people counting will never be perfect.
180+
This allows the current people count to be adjusted easily via Home Assistant.
95181
96-
### Configuration variables
97-
98-
- **i2c_address (Optional, integer)**: The I²C address of the sensor. Defaults to `0x29`.
99-
- **update_interval (Optional, Time)**: The interval to check the sensor. Defaults to `100ms`.
100-
- **calibration (Optional, exclusive-mode)**: Enables automatic zone calibration:
101-
- **max_threshold_percentage (Optional, int)**: The maxium threshold in % which needs to be reached to detect a person. Min: `50` Max: `100`. Defaults to `85`.
102-
- **min_threshold_percentage (Optional, int)**: The minimum threshold in % which needs to be reached to detect a person. Min: `0` Max: `100`. Defaults to `0`.
103-
- **roi_calibration (Optional, bool)**: Enables automatic ROI calibration (experimental). Defaults to `false`.
104-
- **manual (Optional, exclusiv-modee)**: Enables manual sensor setup:
105-
- **manual_threshold (required, int)**: The threshold for both zones. Min: `40` Max: `4000`. Defaults to `2000`.
106-
- **roi_height (required, int)**: The height of the ROI zones. Min: `4` Max: `16`. Defaults to `16`.
107-
- **roi_width (required, int)**: The height of the ROI zones. Min: `4` Max: `16`. Defaults to `6`.
108-
- **sensor_mode(required, int)**: Sets the distance mode of the sensor if `calibration=false`.
109-
- Options: `0=short`, `1=long`, `2=max`. Defaults to `true`.
110-
- **timing_budget (optional, int)**: The timing budget for the sensor. Increasing this slows down detection but increases accuracy. Min: `10ms` Max: `1000s`. Defaults to `10ms`.
111-
- **invert_direction (Optional, bool)**: Inverts the counting direction. Switch to `true` if the movement count appears backwards. Defaults to `false`.
112-
- **advised_sensor_orientation(Optional, bool)**: Advised orientation has the two sensor pads parallel to the entryway.
113-
So `false` means the pads are perpendicular to the entryway.
114-
Defaults to `true`.
115-
116-
### Sensor
117-
118-
Example Sensor setup to use all available features:
182+
#### Other sensors available
119183
120-
```
184+
```yaml
121185
binary_sensor:
122-
- platform: status
123-
name: $friendly_name Status
124186
- platform: roode
125187
presence_sensor:
126188
name: $friendly_name presence
@@ -141,46 +203,13 @@ sensor:
141203
roi_width:
142204
name: $friendly_name ROI width
143205

144-
- platform: wifi_signal
145-
name: $friendly_name RSSI
146-
update_interval: 60s
147-
148-
- platform: uptime
149-
name: Uptime Sensor
150-
id: uptime_sensor
151-
update_interval: 120s
152-
internal: true
153-
on_raw_value:
154-
then:
155-
- text_sensor.template.publish:
156-
id: uptime_human
157-
state: !lambda |-
158-
int seconds = round(id(uptime_sensor).raw_state);
159-
int days = seconds / (24 * 3600);
160-
seconds = seconds % (24 * 3600);
161-
int hours = seconds / 3600;
162-
seconds = seconds % 3600;
163-
int minutes = seconds / 60;
164-
seconds = seconds % 60;
165-
return (
166-
(days ? String(days) + "d " : "") +
167-
(hours ? String(hours) + "h " : "") +
168-
(minutes ? String(minutes) + "m " : "") +
169-
(String(seconds) + "s")
170-
).c_str();
171-
172206
text_sensor:
173207
- platform: roode
174208
version:
175209
name: $friendly_name version
176210
- platform: roode
177211
entry_exit_event:
178212
name: $friendly_name last direction
179-
180-
- platform: template
181-
name: $friendly_name Uptime Human Readable
182-
id: uptime_human
183-
icon: mdi:clock-start
184213
```
185214
186215
### Threshold distance
@@ -290,6 +319,7 @@ lower right.
290319
4. Bad connections
291320

292321
## Sponsors
322+
293323
Thank you very much for you sponsorship!
294-
* sunshine-hass
295324

325+
- sunshine-hass

0 commit comments

Comments
 (0)