added ep760
This commit is contained in:
1 parent
2abcbbb392
commit
8409221675
7 files changed
+25
-18
No files matched your search
@@ -24,10 +24,12 @@ from bluetti_mqtt.mqtt_client import (
|
||||
MqttFieldType,
|
||||
)
|
||||
|
||||
from .bluetti_bt_lib.utils.device_builder import build_device
|
||||
|
||||
from . import device_info as dev_info, get_unique_id
|
||||
from .const import DATA_COORDINATOR, DOMAIN, ADDITIONAL_DEVICE_FIELDS
|
||||
from .coordinator import PollingCoordinator
|
||||
from .utils import unique_id_loggable, build_device
|
||||
from .utils import unique_id_loggable
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
"""EP760 fields."""
|
||||
|
||||
from ..base_devices.ProtocolV2Device import ProtocolV2Device
|
||||
|
||||
|
||||
class EP760(ProtocolV2Device):
|
||||
def __init__(self, address: str, sn: str):
|
||||
super().__init__(address, "EP760", sn)
|
||||
@@ -10,8 +10,11 @@ from ..devices.eb3a import EB3A
|
||||
from ..devices.ep500 import EP500
|
||||
from ..devices.ep500p import EP500P
|
||||
from ..devices.ep600 import EP600
|
||||
from ..devices.ep760 import EP760
|
||||
|
||||
DEVICE_NAME_RE = re.compile(r"^(AC60|AC200M|AC300|AC500|EB3A|EP500|EP500P|EP600)(\d+)$")
|
||||
DEVICE_NAME_RE = re.compile(
|
||||
r"^(AC60|AC200M|AC300|AC500|EB3A|EP500|EP500P|EP600|EP760)(\d+)$"
|
||||
)
|
||||
|
||||
|
||||
def build_device(address: str, name: str):
|
||||
@@ -32,3 +35,5 @@ def build_device(address: str, name: str):
|
||||
return EP500P(address, match[2])
|
||||
if match[1] == "EP600":
|
||||
return EP600(address, match[2])
|
||||
if match[1] == "EP760":
|
||||
return EP760(address, match[2])
|
||||
@@ -19,9 +19,10 @@ from homeassistant.helpers.update_coordinator import (
|
||||
from .bluetti_bt_lib.const import NOTIFY_UUID, RESPONSE_TIMEOUT, WRITE_UUID
|
||||
from .bluetti_bt_lib.exceptions import BadConnectionError, ModbusError, ParseError
|
||||
from .bluetti_bt_lib.utils.commands import ReadHoldingRegisters
|
||||
from .bluetti_bt_lib.utils.device_builder import build_device
|
||||
|
||||
from .const import DATA_POLLING_RUNNING, DOMAIN
|
||||
from .utils import mac_loggable, build_device
|
||||
from .utils import mac_loggable
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -29,10 +29,12 @@ from bluetti_mqtt.mqtt_client import (
|
||||
battery_pack_fields,
|
||||
)
|
||||
|
||||
from .bluetti_bt_lib.utils.device_builder import build_device
|
||||
|
||||
from . import device_info as dev_info, get_unique_id
|
||||
from .const import DATA_COORDINATOR, DOMAIN, CONF_OPTIONS, DIAGNOSTIC_FIELDS, ADDITIONAL_DEVICE_FIELDS
|
||||
from .coordinator import PollingCoordinator
|
||||
from .utils import unique_id_loggable, build_device
|
||||
from .utils import unique_id_loggable
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -31,10 +31,12 @@ from bluetti_mqtt.mqtt_client import (
|
||||
MqttFieldType,
|
||||
)
|
||||
|
||||
from .bluetti_bt_lib.utils.device_builder import build_device
|
||||
|
||||
from . import device_info as dev_info, get_unique_id
|
||||
from .const import CONTROL_FIELDS, DATA_COORDINATOR, DOMAIN, ADDITIONAL_DEVICE_FIELDS
|
||||
from .coordinator import PollingCoordinator
|
||||
from .utils import mac_loggable, unique_id_loggable, build_device
|
||||
from .utils import mac_loggable, unique_id_loggable
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
"""Tools."""
|
||||
|
||||
from .bluetti_bt_lib.utils.device_builder import build_device as orig_build_device
|
||||
|
||||
from .const import DEVICE_NAME_RE
|
||||
from .devices.ep760 import EP760
|
||||
|
||||
|
||||
def mac_loggable(mac: str) -> str:
|
||||
"""Remove parts of the mac address for logging."""
|
||||
splitted = mac.split(":")
|
||||
@@ -16,10 +10,3 @@ def unique_id_loggable(unique_id: str) -> str:
|
||||
splitted = unique_id.split("_", maxsplit=1)
|
||||
serial = splitted[0][:6]
|
||||
return serial + "XXXXXXXXXX" + splitted[1]
|
||||
|
||||
def build_device(address: str, name: str):
|
||||
match = DEVICE_NAME_RE.match(name)
|
||||
if match[1] == 'EP760':
|
||||
return EP760(address, match[2])
|
||||
else:
|
||||
return orig_build_device(address, name)
|
||||
Reference in new issue
Block a user