added ep600 dc input, prevent pack polling
This commit is contained in:
1 parent
18e48092c0
commit
7904a07e7f
4 files changed
+90
-22
No files matched your search
@@ -17,7 +17,7 @@ from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers import selector
|
||||
|
||||
from . import get_type_by_bt_name
|
||||
from .const import CONF_PERSISTENT_CONN, CONF_POLLING_INTERVAL, DATA_COORDINATOR, DOMAIN, CONF_USE_CONTROLS
|
||||
from .const import CONF_PERSISTENT_CONN, CONF_POLLING_INTERVAL, DOMAIN, CONF_USE_CONTROLS
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -79,6 +79,78 @@ ADDITIONAL_DEVICE_FIELDS = {
|
||||
advanced=False,
|
||||
home_assistant_extra={"name": "High Voltage Safety Module Version"},
|
||||
),
|
||||
'pv_input_power1': MqttFieldConfig(
|
||||
type=MqttFieldType.NUMERIC,
|
||||
setter=False,
|
||||
advanced=False,
|
||||
home_assistant_extra={
|
||||
"name": "Solar Input Power 1",
|
||||
"unit_of_measurement": "W",
|
||||
"device_class": "power",
|
||||
"state_class": "measurement",
|
||||
"force_update": True,
|
||||
},
|
||||
),
|
||||
'pv_input_voltage1': MqttFieldConfig(
|
||||
type=MqttFieldType.NUMERIC,
|
||||
setter=False,
|
||||
advanced=False,
|
||||
home_assistant_extra={
|
||||
"name": "Solar Input Voltage 1",
|
||||
"unit_of_measurement": "V",
|
||||
"device_class": "voltage",
|
||||
"state_class": "measurement",
|
||||
"force_update": True,
|
||||
},
|
||||
),
|
||||
'pv_input_current1': MqttFieldConfig(
|
||||
type=MqttFieldType.NUMERIC,
|
||||
setter=False,
|
||||
advanced=False,
|
||||
home_assistant_extra={
|
||||
"name": "Solar Input Current 1",
|
||||
"unit_of_measurement": "A",
|
||||
"device_class": "current",
|
||||
"state_class": "measurement",
|
||||
"force_update": True,
|
||||
},
|
||||
),
|
||||
'pv_input_power2': MqttFieldConfig(
|
||||
type=MqttFieldType.NUMERIC,
|
||||
setter=False,
|
||||
advanced=False,
|
||||
home_assistant_extra={
|
||||
"name": "Solar Input Power 2",
|
||||
"unit_of_measurement": "W",
|
||||
"device_class": "power",
|
||||
"state_class": "measurement",
|
||||
"force_update": True,
|
||||
},
|
||||
),
|
||||
'pv_input_voltage2': MqttFieldConfig(
|
||||
type=MqttFieldType.NUMERIC,
|
||||
setter=False,
|
||||
advanced=False,
|
||||
home_assistant_extra={
|
||||
"name": "Solar Input Voltage 2",
|
||||
"unit_of_measurement": "V",
|
||||
"device_class": "voltage",
|
||||
"state_class": "measurement",
|
||||
"force_update": True,
|
||||
},
|
||||
),
|
||||
'pv_input_current2': MqttFieldConfig(
|
||||
type=MqttFieldType.NUMERIC,
|
||||
setter=False,
|
||||
advanced=False,
|
||||
home_assistant_extra={
|
||||
"name": "Solar Input Current 2",
|
||||
"unit_of_measurement": "A",
|
||||
"device_class": "current",
|
||||
"state_class": "measurement",
|
||||
"force_update": True,
|
||||
},
|
||||
),
|
||||
"adl400_ac_input_power_phase1": MqttFieldConfig(
|
||||
type=MqttFieldType.NUMERIC,
|
||||
setter=False,
|
||||
|
||||
@@ -44,6 +44,13 @@ class DummyDevice(BluettiDevice):
|
||||
self.struct = device.struct
|
||||
|
||||
if device.type == "EP600":
|
||||
# DC Solar Input (copied from PR https://github.com/warhammerkid/bluetti_mqtt/pull/87 by KM011092)
|
||||
self.struct.add_uint_field('pv_input_power1', 1212) # MPP 1 in - value * 0.1
|
||||
#self.struct.add_uint_field('pv_input_voltage1', 1213) # MPP 1 in - value * 0.1
|
||||
#self.struct.add_uint_field('pv_input_current1', 1214) # MPP 1 in
|
||||
self.struct.add_uint_field('pv_input_power2', 1220) # MPP 2 in - value * 0.1
|
||||
#self.struct.add_uint_field('pv_input_voltage2', 1221) # MPP 2 in - value * 0.1
|
||||
#self.struct.add_uint_field('pv_input_current2', 1222) # MPP 2 in
|
||||
# ADL400 Smart Meter for AC Solar
|
||||
self.struct.add_uint_field("adl400_ac_input_power_phase1", 1228)
|
||||
self.struct.add_uint_field("adl400_ac_input_power_phase2", 1236)
|
||||
@@ -73,9 +80,6 @@ class DummyDevice(BluettiDevice):
|
||||
self.struct.add_decimal_field("ac_output_current_phase1", 1512, 1)
|
||||
self.struct.add_decimal_field("ac_output_current_phase2", 1519, 1)
|
||||
self.struct.add_decimal_field("ac_output_current_phase3", 1526, 1)
|
||||
# Testing
|
||||
# for i in range(0, 10):
|
||||
# self.struct.add_decimal_field("testing"+str(i), 1520+i, 1)
|
||||
|
||||
super().__init__(device.address, device.type, device.sn)
|
||||
self._parent = device
|
||||
@@ -94,28 +98,18 @@ class DummyDevice(BluettiDevice):
|
||||
ReadHoldingRegisters(1500, 27),
|
||||
ReadHoldingRegisters(2022, 6),
|
||||
ReadHoldingRegisters(2213, 4),
|
||||
ReadHoldingRegisters(1212, 11),
|
||||
# Battery
|
||||
ReadHoldingRegisters(6101, 7),
|
||||
ReadHoldingRegisters(6175, 11),
|
||||
# Testing
|
||||
# ReadHoldingRegisters(100, 62),
|
||||
# ReadHoldingRegisters(1100, 51),
|
||||
# ReadHoldingRegisters(1200, 80),
|
||||
# ReadHoldingRegisters(1300, 31),
|
||||
# ReadHoldingRegisters(1400, 48),
|
||||
# ReadHoldingRegisters(1500, 30),
|
||||
# ReadHoldingRegisters(2000, 89),
|
||||
# ReadHoldingRegisters(2200, 41),
|
||||
# ReadHoldingRegisters(2300, 36),
|
||||
# ReadHoldingRegisters(6000, 32),
|
||||
# ReadHoldingRegisters(6100, 100),
|
||||
# ReadHoldingRegisters(6300, 100),
|
||||
]
|
||||
|
||||
return self._parent.polling_commands
|
||||
|
||||
@property
|
||||
def pack_polling_commands(self) -> List[ReadHoldingRegisters]:
|
||||
if self.type == "EP600":
|
||||
return []
|
||||
return self._parent.pack_polling_commands
|
||||
|
||||
@property
|
||||
@@ -225,6 +219,8 @@ class PollingCoordinator(DataUpdateCoordinator):
|
||||
except ParseError:
|
||||
self.logger.warning("Got a parse exception...")
|
||||
|
||||
if len(self.bluetti_device.pack_polling_commands) > 0:
|
||||
_LOGGER.debug("Polling battery packs")
|
||||
# pack polling
|
||||
for pack in range (1, self.bluetti_device.pack_num_max + 1):
|
||||
# Set current pack number
|
||||
@@ -243,9 +239,9 @@ class PollingCoordinator(DataUpdateCoordinator):
|
||||
)
|
||||
self.logger.debug("Parsed data: %s", parsed)
|
||||
|
||||
packNo = parsed.get('pack_num')
|
||||
if not isinstance(packNo, int) or packNo != pack:
|
||||
self.logger.debug("Parsed pack_num(%s) does not match expected '%s'", packNo, pack)
|
||||
pack_number = parsed.get('pack_num')
|
||||
if not isinstance(pack_number, int) or pack_number != pack:
|
||||
self.logger.debug("Parsed pack_num(%s) does not match expected '%s'", pack_number, pack)
|
||||
continue
|
||||
|
||||
for key, value in parsed.items():
|
||||
|
||||
@@ -6,7 +6,7 @@ import asyncio
|
||||
import logging
|
||||
import async_timeout
|
||||
|
||||
from bleak import BleakClient, BleakError
|
||||
from bleak import BleakError
|
||||
|
||||
from homeassistant.components import bluetooth
|
||||
from homeassistant.components.switch import SwitchEntity, SwitchDeviceClass
|
||||
@@ -33,7 +33,7 @@ from bluetti_mqtt.mqtt_client import (
|
||||
)
|
||||
|
||||
from . import device_info as dev_info, get_unique_id
|
||||
from .const import CONTROL_FIELDS, DATA_COORDINATOR, DATA_POLLING_RUNNING, DOMAIN, ADDITIONAL_DEVICE_FIELDS
|
||||
from .const import CONTROL_FIELDS, DATA_COORDINATOR, DOMAIN, ADDITIONAL_DEVICE_FIELDS
|
||||
from .coordinator import PollingCoordinator, DummyDevice
|
||||
from .utils import mac_loggable, unique_id_loggable
|
||||
|
||||
|
||||
Reference in new issue
Block a user