Andrea-Fox / peopleCounter

Code for a cheap people counter based on VL53L1X sensor and ESP32/8266
The Unlicense
95 stars 27 forks source link

Integration with Home Assistant: configuration.yaml, sensor: force_update: true #7

Closed LC7894 closed 3 years ago

LC7894 commented 3 years ago

If someone walks in one direction the sensor outputs 1 and is not returning to 0 afterwards. It just stays 1 (that's how it is in my case). The problem: If someone else walks in the same direction (e.g. two people in a room now) the sensor is not updating itself (since it is already 1). Hence there is no update of the input number and the input number never goes higher than 1. I tested the sensor and your code and ran in this problem. The force_update: true command fixed it for me.

Andrea-Fox commented 3 years ago

Are you sure about the fact that the output of the sensor remains 1? Because, if you look at how the function publishSerialData is written in any of the files, you see how at first the output is 1 and then, after 50 milliseconds, there is a new output which is 0.
In any case, how does force_update: true avoids the error? I'm not very familiar with that command

LC7894 commented 3 years ago

I installed the program on an ESP8266. I just started with ESP coding so until now I'm not experienced enough to check whether there is a mistake in the code for the ESP8266. I can just say how the program behaves. My experience ist that it doesn't change the value from 1 back to 0 on the ESP8266. I checked the output of Home Assistant and there is either 1 or 2 as output, but never 0.

force_update: true is a workaround then. In Home Assistant only a change of the sensor value is registered. So if the sensor state is 1 and then someone else passes the sensor, the output stays 1 and nothing is triggered. force_update: true forces the sensor to trigger a "new 1" even if the old value was 1. You can check the function here: https://www.home-assistant.io/integrations/sensor.mqtt/#force_update

Andrea-Fox commented 3 years ago

My bad. I realized that there was an error in the code for ESP8266. You should download the updated file and see if it works.
I forgot to add the part that updates the output to 0 and every time one person passed the output remain stuck onto 1 or 2

LC7894 commented 3 years ago

My bad. I realized that there was an error in the code for ESP8266. You should download the updated file and see if it works

Ahh okay so my assumption was right. I will check it, thanks for updating the code

Andrea-Fox commented 3 years ago

Thank you for making me notice the error. If you see that the new code works without what you added in the configuration.yaml file, feel free to close this request

LC7894 commented 3 years ago

I just tested it - it works like a charm without the adaption of the configuration.yaml (just OTA update code for the ESP8266 is missing now, but thats something I can try to implement on my own ;) ). Thank you for updating the code and replying so fast! And thanks as well for the amazing program - I searched for something like this for a long time! I will close this request now.