Closed Byter09 closed 1 year ago
Hello, I've tested the code, it works fine for me:
bt1 = BTOneApp("hci0", MAC_ADDR, DEVICE_ALIAS, on_connected, on_data_received, 30)
It logs stats every 30 seconds. Are you sure you do not have any other additional logic for polling?
I do not, no. I should note that this only occured a few hours, maybe a day, after first starting the script. I myself am very perplexed how this happened. My temporary fix of not using polling and starting the script using timeout 30s ...
seems to have at least alleviated the problem, even though it now has to fully start up every 30 seconds. It works, but it's a really ugly solution.
I wish I had more information for you. This is sadly all I know. I can't explain the problem myself, I thought my code is fairly trivial and can't be the problem so just in case I opened this ticket, maybe you see something I don't.
Also had to purge the data recorder database of home assistant as the data I had in there was causing all kinds of weird display glitches haha. I do have the raw data in influxDB though, just in case you want to have a look.
It looks to me like you have a thread running from one of your previous experiments. Two entirely different set of datasets point to this. It could be problem with docker? Anyway I do not have any recent changes to polling logic, even if there is a timer bug, it cannot give out two different set of data like in your logs.
Oh god I just had a realisation, it was very likely my problem indeed! Thank you for mentioning this.
I think this might be some weird combination of using shell to start the script and it then not being killed correctly, which would explain the apparent two instances.
Basically, I used solar-monitor
before, but sometimes it would randomly stop sending data so I set up my shell script to time out the process and start a new one. When I switched to this project I didn't touch that logic and was hoping it would just work (effectively restarting it every 24h to be sure), but maybe it didn't kill the process correctly. I'll have to revisit my whole setup and I'll likely start trusting your code to do the right thing. I hope it automatically reconnects if there's problems.
Thank you so much for pointing me in the right direction. I would've never guessed that that was the problem. I'll close this issue :)
Hello again. I've been running this project for a bit now and only made minor changes to the example file in the form of the code below:
And today I woke up with really weird statistics in my home assistant. I checked the logs, and instead of every 60 seconds, it was sending data every second or so. Here's a bit of that output:
The worst part is, if you check
power_generation_total
of each data set, it seems to repeatedly send old data. It goes from263491
to263502
(the correct value), back to263491
. This completely throws off Home Assistants energy dashboard, and is now reporting my battery produced over 100kWh today alone haha.I'll turn off the polling timeout for now and simply call the script in a set interval. If this is actually a problem with my code, please let me know. I am fairly certain the poll timer is somehow broken though.
Thanks again for this amazing project though. Makes sending data so much easier :)