Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More AC60 fields and AC70 support #79

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 73 additions & 2 deletions bluetti_mqtt/core/devices/ac60.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,95 @@
from enum import Enum, unique
from typing import List
from ..commands import ReadHoldingRegisters
from .bluetti_device import BluettiDevice
from .struct import DeviceStruct

@unique
class LedMode(Enum):
OFF = 0
LOW = 1
HIGH = 2
SOS = 3

class ChargingMode(Enum):
STANDARD = 0
SILENT = 1
TURBO = 2


class AC60(BluettiDevice):
def __init__(self, address: str, sn: str):
self.struct = DeviceStruct()

# Core (100)
self.struct.add_uint_field('total_battery_percent', 102)
self.struct.add_uint_field('estimated_time',104)
self.struct.add_swap_string_field('device_type', 110, 6)
self.struct.add_sn_field('serial_number', 116)
self.struct.add_decimal_field('power_generation', 154, 1) # Total power generated since last reset (kwh)
self.struct.add_uint_field('dc_output_power',140)
self.struct.add_uint_field('ac_output_power',142)
self.struct.add_uint_field('dc_input_power',144)
self.struct.add_uint_field('ac_input_power',146)

# Input Details (1100 - 1300)
self.struct.add_swap_string_field('device_type', 1101, 6)
self.struct.add_sn_field('serial_number', 1107)
self.struct.add_decimal_field('power_generation', 1202, 1) # Total power generated since last reset (kwh)
self.struct.add_uint_field('num_packs_connected',1209)
self.struct.add_bool_field('charging_from_internal_dc',1210)
self.struct.add_uint_field('internal_dc_input_power',1212)
self.struct.add_decimal_field('internal_dc_input_voltage',1213,1)
self.struct.add_decimal_field('internal_dc_input_current',1214,1)
self.struct.add_bool_field('charging_from_pack_dc',1218)
self.struct.add_uint_field('pack_dc_input_power',1220)
self.struct.add_decimal_field('pack_dc_input_voltage',1221,1)
self.struct.add_decimal_field('pack_dc_input_current',1222,1)
self.struct.add_decimal_field('internal_ac_input_frequency',1300,1)
self.struct.add_uint_field('internal_ac_input_power',1313)
self.struct.add_decimal_field('internal_ac_input_voltage',1314,1)
self.struct.add_decimal_field('internal_ac_input_current',1315,1)

# Output Details (1400 - 1500)
self.struct.add_uint_field('total_dc_output_power',1400)
self.struct.add_uint_field('dc_usb_output_power',1404)
self.struct.add_uint_field('dc_12v_output_power',1406)
self.struct.add_uint_field('dc_output_uptime_minutes',1410)
self.struct.add_uint_field('ac_output_power',1420)
self.struct.add_uint_field('ac_output_uptime_minutes',1424)
self.struct.add_uint_field('ac_output_power',1430)
self.struct.add_decimal_field('ac_output_frequency',1500,1)
self.struct.add_bool_field('ac_output_on',1509)
self.struct.add_uint_field('battery_inputoutput_power',1510)
self.struct.add_decimal_field('ac_output_voltage',1511,1)
self.struct.add_decimal_field('ac_output_amps',1512,1)

# Controls (2000)
self.struct.add_enum_field('led_mode', 2007, LedMode)
self.struct.add_bool_field('ac_output_on', 2011)
self.struct.add_bool_field('dc_output_on', 2012)
self.struct.add_bool_field('dc_eco_mode_on',2014)
self.struct.add_uint_field('dc_eco_hours',2015)
self.struct.add_uint_field('dc_eco_watts',2016)
self.struct.add_bool_field('ac_eco_mode_on',2017)
self.struct.add_uint_field('ac_eco_hours',2018)
self.struct.add_uint_field('ac_eco_watts',2019)
self.struct.add_enum_field('charging_mode', 2020, ChargingMode)
self.struct.add_bool_field('power_lifting_on', 2021)

# More Controls (2200)
self.struct.add_bool_field('grid_enhancement_mode_on',2225)

# Battery Data Register (6000)
self.struct.add_decimal_field('battery_voltage',6003,2)
bxm6306 marked this conversation as resolved.
Show resolved Hide resolved

# Battery Data Register (6100)
self.struct.add_swap_string_field('battery_type', 6101, 6)
self.struct.add_sn_field('battery_serial_number', 6107)
self.struct.add_decimal_field('battery_voltage',6111,2)
bxm6306 marked this conversation as resolved.
Show resolved Hide resolved
self.struct.add_uint_field('battery_percent',6113)
bxm6306 marked this conversation as resolved.
Show resolved Hide resolved
self.struct.add_version_field('bcu_version', 6175)

# Battery Data Register (6300)

super().__init__(address, 'AC60', sn)

@property
Expand Down