fixed circular import
This commit is contained in:
1 parent
9ef9d38a6e
commit
ebbcea3c4c
7 files changed
+23
-23
No files matched your search
@@ -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.ep760 import EP760
|
||||
|
||||
PLATFORMS: [Platform] = [Platform.BINARY_SENSOR, Platform.SENSOR]
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@@ -110,12 +105,3 @@ def get_type_by_bt_name(bt_name: str):
|
||||
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] == 'EP760':
|
||||
return EP760(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__)
|
||||
|
||||
|
||||
@@ -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__)
|
||||
|
||||
|
||||
@@ -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.13"
|
||||
"version": "0.0.14"
|
||||
}
|
||||
@@ -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__)
|
||||
|
||||
|
||||
@@ -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__)
|
||||
|
||||
|
||||
@@ -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)
|
||||
Reference in new issue
Block a user