Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f9afedfdb | ||
|
|
fe23dd00cd | ||
|
|
566761dba7 | ||
|
|
33cb6e6fbd | ||
|
|
5823136280 | ||
|
|
7b6f845edb | ||
|
|
1fbcf83b1b | ||
|
|
149633f9c8 | ||
|
|
9ab7cefda7 | ||
|
|
52853d6d3e | ||
|
|
c96f551024 | ||
|
|
75209ee1aa | ||
|
|
7396616113 | ||
|
|
a7f7ff1843 | ||
|
|
cc755b3003 | ||
|
|
e5f690ef3b | ||
|
|
3d3401c942 | ||
|
|
f50232ee89 | ||
|
|
5922362772 | ||
|
|
6478825503 | ||
|
|
3169ee182e | ||
|
|
ece1fc4129 | ||
|
|
4d54e048c5 | ||
|
|
09a9112279 | ||
|
|
b37276ec52 | ||
|
|
4f88792371 |
No files matched your search
@@ -14,21 +14,10 @@ body:
|
|||||||
value: "An exception appeared"
|
value: "An exception appeared"
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: dropdown
|
- type: textarea
|
||||||
id: version
|
id: version
|
||||||
attributes:
|
attributes:
|
||||||
label: Version
|
label: What version of our software are you running?
|
||||||
description: What version of our software are you running?
|
|
||||||
options:
|
|
||||||
- 0.0.17
|
|
||||||
- 0.0.16
|
|
||||||
- 0.0.15
|
|
||||||
- 0.0.14
|
|
||||||
- 0.0.13
|
|
||||||
- 0.0.11
|
|
||||||
- 0.0.10
|
|
||||||
- 0.0.9
|
|
||||||
default: 0
|
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
|
|||||||
@@ -17,8 +17,10 @@ After the installation, you can use this button to install the integration:
|
|||||||
### Supported devices:
|
### Supported devices:
|
||||||
|
|
||||||
- AC60
|
- AC60
|
||||||
|
- AC70 (basic data)
|
||||||
|
- AC70P (untested)
|
||||||
- AC180 (basic data)
|
- AC180 (basic data)
|
||||||
- AC180P (basic data)
|
- AC180P (tested)
|
||||||
- AC200L (untested)
|
- AC200L (untested)
|
||||||
- AC200M
|
- AC200M
|
||||||
- AC300 (tested)
|
- AC300 (tested)
|
||||||
|
|||||||
@@ -97,6 +97,27 @@ class BluettiBinarySensor(CoordinatorEntity, BinarySensorEntity):
|
|||||||
"""Return if entity is available."""
|
"""Return if entity is available."""
|
||||||
return self._attr_available
|
return self._attr_available
|
||||||
|
|
||||||
|
def _set_available(self):
|
||||||
|
"""Set sensor as available."""
|
||||||
|
self._attr_available = True
|
||||||
|
self._unavailable_counter = 0
|
||||||
|
self._attr_extra_state_attributes = {}
|
||||||
|
self.async_write_ha_state()
|
||||||
|
|
||||||
|
def _set_unavailable(self, cause: str = "Unknown"):
|
||||||
|
"""Set sensor as unavailable."""
|
||||||
|
self._unavailable_counter += 1
|
||||||
|
|
||||||
|
self._attr_extra_state_attributes = {
|
||||||
|
"unavailable_counter": self._unavailable_counter,
|
||||||
|
"unavailable_cause": cause,
|
||||||
|
}
|
||||||
|
|
||||||
|
if self._unavailable_counter >= 5:
|
||||||
|
self._attr_available = False
|
||||||
|
|
||||||
|
self.async_write_ha_state()
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _handle_coordinator_update(self) -> None:
|
def _handle_coordinator_update(self) -> None:
|
||||||
"""Handle updated data from the coordinator."""
|
"""Handle updated data from the coordinator."""
|
||||||
@@ -104,19 +125,24 @@ class BluettiBinarySensor(CoordinatorEntity, BinarySensorEntity):
|
|||||||
if self.coordinator.reader.persistent_conn and not self.coordinator.reader.client.is_connected:
|
if self.coordinator.reader.persistent_conn and not self.coordinator.reader.client.is_connected:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self.coordinator.data is None:
|
||||||
|
_LOGGER.debug(
|
||||||
|
"Data from coordinator is None",
|
||||||
|
)
|
||||||
|
self._set_unavailable("Data is None")
|
||||||
|
return
|
||||||
|
|
||||||
_LOGGER.debug("Updating state of %s", unique_id_loggable(self._attr_unique_id))
|
_LOGGER.debug("Updating state of %s", unique_id_loggable(self._attr_unique_id))
|
||||||
if not isinstance(self.coordinator.data, dict):
|
if not isinstance(self.coordinator.data, dict):
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Invalid data from coordinator (binary_sensor.%s)", unique_id_loggable(self._attr_unique_id)
|
"Invalid data from coordinator (binary_sensor.%s)", unique_id_loggable(self._attr_unique_id)
|
||||||
)
|
)
|
||||||
self._attr_available = False
|
self._set_unavailable("Invalid data")
|
||||||
self.async_write_ha_state()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
response_data = self.coordinator.data.get(self._response_key)
|
response_data = self.coordinator.data.get(self._response_key)
|
||||||
if response_data is None:
|
if response_data is None:
|
||||||
self._attr_available = False
|
self._set_unavailable("No data")
|
||||||
self.async_write_ha_state()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if not isinstance(response_data, bool):
|
if not isinstance(response_data, bool):
|
||||||
@@ -125,10 +151,9 @@ class BluettiBinarySensor(CoordinatorEntity, BinarySensorEntity):
|
|||||||
unique_id_loggable(self._attr_unique_id),
|
unique_id_loggable(self._attr_unique_id),
|
||||||
response_data,
|
response_data,
|
||||||
)
|
)
|
||||||
self._attr_available = False
|
self._set_unavailable("Invalid data type")
|
||||||
self.async_write_ha_state()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
self._attr_available = True
|
self._set_available()
|
||||||
self._attr_is_on = self.coordinator.data[self._response_key] is True
|
self._attr_is_on = self.coordinator.data[self._response_key] is True
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
@@ -110,7 +110,12 @@ class DeviceReader:
|
|||||||
await self._async_send_command(command)
|
await self._async_send_command(command)
|
||||||
)
|
)
|
||||||
_LOGGER.debug("Raw data set: %s", body)
|
_LOGGER.debug("Raw data set: %s", body)
|
||||||
# b'\x00\x02' b'\x00\x03' here (seems like result)
|
|
||||||
|
# Check set pack_num
|
||||||
|
set_pack = int.from_bytes(body, byteorder='big')
|
||||||
|
if set_pack is not pack:
|
||||||
|
_LOGGER.warning("Pack polling failed (pack_num %i doesn't match expected %i)", set_pack, pack)
|
||||||
|
continue
|
||||||
|
|
||||||
for command in pack_commands:
|
for command in pack_commands:
|
||||||
# Request & parse result for each pack
|
# Request & parse result for each pack
|
||||||
@@ -124,7 +129,9 @@ class DeviceReader:
|
|||||||
_LOGGER.debug("Parsed data: %s", parsed)
|
_LOGGER.debug("Parsed data: %s", parsed)
|
||||||
|
|
||||||
for key, value in parsed.items():
|
for key, value in parsed.items():
|
||||||
parsed_data.update({key + str(pack): value})
|
# Ignore likely unavailable pack data
|
||||||
|
if value != 0:
|
||||||
|
parsed_data.update({key + str(pack): value})
|
||||||
|
|
||||||
except ParseError:
|
except ParseError:
|
||||||
_LOGGER.warning("Got a parse exception...")
|
_LOGGER.warning("Got a parse exception...")
|
||||||
|
|||||||
@@ -1,8 +1,52 @@
|
|||||||
"""AC180P fields."""
|
"""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):
|
class AC180P(ProtocolV2Device):
|
||||||
def __init__(self, address: str, sn: str):
|
def __init__(self, address: str, sn: str):
|
||||||
super().__init__(address, "AC180P", sn)
|
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)
|
||||||
|
]
|
||||||
@@ -13,17 +13,17 @@ class AC200L(ProtocolV1Device):
|
|||||||
|
|
||||||
# Details
|
# Details
|
||||||
self.struct.add_enum_field("ac_output_mode", 70, OutputMode)
|
self.struct.add_enum_field("ac_output_mode", 70, OutputMode)
|
||||||
self.struct.add_decimal_field("internal_ac_voltage", 71, 1)
|
self.struct.add_decimal_field("internal_ac_voltage", 71, 1, multiplier=10)
|
||||||
self.struct.add_decimal_field("internal_current_one", 72, 1)
|
self.struct.add_decimal_field("internal_current_one", 72, 1)
|
||||||
self.struct.add_uint_field("internal_power_one", 73)
|
self.struct.add_uint_field("internal_power_one", 73)
|
||||||
self.struct.add_decimal_field("internal_ac_frequency", 74, 2)
|
self.struct.add_decimal_field("internal_ac_frequency", 74, 2, multiplier=10)
|
||||||
self.struct.add_uint_field("internal_dc_input_voltage", 86)
|
self.struct.add_uint_field("internal_dc_input_voltage", 86, multiplier=.1)
|
||||||
self.struct.add_decimal_field("internal_dc_input_power", 87, 1)
|
self.struct.add_decimal_field("internal_dc_input_power", 87, 1, multiplier=10)
|
||||||
self.struct.add_decimal_field("internal_dc_input_current", 88, 2)
|
self.struct.add_decimal_field("internal_dc_input_current", 88, 2)
|
||||||
|
|
||||||
# Battery packs
|
# Battery packs
|
||||||
self.struct.add_uint_field("pack_num_max", 91) # internal
|
self.struct.add_uint_field("pack_num_max", 91) # internal
|
||||||
self.struct.add_decimal_field("total_battery_voltage", 92, 1)
|
self.struct.add_decimal_field("total_battery_voltage", 92, 1, multiplier=.1)
|
||||||
self.struct.add_uint_field("pack_num_result", 96) # internal
|
self.struct.add_uint_field("pack_num_result", 96) # internal
|
||||||
self.struct.add_decimal_field("pack_voltage", 98, 2) # Full pack voltage
|
self.struct.add_decimal_field("pack_voltage", 98, 2) # Full pack voltage
|
||||||
self.struct.add_uint_field("pack_battery_percent", 99)
|
self.struct.add_uint_field("pack_battery_percent", 99)
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
"""AC70 fields."""
|
||||||
|
|
||||||
|
from ..base_devices.ProtocolV2Device import ProtocolV2Device
|
||||||
|
|
||||||
|
|
||||||
|
class AC70(ProtocolV2Device):
|
||||||
|
def __init__(self, address: str, sn: str):
|
||||||
|
super().__init__(address, "AC70", sn)
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
"""AC70P fields."""
|
||||||
|
|
||||||
|
from ..base_devices.ProtocolV2Device import ProtocolV2Device
|
||||||
|
|
||||||
|
|
||||||
|
class AC70P(ProtocolV2Device):
|
||||||
|
def __init__(self, address: str, sn: str):
|
||||||
|
super().__init__(address, "AC70P", sn)
|
||||||
@@ -316,6 +316,16 @@ FIELD_ATTRIBUTES: dict[str, FieldAttributes] = {
|
|||||||
setter=True,
|
setter=True,
|
||||||
name="Power Lifting",
|
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",
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from ..devices.ac60 import AC60
|
from ..devices.ac60 import AC60
|
||||||
|
from ..devices.ac70 import AC70
|
||||||
|
from ..devices.ac70p import AC70P
|
||||||
from ..devices.ac180 import AC180
|
from ..devices.ac180 import AC180
|
||||||
from ..devices.ac180p import AC180P
|
from ..devices.ac180p import AC180P
|
||||||
from ..devices.ac200l import AC200L
|
from ..devices.ac200l import AC200L
|
||||||
@@ -17,7 +19,7 @@ from ..devices.ep760 import EP760
|
|||||||
from ..devices.ep800 import EP800
|
from ..devices.ep800 import EP800
|
||||||
|
|
||||||
DEVICE_NAME_RE = re.compile(
|
DEVICE_NAME_RE = re.compile(
|
||||||
r"^(AC60|AC180|AC180P|AC200L|AC200M|AC300|AC500|EB3A|EP500|EP500P|EP600|EP760|EP800)(\d+)$"
|
r"^(AC60|AC70|AC70P|AC180|AC180P|AC200L|AC200M|AC300|AC500|EB3A|EP500|EP500P|EP600|EP760|EP800)(\d+)$"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -25,6 +27,10 @@ def build_device(address: str, name: str):
|
|||||||
match = DEVICE_NAME_RE.match(name)
|
match = DEVICE_NAME_RE.match(name)
|
||||||
if match[1] == "AC60":
|
if match[1] == "AC60":
|
||||||
return AC60(address, match[2])
|
return AC60(address, match[2])
|
||||||
|
if match[1] == "AC70":
|
||||||
|
return AC70(address, match[2])
|
||||||
|
if match[1] == "AC70P":
|
||||||
|
return AC70P(address, match[2])
|
||||||
if match[1] == "AC180":
|
if match[1] == "AC180":
|
||||||
return AC180(address, match[2])
|
return AC180(address, match[2])
|
||||||
if match[1] == "AC180P":
|
if match[1] == "AC180P":
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ class DecimalField(DeviceField):
|
|||||||
|
|
||||||
def parse(self, data: bytes) -> Decimal:
|
def parse(self, data: bytes) -> Decimal:
|
||||||
val = Decimal(struct.unpack("!H", data)[0])
|
val = Decimal(struct.unpack("!H", data)[0])
|
||||||
return (val / 10 ** self.scale) * self.multiplier
|
return (val / 10 ** self.scale) * Decimal(self.multiplier)
|
||||||
|
|
||||||
def in_range(self, val: Decimal) -> bool:
|
def in_range(self, val: Decimal) -> bool:
|
||||||
if self.range is None:
|
if self.range is None:
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ SUPPORTED_MODELS = [
|
|||||||
"EP500P",
|
"EP500P",
|
||||||
"EP600",
|
"EP600",
|
||||||
"EP760",
|
"EP760",
|
||||||
|
"AC180P",
|
||||||
]
|
]
|
||||||
|
|
||||||
CONTROL_FIELDS = [
|
CONTROL_FIELDS = [
|
||||||
@@ -31,6 +32,8 @@ CONTROL_FIELDS = [
|
|||||||
"power_off",
|
"power_off",
|
||||||
"eco_on",
|
"eco_on",
|
||||||
"power_lifting_on",
|
"power_lifting_on",
|
||||||
|
"grid_enhancement_mode_on",
|
||||||
|
"silent_charging_on",
|
||||||
]
|
]
|
||||||
|
|
||||||
DIAGNOSTIC_FIELDS = [
|
DIAGNOSTIC_FIELDS = [
|
||||||
@@ -45,4 +48,5 @@ DIAGNOSTIC_FIELDS = [
|
|||||||
"total_ac_consumption",
|
"total_ac_consumption",
|
||||||
"total_grid_consumption",
|
"total_grid_consumption",
|
||||||
"total_grid_feed",
|
"total_grid_feed",
|
||||||
|
"ac_input_voltage",
|
||||||
]
|
]
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
"name": "Bluetti BT",
|
"name": "Bluetti BT",
|
||||||
"bluetooth": [
|
"bluetooth": [
|
||||||
{ "local_name": "AC60*" },
|
{ "local_name": "AC60*" },
|
||||||
|
{ "local_name": "AC70*" },
|
||||||
{ "local_name": "AC180*" },
|
{ "local_name": "AC180*" },
|
||||||
{ "local_name": "AC200L*" },
|
{ "local_name": "AC200L*" },
|
||||||
{ "local_name": "AC200M*" },
|
{ "local_name": "AC200M*" },
|
||||||
@@ -23,5 +24,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.1.0"
|
"version": "0.1.3"
|
||||||
}
|
}
|
||||||
@@ -114,6 +114,7 @@ class BluettiSensor(CoordinatorEntity, SensorEntity):
|
|||||||
e_name = f"{device_info.get('name')} {name}"
|
e_name = f"{device_info.get('name')} {name}"
|
||||||
self._address = address
|
self._address = address
|
||||||
self._response_key = response_key
|
self._response_key = response_key
|
||||||
|
self._unavailable_counter = 0
|
||||||
|
|
||||||
self._attr_device_info = device_info
|
self._attr_device_info = device_info
|
||||||
self._attr_name = name
|
self._attr_name = name
|
||||||
@@ -130,6 +131,27 @@ class BluettiSensor(CoordinatorEntity, SensorEntity):
|
|||||||
"""Return if entity is available."""
|
"""Return if entity is available."""
|
||||||
return self._attr_available
|
return self._attr_available
|
||||||
|
|
||||||
|
def _set_available(self):
|
||||||
|
"""Set sensor as available."""
|
||||||
|
self._attr_available = True
|
||||||
|
self._unavailable_counter = 0
|
||||||
|
self._attr_extra_state_attributes = {}
|
||||||
|
self.async_write_ha_state()
|
||||||
|
|
||||||
|
def _set_unavailable(self, cause: str = "Unknown"):
|
||||||
|
"""Set sensor as unavailable."""
|
||||||
|
self._unavailable_counter += 1
|
||||||
|
|
||||||
|
self._attr_extra_state_attributes = {
|
||||||
|
"unavailable_counter": self._unavailable_counter,
|
||||||
|
"unavailable_cause": cause,
|
||||||
|
}
|
||||||
|
|
||||||
|
if self._unavailable_counter >= 5:
|
||||||
|
self._attr_available = False
|
||||||
|
|
||||||
|
self.async_write_ha_state()
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _handle_coordinator_update(self) -> None:
|
def _handle_coordinator_update(self) -> None:
|
||||||
"""Handle updated data from the coordinator."""
|
"""Handle updated data from the coordinator."""
|
||||||
@@ -141,8 +163,7 @@ class BluettiSensor(CoordinatorEntity, SensorEntity):
|
|||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Data from coordinator is None",
|
"Data from coordinator is None",
|
||||||
)
|
)
|
||||||
self._attr_available = False
|
self._set_unavailable("Data is None")
|
||||||
self.async_write_ha_state()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
_LOGGER.debug("Updating state of %s", unique_id_loggable(self._attr_unique_id))
|
_LOGGER.debug("Updating state of %s", unique_id_loggable(self._attr_unique_id))
|
||||||
@@ -150,15 +171,13 @@ class BluettiSensor(CoordinatorEntity, SensorEntity):
|
|||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Invalid data from coordinator (sensor.%s)", unique_id_loggable(self._attr_unique_id)
|
"Invalid data from coordinator (sensor.%s)", unique_id_loggable(self._attr_unique_id)
|
||||||
)
|
)
|
||||||
self._attr_available = False
|
self._set_unavailable("Invalid data")
|
||||||
self.async_write_ha_state()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
response_data = self.coordinator.data.get(self._response_key)
|
response_data = self.coordinator.data.get(self._response_key)
|
||||||
if response_data is None:
|
if response_data is None:
|
||||||
_LOGGER.debug("No data for available for (%s)", self._response_key)
|
_LOGGER.debug("No data for available for (%s)", self._response_key)
|
||||||
self._attr_available = False
|
self._set_unavailable("No data")
|
||||||
self.async_write_ha_state()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -174,11 +193,10 @@ class BluettiSensor(CoordinatorEntity, SensorEntity):
|
|||||||
response_data,
|
response_data,
|
||||||
type(response_data),
|
type(response_data),
|
||||||
)
|
)
|
||||||
self._attr_available = False
|
self._set_unavailable("Invalid data type")
|
||||||
self.async_write_ha_state()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
self._attr_available = True
|
self._set_available()
|
||||||
|
|
||||||
# Different for enum and numeric
|
# Different for enum and numeric
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
homeassistant
|
||||||
|
bleak_retry_connector
|
||||||
|
pyserial
|
||||||
|
bluetooth_auto_recovery
|
||||||
|
crcmod
|
||||||
@@ -4,6 +4,8 @@ import unittest
|
|||||||
|
|
||||||
from custom_components.bluetti_bt.bluetti_bt_lib.utils.device_builder import build_device
|
from custom_components.bluetti_bt.bluetti_bt_lib.utils.device_builder import build_device
|
||||||
from custom_components.bluetti_bt.bluetti_bt_lib.devices.ac60 import AC60
|
from custom_components.bluetti_bt.bluetti_bt_lib.devices.ac60 import AC60
|
||||||
|
from custom_components.bluetti_bt.bluetti_bt_lib.devices.ac70 import AC70
|
||||||
|
from custom_components.bluetti_bt.bluetti_bt_lib.devices.ac70p import AC70P
|
||||||
from custom_components.bluetti_bt.bluetti_bt_lib.devices.ac180 import AC180
|
from custom_components.bluetti_bt.bluetti_bt_lib.devices.ac180 import AC180
|
||||||
from custom_components.bluetti_bt.bluetti_bt_lib.devices.ac180p import AC180P
|
from custom_components.bluetti_bt.bluetti_bt_lib.devices.ac180p import AC180P
|
||||||
from custom_components.bluetti_bt.bluetti_bt_lib.devices.ac200m import AC200M
|
from custom_components.bluetti_bt.bluetti_bt_lib.devices.ac200m import AC200M
|
||||||
@@ -32,6 +34,22 @@ class TestDeviceBuilder(unittest.TestCase):
|
|||||||
self.assertIsInstance(built, AC60)
|
self.assertIsInstance(built, AC60)
|
||||||
self.assertEqual(built.address, bt_addr)
|
self.assertEqual(built.address, bt_addr)
|
||||||
|
|
||||||
|
def test_build_ac70(self):
|
||||||
|
bt_addr = "aa:bb:cc:dd:ee:ff"
|
||||||
|
bt_name = "AC7056786746478"
|
||||||
|
built = build_device(bt_addr, bt_name)
|
||||||
|
|
||||||
|
self.assertIsInstance(built, AC70)
|
||||||
|
self.assertEqual(built.address, bt_addr)
|
||||||
|
|
||||||
|
def test_build_ac70p(self):
|
||||||
|
bt_addr = "aa:bb:cc:dd:ee:ff"
|
||||||
|
bt_name = "AC70P56786746478"
|
||||||
|
built = build_device(bt_addr, bt_name)
|
||||||
|
|
||||||
|
self.assertIsInstance(built, AC70P)
|
||||||
|
self.assertEqual(built.address, bt_addr)
|
||||||
|
|
||||||
def test_build_ac180(self):
|
def test_build_ac180(self):
|
||||||
bt_addr = "aa:bb:cc:dd:ee:ff"
|
bt_addr = "aa:bb:cc:dd:ee:ff"
|
||||||
bt_name = "AC18056786746478"
|
bt_name = "AC18056786746478"
|
||||||
|
|||||||
Reference in new issue
Block a user