4 files changed
+49
-3
No files matched your search
@@ -28,7 +28,7 @@ from bluetti_mqtt.mqtt_client import (
|
|||||||
|
|
||||||
from . import device_info as dev_info, get_unique_id
|
from . import device_info as dev_info, get_unique_id
|
||||||
from .const import DOMAIN, ADDITIONAL_DEVICE_FIELDS
|
from .const import DOMAIN, ADDITIONAL_DEVICE_FIELDS
|
||||||
from .coordinator import PollingCoordinator
|
from .coordinator import PollingCoordinator, DummyDevice
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -49,6 +49,7 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
# Add sensors according to device_info
|
# Add sensors according to device_info
|
||||||
bluetti_device = build_device(address, device_name)
|
bluetti_device = build_device(address, device_name)
|
||||||
|
bluetti_device = DummyDevice(bluetti_device)
|
||||||
|
|
||||||
sensors_to_add = []
|
sensors_to_add = []
|
||||||
all_fields = NORMAL_DEVICE_FIELDS
|
all_fields = NORMAL_DEVICE_FIELDS
|
||||||
|
|||||||
@@ -68,4 +68,40 @@ ADDITIONAL_DEVICE_FIELDS = {
|
|||||||
advanced=False,
|
advanced=False,
|
||||||
home_assistant_extra={"name": "High Voltage Safety Module Version"},
|
home_assistant_extra={"name": "High Voltage Safety Module Version"},
|
||||||
),
|
),
|
||||||
|
"adl400_ac_input_voltage_phase1": MqttFieldConfig(
|
||||||
|
type=MqttFieldType.NUMERIC,
|
||||||
|
setter=False,
|
||||||
|
advanced=False,
|
||||||
|
home_assistant_extra={
|
||||||
|
"name": "ADL400 AC Input Voltage Phase 1",
|
||||||
|
"unit_of_measurement": "V",
|
||||||
|
"device_class": "voltage",
|
||||||
|
"state_class": "measurement",
|
||||||
|
"force_update": True,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
"adl400_ac_input_voltage_phase2": MqttFieldConfig(
|
||||||
|
type=MqttFieldType.NUMERIC,
|
||||||
|
setter=False,
|
||||||
|
advanced=False,
|
||||||
|
home_assistant_extra={
|
||||||
|
"name": "ADL400 AC Input Voltage Phase 2",
|
||||||
|
"unit_of_measurement": "V",
|
||||||
|
"device_class": "voltage",
|
||||||
|
"state_class": "measurement",
|
||||||
|
"force_update": True,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
"adl400_ac_input_voltage_phase3": MqttFieldConfig(
|
||||||
|
type=MqttFieldType.NUMERIC,
|
||||||
|
setter=False,
|
||||||
|
advanced=False,
|
||||||
|
home_assistant_extra={
|
||||||
|
"name": "ADL400 AC Input Voltage Phase 3",
|
||||||
|
"unit_of_measurement": "V",
|
||||||
|
"device_class": "voltage",
|
||||||
|
"state_class": "measurement",
|
||||||
|
"force_update": True,
|
||||||
|
},
|
||||||
|
),
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,12 @@ class DummyDevice(BluettiDevice):
|
|||||||
def __init__(self, device: BluettiDevice):
|
def __init__(self, device: BluettiDevice):
|
||||||
"""Init dummy device with real device."""
|
"""Init dummy device with real device."""
|
||||||
self.struct = device.struct
|
self.struct = device.struct
|
||||||
|
|
||||||
|
if device.type == "EP600":
|
||||||
|
self.struct.add_decimal_field("adl400_ac_input_voltage_phase1", 1229, 1)
|
||||||
|
self.struct.add_decimal_field("adl400_ac_input_voltage_phase2", 1237, 1)
|
||||||
|
self.struct.add_decimal_field("adl400_ac_input_voltage_phase3", 1245, 1)
|
||||||
|
|
||||||
super().__init__(device.address, device.type, device.sn)
|
super().__init__(device.address, device.type, device.sn)
|
||||||
self._parent = device
|
self._parent = device
|
||||||
|
|
||||||
@@ -48,11 +54,13 @@ class DummyDevice(BluettiDevice):
|
|||||||
if self.type == "EP600":
|
if self.type == "EP600":
|
||||||
return [
|
return [
|
||||||
ReadHoldingRegisters(100, 62),
|
ReadHoldingRegisters(100, 62),
|
||||||
|
ReadHoldingRegisters(1229, 19),
|
||||||
ReadHoldingRegisters(2022, 6),
|
ReadHoldingRegisters(2022, 6),
|
||||||
ReadHoldingRegisters(2213, 4),
|
ReadHoldingRegisters(2213, 4),
|
||||||
# Battery
|
# Battery
|
||||||
ReadHoldingRegisters(6101, 7),
|
ReadHoldingRegisters(6101, 7),
|
||||||
ReadHoldingRegisters(6175, 11),
|
ReadHoldingRegisters(6175, 11),
|
||||||
|
# current limit for reading ReadHoldingRegisters(0x2F2F, 1),
|
||||||
]
|
]
|
||||||
|
|
||||||
return self._parent.polling_commands
|
return self._parent.polling_commands
|
||||||
@@ -149,7 +157,7 @@ class PollingCoordinator(DataUpdateCoordinator):
|
|||||||
command.starting_address, body
|
command.starting_address, body
|
||||||
)
|
)
|
||||||
|
|
||||||
self.logger.error("[NO ERROR] Parsed data: %s", parsed)
|
self.logger.debug("Parsed data: %s", parsed)
|
||||||
parsed_data.update(parsed)
|
parsed_data.update(parsed)
|
||||||
|
|
||||||
except TimeoutError:
|
except TimeoutError:
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ from bluetti_mqtt.mqtt_client import (
|
|||||||
|
|
||||||
from . import device_info as dev_info, get_unique_id
|
from . import device_info as dev_info, get_unique_id
|
||||||
from .const import DOMAIN, CONF_OPTIONS, DIAGNOSTIC_FIELDS, ADDITIONAL_DEVICE_FIELDS
|
from .const import DOMAIN, CONF_OPTIONS, DIAGNOSTIC_FIELDS, ADDITIONAL_DEVICE_FIELDS
|
||||||
from .coordinator import PollingCoordinator
|
from .coordinator import PollingCoordinator, DummyDevice
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -52,6 +52,7 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
# Add sensors according to device_info
|
# Add sensors according to device_info
|
||||||
bluetti_device = build_device(address, device_name)
|
bluetti_device = build_device(address, device_name)
|
||||||
|
bluetti_device = DummyDevice(bluetti_device)
|
||||||
|
|
||||||
sensors_to_add = []
|
sensors_to_add = []
|
||||||
all_fields = NORMAL_DEVICE_FIELDS
|
all_fields = NORMAL_DEVICE_FIELDS
|
||||||
|
|||||||
Reference in new issue
Block a user