dudanov / hassio-ftms

Home Assistant custom component for Bluetooth Fitness Equipment (FTMS).
Apache License 2.0
9 stars 0 forks source link

Issue with using utility sensors to track daily use for different users (tariffs) #12

Open quack3d opened 1 month ago

quack3d commented 1 month ago

My previous attempt of getting daily statistics of the sensors didn't work 100 % when swapping between users. So with help on this thread on Discord (https://discord.com/channels/330944238910963714/1288491404896636982) I created utility sensors with one tariff for each user. The problem is that if integration is reloaded (or HA restarted) while treadmill is on it will add the previous step count to the daily sensor before continuing increasing. So if current step count is 1000 and daily step count is 2000, when I restart HA/integration the step count is still 1000 but daily step count is now 3000.

Any thoughts? The help on Discord had a theory that the sensor may have a weird startup behaviour: "e.g. if it returns 0 while waiting for an initial response from the treadmill even for an instant, then the utility meter will add the returned amount when it goes from 0-> restored value".

quack3d commented 1 month ago

It seems it only happens when I reload the integration. Not when restarting HA. I suppose this could be an issue if BT connection is dropped and integration is reloaded. It has only happened once for me though. Steps etc stopped updating in HA. When I pushed a button I got a popup error and the integration reloaded.