Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
edf5e87720 | ||
|
|
742964b78b | ||
|
|
21e89e738d | ||
|
|
52fd1932fa | ||
|
|
3e54283faf | ||
|
|
9be8aa47ac | ||
|
|
8967f3379c | ||
|
|
6f9afedfdb | ||
|
|
fe23dd00cd | ||
|
|
566761dba7 | ||
|
|
33cb6e6fbd | ||
|
|
5823136280 | ||
|
|
7b6f845edb | ||
|
|
1fbcf83b1b | ||
|
|
da2017a24b | ||
|
|
83f0db267c | ||
|
|
c96f551024 | ||
|
|
75209ee1aa | ||
|
|
7396616113 | ||
|
|
a7f7ff1843 | ||
|
|
cc755b3003 | ||
|
|
e5f690ef3b | ||
|
|
fa9bcf63ca | ||
|
|
211f1971c5 | ||
|
|
a1e9c180b3 | ||
|
|
0e5c1a0b44 | ||
|
|
0f33a31ee5 | ||
|
|
23551ae829 | ||
|
|
a54b36a90b | ||
|
|
f85661345c |
No files matched your search
@@ -1,2 +1,3 @@
|
||||
*/__pycache__/
|
||||
*.pyc
|
||||
.DS_Store
|
||||
@@ -20,11 +20,11 @@ After the installation, you can use this button to install the integration:
|
||||
- AC70 (basic data)
|
||||
- AC70P (untested)
|
||||
- AC180 (basic data)
|
||||
- AC180P (basic data)
|
||||
- AC180P (tested)
|
||||
- AC200L (untested)
|
||||
- AC200M
|
||||
- AC300 (tested)
|
||||
- AC500
|
||||
- AC500 (tested)
|
||||
- EB3A
|
||||
- EP500
|
||||
- EP500P
|
||||
|
||||
@@ -38,9 +38,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
address = entry.data.get(CONF_ADDRESS)
|
||||
device_name = entry.data.get(CONF_NAME)
|
||||
use_controls = entry.data.get(CONF_USE_CONTROLS)
|
||||
polling_interval = entry.data.get(CONF_POLLING_INTERVAL, 20)
|
||||
polling_interval = entry.data.get(CONF_POLLING_INTERVAL, 60)
|
||||
persistent_conn = entry.data.get(CONF_PERSISTENT_CONN, False)
|
||||
polling_timeout = entry.data.get(CONF_POLLING_TIMEOUT, 45)
|
||||
polling_timeout = entry.data.get(CONF_POLLING_TIMEOUT, 120)
|
||||
max_retries = entry.data.get(CONF_MAX_RETRIES, 5)
|
||||
|
||||
if address is None:
|
||||
|
||||
@@ -86,6 +86,7 @@ class BluettiBinarySensor(CoordinatorEntity, BinarySensorEntity):
|
||||
e_name = f"{device_info.get('name')} {name}"
|
||||
self._address = address
|
||||
self._response_key = response_key
|
||||
self._unavailable_counter = 5
|
||||
|
||||
self._attr_device_info = device_info
|
||||
self._attr_name = name
|
||||
|
||||
@@ -14,6 +14,8 @@ class ProtocolV1Device(BluettiDevice):
|
||||
# Device info
|
||||
self.struct.add_string_field("device_type", 10, 6)
|
||||
self.struct.add_sn_field("serial_number", 17)
|
||||
self.struct.add_version_field('arm_version', 23)
|
||||
self.struct.add_version_field('dsp_version', 25)
|
||||
|
||||
# Power IO
|
||||
self.struct.add_uint_field("dc_input_power", 36)
|
||||
|
||||
@@ -53,6 +53,8 @@ class DeviceReader:
|
||||
if filter_registers is not None:
|
||||
polling_commands = filter_registers
|
||||
pack_commands = []
|
||||
_LOGGER.info("Polling commands: " + ",".join([f"{c.starting_address}-{c.starting_address + c.quantity - 1}" for c in polling_commands]))
|
||||
_LOGGER.info("Pack comands: " + ",".join([f"{c.starting_address}-{c.starting_address + c.quantity - 1}" for c in pack_commands]))
|
||||
|
||||
parsed_data: dict = {}
|
||||
|
||||
@@ -66,8 +68,8 @@ class DeviceReader:
|
||||
await self.client.connect()
|
||||
break
|
||||
except Exception as e:
|
||||
if attempt == self.max_retries or attempt == 1:
|
||||
raise # pass exception on max_retries attempt
|
||||
if attempt == self.max_retries:
|
||||
raise e # pass exception on max_retries attempt
|
||||
else:
|
||||
_LOGGER.warning(
|
||||
f"Connect unsucessful (attempt {attempt}): {e}. Retrying..."
|
||||
@@ -117,6 +119,11 @@ class DeviceReader:
|
||||
_LOGGER.warning("Pack polling failed (pack_num %i doesn't match expected %i)", set_pack, pack)
|
||||
continue
|
||||
|
||||
if self.bluetti_device.pack_num_max > 1:
|
||||
# We need to wait after switching packs
|
||||
# for the data to be available
|
||||
await asyncio.sleep(5)
|
||||
|
||||
for command in pack_commands:
|
||||
# Request & parse result for each pack
|
||||
try:
|
||||
@@ -136,8 +143,8 @@ class DeviceReader:
|
||||
except ParseError:
|
||||
_LOGGER.warning("Got a parse exception...")
|
||||
|
||||
except TimeoutError:
|
||||
_LOGGER.warning("Polling timed out. Trying again later")
|
||||
except TimeoutError as err:
|
||||
_LOGGER.error(f"Polling timed out ({self.polling_timeout}s). Trying again later", exc_info=err)
|
||||
return None
|
||||
except BleakError as err:
|
||||
_LOGGER.error("Bleak error: %s", err)
|
||||
|
||||
@@ -1,8 +1,52 @@
|
||||
"""AC180P fields."""
|
||||
|
||||
from ..base_devices.ProtocolV2Device import ProtocolV2Device
|
||||
from typing import List
|
||||
|
||||
from ..field_enums import ChargingMode
|
||||
from ..utils.commands import ReadHoldingRegisters
|
||||
from ..base_devices.ProtocolV2Device import ProtocolV2Device
|
||||
|
||||
class AC180P(ProtocolV2Device):
|
||||
def __init__(self, address: str, sn: str):
|
||||
super().__init__(address, "AC180P", sn)
|
||||
|
||||
# Power IO
|
||||
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_decimal_field('ac_input_voltage', 1314, 1)
|
||||
|
||||
# Controls (2000)
|
||||
self.struct.add_bool_field('ac_output_on_switch', 2011)
|
||||
self.struct.add_bool_field('dc_output_on_switch', 2012)
|
||||
self.struct.add_bool_field('silent_charging_on', 2020) # to be able to choose between normal and silent charging modes
|
||||
self.struct.add_enum_field('charging_mode', 2020, ChargingMode) # can't be set from HA, custom switch needed
|
||||
self.struct.add_bool_field('power_lifting_on', 2021)
|
||||
|
||||
# Controls (2200)
|
||||
self.struct.add_bool_field('grid_enhancement_mode_on', 2225)
|
||||
|
||||
@property
|
||||
def polling_commands(self) -> List[ReadHoldingRegisters]:
|
||||
return super().polling_commands + [
|
||||
ReadHoldingRegisters(140, 1),
|
||||
ReadHoldingRegisters(142, 1),
|
||||
ReadHoldingRegisters(144, 1),
|
||||
ReadHoldingRegisters(146, 1),
|
||||
ReadHoldingRegisters(1314, 1),
|
||||
ReadHoldingRegisters(2011, 1),
|
||||
ReadHoldingRegisters(2012, 1),
|
||||
ReadHoldingRegisters(2020, 1),
|
||||
ReadHoldingRegisters(2021, 1),
|
||||
ReadHoldingRegisters(2225, 1),
|
||||
]
|
||||
|
||||
@property
|
||||
def writable_ranges(self) -> List[range]:
|
||||
return super().writable_ranges + [
|
||||
range(2000, 2022),
|
||||
range(2200, 2226)
|
||||
]
|
||||
@@ -28,6 +28,7 @@ class AC200L(ProtocolV1Device):
|
||||
self.struct.add_decimal_field("pack_voltage", 98, 2) # Full pack voltage
|
||||
self.struct.add_uint_field("pack_battery_percent", 99)
|
||||
self.struct.add_decimal_array_field("cell_voltages", 105, 16, 2) # internal
|
||||
self.struct.add_version_field("pack_bms_version", 201)
|
||||
|
||||
# Controls
|
||||
self.struct.add_bool_field("power_off", 3060)
|
||||
@@ -39,12 +40,9 @@ class AC200L(ProtocolV1Device):
|
||||
|
||||
@property
|
||||
def polling_commands(self) -> List[ReadHoldingRegisters]:
|
||||
return super().polling_commands + [
|
||||
ReadHoldingRegisters(70, 5),
|
||||
ReadHoldingRegisters(86, 3),
|
||||
ReadHoldingRegisters(92, 1),
|
||||
ReadHoldingRegisters(3060, 2),
|
||||
]
|
||||
return self.struct.get_read_holding_registers(
|
||||
filter=lambda address: address <= 90 or address >= 256 # pack_polling_commands
|
||||
)
|
||||
|
||||
@property
|
||||
def writable_ranges(self) -> List[range]:
|
||||
@@ -53,8 +51,6 @@ class AC200L(ProtocolV1Device):
|
||||
@property
|
||||
def pack_polling_commands(self) -> List[ReadHoldingRegisters]:
|
||||
return [
|
||||
ReadHoldingRegisters(91, 2),
|
||||
ReadHoldingRegisters(96, 1),
|
||||
ReadHoldingRegisters(98, 2),
|
||||
ReadHoldingRegisters(105, 16)
|
||||
ReadHoldingRegisters(91, 37),
|
||||
ReadHoldingRegisters(201, 2),
|
||||
]
|
||||
@@ -28,6 +28,7 @@ class AC200M(ProtocolV1Device):
|
||||
self.struct.add_decimal_field("pack_voltage", 98, 2) # Full pack voltage
|
||||
self.struct.add_uint_field("pack_battery_percent", 99)
|
||||
self.struct.add_decimal_array_field("cell_voltages", 105, 16, 2) # internal
|
||||
self.struct.add_version_field("pack_bms_version", 201)
|
||||
|
||||
# Controls
|
||||
self.struct.add_bool_field("power_off", 3060)
|
||||
@@ -39,12 +40,9 @@ class AC200M(ProtocolV1Device):
|
||||
|
||||
@property
|
||||
def polling_commands(self) -> List[ReadHoldingRegisters]:
|
||||
return super().polling_commands + [
|
||||
ReadHoldingRegisters(70, 5),
|
||||
ReadHoldingRegisters(86, 3),
|
||||
ReadHoldingRegisters(92, 1),
|
||||
ReadHoldingRegisters(3060, 2),
|
||||
]
|
||||
return self.struct.get_read_holding_registers(
|
||||
filter=lambda address: address <= 90 or address >= 256 # pack_polling_commands
|
||||
)
|
||||
|
||||
@property
|
||||
def writable_ranges(self) -> List[range]:
|
||||
@@ -53,8 +51,6 @@ class AC200M(ProtocolV1Device):
|
||||
@property
|
||||
def pack_polling_commands(self) -> List[ReadHoldingRegisters]:
|
||||
return [
|
||||
ReadHoldingRegisters(91, 2),
|
||||
ReadHoldingRegisters(96, 1),
|
||||
ReadHoldingRegisters(98, 2),
|
||||
ReadHoldingRegisters(105, 16)
|
||||
ReadHoldingRegisters(91, 37),
|
||||
ReadHoldingRegisters(201, 2),
|
||||
]
|
||||
@@ -54,17 +54,9 @@ class AC300(ProtocolV1Device):
|
||||
|
||||
@property
|
||||
def polling_commands(self) -> List[ReadHoldingRegisters]:
|
||||
return super().polling_commands + [
|
||||
ReadHoldingRegisters(70, 11),
|
||||
ReadHoldingRegisters(86, 3),
|
||||
ReadHoldingRegisters(92, 1),
|
||||
ReadHoldingRegisters(3001, 1),
|
||||
ReadHoldingRegisters(3004, 2),
|
||||
ReadHoldingRegisters(3011, 1),
|
||||
ReadHoldingRegisters(3013, 1),
|
||||
ReadHoldingRegisters(3015, 2),
|
||||
ReadHoldingRegisters(3061, 1),
|
||||
]
|
||||
return self.struct.get_read_holding_registers(
|
||||
filter=lambda address: address <= 90 or address >= 256 # pack_polling_commands
|
||||
)
|
||||
|
||||
@property
|
||||
def writable_ranges(self) -> List[range]:
|
||||
@@ -76,9 +68,6 @@ class AC300(ProtocolV1Device):
|
||||
@property
|
||||
def pack_polling_commands(self) -> List[ReadHoldingRegisters]:
|
||||
return [
|
||||
ReadHoldingRegisters(91, 2),
|
||||
ReadHoldingRegisters(96, 1),
|
||||
ReadHoldingRegisters(98, 2),
|
||||
ReadHoldingRegisters(105, 16),
|
||||
ReadHoldingRegisters(91, 37),
|
||||
ReadHoldingRegisters(201, 2),
|
||||
]
|
||||
@@ -34,6 +34,7 @@ class AC500(ProtocolV1Device):
|
||||
self.struct.add_decimal_field("pack_voltage", 98, 2) # Full pack voltage
|
||||
self.struct.add_uint_field("pack_battery_percent", 99)
|
||||
self.struct.add_decimal_array_field("cell_voltages", 105, 16, 2) # internal
|
||||
self.struct.add_version_field('pack_bms_version', 201)
|
||||
|
||||
# Controls
|
||||
self.struct.add_enum_field("ups_mode", 3001, UpsMode)
|
||||
@@ -49,21 +50,13 @@ class AC500(ProtocolV1Device):
|
||||
|
||||
@property
|
||||
def pack_num_max(self):
|
||||
return 4
|
||||
return 6
|
||||
|
||||
@property
|
||||
def polling_commands(self) -> List[ReadHoldingRegisters]:
|
||||
return super().polling_commands + [
|
||||
ReadHoldingRegisters(70, 11),
|
||||
ReadHoldingRegisters(86, 3),
|
||||
ReadHoldingRegisters(92, 1),
|
||||
ReadHoldingRegisters(3001, 1),
|
||||
ReadHoldingRegisters(3004, 2),
|
||||
ReadHoldingRegisters(3011, 1),
|
||||
ReadHoldingRegisters(3013, 1),
|
||||
ReadHoldingRegisters(3015, 2),
|
||||
ReadHoldingRegisters(3061, 1),
|
||||
]
|
||||
return self.struct.get_read_holding_registers(
|
||||
filter=lambda address: address <= 90 or address >= 256 # pack_polling_commands
|
||||
)
|
||||
|
||||
@property
|
||||
def writable_ranges(self) -> List[range]:
|
||||
@@ -75,8 +68,6 @@ class AC500(ProtocolV1Device):
|
||||
@property
|
||||
def pack_polling_commands(self) -> List[ReadHoldingRegisters]:
|
||||
return [
|
||||
ReadHoldingRegisters(91, 2),
|
||||
ReadHoldingRegisters(96, 1),
|
||||
ReadHoldingRegisters(98, 2),
|
||||
ReadHoldingRegisters(105, 16),
|
||||
ReadHoldingRegisters(91, 37),
|
||||
ReadHoldingRegisters(201, 2),
|
||||
]
|
||||
@@ -25,13 +25,7 @@ class EB3A(ProtocolV1Device):
|
||||
|
||||
@property
|
||||
def polling_commands(self) -> List[ReadHoldingRegisters]:
|
||||
return super().polling_commands + [
|
||||
ReadHoldingRegisters(77, 1),
|
||||
ReadHoldingRegisters(86, 1),
|
||||
ReadHoldingRegisters(3034, 1),
|
||||
ReadHoldingRegisters(3060, 1),
|
||||
ReadHoldingRegisters(3063, 5),
|
||||
]
|
||||
return self.struct.get_read_holding_registers()
|
||||
|
||||
@property
|
||||
def writable_ranges(self) -> List[range]:
|
||||
|
||||
@@ -34,6 +34,7 @@ class EP500(ProtocolV1Device):
|
||||
self.struct.add_decimal_field("pack_voltage", 98, 2) # Full pack voltage
|
||||
self.struct.add_uint_field("pack_battery_percent", 99)
|
||||
self.struct.add_decimal_array_field("cell_voltages", 105, 16, 2) # internal
|
||||
self.struct.add_version_field("pack_bms_version", 201)
|
||||
|
||||
# Controls
|
||||
self.struct.add_enum_field("ups_mode", 3001, UpsMode)
|
||||
@@ -49,17 +50,9 @@ class EP500(ProtocolV1Device):
|
||||
|
||||
@property
|
||||
def polling_commands(self) -> List[ReadHoldingRegisters]:
|
||||
return super().polling_commands + [
|
||||
ReadHoldingRegisters(70, 11),
|
||||
ReadHoldingRegisters(86, 3),
|
||||
ReadHoldingRegisters(92, 1),
|
||||
ReadHoldingRegisters(3001, 1),
|
||||
ReadHoldingRegisters(3004, 2),
|
||||
ReadHoldingRegisters(3011, 1),
|
||||
ReadHoldingRegisters(3013, 1),
|
||||
ReadHoldingRegisters(3015, 2),
|
||||
ReadHoldingRegisters(3061, 1),
|
||||
]
|
||||
return self.struct.get_read_holding_registers(
|
||||
filter=lambda address: address <= 90 or address >= 256 # pack_polling_commands
|
||||
)
|
||||
|
||||
@property
|
||||
def writable_ranges(self) -> List[range]:
|
||||
@@ -71,8 +64,6 @@ class EP500(ProtocolV1Device):
|
||||
@property
|
||||
def pack_polling_commands(self) -> List[ReadHoldingRegisters]:
|
||||
return [
|
||||
ReadHoldingRegisters(91, 2),
|
||||
ReadHoldingRegisters(96, 1),
|
||||
ReadHoldingRegisters(98, 2),
|
||||
ReadHoldingRegisters(105, 16),
|
||||
ReadHoldingRegisters(91, 37),
|
||||
ReadHoldingRegisters(201, 2),
|
||||
]
|
||||
@@ -34,6 +34,7 @@ class EP500P(ProtocolV1Device):
|
||||
self.struct.add_decimal_field("pack_voltage", 98, 2) # Full pack voltage
|
||||
self.struct.add_uint_field("pack_battery_percent", 99)
|
||||
self.struct.add_decimal_array_field("cell_voltages", 105, 16, 2) # internal
|
||||
self.struct.add_version_field("pack_bms_version", 201)
|
||||
|
||||
# Controls
|
||||
self.struct.add_enum_field("ups_mode", 3001, UpsMode)
|
||||
@@ -49,17 +50,9 @@ class EP500P(ProtocolV1Device):
|
||||
|
||||
@property
|
||||
def polling_commands(self) -> List[ReadHoldingRegisters]:
|
||||
return super().polling_commands + [
|
||||
ReadHoldingRegisters(70, 11),
|
||||
ReadHoldingRegisters(86, 3),
|
||||
ReadHoldingRegisters(92, 1),
|
||||
ReadHoldingRegisters(3001, 1),
|
||||
ReadHoldingRegisters(3004, 2),
|
||||
ReadHoldingRegisters(3011, 1),
|
||||
ReadHoldingRegisters(3013, 1),
|
||||
ReadHoldingRegisters(3015, 2),
|
||||
ReadHoldingRegisters(3061, 1),
|
||||
]
|
||||
return self.struct.get_read_holding_registers(
|
||||
filter=lambda address: address <= 90 or address >= 256 # pack_polling_commands
|
||||
)
|
||||
|
||||
@property
|
||||
def writable_ranges(self) -> List[range]:
|
||||
@@ -71,8 +64,6 @@ class EP500P(ProtocolV1Device):
|
||||
@property
|
||||
def pack_polling_commands(self) -> List[ReadHoldingRegisters]:
|
||||
return [
|
||||
ReadHoldingRegisters(91, 2),
|
||||
ReadHoldingRegisters(96, 1),
|
||||
ReadHoldingRegisters(98, 2),
|
||||
ReadHoldingRegisters(105, 16),
|
||||
ReadHoldingRegisters(91, 37),
|
||||
ReadHoldingRegisters(201, 2),
|
||||
]
|
||||
@@ -97,28 +97,4 @@ class EP600(ProtocolV2Device):
|
||||
|
||||
@property
|
||||
def polling_commands(self) -> List[ReadHoldingRegisters]:
|
||||
return super().polling_commands + [
|
||||
ReadHoldingRegisters(2022, 2),
|
||||
ReadHoldingRegisters(2213, 5),
|
||||
ReadHoldingRegisters(1212, 3),
|
||||
ReadHoldingRegisters(1220, 3),
|
||||
ReadHoldingRegisters(1228, 3),
|
||||
ReadHoldingRegisters(1236, 3),
|
||||
ReadHoldingRegisters(1244, 3),
|
||||
ReadHoldingRegisters(1300, 1),
|
||||
ReadHoldingRegisters(1313, 3),
|
||||
ReadHoldingRegisters(1319, 3),
|
||||
ReadHoldingRegisters(1325, 3),
|
||||
ReadHoldingRegisters(1500, 1),
|
||||
ReadHoldingRegisters(1510, 3),
|
||||
ReadHoldingRegisters(1517, 3),
|
||||
ReadHoldingRegisters(1524, 3),
|
||||
ReadHoldingRegisters(152, 1),
|
||||
ReadHoldingRegisters(156, 1),
|
||||
ReadHoldingRegisters(158, 1),
|
||||
# KM - Consumption
|
||||
ReadHoldingRegisters(1430, 15),
|
||||
# KM - Totals
|
||||
ReadHoldingRegisters(142, 5),
|
||||
|
||||
]
|
||||
return self.struct.get_read_holding_registers()
|
||||
@@ -125,6 +125,14 @@ FIELD_ATTRIBUTES: dict[str, FieldAttributes] = {
|
||||
"ac_input_power": PowerFieldAttributes("AC Input Power"),
|
||||
"ac_output_power": PowerFieldAttributes("AC Output Power"),
|
||||
"dc_output_power": PowerFieldAttributes("DC Output Power"),
|
||||
"dsp_version": FieldAttributes(
|
||||
type=FieldType.NUMERIC,
|
||||
name=f"DSP Version",
|
||||
),
|
||||
"arm_version": FieldAttributes(
|
||||
type=FieldType.NUMERIC,
|
||||
name=f"ARM Version",
|
||||
),
|
||||
"power_generation": EnergyFieldAttributes("Total Power Generation"),
|
||||
"total_battery_percent": FieldAttributes(
|
||||
type=FieldType.NUMERIC,
|
||||
@@ -316,6 +324,16 @@ FIELD_ATTRIBUTES: dict[str, FieldAttributes] = {
|
||||
setter=True,
|
||||
name="Power Lifting",
|
||||
),
|
||||
"grid_enhancement_mode_on": FieldAttributes(
|
||||
type=FieldType.BOOL,
|
||||
setter=True,
|
||||
name="Grid Enhancement Mode",
|
||||
),
|
||||
"silent_charging_on": FieldAttributes(
|
||||
type=FieldType.BOOL,
|
||||
setter=True,
|
||||
name="Silent Charging",
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
from decimal import Decimal
|
||||
from enum import Enum
|
||||
from .commands import ReadHoldingRegisters
|
||||
import struct
|
||||
from typing import Any, List, Optional, Tuple, Type
|
||||
|
||||
@@ -180,6 +181,35 @@ class DeviceStruct:
|
||||
def add_sn_field(self, name: str, address: int):
|
||||
self.fields.append(SerialNumberField(name, address))
|
||||
|
||||
def get_read_holding_registers(self, tolerance=20, filter=lambda address: True):
|
||||
address_set = set()
|
||||
for field in self.fields:
|
||||
for address in range(field.address, field.address + field.size):
|
||||
address_set.add(address)
|
||||
# Filter out addresses that we specificly
|
||||
# specified to exclude.
|
||||
for address in set(address_set):
|
||||
if not filter(address):
|
||||
address_set.remove(address)
|
||||
# Fast path: no addresses -> no commands.
|
||||
if not address_set:
|
||||
return []
|
||||
|
||||
commands = []
|
||||
|
||||
address_list = sorted(address_set)
|
||||
start = address_list[0]
|
||||
last = address_list[0]
|
||||
for address in address_list[1:]:
|
||||
# Create a new group if there's a gap
|
||||
# in the addresses.
|
||||
if address >= last + tolerance:
|
||||
commands.append(ReadHoldingRegisters(start, last - start + 1))
|
||||
start = address
|
||||
last = address
|
||||
commands.append(ReadHoldingRegisters(start, last - start + 1))
|
||||
return commands
|
||||
|
||||
def parse(self, starting_address: int, data: bytes) -> dict:
|
||||
# Offsets and size are counted in 2 byte chunks, so for the range we
|
||||
# need to divide the byte size by 2
|
||||
|
||||
@@ -150,7 +150,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
if user_input[CONF_MAX_RETRIES] < 1:
|
||||
return self.async_abort(reason="invalid_retries")
|
||||
|
||||
changed = self.hass.config_entries.async_update_entry(
|
||||
self.hass.config_entries.async_update_entry(
|
||||
self.config_entry,
|
||||
data={
|
||||
**self.config_entry.data,
|
||||
@@ -163,11 +163,6 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
},
|
||||
},
|
||||
)
|
||||
if changed is False:
|
||||
_LOGGER.error(
|
||||
"Method OptionsFlowHandler.async_step_init: Config entry %s has not been changed",
|
||||
self.config_entry.entry_id,
|
||||
)
|
||||
return self.async_create_entry(
|
||||
title="",
|
||||
data={
|
||||
|
||||
@@ -23,6 +23,7 @@ SUPPORTED_MODELS = [
|
||||
"EP500P",
|
||||
"EP600",
|
||||
"EP760",
|
||||
"AC180P",
|
||||
]
|
||||
|
||||
CONTROL_FIELDS = [
|
||||
@@ -31,6 +32,8 @@ CONTROL_FIELDS = [
|
||||
"power_off",
|
||||
"eco_on",
|
||||
"power_lifting_on",
|
||||
"grid_enhancement_mode_on",
|
||||
"silent_charging_on",
|
||||
]
|
||||
|
||||
DIAGNOSTIC_FIELDS = [
|
||||
@@ -39,10 +42,13 @@ DIAGNOSTIC_FIELDS = [
|
||||
"max_ac_output_power",
|
||||
"max_ac_output_current",
|
||||
"bcu_version",
|
||||
"dsp_version",
|
||||
"arm_version",
|
||||
"safety_module_version",
|
||||
"high_voltage_module_version",
|
||||
"power_generation",
|
||||
"total_ac_consumption",
|
||||
"total_grid_consumption",
|
||||
"total_grid_feed",
|
||||
"ac_input_voltage",
|
||||
]
|
||||
@@ -3,6 +3,7 @@
|
||||
"name": "Bluetti BT",
|
||||
"bluetooth": [
|
||||
{ "local_name": "AC60*" },
|
||||
{ "local_name": "AC70*" },
|
||||
{ "local_name": "AC180*" },
|
||||
{ "local_name": "AC200L*" },
|
||||
{ "local_name": "AC200M*" },
|
||||
@@ -23,5 +24,5 @@
|
||||
"iot_class": "local_polling",
|
||||
"issue_tracker": "https://github.com/Patrick762/hassio-bluetti-bt/issues",
|
||||
"requirements": [],
|
||||
"version": "0.1.2"
|
||||
"version": "0.1.4"
|
||||
}
|
||||
Reference in new issue
Block a user