A C# library for connecting to Bluetti power stations via their Cloud API, receiving real-time device telemetry over a STOMP/WebSocket connection.
$ dotnet add package BluettiCloudA C# library for connecting to Bluetti power stations via their Cloud API, receiving real-time device telemetry over a STOMP/WebSocket connection.
Platform: Windows only (token storage uses Windows Credential Manager)
Runtime: .NET 10
Warning! Telemetry data is pushed by the server only when the device state changes or a heartbeat occurs. The interval between updates is unpredictable: it can be as short as 30 seconds or as long as 5+ minutes.
using BluettiCloud.Services;
using Serilog;
namespace BluettiCloudConsole
{
internal class Program
{
static async Task Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.Console()
.CreateLogger();
Client client = await ClientFactory.CreateAsync();
client.OnRealtimeStatus += Client_OnRealtimeStatus;
await client.StartAsync();
while (true)
{
await Task.Delay(1000);
}
}
private static void Client_OnRealtimeStatus(object? sender, BluettiCloud.Models.DeviceRealtimeStatus e)
{
if (e.BatterySoc == null)
{
return;
}
Log.Information($"{e.DeviceSn} = {e.BatterySoc}%. Grid In {e.PowerGridIn}W. AC Out {e.PowerAcOut}W. DC Out {e.PowerDcOut}W.");
}
}
}
DeviceRealtimeStatus exposes the following fields (all nullable string):
| Property | Description |
|---|---|
BatterySoc | Battery state of charge (%) |
PowerPvIn | Solar panel input power (W) |
PowerGridIn | Grid input power (W) |
PowerAcOut | AC output power (W) |
PowerDcOut | DC output power (W) |
BatterySoh | Battery state of health |
DsgEmptyTime | Estimated time to discharge |
ChgFullTime | Estimated time to full charge |
AcSwitch / DcSwitch / PvSwitch | Switch states |
DeviceActState | Device activity state |
| (and 40+ more fields) | See Models/DeviceRealtimeStatus.cs |
TokenStorage uses Windows.Security.Credentials.PasswordVault. Linux/macOS support would require an alternative storage backend.Issues and pull requests are welcome. If Bluetti changes their API and the library breaks, please open an issue with the raw WebSocket frames if possible.
This library is a native .NET implementation of the communication protocol used in the Official Bluetti Home Assistant repository (https://github.com/bluetti-official/bluetti-home-assistant). Special thanks to the Bluetti for providing the reference implementation!