emericg / WatchFlower

A plant monitoring application that reads and plots data from compatible Bluetooth sensors and thermometers like Xiaomi 'Flower Care' or Parrot 'Flower Power'
https://emeric.io/WatchFlower
GNU General Public License v3.0
192 stars 27 forks source link

Device database initialization error #51

Closed TUstudents closed 2 years ago

TUstudents commented 2 years ago

Describe the bug If a new device is added (maybe only the first in the database), and the history is synced the first database entry is initialized with wrong values. The first entry in the history is Moisture 255%, Temperature -0.1°, Luminosity -1 lux, Fertility -1µs/cm (which is probably -1 cast into uint 8bit, -1 for floats as temperature is reported in 0.1°C units AFAIK. These artifacts are present both on the Windows and Android app and probably for all platforms. While not a serious issue itself, this bug is affecting the auto-scaling, as 255% moisture can not be reached in live operation and all subsequent values are scaled down to tiny bars.

Expected behavior Initialize moisture to 0% and do not use first value for auto-scaling at all

Screenshots image

Your environment Win10 WatchFlower v2.1 Android11

emericg commented 2 years ago

I think the FlowerCare is returning wrong values, as you mentionned probably -1 on all values. My default values in the code are actually -99 ^^ (because -1 is a valid value in many cases).

Now that being said, I never saw this particular case, but I can set the app to not register values when we get -1 on all sensors. I'll add that for the next release!

emericg commented 2 years ago

This commit should fix the issue you mention (and more similar it) by preventing these values to ever make it to the database. Can you try latest version and tell me if it works for you?

TUstudents commented 2 years ago

Unfortunately I can't compile the exe myself, however I saw you released V3.0 as an installer in the meantime. On the Android the strange values are no longer displayed, but I think the scaling can be still improved, as the scaling on the dayly graph is odd. Here there are tiny bars (like 0-200% moisture full scale, even if all values are ~25%), that have a different scaling than the weekly and monthly bars. The strangest thing is the bars scale is different for every flower, for a specific day, if you open the app again, .... If autoscaling is not reliable, would it be better to fix it to e.g. recommended moisture levels of flower +-10%?.

There is also an update bug: If you switch from month to week to day the value of the yellow bar is not updated.