renogy-bt icon indicating copy to clipboard operation
renogy-bt copied to clipboard

Bleak port

Open cyrils opened this issue 10 months ago • 7 comments

This experimental bleak port adds support on Win/Mac/Linux/RPI-4 platforms. Bleak is a platform agnostic BLE client.

  • Supports Windows 10, version 16299 (Fall Creators Update) or greater
  • Supports Linux distributions with BlueZ >= 5.43
  • OS X/macOS support via Core Bluetooth API, from at least OS X version 10.11

TODO

  • [ ] Update documentation
  • [x] Test RoverClient / RoverHistoryClient
  • [ ] Test BatteryClient
  • [ ] Test InverterClient
  • [x] Test MacOS
  • [ ] Test Linux
  • [ ] Test Windows

cyrils avatar Apr 03 '24 07:04 cyrils

FYI I tested this on Linux with a BT-2 connected to three batteries (daisy-chained) and was able to pull values.

I also tested on Linux with a BT-2 connected to a 60A Rover, and was able to pull values.

mavenius avatar Jul 05 '24 19:07 mavenius

Tested (successfully) BatteryClient and RoverClient on Windows 10.

mavenius avatar Jul 11 '24 17:07 mavenius

Did you see any stability improvements in long term compared to main version?

cyrils avatar Jul 12 '24 04:07 cyrils

Did you see any stability improvements in long term compared to main version?

I haven't done any long term testing; just a few minutes on each platform. I can do so (for one at a time, at least) through next week though.

That said, it seemed solid so far. On main, I get errors probably 3/10 or more times I try to read. Now that I have error tracking, I can get more precise data on that (including with the bleak branch.)

mavenius avatar Jul 12 '24 10:07 mavenius

I used a Raspberry PI 3 Model B and only this bleak port works to find and connect to the BT-1 + SRNE ML4860. It's just odd though that in https://github.com/cyrils/renogy-bt/issues/55 it worked well with the ML2440.

I only get this in RNG_CTRL, and even RNG_CTRL_HIST doesn't get anything.

~/renogy-bt $ python3 ./example.py config.ini 
INFO:root:Init RoverClient: BT-TH-487ACA33 => 20:91:48:7A:CA:33
INFO:root:Starting discovery...
INFO:root:Devices found: 37
INFO:root:Found matching device BT-TH-487ACA33 => 20:91:48:7A:CA:33
INFO:root:Client connection: True
INFO:root:subscribed to notification 0000fff1-0000-1000-8000-00805f9b34fb
INFO:root:found write characteristic 0000ffd1-0000-1000-8000-00805f9b34fb
INFO:root:writing to 0000ffd1-0000-1000-8000-00805f9b34fb [255, 3, 0, 12, 0, 8, 145, 209]
INFO:root:characteristic_write_value succeeded
INFO:root:notification_callback
INFO:root:on_data_received: response for read operation
INFO:root:notification_callback
WARNING:root:on_data_received: unknown operation=0
INFO:root:writing to 0000ffd1-0000-1000-8000-00805f9b34fb [255, 3, 0, 26, 0, 1, 176, 19]
INFO:root:characteristic_write_value succeeded
INFO:root:notification_callback
INFO:root:on_data_received: response for read operation
INFO:root:writing to 0000ffd1-0000-1000-8000-00805f9b34fb [255, 3, 1, 0, 0, 34, 209, 241]
INFO:root:characteristic_write_value succeeded
INFO:root:notification_callback
INFO:root:on_data_received: response for read operation
INFO:root:notification_callback
WARNING:root:on_data_received: unknown operation=1
INFO:root:notification_callback
WARNING:root:on_data_received: unknown operation=27
INFO:root:notification_callback
WARNING:root:on_data_received: unknown operation=44
INFO:root:writing to 0000ffd1-0000-1000-8000-00805f9b34fb [255, 3, 224, 4, 0, 1, 231, 213]
INFO:root:characteristic_write_value succeeded
INFO:root:notification_callback
INFO:root:on_data_received: response for read operation
INFO:root:on_read_operation_complete
INFO:root:BT-TH-487ACA33 => {'device_id': 1, 'function': 'READ', 'battery_type': 'lithium', '__device': 'BT-TH-487ACA33', '__client': 'RoverClient'}
INFO:root:mqtt logging
INFO:root:Exit: Disconnecting device: BT-TH-487ACA33 20:91:48:7A:CA:33

Has this got to do with the device_id?

rollyceballos avatar Sep 28 '24 07:09 rollyceballos

BT-1 supports only one device at a time, so device_id shouldn't matter.

cyrils avatar Sep 30 '24 05:09 cyrils

It looks like I'm using a rather older version of the BT-1 for the SRNE. Mine looks like https://www.aliexpress.com/item/1005004587282405.html but it works with the Renogy app. I've seen the newer BT-1 but not sure if that matters?

rollyceballos avatar Oct 01 '24 11:10 rollyceballos

Tried with device id 1?

cyrils avatar Oct 06 '24 22:10 cyrils

Yes, I tried device_id = 1 and you're right didn't really change anything. I bought the newer BT-1 and will arrive this week I'll see if that changes anything.

rollyceballos avatar Oct 07 '24 01:10 rollyceballos

Got the new BT-1 and indeed this one reports the needed values. The older BT-1 may not be using the same protocol.

rollyceballos avatar Oct 08 '24 07:10 rollyceballos