screekworkshop / screek-human-sensor

124 stars 28 forks source link

dedup logs and published states #25

Closed durd closed 1 month ago

durd commented 1 month ago

This PR adds dedup of logs so the device isn't as chatty when viewing logs. This means that the same value will not be published or printed twice. The BH1750 sensor follows the log-level of "logger" which defaults to DEBUG, I changed only the sensors log-level to INFO.

The result is a less chatty log, and probably some power improvements as only new data is sent over WiFi. It's still very chatty when movement is detected, but that is "legitimate" data.

I added your fix for the self-detect, if you push your change to the repo I will make sure mine doesn't contain it.

Also cleaned up some whitespace and corrected strs to ints.

durd commented 1 month ago

I'm still unsure about sliding_window_moving_average filter, I've commented it out for the time being.

screekworkshop commented 1 month ago

thx, i will test it later:)

durd commented 1 month ago

Changed ">" to ">=" for time comparison, else Clearance and Movement time would be 1s more than set intervals.

Also added "update_interval" to Distance sensor, this replaces heartbeat filter but the value is still subject to delta filter.

Also made binary sensors publish initial state. Now HA isn't "unknown" after reset device.

durd commented 1 month ago

An unintended effect is I think the sensor is quicker now. Before we started troubleshooting the issue of false detection I usually had a "cool down", after the Movement sensor went "Clear", of about 20-25s. Now it's down to ~5-6s. I've also noticed that if the sensor doesn't detect occupancy and immediately clears it also clears the "Occupancy or Movement" sensor and the "Occupancy Status" sensor. I don't recall noticing this before as well. I might be wrong and my testing is incomplete, but I think this is better and will be leaving it as it is.

screekworkshop commented 1 month ago

An unintended effect is I think the sensor is quicker now. Before we started troubleshooting the issue of false detection I usually had a "cool down", after the Movement sensor went "Clear", of about 20-25s. Now it's down to ~5-6s. I've also noticed that if the sensor doesn't detect occupancy and immediately clears it also clears the "Occupancy or Movement" sensor and the "Occupancy Status" sensor. I don't recall noticing this before as well. I might be wrong and my testing is incomplete, but I think this is better and will be leaving it as it is.

Can confirm that this became a new side effect, caused by reading the null state to clear all properties. This requires removing some of the null code. As we've had a bit too much on our hands in the last couple of days, we're hoping to find some time to clean them up completely and then integrate your code. Some of the functionality we'll put in the beta firmware, but for basic dis=0.00 cases like this, I think they can be merged into the stable firmware (they're a completely irrational behaviour).

Thank you very much for your submission, these cleanups of extra spaces and quotes can be a nice improve.

screekworkshop commented 1 month ago

https://www.reddit.com/r/screekworkshop/comments/1eco789/human_sensor_f2_beta_firmware_v2474_beta/ https://github.com/screekworkshop/screek-human-sensor/blob/main/f2/yaml/beta-version/human-sensor-f2-beta-github.yaml

we have add some feather, plz have a test.

durd commented 1 month ago

Hi! I've tried it, works good! It doesn't have my changes to it's very chatty ;)

The refresh rate is nice!

When you change the beta to stable I will update my code to fit your new code.

screekworkshop commented 1 month ago

Hi, we merged some of the changes into the new beta, and later changes can be made based on the beta.