Renogy Bluetooth SDK for Python
Project description
RenogyBT for Python SDK
RenogyBT is a Python SDK designed for Modbus communication with Renogy products. This project provides functionality to communicate with Renogy devices via Bluetooth.
Installation
Ensure your Python version is 3.6 or above. You can install the required dependencies using the following command:
pip install renogy-modbus-lib-python
Usage
Initialization
First, initialize the EnhancedModbusClient class to scan and connect to devices:
from modbus_bt_pkg.src.renogy_lib_python import EnhancedModbusClient
async def main():
client = EnhancedModbusClient(slave_address=0xFF)
devices = await client.scan_devices()
# Select and connect to a device
success = await client.connect(selected_device['address'])
Data Retrieval
Once connected, you can use the following methods to retrieve battery raw data and status information:
response = await client.get_hole_original_data()
status = await client.get_status()
Example
import asyncio
import sys
import os
from renogy_lib_python.modbus_comm import EnhancedModbusClient
async def main():
client = EnhancedModbusClient(slave_address=0xFF)
connected = False
choices = ["battery","controller"]
try:
# start scanning for devices
devices = await client.scan_devices()
if len(devices):
print("\nList of available devices:")
for i, dev in enumerate(devices, 1):
print(f"{i}. {dev['name']} ({dev['address']})")
if devices:
# select a device to connect
choice = int(input("\nPlease select the device type to connect (1 battery- 2 controller):"))
if 1 <= choice <= len(choices):
selected_type = choices[choice - 1]
else:
print("Input out of range, please try again")
return
while True:
try:
choice = int(input("\nPlease enter the device number to connect (1-{}): ".format(len(devices))))
if 1 <= choice <= len(devices):
selected_device = devices[choice - 1]
break
else:
print("Input out of range, please try again")
except ValueError:
print("Invalid input, please enter a number")
success = await client.connect(selected_device['address'])
connected = success
print(f"\nconnect status: {'success' if success else 'failture'}")
if success:
while True:
# send read command: get data
print("get data")
response = await client.get_hole_original_data(DeviceType=selected_type)
print(response)
# send write command: set data
print("get status")
response = await client.get_status(DeviceType=selected_type)
print(response)
choice = int(input("continue or exit? 1.continue 2.exit\n"))
if choice==1:
continue
else:
break
except Exception as e:
print(f"catch exception:{str(e)}")
finally:
if connected:
await client.disconnect()
if __name__ == "__main__":
asyncio.run(main())
Features
- Device Scanning : Use the scan_devices method to scan nearby Bluetooth devices.
- Device Connection : Use the connect method to connect to the selected device.
- Data Retrieval : Use the get_hole_original_data and get_status methods to obtain raw data and status information from the device.
License
This project is licensed under the Renogy License. For more details, please refer to the https://www.renogy.com.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file renogy_modbus_lib_python-0.1.9.tar.gz.
File metadata
- Download URL: renogy_modbus_lib_python-0.1.9.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bff682925c6ce6e807f504743cff2890dee4bdaae063737491157ef3972231f6
|
|
| MD5 |
806a738bf3f8fd976b9694e8191ef51d
|
|
| BLAKE2b-256 |
f45a3a4270abacf285438168c0370b7529c2c653ddc2d51c2334deee5bc01ce4
|
File details
Details for the file renogy_modbus_lib_python-0.1.9-py3-none-any.whl.
File metadata
- Download URL: renogy_modbus_lib_python-0.1.9-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b13d2d715c3f29f5cb1bfba1ff93b1d7b60eb1f4fb953aeea67b9f53360dcf18
|
|
| MD5 |
34dc8fc2bcc6f1a3d4df4497cf200a15
|
|
| BLAKE2b-256 |
ac383f26303cf688ccbe651b48d41384067302917a38e35f73a190a1d73ac78c
|