Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8ed8141ac | ||
|
|
bf86fe172b | ||
|
|
babdd1755e | ||
|
|
7596f8cee1 | ||
|
|
98d2a0b73e | ||
|
|
c499fbcd9b | ||
|
|
ec996d5728 |
No files matched your search
@@ -33,6 +33,8 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up Bluetti Powerstation from a config entry."""
|
"""Set up Bluetti Powerstation from a config entry."""
|
||||||
|
|
||||||
|
_LOGGER.debug("Init Bluetti BT Integration")
|
||||||
|
|
||||||
address = entry.data.get(CONF_ADDRESS)
|
address = entry.data.get(CONF_ADDRESS)
|
||||||
device_name = entry.data.get(CONF_NAME)
|
device_name = entry.data.get(CONF_NAME)
|
||||||
use_controls = entry.data.get(CONF_USE_CONTROLS)
|
use_controls = entry.data.get(CONF_USE_CONTROLS)
|
||||||
@@ -53,10 +55,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
hass.data[DOMAIN][entry.entry_id].setdefault(DATA_POLLING_RUNNING, False)
|
hass.data[DOMAIN][entry.entry_id].setdefault(DATA_POLLING_RUNNING, False)
|
||||||
|
|
||||||
# Create coordinator for polling
|
# Create coordinator for polling
|
||||||
|
_LOGGER.debug("Creating coordinator")
|
||||||
coordinator = PollingCoordinator(hass, address, device_name, polling_interval, persistent_conn, polling_timeout, max_retries)
|
coordinator = PollingCoordinator(hass, address, device_name, polling_interval, persistent_conn, polling_timeout, max_retries)
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
hass.data[DOMAIN][entry.entry_id].setdefault(DATA_COORDINATOR, coordinator)
|
hass.data[DOMAIN][entry.entry_id].setdefault(DATA_COORDINATOR, coordinator)
|
||||||
|
|
||||||
|
_LOGGER.debug("Creating entities")
|
||||||
platforms: list = PLATFORMS
|
platforms: list = PLATFORMS
|
||||||
if use_controls is True:
|
if use_controls is True:
|
||||||
_LOGGER.warning("You are using controls with this integration at your own risk!")
|
_LOGGER.warning("You are using controls with this integration at your own risk!")
|
||||||
@@ -65,6 +69,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
# Setup platforms
|
# Setup platforms
|
||||||
await hass.config_entries.async_forward_entry_setups(entry, platforms)
|
await hass.config_entries.async_forward_entry_setups(entry, platforms)
|
||||||
|
|
||||||
|
_LOGGER.debug("Setup done")
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class ProtocolV1Device(BluettiDevice):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def writable_ranges(self) -> List[range]:
|
def writable_ranges(self) -> List[range]:
|
||||||
return [range(3006, 3008)]
|
return [range(3006, 3009)]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def pack_polling_commands(self) -> List[ReadHoldingRegisters]:
|
def pack_polling_commands(self) -> List[ReadHoldingRegisters]:
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class AC300(ProtocolV1Device):
|
|||||||
def writable_ranges(self) -> List[range]:
|
def writable_ranges(self) -> List[range]:
|
||||||
return super().writable_ranges + [
|
return super().writable_ranges + [
|
||||||
range(3001, 3016),
|
range(3001, 3016),
|
||||||
3061,
|
range(3061),
|
||||||
]
|
]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class AC500(ProtocolV1Device):
|
|||||||
def writable_ranges(self) -> List[range]:
|
def writable_ranges(self) -> List[range]:
|
||||||
return super().writable_ranges + [
|
return super().writable_ranges + [
|
||||||
range(3001, 3016),
|
range(3001, 3016),
|
||||||
3061,
|
range(3061),
|
||||||
]
|
]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -28,12 +28,15 @@ class EB3A(ProtocolV1Device):
|
|||||||
return super().polling_commands + [
|
return super().polling_commands + [
|
||||||
ReadHoldingRegisters(77, 1),
|
ReadHoldingRegisters(77, 1),
|
||||||
ReadHoldingRegisters(86, 1),
|
ReadHoldingRegisters(86, 1),
|
||||||
|
ReadHoldingRegisters(3034, 1),
|
||||||
|
ReadHoldingRegisters(3060, 1),
|
||||||
|
ReadHoldingRegisters(3063, 5),
|
||||||
]
|
]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def writable_ranges(self) -> List[range]:
|
def writable_ranges(self) -> List[range]:
|
||||||
return super().writable_ranges + [
|
return super().writable_ranges + [
|
||||||
3034,
|
range(3034, 3035),
|
||||||
3060,
|
range(3060, 3061),
|
||||||
range(3063, 3066),
|
range(3063, 3067),
|
||||||
]
|
]
|
||||||
@@ -53,7 +53,7 @@ class EP500(ProtocolV1Device):
|
|||||||
def writable_ranges(self) -> List[range]:
|
def writable_ranges(self) -> List[range]:
|
||||||
return super().writable_ranges + [
|
return super().writable_ranges + [
|
||||||
range(3001, 3016),
|
range(3001, 3016),
|
||||||
3061,
|
range(3061),
|
||||||
]
|
]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class EP500P(ProtocolV1Device):
|
|||||||
def writable_ranges(self) -> List[range]:
|
def writable_ranges(self) -> List[range]:
|
||||||
return super().writable_ranges + [
|
return super().writable_ranges + [
|
||||||
range(3001, 3016),
|
range(3001, 3016),
|
||||||
3061,
|
range(3061),
|
||||||
]
|
]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ class FieldType(Enum):
|
|||||||
NUMERIC = auto()
|
NUMERIC = auto()
|
||||||
BOOL = auto()
|
BOOL = auto()
|
||||||
ENUM = auto()
|
ENUM = auto()
|
||||||
BUTTON = auto()
|
|
||||||
|
|
||||||
|
|
||||||
class FieldAttributes:
|
class FieldAttributes:
|
||||||
@@ -220,7 +219,7 @@ FIELD_ATTRIBUTES: dict[str, FieldAttributes] = {
|
|||||||
"total_grid_feed": EnergyFieldAttributes("Total Grid Feed"),
|
"total_grid_feed": EnergyFieldAttributes("Total Grid Feed"),
|
||||||
# Device specific controls
|
# Device specific controls
|
||||||
"power_off": FieldAttributes(
|
"power_off": FieldAttributes(
|
||||||
type=FieldType.BUTTON,
|
type=FieldType.BOOL,
|
||||||
setter=True,
|
setter=True,
|
||||||
name="Power Off",
|
name="Power Off",
|
||||||
),
|
),
|
||||||
@@ -294,7 +293,7 @@ FIELD_ATTRIBUTES: dict[str, FieldAttributes] = {
|
|||||||
),
|
),
|
||||||
"power_lifting_on": FieldAttributes(
|
"power_lifting_on": FieldAttributes(
|
||||||
type=FieldType.BOOL,
|
type=FieldType.BOOL,
|
||||||
setter=False, # Disabled for safety reasons
|
setter=True,
|
||||||
name="Power Lifting",
|
name="Power Lifting",
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,11 @@ SUPPORTED_MODELS = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
CONTROL_FIELDS = [
|
CONTROL_FIELDS = [
|
||||||
"ac_output_on",
|
"ac_output_on_switch",
|
||||||
"dc_output_on",
|
"dc_output_on_switch",
|
||||||
|
"power_off",
|
||||||
|
"eco_on",
|
||||||
|
"power_lifting_on",
|
||||||
]
|
]
|
||||||
|
|
||||||
DIAGNOSTIC_FIELDS = [
|
DIAGNOSTIC_FIELDS = [
|
||||||
|
|||||||
@@ -22,5 +22,5 @@
|
|||||||
"iot_class": "local_polling",
|
"iot_class": "local_polling",
|
||||||
"issue_tracker": "https://github.com/Patrick762/hassio-bluetti-bt/issues",
|
"issue_tracker": "https://github.com/Patrick762/hassio-bluetti-bt/issues",
|
||||||
"requirements": [],
|
"requirements": [],
|
||||||
"version": "0.0.19"
|
"version": "0.0.20"
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user