fl4p / batmon-ha

Add-on for Home Assistant to connect JK, JBD, Daly, ANT, SOK and Supervolt BMS via Bluetooth
MIT License
287 stars 55 forks source link

HA installation #1

Closed AntoineLaporte closed 2 years ago

AntoineLaporte commented 2 years ago

Hi,

your add-on is just what I was looking (BlueTooth) for but I don't know how to install it in HA with the graphic interface. You have linked this other project that is over USB (Daly: similar add-on) and there is a link to an HA repository that is working for me: https://github.com/MindFreeze/home-assistant-addons

Would it be possible to do the same for your add-on ?

Thank you !

fl4p-old commented 2 years ago

Hi,

I just created a new repository for this add-on. Try https://github.com/fl4p/home-assistant-addons for HA repository link. Let me know if it works for you.

Cheers

AntoineLaporte commented 2 years ago

Thanks a lot, it will be a really nice add-on to have in my van, I'll try it in the next days and tell you.

AntoineLaporte commented 2 years ago

Actually I got an error in the logs [s6-init] making user provided files available at /var/run/s6/etc...exited 0. [s6-init] ensuring user provided files have correct perms...exited 0. [fix-attrs.d] applying ownership & permissions fixes... [fix-attrs.d] done. [cont-init.d] executing container initialization scripts... [cont-init.d] done. [services.d] starting services [services.d] done. ifelse: fatal: unable to exec ./run.sh: Permission denied [cmd] ./run.sh exited 126 [cont-finish.d] executing container finish scripts... [cont-finish.d] done. [s6-finish] waiting for services.

fl4p-old commented 2 years ago

Nice, I'm using it in my van too.

I just pushed an update, try this

AntoineLaporte commented 2 years ago

Same [s6-init] making user provided files available at /var/run/s6/etc...exited 0. [s6-init] ensuring user provided files have correct perms...exited 0. [fix-attrs.d] applying ownership & permissions fixes... [fix-attrs.d] done. [cont-init.d] executing container initialization scripts... [cont-init.d] done. [services.d] starting services [services.d] done. ifelse: fatal: unable to exec ./run.sh: Permission denied [cmd] ./run.sh exited 126 [cont-finish.d] executing container finish scripts... [cont-finish.d] done. [s6-finish] waiting for services. [s6-finish] sending all processes the TERM signal.

AntoineLaporte commented 2 years ago

Just got the update on ha now and it works, I don't understand all the "errors" in the logs but I see that I get the data from the BT. Thanks again for your work.

P.S.: I would put the possility to put the name of the device (DL-5XXXXXXXXX), I think it's not very hard for you as I was seeing it in the logs assiciated to the mac address. Also the lasts ":" just after the mac address in the logs could be confusing for people who don't know how a mac address should be.

AntoineLaporte commented 2 years ago

I have some new errors INFO [main.py:55] connecting bms DalyBt(26:62:04:05:01:5D) INFO [main.py:63] daly_bms result@2022-02-18T00:21:45.552220 BmsSample(U=26.6V,I=0.00A,P=0W,q=502.3Ah/560) INFO [main.py:67] daly_bms Voltages: [3325, 3326, 3325, 3325, 3325, 3325, 3326, 3325] ERROR [main.py:75] daly_bms error: <class 'asyncio.exceptions.TimeoutError'> ERROR [main.py:146] 1 exceptions occurred fetching BMSs ERROR [main.py:153] Error (num 5) reading BMS: ERROR [main.py:154] Stack: Traceback (most recent call last): File "/usr/lib/python3.9/asyncio/tasks.py", line 492, in wait_for fut.result() asyncio.exceptions.CancelledError The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/app/main.py", line 147, in main raise exceptions[0] File "/app/main.py", line 142, in main await t File "/app/main.py", line 69, in sample_bms temperatures = sample.temperatures or await bms.fetch_temperatures() File "/app/bmslib/daly.py", line 136, in fetch_temperatures resp = await self._q(0x96, num_responses=n_resp) File "/app/bmslib/daly.py", line 71, in _q sample = await asyncio.wait_for(self._fetch_futures[command], self.TIMEOUT) File "/usr/lib/python3.9/asyncio/tasks.py", line 494, in wait_for raise exceptions.TimeoutError() from exc asyncio.exceptions.TimeoutError BT Discovery: too many errors, abort [cmd] ./run.sh exited 1 [cont-finish.d] executing container finish scripts... [cont-finish.d] done. [s6-finish] waiting for services. [s6-finish] sending all processes the TERM signal.

Also I get a lot of 0Amps data, even with for sure some current used all the time and not input, but it's the same in the BT app, is it the same for you ?

fl4p-old commented 2 years ago

Hi, with the next update you can use the device name (DL-...) for the address. Also I changed the log output of the discovered devices, I agree the extra ":" is confusing

fl4p-old commented 2 years ago

Yes same here. The Daly BMS has poor current measuring. It shows 0A for currents below 0.3A.

fl4p-old commented 2 years ago

The error you posted is related to reading temperature values.

What is your Daly BMS model and how many temperature sensors does it show in the app?

AntoineLaporte commented 2 years ago

I got the 120A with one temp sensor. The problem I got is that it was reading 0 and -4 and then 0 and again -4, etc... I tried the UART cable addon and I do not have this problem with it.

fl4p-old commented 2 years ago

Please try the update I just pushed

AntoineLaporte commented 2 years ago

I will probably tomorrow. Thanks

AntoineLaporte commented 2 years ago

I'm sorry I couldn't test your update because I burnt my BMS, I'm waiting for the new one and I'll test it right away !

AntoineLaporte commented 2 years ago

Hey,

I finally got the BMS and testing it right now. It looks good and the data updates are looking great. Just my SOC is not changing much right now and I guess if it is the same there is no update of the sensor ? Thank you !

fl4p-old commented 2 years ago

Hi, ok great. Daly BMS reports SoC with 1 decimal precision. Check capacity_ah which might be more precise.

See the add-on logs to verify that it is sampling the BMS. You should see lines like

INFO     [sampling.py:53] daly_bms result@2022-03-16T17:45:29.786835 BmsSample(U=26.3V,I=0.70A,P=18W,q=120.4Ah/280)
AntoineLaporte commented 2 years ago

Hi,

I've tried a bit of everything and I found 2 problems:

ERROR [main.py:171] Stack: Traceback (most recent call last): File "/app/main.py", line 164, in main raise exceptions[0] File "/app/main.py", line 159, in main await t File "/app/main.py", line 63, in sample_bms async with bms: File "/app/bmslib/bt.py", line 42, in aenter await self.connect() File "/app/bmslib/daly.py", line 56, in connect await super().connect() File "/app/bmslib/bt.py", line 21, in connect await self.client.connect() File "/usr/lib/python3.9/site-packages/bleak/backends/bluezdbus/client.py", line 297, in connect raise BleakError( bleak.exc.BleakError: Device with address 96:69:08:04:0B:2D could not be found. Try increasing timeout value or moving the device closer. too many errors, abort [cmd] ./run.sh exited 1 [cont-finish.d] executing container finish scripts... [cont-finish.d] done. [s6-finish] waiting for services. [s6-finish] sending all processes the TERM signal.

fl4p-old commented 2 years ago

Hi

  • if you put the stay alive option the Daly BT dongle is not accessible by anything else (which is normal) but if I restart the server it is also not accessible by the server anymore. I'm not sure if it happens all the time but I think so. Then I have to unplug the dongle and and put it back to be able to reconnect

This appears to be a Daly BT Dongle issue. I have this issue with Daly and JBD BMSs.

The add-on intentionally exits itself for a clean re-start after too many errors. Try to disable the watchdog and enable it again.

fl4p-old commented 2 years ago

Bluetooth Timeout is set 10 sec, will increase it to 20 with the next update

AntoineLaporte commented 2 years ago

Everything else is working good, thank you again for this addon, it's way easier to just have a look to HA than having to open the app, and I love stats !

AntoineLaporte commented 2 years ago

I'm actually experiencing some troubles with my phone BT presence detection, do you think that batmon could use "too much" BT so my Pi has not time to try to detect my phone ?