Compare commits

...
2 Commits
Author SHA1 Message Date
Patrick762 ebbcea3c4c fixed circular import 2024-02-05 19:10:11 +01:00
Patrick762 9ef9d38a6e renamed ep700 to ep760 2024-02-04 12:05:53 +01:00
10 changed files with 31 additions and 31 deletions

No files matched your search

+1 -1
View File
@@ -27,7 +27,7 @@ After the installation, you can use this button to install the integration:
- EP500
- EP500P
- EP600 (tested)
- EP700 (beta, untested)
- EP760 (beta, untested)
### Available sensors:
All sensors which are available in bluetti_mqtt (Based on [this file](https://github.com/warhammerkid/bluetti_mqtt/blob/main/bluetti_mqtt/mqtt_client.py)).
+2 -16
View File
@@ -12,8 +12,6 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.exceptions import ConfigEntryNotReady
from bluetti_mqtt.bluetooth import build_device as orig_build_device
from .const import (
CONF_MAX_RETRIES,
CONF_PERSISTENT_CONN,
@@ -22,13 +20,10 @@ from .const import (
CONF_USE_CONTROLS,
DATA_COORDINATOR,
DATA_POLLING_RUNNING,
DEVICE_NAME_RE,
DOMAIN,
MANUFACTURER,
)
from .coordinator import PollingCoordinator
from .devices.ep600 import EP600
from .devices.ep700 import EP700
PLATFORMS: [Platform] = [Platform.BINARY_SENSOR, Platform.SENSOR]
_LOGGER = logging.getLogger(__name__)
@@ -107,15 +102,6 @@ def get_type_by_bt_name(bt_name: str):
dev_type = "EP500"
elif bt_name.startswith("EP600"):
dev_type = "EP600"
elif bt_name.startswith("EP700"):
dev_type = "EP700"
elif bt_name.startswith("EP760"):
dev_type = "EP760"
return dev_type
def build_device(address: str, name: str):
match = DEVICE_NAME_RE.match(name)
if match[1] == 'EP700':
return EP700(address, match[2])
elif match[1] == 'EP600':
return EP600(address, match[2])
else:
return orig_build_device(address, name)
@@ -24,10 +24,10 @@ from bluetti_mqtt.mqtt_client import (
MqttFieldType,
)
from . import device_info as dev_info, get_unique_id, 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
from .utils import unique_id_loggable, build_device
_LOGGER = logging.getLogger(__name__)
+1 -1
View File
@@ -17,7 +17,7 @@ CONF_MAX_RETRIES = "max_retries"
DATA_COORDINATOR = "coordinator"
DATA_POLLING_RUNNING = "polling_running"
DEVICE_NAME_RE = re.compile(r'^(AC200M|AC300|AC500|AC60|EP500P|EP500|EP600|EP700|EB3A)(\d+)$')
DEVICE_NAME_RE = re.compile(r'^(AC200M|AC300|AC500|AC60|EP500P|EP500|EP600|EP760|EB3A)(\d+)$')
CONTROL_FIELDS = [
"ac_output_on",
+1 -2
View File
@@ -25,9 +25,8 @@ from bluetti_mqtt.bluetooth import (
from bluetti_mqtt.core.devices.bluetti_device import BluettiDevice
from bluetti_mqtt.core.commands import ReadHoldingRegisters
from . import build_device
from .const import DATA_POLLING_RUNNING, DOMAIN
from .utils import mac_loggable
from .utils import mac_loggable, build_device
_LOGGER = logging.getLogger(__name__)
@@ -1,4 +1,4 @@
"""EP700 Field definitions.
"""EP760 Field definitions.
Changes made here are only temporary and should also be
contributed to https://github.com/warhammerkid/bluetti_mqtt
@@ -10,7 +10,7 @@ from bluetti_mqtt.core.devices.bluetti_device import BluettiDevice
from bluetti_mqtt.core.devices.struct import DeviceStruct
from bluetti_mqtt.core.commands import ReadHoldingRegisters
class EP700(BluettiDevice):
class EP760(BluettiDevice):
def __init__(self, address: str, sn: str):
self.struct = DeviceStruct()
@@ -36,7 +36,7 @@ class EP700(BluettiDevice):
self.struct.add_version_field('safety_module_version', 6181)
self.struct.add_version_field('high_voltage_module_version', 6184)
super().__init__(address, 'EP700', sn)
super().__init__(address, 'EP760', sn)
@property
def polling_commands(self) -> List[ReadHoldingRegisters]:
+2 -2
View File
@@ -9,7 +9,7 @@
{ "local_name": "EB3A*" },
{ "local_name": "EP500*" },
{ "local_name": "EP600*" },
{ "local_name": "EP700*" }
{ "local_name": "EP760*" }
],
"codeowners": ["@Patrick762"],
"config_flow": true,
@@ -19,5 +19,5 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/Patrick762/hassio-bluetti-bt/issues",
"requirements": ["bluetti_mqtt==0.15.0"],
"version": "0.0.12"
"version": "0.0.14"
}
+2 -2
View File
@@ -29,10 +29,10 @@ from bluetti_mqtt.mqtt_client import (
battery_pack_fields,
)
from . import device_info as dev_info, get_unique_id, 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
from .utils import unique_id_loggable, build_device
_LOGGER = logging.getLogger(__name__)
+2 -2
View File
@@ -31,10 +31,10 @@ from bluetti_mqtt.mqtt_client import (
MqttFieldType,
)
from . import device_info as dev_info, get_unique_id, 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
from .utils import mac_loggable, unique_id_loggable, build_device
_LOGGER = logging.getLogger(__name__)
+15
View File
@@ -1,5 +1,11 @@
"""Tools."""
from bluetti_mqtt.bluetooth import build_device as orig_build_device
from .const import DEVICE_NAME_RE
from .devices.ep600 import EP600
from .devices.ep760 import EP760
def mac_loggable(mac: str) -> str:
"""Remove parts of the mac address for logging."""
splitted = mac.split(":")
@@ -10,3 +16,12 @@ 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])
elif match[1] == 'EP600':
return EP600(address, match[2])
else:
return orig_build_device(address, name)