diff --git a/custom_components/solax_modbus/__init__.py b/custom_components/solax_modbus/__init__.py index 921de49f..8ce442b3 100644 --- a/custom_components/solax_modbus/__init__.py +++ b/custom_components/solax_modbus/__init__.py @@ -27,12 +27,16 @@ from homeassistant.helpers.event import async_track_time_interval from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.device_registry import DeviceInfo + try: from homeassistant.components.modbus import ModbusHub as CoreModbusHub, get_hub as get_core_hub except ImportError: - def get_hub(name): None - class CoreModbusHub: - """ place holder dummy """ + + def get_hub(name): + None + + class CoreModbusHub: + """place holder dummy""" from .sensor import SolaXModbusSensor @@ -98,7 +102,7 @@ class CoreModbusHub: SLEEPMODE_LASTAWAKE, ) -PLATFORMS = [Platform.BUTTON, Platform.NUMBER, Platform.SELECT, Platform.SENSOR] +PLATFORMS = [Platform.BUTTON, Platform.NUMBER, Platform.SELECT, Platform.SENSOR, Platform.SWITCH] # seriesnumber = 'unknown' @@ -130,9 +134,7 @@ async def async_migrate_entry(hass, config_entry: ConfigEntry): def _load_plugin(plugin_name: str) -> ModuleType: _LOGGER.info("trying to load plugin - plugin_name: %s", plugin_name) - plugin = importlib.import_module( - f".plugin_{plugin_name}", "custom_components.solax_modbus" - ) + plugin = importlib.import_module(f".plugin_{plugin_name}", "custom_components.solax_modbus") if not plugin: _LOGGER.error("Could not import plugin with name: %s", plugin_name) return plugin @@ -165,7 +167,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): # ====================== end of dynamic load ============================================================== - if config.get(CONF_INTERFACE,None) == 'core': + if config.get(CONF_INTERFACE, None) == "core": hub = SolaXCoreModbusHub( hass, plugin, @@ -232,9 +234,7 @@ def __init__( f"{name} integration may need to be reconfigured for this version; using default Solax modbus_address {modbus_addr}" ) interface = config.get(CONF_INTERFACE, None) - if ( - not interface - ): # core modbus parameter name was read_serial, this block can be removed later + if not interface: # core modbus parameter name was read_serial, this block can be removed later if config.get("read_serial", False): interface = "serial" else: @@ -245,9 +245,7 @@ def __init__( _LOGGER.debug(f"solax serial port {serial_port} interface {interface}") """Initialize the Modbus hub.""" - _LOGGER.debug( - f"solax modbushub creation with interface {interface} baudrate (only for serial): {baudrate}" - ) + _LOGGER.debug(f"solax modbushub creation with interface {interface} baudrate (only for serial): {baudrate}") self._hass = hass if interface == "serial": self._client = AsyncModbusSerialClient( @@ -261,9 +259,7 @@ def __init__( ) elif interface == "tcp": if tcp_type == "rtu": - self._client = AsyncModbusTcpClient( - host=host, port=port, timeout=5, framer=ModbusRtuFramer, retries=6 - ) + self._client = AsyncModbusTcpClient(host=host, port=port, timeout=5, framer=ModbusRtuFramer, retries=6) elif tcp_type == "ascii": self._client = AsyncModbusTcpClient( host=host, port=port, timeout=5, framer=ModbusAsciiFramer, retries=6 @@ -279,9 +275,7 @@ def __init__( self.read_serial_port = serial_port self._baudrate = int(baudrate) self.groups = {} # group info, below - self.empty_interval_group = lambda: SimpleNamespace( - interval=0, unsub_interval_method=None, device_groups={} - ) + self.empty_interval_group = lambda: SimpleNamespace(interval=0, unsub_interval_method=None, device_groups={}) self.empty_device_group = lambda: SimpleNamespace( sensors=[], inputBlocks={}, @@ -289,17 +283,19 @@ def __init__( readPreparation=None, # function to call before read group readFollowUp=None, # function to call after read group ) - self.data = { - "_repeatUntil": {} - } # _repeatuntil contains button autorepeat expiry times + self.data = {"_repeatUntil": {}} # _repeatuntil contains button autorepeat expiry times self.tmpdata = {} # for WRITE_DATA_LOCAL entities with corresponding prevent_update number/sensor self.tmpdata_expiry = {} # expiry timestamps for tempdata self.cyclecount = 0 # temporary - remove later - self.slowdown = 1 # slow down factor when modbus is not responding: 1 : no slowdown, 10: ignore 9 out of 10 cycles + self.slowdown = ( + 1 # slow down factor when modbus is not responding: 1 : no slowdown, 10: ignore 9 out of 10 cycles + ) self.computedSensors = {} self.computedButtons = {} + self.computedSwitches = {} self.sensorEntities = {} # all sensor entities, indexed by key self.numberEntities = {} # all number entities, indexed by key + self.switchEntities = {} # self.preventSensors = {} # sensors with prevent_update = True self.writeLocals = {} # key to description lookup dict for write_method = WRITE_DATA_LOCAL entities self.sleepzero = [] # sensors that will be set to zero in sleepmode @@ -320,9 +316,7 @@ def __init__( async def async_init(self, *args: Any) -> None: # noqa: D102 while self._invertertype in (None, 0): await self._check_connection() - self._invertertype = await self.plugin.async_determineInverterType( - self, self.config - ) + self._invertertype = await self.plugin.async_determineInverterType(self, self.config) if self._invertertype == 0: _LOGGER.info("next inverter check in 10sec") @@ -340,9 +334,7 @@ async def async_init(self, *args: Any) -> None: # noqa: D102 serial_number=self.seriesnumber, ) - await self._hass.config_entries.async_forward_entry_setups( - self.entry, PLATFORMS - ) + await self._hass.config_entries.async_forward_entry_setups(self.entry, PLATFORMS) # save and load local data entity values to make them persistent DATAFORMAT_VERSION = 1 @@ -351,6 +343,7 @@ def saveLocalData(self): tosave = {"_version": self.DATAFORMAT_VERSION} for desc in self.writeLocals: tosave[desc] = self.data.get(desc) + with open(self._hass.config.path(f"{self.name}_data.json"), "w") as fp: json.dump(tosave, fp) self.localsUpdated = False @@ -364,9 +357,7 @@ def loadLocalData(self): _LOGGER.info( f"no local data file found after 5 tries - is this a first time run? or didnt you modify any DATA_LOCAL entity?" ) - self.localsLoaded = ( - True # retry a couple of polling cycles - then assume non-existent" - ) + self.localsLoaded = True # retry a couple of polling cycles - then assume non-existent" return try: loaded = json.load(fp) @@ -380,9 +371,7 @@ def loadLocalData(self): for desc in self.writeLocals: self.data[desc] = loaded.get(desc) else: - _LOGGER.warning( - f"local persistent data lost - please reinitialize {self.writeLocals.keys()}" - ) + _LOGGER.warning(f"local persistent data lost - please reinitialize {self.writeLocals.keys()}") fp.close() self.localsLoaded = True self.plugin.localDataCallback(self) @@ -429,9 +418,7 @@ async def _refresh(_now: Optional[int] = None) -> None: ) device_key = self.device_group_key(sensor.device_info) - grp = interval_group.device_groups.setdefault( - device_key, self.empty_device_group() - ) + grp = interval_group.device_groups.setdefault(device_key, self.empty_device_group()) grp.sensors.append(sensor) @callback @@ -462,17 +449,13 @@ async def async_remove_solax_modbus_sensor(self, sensor): if not self.groups: await self.async_close() - async def async_refresh_modbus_data( - self, interval_group, _now: Optional[int] = None - ) -> None: + async def async_refresh_modbus_data(self, interval_group, _now: Optional[int] = None) -> None: """Time to update.""" self.cyclecount = self.cyclecount + 1 if not interval_group.device_groups: return - if ( - self.cyclecount % self.slowdown - ) == 0: # only execute once every slowdown count + if (self.cyclecount % self.slowdown) == 0: # only execute once every slowdown count for group in interval_group.device_groups.values(): update_result = await self.async_read_modbus_data(group) if update_result: @@ -573,9 +556,7 @@ async def async_read_input_registers(self, unit, address, count): async def async_lowlevel_write_register(self, unit, address, payload): kwargs = {"slave": unit} if unit else {} # builder = BinaryPayloadBuilder(byteorder=Endian.BIG, wordorder=Endian.BIG) - builder = BinaryPayloadBuilder( - byteorder=self.plugin.order16, wordorder=self.plugin.order32 - ) + builder = BinaryPayloadBuilder(byteorder=self.plugin.order16, wordorder=self.plugin.order32) builder.reset() builder.add_16bit_int(payload) payload = builder.to_registers() @@ -606,14 +587,10 @@ async def async_write_register(self, unit, address, payload): _LOGGER.warning("cannot wakeup inverter: no awake button found") return res - async def async_write_registers_single( - self, unit, address, payload - ): # Needs adapting for regiater que + async def async_write_registers_single(self, unit, address, payload): # Needs adapting for regiater que """Write registers multi, but write only one register of type 16bit""" kwargs = {"slave": unit} if unit else {} - builder = BinaryPayloadBuilder( - byteorder=self.plugin.order16, wordorder=self.plugin.order32 - ) + builder = BinaryPayloadBuilder(byteorder=self.plugin.order16, wordorder=self.plugin.order32) builder.reset() builder.add_16bit_int(payload) payload = builder.to_registers() @@ -623,14 +600,10 @@ async def async_write_registers_single( resp = await self._client.write_registers(address, payload, **kwargs) except (ConnectionException, ModbusIOException) as e: original_message = str(e) - raise HomeAssistantError( - f"Error writing single Modbus registers: {original_message}" - ) from e + raise HomeAssistantError(f"Error writing single Modbus registers: {original_message}") from e return resp - async def async_write_registers_multi( - self, unit, address, payload - ): # Needs adapting for regiater que + async def async_write_registers_multi(self, unit, address, payload): # Needs adapting for regiater que """Write registers multi. unit is the modbus address of the device that will be writen to address us the start register address @@ -643,9 +616,7 @@ async def async_write_registers_multi( 32bit integers will be converted to 2 modbus register values according to the endian strategy of the plugin """ kwargs = {"slave": unit} if unit else {} - builder = BinaryPayloadBuilder( - byteorder=self.plugin.order16, wordorder=self.plugin.order32 - ) + builder = BinaryPayloadBuilder(byteorder=self.plugin.order16, wordorder=self.plugin.order32) builder.reset() if isinstance(payload, list): for ( @@ -680,25 +651,17 @@ async def async_write_registers_multi( _LOGGER.error(f"unsupported unit type: {typ} for {key}") payload = builder.to_registers() # for easier debugging, make next line a _LOGGER.info line - _LOGGER.debug( - f"Ready to write multiple registers at 0x{address:02x}: {payload}" - ) + _LOGGER.debug(f"Ready to write multiple registers at 0x{address:02x}: {payload}") async with self._lock: await self._check_connection() try: - resp = await self._client.write_registers( - address, payload, **kwargs - ) + resp = await self._client.write_registers(address, payload, **kwargs) except (ConnectionException, ModbusIOException) as e: original_message = str(e) - raise HomeAssistantError( - f"Error writing multiple Modbus registers: {original_message}" - ) from e + raise HomeAssistantError(f"Error writing multiple Modbus registers: {original_message}") from e return resp else: - _LOGGER.error( - f"write_registers_multi expects a list of tuples 0x{address:02x} payload: {payload}" - ) + _LOGGER.error(f"write_registers_multi expects a list of tuples 0x{address:02x} payload: {payload}") return None async def async_read_modbus_data(self, group): @@ -735,18 +698,13 @@ def treat_address(self, data, decoder, descr, initval=0): elif descr.unit == REGISTER_WORDS: val = [decoder.decode_16bit_uint() for val in range(descr.wordcount)] elif descr.unit == REGISTER_ULSB16MSB16: - val = ( - decoder.decode_16bit_uint() - + decoder.decode_16bit_uint() * 256 * 256 - ) + val = decoder.decode_16bit_uint() + decoder.decode_16bit_uint() * 256 * 256 elif descr.unit == REGISTER_U8L: val = initval % 256 elif descr.unit == REGISTER_U8H: val = initval >> 8 else: - _LOGGER.warning( - f"undefinded unit for entity {descr.key} - setting value to zero" - ) + _LOGGER.warning(f"undefinded unit for entity {descr.key} - setting value to zero") val = 0 except Exception as ex: if self.cyclecount < 5: @@ -755,9 +713,7 @@ def treat_address(self, data, decoder, descr, initval=0): exc_info=True, ) else: - _LOGGER.warning( - f"{self.name}: read failed at 0x{descr.register:02x}: {descr.key} " - ) + _LOGGER.warning(f"{self.name}: read failed at 0x{descr.register:02x}: {descr.key} ") """ TO BE REMOVED if descr.prevent_update: if (self.tmpdata_expiry.get(descr.key, 0) > time()): @@ -846,21 +802,13 @@ async def async_read_modbus_block(self, data, block, typ): prevreg = reg + 1 return True else: # block read failure - firstdescr = block.descriptions[ - block.start - ] # check only first item in block - if ( - firstdescr.ignore_readerror != False - ): # ignore block read errors and return static data + firstdescr = block.descriptions[block.start] # check only first item in block + if firstdescr.ignore_readerror != False: # ignore block read errors and return static data for reg in block.regs: descr = block.descriptions[reg] if not (type(descr) is dict): - if (descr.ignore_readerror != True) and ( - descr.ignore_readerror != False - ): - data[descr.key] = ( - descr.ignore_readerror - ) # return something static + if (descr.ignore_readerror != True) and (descr.ignore_readerror != False): + data[descr.key] = descr.ignore_readerror # return something static return True else: if self.slowdown == 1: @@ -902,13 +850,9 @@ async def async_read_modbus_registers_all(self, group): for key, value in data.items(): self.data[key] = value - if ( - res and self.writequeue and self.plugin.isAwake(self.data) - ): # self.awakeplugin(self.data): + if res and self.writequeue and self.plugin.isAwake(self.data): # self.awakeplugin(self.data): # process outstanding write requests - _LOGGER.info( - f"inverter is now awake, processing outstanding write requests {self.writequeue}" - ) + _LOGGER.info(f"inverter is now awake, processing outstanding write requests {self.writequeue}") for addr in self.writequeue.keys(): val = self.writequeue.get(addr) await self.async_write_register(self._modbus_addr, addr, val) @@ -929,7 +873,8 @@ async def async_read_modbus_registers_all(self, group): ) return res -class SolaXCoreModbusHub(SolaXModbusHub,CoreModbusHub): + +class SolaXCoreModbusHub(SolaXModbusHub, CoreModbusHub): """Thread safe wrapper class for pymodbus.""" def __init__( @@ -938,17 +883,15 @@ def __init__( plugin, entry, ): - SolaXModbusHub.__init__(self,hass,plugin,entry) + SolaXModbusHub.__init__(self, hass, plugin, entry) config = entry.options - core_hub_name = config.get(CONF_CORE_HUB,"") + core_hub_name = config.get(CONF_CORE_HUB, "") self._core_hub = core_hub_name self._hub = None _LOGGER.debug(f"solax via core modbus hub '{core_hub_name}") _LOGGER.debug("setup solax core modbus hub done %s", self.__dict__) - - async def async_close(self): """Disconnect client.""" with self._lock: @@ -965,31 +908,31 @@ async def async_close(self): async def _check_connection(self): # get hold of temporary strong reference to CoreModbusHub object # and pass it on success to caller if available - if ( self._hub is None or ( hub := self._hub() ) is None ): + if self._hub is None or (hub := self._hub()) is None: return await self.async_connect() async with hub._lock: try: if hub._client.connected: return hub - except (TypeError,AttributeError): + except (TypeError, AttributeError): pass _LOGGER.info("Inverter is not connected, trying to connect") return await self.async_connect(hub) - - def _hub_closed_now(self,ref_obj): + + def _hub_closed_now(self, ref_obj): with self._lock: if ref_obj is self._hub: self._hub = None - async def async_connect(self,hub = None): + async def async_connect(self, hub=None): delay = True while True: - # check if strong reference to + # check if strong reference to # get one. - if hub is not None or ( self._hub is not None and ( hub := self._hub() ) is not None ): - port = hub._pb_params.get('port',0) - host = hub._pb_params.get('host',port) - # TODO just wait some time and recheck again if client connected before + if hub is not None or (self._hub is not None and (hub := self._hub()) is not None): + port = hub._pb_params.get("port", 0) + host = hub._pb_params.get("host", port) + # TODO just wait some time and recheck again if client connected before # giving up await hub._lock.acquire() try: @@ -997,23 +940,22 @@ async def async_connect(self,hub = None): hub._lock.release() _LOGGER.info( "Inverter connected at %s:%s", - host,port, + host, + port, ) return hub - except (TypeError,AttributeError): + except (TypeError, AttributeError): pass hub._lock.release() if not delay: reason = " core modbus hub '{self._core_hub}' not ready" if hub._config_delay else "" - _LOGGER.warning( - f"Unable to connect to Inverter at {host}:{port}.{reason}" - ) + _LOGGER.warning(f"Unable to connect to Inverter at {host}:{port}.{reason}") return None else: # get hold of current CoreModbusHub object with # provided entity name try: - hub = get_core_hub(self._hass,self._core_hub) + hub = get_core_hub(self._hass, self._core_hub) except KeyError: _LOGGER.warning( f"CoreModbusHub '{self._core_hub}' not available", @@ -1023,7 +965,7 @@ async def async_connect(self,hub = None): if hub: # upbdate weak reference handle to refere to # the actual CoreModbusHub object - self._hub = WeakRef(hub,self._hub_closed_now) + self._hub = WeakRef(hub, self._hub_closed_now) continue if not delay: _LOGGER.warning( @@ -1050,15 +992,10 @@ async def async_read_holding_registers(self, unit, address, count): resp = await hub._client.read_holding_registers(address, count, **kwargs) except (ConnectionException, ModbusIOException) as e: original_message = str(e) - raise HomeAssistantError( - f"Error reading Modbus holding registers: {original_message}" - ) from e + raise HomeAssistantError(f"Error reading Modbus holding registers: {original_message}") from e return resp except (TypeError, AttributeError) as e: - raise HomeAssistantError( - f"Error reading Modbus holding registers: core modbus access failed" - ) from e - + raise HomeAssistantError(f"Error reading Modbus holding registers: core modbus access failed") from e async def async_read_input_registers(self, unit, address, count): """Read input registers.""" @@ -1073,20 +1010,14 @@ async def async_read_input_registers(self, unit, address, count): resp = await hub._client.read_input_registers(address, count, **kwargs) except (ConnectionException, ModbusIOException) as e: original_message = str(e) - raise HomeAssistantError( - f"Error reading Modbus input registers: {original_message}" - ) from e + raise HomeAssistantError(f"Error reading Modbus input registers: {original_message}") from e except (TypeError, AttributeError) as e: - raise HomeAssistantError( - f"Error reading Modbus input registers: core modbus access failed" - ) from e + raise HomeAssistantError(f"Error reading Modbus input registers: core modbus access failed") from e return resp async def async_lowlevel_write_register(self, unit, address, payload): # builder = BinaryPayloadBuilder(byteorder=Endian.BIG, wordorder=Endian.BIG) - builder = BinaryPayloadBuilder( - byteorder=self.plugin.order16, wordorder=self.plugin.order32 - ) + builder = BinaryPayloadBuilder(byteorder=self.plugin.order16, wordorder=self.plugin.order32) builder.reset() builder.add_16bit_int(payload) payload = builder.to_registers() @@ -1101,23 +1032,14 @@ async def async_lowlevel_write_register(self, unit, address, payload): resp = await self._client.write_register(address, payload[0], **kwargs) except (ConnectionException, ModbusIOException) as e: original_message = str(e) - raise HomeAssistantError( - f"Error writing single Modbus register: {original_message}" - ) from e + raise HomeAssistantError(f"Error writing single Modbus register: {original_message}") from e return resp except (TypeError, AttributeError) as e: - raise HomeAssistantError( - f"Error writing single Modbus input register: core modbus access failed" - ) from e - + raise HomeAssistantError(f"Error writing single Modbus input register: core modbus access failed") from e - async def async_write_registers_single( - self, unit, address, payload - ): # Needs adapting for regiater que + async def async_write_registers_single(self, unit, address, payload): # Needs adapting for regiater que """Write registers multi, but write only one register of type 16bit""" - builder = BinaryPayloadBuilder( - byteorder=self.plugin.order16, wordorder=self.plugin.order32 - ) + builder = BinaryPayloadBuilder(byteorder=self.plugin.order16, wordorder=self.plugin.order32) builder.reset() builder.add_16bit_int(payload) payload = builder.to_registers() @@ -1132,19 +1054,13 @@ async def async_write_registers_single( resp = await self._client.write_registers(address, payload, **kwargs) except (ConnectionException, ModbusIOException) as e: original_message = str(e) - raise HomeAssistantError( - f"Error writing single Modbus registers: {original_message}" - ) from e - + raise HomeAssistantError(f"Error writing single Modbus registers: {original_message}") from e + return resp except (TypeError, AttributeError) as e: - raise HomeAssistantError( - f"Error writing single Modbus Modbus registers: core modbus access failed" - ) from e + raise HomeAssistantError(f"Error writing single Modbus Modbus registers: core modbus access failed") from e - async def async_write_registers_multi( - self, unit, address, payload - ): # Needs adapting for regiater que + async def async_write_registers_multi(self, unit, address, payload): # Needs adapting for regiater que """Write registers multi. unit is the modbus address of the device that will be writen to address us the start register address @@ -1157,9 +1073,7 @@ async def async_write_registers_multi( 32bit integers will be converted to 2 modbus register values according to the endian strategy of the plugin """ kwargs = {"slave": unit} if unit else {} - builder = BinaryPayloadBuilder( - byteorder=self.plugin.order16, wordorder=self.plugin.order32 - ) + builder = BinaryPayloadBuilder(byteorder=self.plugin.order16, wordorder=self.plugin.order32) builder.reset() if isinstance(payload, list): for ( @@ -1194,9 +1108,7 @@ async def async_write_registers_multi( _LOGGER.error(f"unsupported unit type: {typ} for {key}") payload = builder.to_registers() # for easier debugging, make next line a _LOGGER.info line - _LOGGER.debug( - f"Ready to write multiple registers at 0x{address:02x}: {payload}" - ) + _LOGGER.debug(f"Ready to write multiple registers at 0x{address:02x}: {payload}") async with self._lock: hub = await self._check_connection() try: @@ -1204,23 +1116,15 @@ async def async_write_registers_multi( return None async with hub._lock: try: - resp = await self._client.write_registers( - address, payload, **kwargs - ) + resp = await self._client.write_registers(address, payload, **kwargs) except (ConnectionException, ModbusIOException) as e: original_message = str(e) - raise HomeAssistantError( - f"Error writing multiple Modbus registers: {original_message}" - ) from e + raise HomeAssistantError(f"Error writing multiple Modbus registers: {original_message}") from e return resp except (TypeError, AttributeError) as e: raise HomeAssistantError( f"Error writing single Modbus Modbus registers: core modbus access failed" ) from e else: - _LOGGER.error( - f"write_registers_multi expects a list of tuples 0x{address:02x} payload: {payload}" - ) + _LOGGER.error(f"write_registers_multi expects a list of tuples 0x{address:02x} payload: {payload}") return None - - diff --git a/custom_components/solax_modbus/const.py b/custom_components/solax_modbus/const.py index 8b49d508..efa0be01 100644 --- a/custom_components/solax_modbus/const.py +++ b/custom_components/solax_modbus/const.py @@ -1,4 +1,3 @@ - import logging from homeassistant.components.sensor import ( SensorDeviceClass, @@ -10,6 +9,7 @@ NumberEntityDescription, ) from homeassistant.components.select import SelectEntityDescription +from homeassistant.components.switch import SwitchEntityDescription from homeassistant.components.button import ButtonEntityDescription from homeassistant.helpers.entity import EntityCategory from pymodbus.payload import Endian @@ -33,15 +33,14 @@ try: from homeassistant.const import ( UnitOfReactivePower, - ) ## some changes maybe revert on update of hass + ) ## some changes maybe revert on update of hass except ImportError: # NOTE:fallback for older homeassistant installation # likely to be removed in future version from enum import StrEnum - from homeassistant.const import ( - POWER_VOLT_AMPERE_REACTIVE - ) + from homeassistant.const import POWER_VOLT_AMPERE_REACTIVE + class UnitOfReactivePower(StrEnum): VOLT_AMPERE_REACTIVE = POWER_VOLT_AMPERE_REACTIVE @@ -57,75 +56,75 @@ class UnitOfReactivePower(StrEnum): DEFAULT_MODBUS_ADDR = 1 DEFAULT_TCP_TYPE = "tcp" CONF_TCP_TYPE = "tcp_type" -TMPDATA_EXPIRY = 120 # seconds before temp entities return to modbus value +TMPDATA_EXPIRY = 120 # seconds before temp entities return to modbus value CONF_INVERTER_NAME_SUFFIX = "inverter_name_suffix" -CONF_READ_EPS = "read_eps" -CONF_READ_DCB = "read_dcb" -CONF_READ_PM = "read_pm" +CONF_READ_EPS = "read_eps" +CONF_READ_DCB = "read_dcb" +CONF_READ_PM = "read_pm" CONF_MODBUS_ADDR = "read_modbus_addr" -CONF_INTERFACE = "interface" +CONF_INTERFACE = "interface" CONF_SERIAL_PORT = "read_serial_port" -CONF_SolaX_HUB = "solax_hub" -CONF_BAUDRATE = "baudrate" -CONF_PLUGIN = "plugin" +CONF_SolaX_HUB = "solax_hub" +CONF_BAUDRATE = "baudrate" +CONF_PLUGIN = "plugin" CONF_READ_BATTERY = "read_battery" CONF_CORE_HUB = "read_core_hub" ATTR_MANUFACTURER = "SolaX Power" -DEFAULT_INTERFACE = "tcp" +DEFAULT_INTERFACE = "tcp" DEFAULT_SERIAL_PORT = "/dev/ttyUSB0" DEFAULT_READ_EPS = False DEFAULT_READ_DCB = False DEFAULT_READ_PM = False DEFAULT_BAUDRATE = "19200" -DEFAULT_PLUGIN = "solax" +DEFAULT_PLUGIN = "solax" DEFAULT_READ_BATTERY = False PLUGIN_PATH = f"{pathlib.Path(__file__).parent.absolute()}/plugin_*.py" -SLEEPMODE_NONE = None -SLEEPMODE_ZERO = 0 # when no communication at all -SLEEPMODE_LAST = 1 # when no communication at all -SLEEPMODE_LASTAWAKE = 2 # when still responding but register must be ignored when not awake -#keys for config +SLEEPMODE_NONE = None +SLEEPMODE_ZERO = 0 # when no communication at all +SLEEPMODE_LAST = 1 # when no communication at all +SLEEPMODE_LASTAWAKE = 2 # when still responding but register must be ignored when not awake +# keys for config CONF_SCAN_INTERVAL_MEDIUM = "scan_interval_medium" -CONF_SCAN_INTERVAL_FAST = "scan_interval_fast" -#values for scan_group attribute -SCAN_GROUP_DEFAULT = CONF_SCAN_INTERVAL # default scan group, slow; should always work -SCAN_GROUP_MEDIUM = CONF_SCAN_INTERVAL_MEDIUM # medium speed scanning (energy, temp, soc...) -SCAN_GROUP_FAST = CONF_SCAN_INTERVAL_FAST # fast scanning (power,...) +CONF_SCAN_INTERVAL_FAST = "scan_interval_fast" +# values for scan_group attribute +SCAN_GROUP_DEFAULT = CONF_SCAN_INTERVAL # default scan group, slow; should always work +SCAN_GROUP_MEDIUM = CONF_SCAN_INTERVAL_MEDIUM # medium speed scanning (energy, temp, soc...) +SCAN_GROUP_FAST = CONF_SCAN_INTERVAL_FAST # fast scanning (power,...) # ================================= Definitions for Sensor Declarations ================================================= REG_HOLDING = 1 # modbus holding register -REG_INPUT = 2 # modbus input register +REG_INPUT = 2 # modbus input register REGISTER_U16 = "_uint16" REGISTER_U32 = "_uint32" REGISTER_S16 = "_int16" REGISTER_S32 = "_int32" -REGISTER_ULSB16MSB16 = "_ulsb16msb16" # probably same as REGISTER_U32 - suggest to remove later +REGISTER_ULSB16MSB16 = "_ulsb16msb16" # probably same as REGISTER_U32 - suggest to remove later REGISTER_STR = "_string" # nr of bytes must be specified in wordcount and is 2*wordcount -REGISTER_WORDS = "_words" # nr or words must be specified in wordcount +REGISTER_WORDS = "_words" # nr or words must be specified in wordcount REGISTER_U8L = "_int8L" REGISTER_U8H = "_int8H" -WRITE_SINGLE_MODBUS = 1 # use write_single_modbus command -WRITE_MULTISINGLE_MODBUS = 2 # use write_mutiple modbus command for single register -WRITE_DATA_LOCAL = 3 # write only to local data storage (not persistent) -WRITE_MULTI_MODBUS = 4 # use write_multiple modbus command +WRITE_SINGLE_MODBUS = 1 # use write_single_modbus command +WRITE_MULTISINGLE_MODBUS = 2 # use write_mutiple modbus command for single register +WRITE_DATA_LOCAL = 3 # write only to local data storage (not persistent) +WRITE_MULTI_MODBUS = 4 # use write_multiple modbus command _LOGGER = logging.getLogger(__name__) - +DEBOUNCE_TIME = timedelta(seconds=5) # Time to prioritize user actions # ==================================== plugin base class ==================================================================== + @dataclass class base_battery_config: - def __init__( - self - ): + def __init__(self): self.battery_sensor_type: list[SelectEntityDescription] | None = None self.battery_sensor_name_prefix: str | None = None self.battery_sensor_key_prefix: str | None = None + @dataclass class plugin_base: plugin_name: str @@ -134,18 +133,21 @@ class plugin_base: BUTTON_TYPES: list[ButtonEntityDescription] NUMBER_TYPES: list[NumberEntityDescription] SELECT_TYPES: list[SelectEntityDescription] + SWITCH_TYPES: list[SwitchEntityDescription] BATTERY_CONFIG: base_battery_config | None = None block_size: int = 100 - auto_block_ignore_readerror: bool | None = None # if True or False, inserts a ignore_readerror statement for each block - order16: int | None = None # Endian.BIG or Endian.LITTLE + auto_block_ignore_readerror: bool | None = ( + None # if True or False, inserts a ignore_readerror statement for each block + ) + order16: int | None = None # Endian.BIG or Endian.LITTLE order32: int | None = None inverter_model: str = None def isAwake(self, datadict): - return True # always awake by default + return True # always awake by default def wakeupButton(self): - return None # no wakeup button + return None # no wakeup button async def async_determineInverterType(self, hub, configdict): return 0 @@ -153,10 +155,10 @@ async def async_determineInverterType(self, hub, configdict): async def async_determineInverterData(self, hub, configdict): return False - def matchInverterWithMask (self, inverterspec, entitymask, serialnumber = 'not relevant', blacklist = None): + def matchInverterWithMask(self, inverterspec, entitymask, serialnumber="not relevant", blacklist=None): return False - def localDataCallback(self, hub): # called when local data is updated or on startup + def localDataCallback(self, hub): # called when local data is updated or on startup return True def getModel(self, new_data): @@ -168,182 +170,291 @@ def getSoftwareVersion(self, new_data): def getHardwareVersion(self, new_data): return None + # =================================== base class for sensor entity descriptions ========================================= + @dataclass class BaseModbusSensorEntityDescription(SensorEntityDescription): - """ base class for modbus sensor declarations """ - allowedtypes: int = 0 # overload with ALLDEFAULT from plugin - scale: float = 1 # can be float, dictionary or callable function(initval, descr, datadict) - read_scale_exceptions: list = None # additional scaling when reading from modbus + """base class for modbus sensor declarations""" + + allowedtypes: int = 0 # overload with ALLDEFAULT from plugin + scale: float = 1 # can be float, dictionary or callable function(initval, descr, datadict) + read_scale_exceptions: list = None # additional scaling when reading from modbus read_scale: float = 1 blacklist: list = None - register: int = -1 # initialize with invalid register + register: int = -1 # initialize with invalid register rounding: int = 1 - register_type: int = None # REGISTER_HOLDING or REGISTER_INPUT or REG_DATA - unit: int = None # e.g. REGISTER_U16 - scan_group: int = None # <=0 -> default group - internal: bool = False # internal sensors are used for reading data only; used for computed, selects, etc - newblock: bool = False # set to True to start a new modbus read block operation - do not use frequently - #prevent_update: bool = False # if set to True, value will not be re-read/updated with each polling cycle; only when read value changes - value_function: callable = None # value = function(initval, descr, datadict) - wordcount: int = None # only for unit = REGISTER_STR and REGISTER_WORDS - sleepmode: int = SLEEPMODE_LAST # or SLEEPMODE_ZERO or SLEEPMODE_NONE - ignore_readerror: bool = False # if not False, ignore read errors for this block and return this static value - # A failing block read will be accepted as valid block if the first entity of the block contains a non-False ignore_readerror attribute. - # The other entitties of the block can also have an ignore_readerror attribute that determines the value returned upon failure - # so typically this attribute can be set to None or "Unknown" or any other value - # This only works if the first entity of a block contains this attribute - # When simply set to True, no initial value will be returned, but the block will be considered valid - value_series: int = None # if not None, the value is part of a series of values with similar properties - # The name and key must contain a placeholder {} that is replaced by the preceding number + register_type: int = None # REGISTER_HOLDING or REGISTER_INPUT or REG_DATA + unit: int = None # e.g. REGISTER_U16 + scan_group: int = None # <=0 -> default group + internal: bool = False # internal sensors are used for reading data only; used for computed, selects, etc + newblock: bool = False # set to True to start a new modbus read block operation - do not use frequently + # prevent_update: bool = False # if set to True, value will not be re-read/updated with each polling cycle; only when read value changes + value_function: callable = None # value = function(initval, descr, datadict) + wordcount: int = None # only for unit = REGISTER_STR and REGISTER_WORDS + sleepmode: int = SLEEPMODE_LAST # or SLEEPMODE_ZERO or SLEEPMODE_NONE + ignore_readerror: bool = False # if not False, ignore read errors for this block and return this static value + # A failing block read will be accepted as valid block if the first entity of the block contains a non-False ignore_readerror attribute. + # The other entitties of the block can also have an ignore_readerror attribute that determines the value returned upon failure + # so typically this attribute can be set to None or "Unknown" or any other value + # This only works if the first entity of a block contains this attribute + # When simply set to True, no initial value will be returned, but the block will be considered valid + value_series: int = None # if not None, the value is part of a series of values with similar properties + # The name and key must contain a placeholder {} that is replaced by the preceding number + @dataclass class BaseModbusButtonEntityDescription(ButtonEntityDescription): - allowedtypes: int = 0 # overload with ALLDEFAULT from plugin + allowedtypes: int = 0 # overload with ALLDEFAULT from plugin register: int = None command: int = None - blacklist: list = None # none or list of serial number prefixes - write_method: int = WRITE_SINGLE_MODBUS # WRITE_SINGLE_MOBUS or WRITE_MULTI_MODBUS or WRITE_DATA_LOCAL - value_function: callable = None # value = function(initval, descr, datadict) + blacklist: list = None # none or list of serial number prefixes + write_method: int = WRITE_SINGLE_MODBUS # WRITE_SINGLE_MOBUS or WRITE_MULTI_MODBUS or WRITE_DATA_LOCAL + value_function: callable = None # value = function(initval, descr, datadict) autorepeat: str = None # if not None: name of entity that contains autorepeat duration in seconds + @dataclass class BaseModbusSelectEntityDescription(SelectEntityDescription): - allowedtypes: int = 0 # overload with ALLDEFAULT from plugin + allowedtypes: int = 0 # overload with ALLDEFAULT from plugin register: int = None option_dict: dict = None - reverse_option_dict: dict = None # autocomputed - blacklist: list = None # none or list of serial number prefixes - write_method: int = WRITE_SINGLE_MODBUS # WRITE_SINGLE_MOBUS or WRITE_MULTI_MODBUS or WRITE_DATA_LOCAL - initvalue: int = None # initial default value for WRITE_DATA_LOCAL entities - unit: int = None # optional for WRITE_DATA_LOCAL e.g REGISTER_U16, REGISTER_S32 ... + reverse_option_dict: dict = None # autocomputed + blacklist: list = None # none or list of serial number prefixes + write_method: int = WRITE_SINGLE_MODBUS # WRITE_SINGLE_MOBUS or WRITE_MULTI_MODBUS or WRITE_DATA_LOCAL + initvalue: int = None # initial default value for WRITE_DATA_LOCAL entities + unit: int = None # optional for WRITE_DATA_LOCAL e.g REGISTER_U16, REGISTER_S32 ... + + +@dataclass +class BaseModbusSwitchEntityDescription(SwitchEntityDescription): + allowedtypes: int = 0 # overload with ALLDEFAULT from plugin + register: int = None + register_bit: int = None + blacklist: list = None # none or list of serial number prefixes + write_method: int = WRITE_SINGLE_MODBUS # WRITE_SINGLE_MOBUS or WRITE_MULTI_MODBUS or WRITE_DATA_LOCAL + initvalue: int = None # initial default value for WRITE_DATA_LOCAL entities + sensor_key: str = None # The associated sensor key + value_function: callable = None # Value function used to determine the new sensor value when the switch changes + @dataclass class BaseModbusNumberEntityDescription(NumberEntityDescription): - allowedtypes: int = 0 # overload with ALLDEFAULT from plugin + allowedtypes: int = 0 # overload with ALLDEFAULT from plugin register: int = None read_scale_exceptions: list = None read_scale: float = 1 fmt: str = None scale: float = 1 state: str = None - max_exceptions: list = None # None or list with structue [ ('U50EC' , 40,) ] - min_exceptions_minus: list = None # same structure as max_exceptions, values are applied with a minus - blacklist: list = None # None or list of serial number prefixes like - write_method: int = WRITE_SINGLE_MODBUS # WRITE_SINGLE_MOBUS or WRITE_MULTI_MODBUS or WRITE_DATA_LOCAL - initvalue: int = None # initial default value for WRITE_DATA_LOCAL entities - unit: int = None # optional for WRITE_DATA_LOCAL e.g REGISTER_U16, REGISTER_S32 ... - prevent_update: bool = False # if set to True, value will not be re-read/updated with each polling cycle; only when read value changes + max_exceptions: list = None # None or list with structue [ ('U50EC' , 40,) ] + min_exceptions_minus: list = None # same structure as max_exceptions, values are applied with a minus + blacklist: list = None # None or list of serial number prefixes like + write_method: int = WRITE_SINGLE_MODBUS # WRITE_SINGLE_MOBUS or WRITE_MULTI_MODBUS or WRITE_DATA_LOCAL + initvalue: int = None # initial default value for WRITE_DATA_LOCAL entities + unit: int = None # optional for WRITE_DATA_LOCAL e.g REGISTER_U16, REGISTER_S32 ... + prevent_update: bool = ( + False # if set to True, value will not be re-read/updated with each polling cycle; only when read value changes + ) # ========================= autorepeat aux functions to be used on hub.data dictionary =============================== + def autorepeat_set(datadict, entitykey, value): - datadict['_repeatUntil'][entitykey] = value + datadict["_repeatUntil"][entitykey] = value + def autorepeat_stop(datadict, entitykey): - datadict['_repeatUntil'][entitykey] = 0 + datadict["_repeatUntil"][entitykey] = 0 + def autorepeat_remaining(datadict, entitykey, timestamp): - remaining = datadict['_repeatUntil'].get(entitykey,0) - timestamp - return int(remaining) if remaining >0 else 0 + remaining = datadict["_repeatUntil"].get(entitykey, 0) - timestamp + return int(remaining) if remaining > 0 else 0 + # ================================= Computed sensor value functions ================================================= + def value_function_pv_power_total(initval, descr, datadict): - return datadict.get('pv_power_1', 0) + datadict.get('pv_power_2',0) + datadict.get('pv_power_3',0) + return datadict.get("pv_power_1", 0) + datadict.get("pv_power_2", 0) + datadict.get("pv_power_3", 0) + def value_function_battery_output(initval, descr, datadict): - val = datadict.get('battery_power_charge', 0) - if val<0: return abs(val) - else: return 0 + val = datadict.get("battery_power_charge", 0) + if val < 0: + return abs(val) + else: + return 0 + def value_function_battery_input(initval, descr, datadict): - val = datadict.get('battery_power_charge', 0) - if val>0: return val - else: return 0 + val = datadict.get("battery_power_charge", 0) + if val > 0: + return val + else: + return 0 + def value_function_battery_output_solis(initval, descr, datadict): - inout = datadict.get('battery_charge_direction', 0) - val = datadict.get('battery_power', 0) - if inout == 1: return abs(val) - else: return 0 + inout = datadict.get("battery_charge_direction", 0) + val = datadict.get("battery_power", 0) + if inout == 1: + return abs(val) + else: + return 0 + def value_function_battery_input_solis(initval, descr, datadict): - inout = datadict.get('battery_charge_direction', 0) - val = datadict.get('battery_power', 0) - if inout == 0: return val - else: return 0 + inout = datadict.get("battery_charge_direction", 0) + val = datadict.get("battery_power", 0) + if inout == 0: + return val + else: + return 0 + def value_function_grid_import(initval, descr, datadict): - val = datadict.get('measured_power', 0) - if val<0: return abs(val) - else: return 0 + val = datadict.get("measured_power", 0) + if val < 0: + return abs(val) + else: + return 0 + def value_function_grid_export(initval, descr, datadict): - val = datadict.get('measured_power', 0) - if val>0: return val - else: return 0 + val = datadict.get("measured_power", 0) + if val > 0: + return val + else: + return 0 + def value_function_sync_rtc(initval, descr, datadict): now = datetime.now() - return [ (REGISTER_U16, now.second, ), - (REGISTER_U16, now.minute, ), - (REGISTER_U16, now.hour, ), - (REGISTER_U16, now.day, ), - (REGISTER_U16, now.month, ), - (REGISTER_U16, now.year % 100, ), - ] + return [ + ( + REGISTER_U16, + now.second, + ), + ( + REGISTER_U16, + now.minute, + ), + ( + REGISTER_U16, + now.hour, + ), + ( + REGISTER_U16, + now.day, + ), + ( + REGISTER_U16, + now.month, + ), + ( + REGISTER_U16, + now.year % 100, + ), + ] + def value_function_sync_rtc_ymd(initval, descr, datadict): - offset = datadict.get('sync_rtc_offset', 0) + offset = datadict.get("sync_rtc_offset", 0) if isinstance(offset, float) or isinstance(offset, int): now = datetime.now() + timedelta(seconds=offset) else: now = datetime.now() - return [ (REGISTER_U16, now.year % 100, ), - (REGISTER_U16, now.month, ), - (REGISTER_U16, now.day, ), - (REGISTER_U16, now.hour, ), - (REGISTER_U16, now.minute, ), - (REGISTER_U16, now.second, ), - ] + return [ + ( + REGISTER_U16, + now.year % 100, + ), + ( + REGISTER_U16, + now.month, + ), + ( + REGISTER_U16, + now.day, + ), + ( + REGISTER_U16, + now.hour, + ), + ( + REGISTER_U16, + now.minute, + ), + ( + REGISTER_U16, + now.second, + ), + ] + def value_function_rtc(initval, descr, datadict): try: - (rtc_seconds, rtc_minutes, rtc_hours, rtc_days, rtc_months, rtc_years, ) = initval + ( + rtc_seconds, + rtc_minutes, + rtc_hours, + rtc_days, + rtc_months, + rtc_years, + ) = initval val = f"{rtc_days:02}/{rtc_months:02}/{rtc_years:02} {rtc_hours:02}:{rtc_minutes:02}:{rtc_seconds:02}" - return datetime.strptime(val, '%d/%m/%y %H:%M:%S') # ok since sensor.py has been adapted - except: pass + return datetime.strptime(val, "%d/%m/%y %H:%M:%S") # ok since sensor.py has been adapted + except: + pass + def value_function_rtc_ymd(initval, descr, datadict): try: - (rtc_years, rtc_months, rtc_days, rtc_hours, rtc_minutes, rtc_seconds, ) = initval + ( + rtc_years, + rtc_months, + rtc_days, + rtc_hours, + rtc_minutes, + rtc_seconds, + ) = initval val = f"{rtc_days:02}/{rtc_months:02}/{rtc_years:02} {rtc_hours:02}:{rtc_minutes:02}:{rtc_seconds:02}" - return datetime.strptime(val, '%d/%m/%y %H:%M:%S') # ok since sensor.py has been adapted - except: pass + return datetime.strptime(val, "%d/%m/%y %H:%M:%S") # ok since sensor.py has been adapted + except: + pass + def value_function_gen4time(initval, descr, datadict): h = initval % 256 m = initval >> 8 return f"{h:02d}:{m:02d}" + def value_function_gen23time(initval, descr, datadict): - (h,m,) = initval + ( + h, + m, + ) = initval return f"{h:02d}:{m:02d}" + def value_function_sofartime(initval, descr, datadict): m = initval % 256 h = initval >> 8 return f"{h:02d}:{m:02d}" + def value_function_firmware(initval, descr, datadict): m = initval % 256 h = initval >> 8 return f"{h}.{m:02d}" + def value_function_2byte_timestamp(initval, descr, datadict): # Real-time data timestamp # Bit0-5: second, range 0-59 @@ -365,21 +476,34 @@ def value_function_2byte_timestamp(initval, descr, datadict): initval = initval >> 4 year = initval & 0b111111 val = f"{day:02}/{month:02}/{year:02} {hour:02}:{minute:02}:{second:02}" - return datetime.strptime(val, '%d/%m/%y %H:%M:%S') - except: # noqa: E722 + return datetime.strptime(val, "%d/%m/%y %H:%M:%S") + except: # noqa: E722 pass + # ================================= Computed Time Values ================================================= -TIME_OPTIONS = { } -TIME_OPTIONS_GEN4 = { } -for h in range(0,24): +TIME_OPTIONS = {} +TIME_OPTIONS_GEN4 = {} +for h in range(0, 24): for m in range(0, 60, 5): - TIME_OPTIONS[m*256+h] = f"{h:02}:{m:02}" - TIME_OPTIONS_GEN4[h*256+m] = f"{h:02}:{m:02}" - if (h, m,) == (0, 0,): # add extra entry 00:01 - TIME_OPTIONS[1*256+h] = f"{h:02}:{m+1:02}" - TIME_OPTIONS_GEN4[h*256+1] = f"{h:02}:{m+1:02}" - if (h, m,) == (23, 55,): # add extra entry 23:59 - TIME_OPTIONS[(m+4)*256+h] = f"{h:02}:{m+4:02}" - TIME_OPTIONS_GEN4[h*256+m+4] = f"{h:02}:{m+4:02}" + TIME_OPTIONS[m * 256 + h] = f"{h:02}:{m:02}" + TIME_OPTIONS_GEN4[h * 256 + m] = f"{h:02}:{m:02}" + if ( + h, + m, + ) == ( + 0, + 0, + ): # add extra entry 00:01 + TIME_OPTIONS[1 * 256 + h] = f"{h:02}:{m+1:02}" + TIME_OPTIONS_GEN4[h * 256 + 1] = f"{h:02}:{m+1:02}" + if ( + h, + m, + ) == ( + 23, + 55, + ): # add extra entry 23:59 + TIME_OPTIONS[(m + 4) * 256 + h] = f"{h:02}:{m+4:02}" + TIME_OPTIONS_GEN4[h * 256 + m + 4] = f"{h:02}:{m+4:02}" diff --git a/custom_components/solax_modbus/number.py b/custom_components/solax_modbus/number.py index dcbcce13..575632cb 100644 --- a/custom_components/solax_modbus/number.py +++ b/custom_components/solax_modbus/number.py @@ -1,6 +1,7 @@ from .const import ATTR_MANUFACTURER, DOMAIN, CONF_MODBUS_ADDR, DEFAULT_MODBUS_ADDR from .const import WRITE_DATA_LOCAL, WRITE_MULTISINGLE_MODBUS, WRITE_SINGLE_MODBUS, TMPDATA_EXPIRY -#from .const import GEN2, GEN3, GEN4, X1, X3, HYBRID, AC, EPS + +# from .const import GEN2, GEN3, GEN4, X1, X3, HYBRID, AC, EPS from homeassistant.components.number import PLATFORM_SCHEMA, NumberEntity from homeassistant.const import CONF_NAME from homeassistant.core import callback @@ -11,16 +12,17 @@ _LOGGER = logging.getLogger(__name__) + async def async_setup_entry(hass, entry, async_add_entities) -> None: - if entry.data: # old style - remove soon + if entry.data: # old style - remove soon hub_name = entry.data[CONF_NAME] modbus_addr = entry.data.get(CONF_MODBUS_ADDR, DEFAULT_MODBUS_ADDR) - else: # new style + else: # new style hub_name = entry.options[CONF_NAME] modbus_addr = entry.options.get(CONF_MODBUS_ADDR, DEFAULT_MODBUS_ADDR) hub = hass.data[DOMAIN][hub_name]["hub"] - plugin = hub.plugin #getPlugin(hub_name) + plugin = hub.plugin # getPlugin(hub_name) inverter_name_suffix = "" if hub.inverterNameSuffix is not None and hub.inverterNameSuffix != "": inverter_name_suffix = hub.inverterNameSuffix + " " @@ -29,27 +31,37 @@ async def async_setup_entry(hass, entry, async_add_entities) -> None: for number_info in plugin.NUMBER_TYPES: newdescr = number_info if number_info.read_scale_exceptions: - for (prefix, value,) in number_info.read_scale_exceptions: - if hub.seriesnumber.startswith(prefix): newdescr = replace(number_info, read_scale = value) - if plugin.matchInverterWithMask(hub._invertertype,newdescr.allowedtypes, hub.seriesnumber ,newdescr.blacklist): - if not (newdescr.name.startswith(inverter_name_suffix)): newdescr.name = inverter_name_suffix + newdescr.name - number = SolaXModbusNumber( hub_name, hub, modbus_addr, hub.device_info, newdescr) - if newdescr.write_method==WRITE_DATA_LOCAL: hub.writeLocals[newdescr.key] = newdescr + for ( + prefix, + value, + ) in number_info.read_scale_exceptions: + if hub.seriesnumber.startswith(prefix): + newdescr = replace(number_info, read_scale=value) + if plugin.matchInverterWithMask( + hub._invertertype, newdescr.allowedtypes, hub.seriesnumber, newdescr.blacklist + ): + if not (newdescr.name.startswith(inverter_name_suffix)): + newdescr.name = inverter_name_suffix + newdescr.name + number = SolaXModbusNumber(hub_name, hub, modbus_addr, hub.device_info, newdescr) + if newdescr.write_method == WRITE_DATA_LOCAL: + hub.writeLocals[newdescr.key] = newdescr hub.numberEntities[newdescr.key] = number entities.append(number) async_add_entities(entities) return True + class SolaXModbusNumber(NumberEntity): """Representation of an SolaX Modbus number.""" - def __init__(self, - platform_name, - hub, - modbus_addr, - device_info, - number_info, - # read_scale + def __init__( + self, + platform_name, + hub, + modbus_addr, + device_info, + number_info, + # read_scale ) -> None: """Initialize the number.""" self._platform_name = platform_name @@ -66,14 +78,22 @@ def __init__(self, self._attr_scale = number_info.scale self.entity_description = number_info if number_info.max_exceptions: - for (prefix, native_value,) in number_info.max_exceptions: - if hub.seriesnumber.startswith(prefix): self._attr_native_max_value = native_value + for ( + prefix, + native_value, + ) in number_info.max_exceptions: + if hub.seriesnumber.startswith(prefix): + self._attr_native_max_value = native_value if number_info.min_exceptions_minus: - for (prefix, native_value,) in number_info.min_exceptions_minus: - if hub.seriesnumber.startswith(prefix): self._attr_native_min_value = -native_value + for ( + prefix, + native_value, + ) in number_info.min_exceptions_minus: + if hub.seriesnumber.startswith(prefix): + self._attr_native_min_value = -native_value self._attr_native_step = number_info.native_step self._attr_native_unit_of_measurement = number_info.native_unit_of_measurement - self._state = number_info.state # not used AFAIK + self._state = number_info.state # not used AFAIK self.entity_description = number_info self._write_method = number_info.write_method @@ -98,7 +118,6 @@ def name(self) -> str: """Return the name.""" return f"{self._platform_name} {self._name}" - @property def unique_id(self) -> Optional[str]: return f"{self._platform_name}_{self._key}" @@ -107,58 +126,69 @@ def unique_id(self) -> Optional[str]: def native_value(self) -> float: descr = self.entity_description if descr.prevent_update: - if (self._hub.tmpdata_expiry.get(descr.key, 0) > time()): + if self._hub.tmpdata_expiry.get(descr.key, 0) > time(): val = self._hub.tmpdata.get(descr.key, None) if val == None: _LOGGER.warning(f"cannot find tmpdata for {descr.key} - setting value to zero") val = 0 - if (descr.read_scale and self._hub.tmpdata[self._key]): res = val*descr.read_scale - else: res = val - #_LOGGER.debug(f"prevent_update returning native value {descr.key} : {res}") + if descr.read_scale and self._hub.tmpdata[self._key]: + res = val * descr.read_scale + else: + res = val + # _LOGGER.debug(f"prevent_update returning native value {descr.key} : {res}") return res - else: # expired - if self._hub.tmpdata_expiry.get(descr.key, 0) > 0: self._hub.localsUpdated = True - self._hub.tmpdata_expiry[descr.key] = 0 # update locals only once + else: # expired + if self._hub.tmpdata_expiry.get(descr.key, 0) > 0: + self._hub.localsUpdated = True + self._hub.tmpdata_expiry[descr.key] = 0 # update locals only once if self._key in self._hub.data: - try: val = self._hub.data[self._key]*descr.read_scale - except: val = self._hub.data[self._key] + try: + val = self._hub.data[self._key] * descr.read_scale + except: + val = self._hub.data[self._key] return val - else: # first time initialize - if descr.initvalue == None: return None + else: # first time initialize + if descr.initvalue == None: + return None else: res = descr.initvalue - if self._attr_native_max_value != None: res = min(res, self._attr_native_max_value) - if self._attr_native_min_value != None: res = max(res, self._attr_native_min_value) + if self._attr_native_max_value != None: + res = min(res, self._attr_native_max_value) + if self._attr_native_min_value != None: + res = max(res, self._attr_native_min_value) self._hub.data[self._key] = res - #_LOGGER.warning(f"****** (debug) initializing {self._key} = {res}") + # _LOGGER.warning(f"****** (debug) initializing {self._key} = {res}") return res - async def async_set_native_value(self, value: float) -> None: """Change the number value.""" payload = value if self._fmt == "i": - payload = int(value/(self._attr_scale*self.entity_description.read_scale)) + payload = int(value / (self._attr_scale * self.entity_description.read_scale)) elif self._fmt == "f": - payload = int(value/(self._attr_scale*self.entity_description.read_scale)) + payload = int(value / (self._attr_scale * self.entity_description.read_scale)) if self._write_method == WRITE_MULTISINGLE_MODBUS: - _LOGGER.info(f"writing {self._platform_name} {self._key} number register {self._register} value {payload} after div by readscale {self.entity_description.read_scale} scale {self._attr_scale}") + _LOGGER.info( + f"writing {self._platform_name} {self._key} number register {self._register} value {payload} after div by readscale {self.entity_description.read_scale} scale {self._attr_scale}" + ) await self._hub.async_write_registers_single( unit=self._modbus_addr, address=self._register, payload=payload ) elif self._write_method == WRITE_SINGLE_MODBUS: - _LOGGER.info(f"writing {self._platform_name} {self._key} number register {self._register} value {payload} after div by readscale {self.entity_description.read_scale} scale {self._attr_scale}") - await self._hub.async_write_register( - unit=self._modbus_addr, address=self._register, payload=payload + _LOGGER.info( + f"writing {self._platform_name} {self._key} number register {self._register} value {payload} after div by readscale {self.entity_description.read_scale} scale {self._attr_scale}" ) + await self._hub.async_write_register(unit=self._modbus_addr, address=self._register, payload=payload) elif self._write_method == WRITE_DATA_LOCAL: _LOGGER.info(f"*** local data written {self._key}: {payload}") - #corresponding_sensor = self._hub.preventSensors.get(self.entity_description.key, None) - if self.entity_description.prevent_update: # if corresponding_sensor: # only if corresponding sensor has prevent_update=True + # corresponding_sensor = self._hub.preventSensors.get(self.entity_description.key, None) + if ( + self.entity_description.prevent_update + ): # if corresponding_sensor: # only if corresponding sensor has prevent_update=True self._hub.tmpdata[self.entity_description.key] = payload self._hub.tmpdata_expiry[self.entity_description.key] = time() + TMPDATA_EXPIRY # corresponding_sensor.async_write_ha_state() - self._hub.localsUpdated = True # mark to save permanently - self._hub.data[self._key] = value/self.entity_description.read_scale - #_LOGGER.info(f"*** data written part 2 {self._key}: {self._hub.data[self._key]}") - self.async_write_ha_state() # is this needed ? + self._hub.localsUpdated = True # mark to save permanently + self._hub.data[self._key] = value / self.entity_description.read_scale + # _LOGGER.info(f"*** data written part 2 {self._key}: {self._hub.data[self._key]}") + self.async_write_ha_state() # is this needed ? diff --git a/custom_components/solax_modbus/plugin_alphaess.py b/custom_components/solax_modbus/plugin_alphaess.py index 185ee69d..0f586700 100644 --- a/custom_components/solax_modbus/plugin_alphaess.py +++ b/custom_components/solax_modbus/plugin_alphaess.py @@ -20,41 +20,41 @@ An entity can be declared multiple times (with different bitmasks) if the parameters are different for each inverter type """ -GEN = 0x0001 # base generation for MIC, PV, AC -GEN2 = 0x0002 -GEN3 = 0x0004 -GEN4 = 0x0008 -GEN5 = 0x0010 -ALL_GEN_GROUP = GEN2 | GEN3 | GEN4 | GEN5 | GEN +GEN = 0x0001 # base generation for MIC, PV, AC +GEN2 = 0x0002 +GEN3 = 0x0004 +GEN4 = 0x0008 +GEN5 = 0x0010 +ALL_GEN_GROUP = GEN2 | GEN3 | GEN4 | GEN5 | GEN -X1 = 0x0100 -X3 = 0x0200 -ALL_X_GROUP = X1 | X3 +X1 = 0x0100 +X3 = 0x0200 +ALL_X_GROUP = X1 | X3 -PV = 0x0400 # Needs further work on PV Only Inverters -AC = 0x0800 -HYBRID = 0x1000 -MIC = 0x2000 -MAX = 0x4000 +PV = 0x0400 # Needs further work on PV Only Inverters +AC = 0x0800 +HYBRID = 0x1000 +MIC = 0x2000 +MAX = 0x4000 ALL_TYPE_GROUP = PV | AC | HYBRID | MIC | MAX -EPS = 0x8000 -ALL_EPS_GROUP = EPS +EPS = 0x8000 +ALL_EPS_GROUP = EPS -DCB = 0x10000 # dry contact box - gen4 -ALL_DCB_GROUP = DCB +DCB = 0x10000 # dry contact box - gen4 +ALL_DCB_GROUP = DCB -PM = 0x20000 +PM = 0x20000 ALL_PM_GROUP = PM -MPPT3 = 0x40000 -MPPT4 = 0x80000 -MPPT5 = 0x100000 -MPPT6 = 0x200000 -MPPT10 = 0x400000 +MPPT3 = 0x40000 +MPPT4 = 0x80000 +MPPT5 = 0x100000 +MPPT6 = 0x200000 +MPPT10 = 0x400000 ALL_MPPT_GROUP = MPPT3 | MPPT4 | MPPT5 | MPPT6 | MPPT10 -ALLDEFAULT = 0 # should be equivalent to AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5 | X1 | X3 +ALLDEFAULT = 0 # should be equivalent to AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5 | X1 | X3 # ======================= end of bitmask handling code ============================================= @@ -62,6 +62,7 @@ # ====================== find inverter type and details =========================================== + async def async_read_serialnr(hub, address): res = None inverter_data = None @@ -71,31 +72,43 @@ async def async_read_serialnr(hub, address): decoder = BinaryPayloadDecoder.fromRegisters(inverter_data.registers, byteorder=Endian.BIG) res = decoder.decode_string(20).decode("ascii") hub.seriesnumber = res - except Exception as ex: _LOGGER.warning(f"{hub.name}: attempt to read serialnumber failed at 0x{address:x} data: {inverter_data}", exc_info=True) - if not res: _LOGGER.warning(f"{hub.name}: reading serial number from address 0x{address:x} failed; other address may succeed") + except Exception as ex: + _LOGGER.warning( + f"{hub.name}: attempt to read serialnumber failed at 0x{address:x} data: {inverter_data}", exc_info=True + ) + if not res: + _LOGGER.warning( + f"{hub.name}: reading serial number from address 0x{address:x} failed; other address may succeed" + ) _LOGGER.info(f"Read {hub.name} 0x{address:x} serial number: {res}") return res + # ================================================================================================= + @dataclass class AlphaESSModbusButtonEntityDescription(BaseModbusButtonEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class AlphaESSModbusNumberEntityDescription(BaseModbusNumberEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class AlphaESSModbusSelectEntityDescription(BaseModbusSelectEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class AlphaESSModbusSensorEntityDescription(BaseModbusSensorEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice unit: int = REGISTER_U16 register_type: int = REG_HOLDING + # ====================================== Computed value functions ================================================= # ================================= Button Declarations ============================================================ @@ -111,221 +124,221 @@ class AlphaESSModbusSensorEntityDescription(BaseModbusSensorEntityDescription): EXPORT_LIMIT_SCALE_EXCEPTIONS = [] NUMBER_TYPES = [ - AlphaESSModbusNumberEntityDescription( - name = "Discharge Minimum SOC", - key = "discharge_minimum_soc", - register = 0x850, - fmt = "i", - native_min_value = 10, - native_max_value = 99, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = GEN, - icon = "mdi:battery-sync", + AlphaESSModbusNumberEntityDescription( + name="Discharge Minimum SOC", + key="discharge_minimum_soc", + register=0x850, + fmt="i", + native_min_value=10, + native_max_value=99, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=GEN, + icon="mdi:battery-sync", ), AlphaESSModbusNumberEntityDescription( - name = "Discharge Start 1 Hours", - key = "discharge_start_1_hours", - register = 0x851, - fmt = "i", - native_min_value = 0, - native_max_value = 23, - native_step = 1, - native_unit_of_measurement = UnitOfTime.HOURS, - allowedtypes = GEN, - icon = "mdi:battery-clock", + name="Discharge Start 1 Hours", + key="discharge_start_1_hours", + register=0x851, + fmt="i", + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=GEN, + icon="mdi:battery-clock", ), AlphaESSModbusNumberEntityDescription( - name = "Discharge Stop 1 Hours", - key = "discharge_stop_1_hours", - register = 0x852, - fmt = "i", - native_min_value = 0, - native_max_value = 23, - native_step = 1, - native_unit_of_measurement = UnitOfTime.HOURS, - allowedtypes = GEN, - icon = "mdi:battery-clock", + name="Discharge Stop 1 Hours", + key="discharge_stop_1_hours", + register=0x852, + fmt="i", + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=GEN, + icon="mdi:battery-clock", ), AlphaESSModbusNumberEntityDescription( - name = "Discharge Start 2 Hours", - key = "discharge_start_2_hours", - register = 0x853, - fmt = "i", - native_min_value = 0, - native_max_value = 23, - native_step = 1, - native_unit_of_measurement = UnitOfTime.HOURS, - allowedtypes = GEN, - icon = "mdi:battery-clock", + name="Discharge Start 2 Hours", + key="discharge_start_2_hours", + register=0x853, + fmt="i", + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=GEN, + icon="mdi:battery-clock", ), AlphaESSModbusNumberEntityDescription( - name = "Discharge Stop 2 Hours", - key = "discharge_stop_2_hours", - register = 0x854, - fmt = "i", - native_min_value = 0, - native_max_value = 23, - native_step = 1, - native_unit_of_measurement = UnitOfTime.HOURS, - allowedtypes = GEN, - icon = "mdi:battery-clock", + name="Discharge Stop 2 Hours", + key="discharge_stop_2_hours", + register=0x854, + fmt="i", + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=GEN, + icon="mdi:battery-clock", ), AlphaESSModbusNumberEntityDescription( - name = "Charge Target SOC", - key = "charge_target_soc", - register = 0x855, - fmt = "i", - native_min_value = 10, - native_max_value = 99, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = GEN, - icon = "mdi:battery-sync", + name="Charge Target SOC", + key="charge_target_soc", + register=0x855, + fmt="i", + native_min_value=10, + native_max_value=99, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=GEN, + icon="mdi:battery-sync", ), AlphaESSModbusNumberEntityDescription( - name = "Charge Start 1 Hours", - key = "charge_start_1_hours", - register = 0x856, - fmt = "i", - native_min_value = 0, - native_max_value = 23, - native_step = 1, - native_unit_of_measurement = UnitOfTime.HOURS, - allowedtypes = GEN, - icon = "mdi:battery-clock", + name="Charge Start 1 Hours", + key="charge_start_1_hours", + register=0x856, + fmt="i", + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=GEN, + icon="mdi:battery-clock", ), AlphaESSModbusNumberEntityDescription( - name = "Charge Stop 1 Hours", - key = "charge_stop_1_hours", - register = 0x857, - fmt = "i", - native_min_value = 0, - native_max_value = 23, - native_step = 1, - native_unit_of_measurement = UnitOfTime.HOURS, - allowedtypes = GEN, - icon = "mdi:battery-clock", + name="Charge Stop 1 Hours", + key="charge_stop_1_hours", + register=0x857, + fmt="i", + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=GEN, + icon="mdi:battery-clock", ), AlphaESSModbusNumberEntityDescription( - name = "Charge Start 2 Hours", - key = "charge_start_2_hours", - register = 0x858, - fmt = "i", - native_min_value = 0, - native_max_value = 23, - native_step = 1, - native_unit_of_measurement = UnitOfTime.HOURS, - allowedtypes = GEN, - icon = "mdi:battery-clock", + name="Charge Start 2 Hours", + key="charge_start_2_hours", + register=0x858, + fmt="i", + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=GEN, + icon="mdi:battery-clock", ), AlphaESSModbusNumberEntityDescription( - name = "Charge Stop 2 Hours", - key = "charge_stop_2_hours", - register = 0x859, - fmt = "i", - native_min_value = 0, - native_max_value = 23, - native_step = 1, - native_unit_of_measurement = UnitOfTime.HOURS, - allowedtypes = GEN, - icon = "mdi:battery-clock", + name="Charge Stop 2 Hours", + key="charge_stop_2_hours", + register=0x859, + fmt="i", + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=GEN, + icon="mdi:battery-clock", ), AlphaESSModbusNumberEntityDescription( - name = "Discharge Start 1 Mins", - key = "discharge_start_1_mins", - register = 0x85A, - fmt = "i", - native_min_value = 0, - native_max_value = 59, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = GEN, - icon = "mdi:battery-clock", + name="Discharge Start 1 Mins", + key="discharge_start_1_mins", + register=0x85A, + fmt="i", + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=GEN, + icon="mdi:battery-clock", ), AlphaESSModbusNumberEntityDescription( - name = "Discharge Stop 1 Mins", - key = "discharge_stop_1_mins", - register = 0x85B, - fmt = "i", - native_min_value = 0, - native_max_value = 59, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = GEN, - icon = "mdi:battery-clock", + name="Discharge Stop 1 Mins", + key="discharge_stop_1_mins", + register=0x85B, + fmt="i", + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=GEN, + icon="mdi:battery-clock", ), AlphaESSModbusNumberEntityDescription( - name = "Discharge Start 2 Mins", - key = "discharge_start_2_mins", - register = 0x85C, - fmt = "i", - native_min_value = 0, - native_max_value = 59, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = GEN, - icon = "mdi:battery-clock", + name="Discharge Start 2 Mins", + key="discharge_start_2_mins", + register=0x85C, + fmt="i", + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=GEN, + icon="mdi:battery-clock", ), AlphaESSModbusNumberEntityDescription( - name = "Discharge Stop 2 Mins", - key = "discharge_stop_2_mins", - register = 0x85D, - fmt = "i", - native_min_value = 0, - native_max_value = 59, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = GEN, - icon = "mdi:battery-clock", + name="Discharge Stop 2 Mins", + key="discharge_stop_2_mins", + register=0x85D, + fmt="i", + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=GEN, + icon="mdi:battery-clock", ), AlphaESSModbusNumberEntityDescription( - name = "Charge Start 1 Mins", - key = "charge_start_1_mins", - register = 0x85E, - fmt = "i", - native_min_value = 0, - native_max_value = 59, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = GEN, - icon = "mdi:battery-clock", + name="Charge Start 1 Mins", + key="charge_start_1_mins", + register=0x85E, + fmt="i", + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=GEN, + icon="mdi:battery-clock", ), AlphaESSModbusNumberEntityDescription( - name = "Charge Stop 1 Mins", - key = "charge_stop_1_mins", - register = 0x85F, - fmt = "i", - native_min_value = 0, - native_max_value = 59, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = GEN, - icon = "mdi:battery-clock", + name="Charge Stop 1 Mins", + key="charge_stop_1_mins", + register=0x85F, + fmt="i", + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=GEN, + icon="mdi:battery-clock", ), AlphaESSModbusNumberEntityDescription( - name = "Charge Start 2 Mins", - key = "charge_start_2_mins", - register = 0x860, - fmt = "i", - native_min_value = 0, - native_max_value = 59, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = GEN, - icon = "mdi:battery-clock", + name="Charge Start 2 Mins", + key="charge_start_2_mins", + register=0x860, + fmt="i", + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=GEN, + icon="mdi:battery-clock", ), AlphaESSModbusNumberEntityDescription( - name = "Charge Stop 2 Mins", - key = "charge_stop_2_mins", - register = 0x861, - fmt = "i", - native_min_value = 0, - native_max_value = 59, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = GEN, - icon = "mdi:battery-clock", + name="Charge Stop 2 Mins", + key="charge_stop_2_mins", + register=0x861, + fmt="i", + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=GEN, + icon="mdi:battery-clock", ), ] @@ -333,780 +346,794 @@ class AlphaESSModbusSensorEntityDescription(BaseModbusSensorEntityDescription): SELECT_TYPES = [ AlphaESSModbusSelectEntityDescription( - name = "System Mode", - key = "system_mode", - register = 0x805, - option_dict = { - 0: "AC Mode", - 1: "DC Mode", - 2: "Hybrid Mode", - }, - allowedtypes = GEN, - icon = "mdi:dip-switch", + name="System Mode", + key="system_mode", + register=0x805, + option_dict={ + 0: "AC Mode", + 1: "DC Mode", + 2: "Hybrid Mode", + }, + allowedtypes=GEN, + icon="mdi:dip-switch", ), AlphaESSModbusSelectEntityDescription( - name = "3Phase Unbalance Mode", - key = "3phase_unbalance_mode", - register = 0x811, - option_dict = { - 0: "Disabled", - 1: "Enabled", - }, - allowedtypes = GEN | X3, - icon = "mdi:dip-switch", + name="3Phase Unbalance Mode", + key="3phase_unbalance_mode", + register=0x811, + option_dict={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=GEN | X3, + icon="mdi:dip-switch", ), AlphaESSModbusSelectEntityDescription( - name = "Time Preiod Control", - key = "time_preiod_control", - register = 0x84F, - option_dict = { - 0: "Disabled", - 1: "Charge - Enabled", - 2: "Discharge - Enabled", - 3: "Both - Enabled", - }, - allowedtypes = GEN, - icon = "mdi:dip-switch", + name="Time Preiod Control", + key="time_preiod_control", + register=0x84F, + option_dict={ + 0: "Disabled", + 1: "Charge - Enabled", + 2: "Discharge - Enabled", + 3: "Both - Enabled", + }, + allowedtypes=GEN, + icon="mdi:dip-switch", ), ] # ================================= Sennsor Declarations ============================================================ SENSOR_TYPES_MAIN: list[AlphaESSModbusSensorEntityDescription] = [ -##### -# -# Holding Registers -# -##### - AlphaESSModbusSensorEntityDescription( - name = "Grid Voltage", - key = "grid_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x14, - allowedtypes = GEN | X1, - ), - AlphaESSModbusSensorEntityDescription( - name = "Grid Voltage L1", - key = "grid_voltage_l1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x14, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "Grid Voltage L2", - key = "grid_voltage_l2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x15, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "Grid Voltage L3", - key = "grid_voltage_l3", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x16, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "Grid Current", - key = "grid_current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x17, - scale = 0.1, - rounding = 1, - allowedtypes = GEN | X1, - ), - AlphaESSModbusSensorEntityDescription( - name = "Grid Current L1", - key = "grid_current_l1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x17, - scale = 0.1, - rounding = 1, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "Grid Current L2", - key = "grid_current_l2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x18, - scale = 0.1, - rounding = 1, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "Grid Current L3", - key = "grid_current_l3", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x19, - scale = 0.1, - rounding = 1, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "Grid Frequency", - key = "grid_frequency", - native_unit_of_measurement = UnitOfFrequency.HERTZ, - state_class = SensorStateClass.MEASUREMENT, - register = 0x1A, - scale = 0.01, - rounding = 2, - allowedtypes = GEN, - ), - AlphaESSModbusSensorEntityDescription( - name = "Active Power Energy", - key = "active_power_energy", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x21, - unit = REGISTER_S32, - allowedtypes = GEN, - ), - AlphaESSModbusSensorEntityDescription( - name = "Reactive Power", - key = "reactive_power", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x29, - unit = REGISTER_S32, - allowedtypes = MAX | GEN2, - ), - AlphaESSModbusSensorEntityDescription( - name = "Battery Voltage", - key = "battery_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x100, - scale = 0.1, - unit = REGISTER_S16, - allowedtypes = GEN, - ), - AlphaESSModbusSensorEntityDescription( - name = "Battery Current", - key = "battery_current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x101, - scale = 0.1, - unit = REGISTER_S16, - allowedtypes = HYBRID | GEN2, - icon = "mdi:current-dc", - ), - AlphaESSModbusSensorEntityDescription( - name = "Battery SOC", - key = "battery_soc", - native_unit_of_measurement = PERCENTAGE, - device_class = SensorDeviceClass.BATTERY, - register = 0x102, - allowedtypes = GEN, - ), - AlphaESSModbusSensorEntityDescription( - name = "Battery Capacity", - key = "battery_capacity", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - register = 0x119, - scale = 0.1, - allowedtypes = GEN, - ), - AlphaESSModbusSensorEntityDescription( - name = "Battery Input Energy", - key = "battery_input_energy", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - icon = "mdi:battery-arrow-up", - register = 0x120, - unit = REGISTER_U32, - scale = 0.1, - allowedtypes = GEN, - ), - AlphaESSModbusSensorEntityDescription( - name = "Battery Output Energy", - key = "battery_output_energy", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - icon = "mdi:battery-arrow-down", - register = 0x122, - unit = REGISTER_U32, - scale = 0.1, - allowedtypes = GEN, - ), - AlphaESSModbusSensorEntityDescription( - name = "Inverter Voltage", - key = "inverter_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x400, - allowedtypes = GEN | X1, - ), - AlphaESSModbusSensorEntityDescription( - name = "Inverter Voltage L1", - key = "inverter_voltage_l1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x400, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "Inverter Voltage L2", - key = "inverter_voltage_l2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x401, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "Inverter Voltage L3", - key = "inverter_voltage_l3", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x402, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "Inverter Current", - key = "inverter_current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x403, - scale = 0.1, - rounding = 1, - allowedtypes = GEN | X1, - ), - AlphaESSModbusSensorEntityDescription( - name = "Inverter Current L1", - key = "inverter_current_l1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x403, - scale = 0.1, - rounding = 1, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "Inverter Current L2", - key = "inverter_current_l2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x404, - scale = 0.1, - rounding = 1, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "Inverter Current L3", - key = "inverter_current_l3", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x405, - scale = 0.1, - rounding = 1, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "Inverter Power L1", - key = "inverter_power_l1", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x406, - unit = REGISTER_S32, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "Inverter Power L2", - key = "inverter_power_l2", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x408, - unit = REGISTER_S32, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "Inverter Power L3", - key = "inverter_power_l3", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x40A, - unit = REGISTER_S32, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "Inverter Power", - key = "inverter_power", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x40C, - unit = REGISTER_S32, - allowedtypes = GEN, - ), - AlphaESSModbusSensorEntityDescription( - name = "EPS Voltage", - key = "eps_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x40E, - allowedtypes = GEN | X1, - ), - AlphaESSModbusSensorEntityDescription( - name = "EPS Voltage L1", - key = "eps_voltage_l1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x40E, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "EPS Voltage L2", - key = "eps_voltage_l2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x40F, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "EPS Voltage L3", - key = "eps_voltage_l3", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x410, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "EPS Current", - key = "eps_current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x411, - scale = 0.1, - rounding = 1, - allowedtypes = GEN | X1, - ), - AlphaESSModbusSensorEntityDescription( - name = "EPS Current L1", - key = "eps_current_l1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x411, - scale = 0.1, - rounding = 1, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "EPS Current L2", - key = "eps_current_l2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x412, - scale = 0.1, - rounding = 1, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "EPS Current L3", - key = "eps_current_l3", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x413, - scale = 0.1, - rounding = 1, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "EPS Power L1", - key = "eps_power_l1", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x414, - unit = REGISTER_S32, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "EPS Power L2", - key = "eps_power_l2", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x416, - unit = REGISTER_S32, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "EPS Power L3", - key = "eps_power_l3", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x418, - unit = REGISTER_S32, - allowedtypes = GEN | X3, - ), - AlphaESSModbusSensorEntityDescription( - name = "EPS Power", - key = "eps_power", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x41A, - unit = REGISTER_S32, - allowedtypes = GEN | EPS, - ), - AlphaESSModbusSensorEntityDescription( - name = "Inverter Frequency", - key = "inverter_frequency", - native_unit_of_measurement = UnitOfFrequency.HERTZ, - state_class = SensorStateClass.MEASUREMENT, - register = 0x41C, - scale = 0.01, - rounding = 2, - allowedtypes = GEN, - ), - AlphaESSModbusSensorEntityDescription( - name = "PV Voltage 1", - key = "pv_voltage_1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x41D, - scale = 0.1, - rounding = 1, - allowedtypes = GEN, - ), - AlphaESSModbusSensorEntityDescription( - name = "PV Current 1", - key = "pv_current_1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x41E, - scale = 0.1, - rounding = 1, - allowedtypes = GEN, - icon = "mdi:current-dc", - ), - AlphaESSModbusSensorEntityDescription( - name = "PV Power 1", - key = "pv_power_1", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x41F, - unit = REGISTER_S32, - allowedtypes = GEN, - icon = "mdi:solar-power-variant", - ), - AlphaESSModbusSensorEntityDescription( - name = "PV Voltage 2", - key = "pv_voltage_2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x421, - scale = 0.1, - rounding = 1, - allowedtypes = GEN, - ), - AlphaESSModbusSensorEntityDescription( - name = "PV Current 2", - key = "pv_current_2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x422, - scale = 0.1, - rounding = 1, - allowedtypes = GEN, - icon = "mdi:current-dc", - ), - AlphaESSModbusSensorEntityDescription( - name = "PV Power 2", - key = "pv_power_2", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x423, - unit = REGISTER_S32, - allowedtypes = GEN, - icon = "mdi:solar-power-variant", - ), - AlphaESSModbusSensorEntityDescription( - name = "PV Voltage 3", - key = "pv_voltage_3", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x425, - scale = 0.1, - rounding = 1, - allowedtypes = GEN | MPPT3, - ), - AlphaESSModbusSensorEntityDescription( - name = "PV Current 3", - key = "pv_current_3", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x426, - scale = 0.1, - rounding = 1, - allowedtypes = GEN | MPPT3, - icon = "mdi:current-dc", - ), - AlphaESSModbusSensorEntityDescription( - name = "PV Power 3", - key = "pv_power_3", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x427, - unit = REGISTER_S32, - allowedtypes = GEN | MPPT3, - icon = "mdi:solar-power-variant", - ), - AlphaESSModbusSensorEntityDescription( - name = "Inverter Temperature", - key = "inverter_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x435, - scale = 0.1, - allowedtypes = GEN, - entity_category = EntityCategory.DIAGNOSTIC, - ), - AlphaESSModbusSensorEntityDescription( - name = "Run Mode", - key = "run_mode", - register = 0x440, - scale = { 0: "Waiting", - 1: "Online", - 2: "UPS Mode", - 3: "Bypass Mode", - 4: "Fault Mode", - 5: "DC Mode", - 6: "Self Test Mode", - 7: "Check Mode", - 8: "Update Master", - 9: "Update Slave", - 10: "Update ARM", }, - allowedtypes = GEN, - icon = "mdi:run", - ), - AlphaESSModbusSensorEntityDescription( - name = "Software Master Version", - key = "software_master_version", - register = 0x640, - unit = REGISTER_STR, - wordcount = 5, - allowedtypes = GEN, - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:information", - ), - AlphaESSModbusSensorEntityDescription( - name = "Software Slave Version", - key = "software_slave_version", - register = 0x645, - unit = REGISTER_STR, - wordcount = 8, - allowedtypes = GEN, - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:information", - ), - AlphaESSModbusSensorEntityDescription( - key = "system_mode", - register = 0x805, - scale = { 0: "AC Mode", - 1: "DC Mode", - 2: "Hybrid Mode", }, - allowedtypes = GEN, - internal = True, - ), - AlphaESSModbusSensorEntityDescription( - key = "3phase_unbalanced_mode", - register = 0x811, - scale = { 0: "Disabled", - 1: "Enabled", }, - allowedtypes = GEN | X3, - internal = True, - ), - AlphaESSModbusSensorEntityDescription( - key = "time_preiod_control", - register = 0x84F, - scale = { 0: "Disabled", - 1: "Charge - Enabled", - 2: "Discharge - Enabled", - 3: "Both - Enabled", }, - allowedtypes = GEN, - internal = True, + ##### + # + # Holding Registers + # + ##### + AlphaESSModbusSensorEntityDescription( + name="Grid Voltage", + key="grid_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x14, + allowedtypes=GEN | X1, + ), + AlphaESSModbusSensorEntityDescription( + name="Grid Voltage L1", + key="grid_voltage_l1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x14, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="Grid Voltage L2", + key="grid_voltage_l2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x15, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="Grid Voltage L3", + key="grid_voltage_l3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x16, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="Grid Current", + key="grid_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x17, + scale=0.1, + rounding=1, + allowedtypes=GEN | X1, + ), + AlphaESSModbusSensorEntityDescription( + name="Grid Current L1", + key="grid_current_l1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x17, + scale=0.1, + rounding=1, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="Grid Current L2", + key="grid_current_l2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x18, + scale=0.1, + rounding=1, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="Grid Current L3", + key="grid_current_l3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x19, + scale=0.1, + rounding=1, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="Grid Frequency", + key="grid_frequency", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0x1A, + scale=0.01, + rounding=2, + allowedtypes=GEN, + ), + AlphaESSModbusSensorEntityDescription( + name="Active Power Energy", + key="active_power_energy", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x21, + unit=REGISTER_S32, + allowedtypes=GEN, + ), + AlphaESSModbusSensorEntityDescription( + name="Reactive Power", + key="reactive_power", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x29, + unit=REGISTER_S32, + allowedtypes=MAX | GEN2, + ), + AlphaESSModbusSensorEntityDescription( + name="Battery Voltage", + key="battery_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x100, + scale=0.1, + unit=REGISTER_S16, + allowedtypes=GEN, + ), + AlphaESSModbusSensorEntityDescription( + name="Battery Current", + key="battery_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x101, + scale=0.1, + unit=REGISTER_S16, + allowedtypes=HYBRID | GEN2, + icon="mdi:current-dc", + ), + AlphaESSModbusSensorEntityDescription( + name="Battery SOC", + key="battery_soc", + native_unit_of_measurement=PERCENTAGE, + device_class=SensorDeviceClass.BATTERY, + register=0x102, + allowedtypes=GEN, + ), + AlphaESSModbusSensorEntityDescription( + name="Battery Capacity", + key="battery_capacity", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + register=0x119, + scale=0.1, + allowedtypes=GEN, + ), + AlphaESSModbusSensorEntityDescription( + name="Battery Input Energy", + key="battery_input_energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + icon="mdi:battery-arrow-up", + register=0x120, + unit=REGISTER_U32, + scale=0.1, + allowedtypes=GEN, + ), + AlphaESSModbusSensorEntityDescription( + name="Battery Output Energy", + key="battery_output_energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + icon="mdi:battery-arrow-down", + register=0x122, + unit=REGISTER_U32, + scale=0.1, + allowedtypes=GEN, + ), + AlphaESSModbusSensorEntityDescription( + name="Inverter Voltage", + key="inverter_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x400, + allowedtypes=GEN | X1, + ), + AlphaESSModbusSensorEntityDescription( + name="Inverter Voltage L1", + key="inverter_voltage_l1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x400, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="Inverter Voltage L2", + key="inverter_voltage_l2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x401, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="Inverter Voltage L3", + key="inverter_voltage_l3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x402, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="Inverter Current", + key="inverter_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x403, + scale=0.1, + rounding=1, + allowedtypes=GEN | X1, + ), + AlphaESSModbusSensorEntityDescription( + name="Inverter Current L1", + key="inverter_current_l1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x403, + scale=0.1, + rounding=1, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="Inverter Current L2", + key="inverter_current_l2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x404, + scale=0.1, + rounding=1, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="Inverter Current L3", + key="inverter_current_l3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x405, + scale=0.1, + rounding=1, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="Inverter Power L1", + key="inverter_power_l1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x406, + unit=REGISTER_S32, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="Inverter Power L2", + key="inverter_power_l2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x408, + unit=REGISTER_S32, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="Inverter Power L3", + key="inverter_power_l3", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x40A, + unit=REGISTER_S32, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="Inverter Power", + key="inverter_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x40C, + unit=REGISTER_S32, + allowedtypes=GEN, + ), + AlphaESSModbusSensorEntityDescription( + name="EPS Voltage", + key="eps_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x40E, + allowedtypes=GEN | X1, + ), + AlphaESSModbusSensorEntityDescription( + name="EPS Voltage L1", + key="eps_voltage_l1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x40E, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="EPS Voltage L2", + key="eps_voltage_l2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x40F, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="EPS Voltage L3", + key="eps_voltage_l3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x410, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="EPS Current", + key="eps_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x411, + scale=0.1, + rounding=1, + allowedtypes=GEN | X1, + ), + AlphaESSModbusSensorEntityDescription( + name="EPS Current L1", + key="eps_current_l1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x411, + scale=0.1, + rounding=1, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="EPS Current L2", + key="eps_current_l2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x412, + scale=0.1, + rounding=1, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="EPS Current L3", + key="eps_current_l3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x413, + scale=0.1, + rounding=1, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="EPS Power L1", + key="eps_power_l1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x414, + unit=REGISTER_S32, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="EPS Power L2", + key="eps_power_l2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x416, + unit=REGISTER_S32, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="EPS Power L3", + key="eps_power_l3", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x418, + unit=REGISTER_S32, + allowedtypes=GEN | X3, + ), + AlphaESSModbusSensorEntityDescription( + name="EPS Power", + key="eps_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x41A, + unit=REGISTER_S32, + allowedtypes=GEN | EPS, + ), + AlphaESSModbusSensorEntityDescription( + name="Inverter Frequency", + key="inverter_frequency", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0x41C, + scale=0.01, + rounding=2, + allowedtypes=GEN, + ), + AlphaESSModbusSensorEntityDescription( + name="PV Voltage 1", + key="pv_voltage_1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x41D, + scale=0.1, + rounding=1, + allowedtypes=GEN, + ), + AlphaESSModbusSensorEntityDescription( + name="PV Current 1", + key="pv_current_1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x41E, + scale=0.1, + rounding=1, + allowedtypes=GEN, + icon="mdi:current-dc", + ), + AlphaESSModbusSensorEntityDescription( + name="PV Power 1", + key="pv_power_1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x41F, + unit=REGISTER_S32, + allowedtypes=GEN, + icon="mdi:solar-power-variant", + ), + AlphaESSModbusSensorEntityDescription( + name="PV Voltage 2", + key="pv_voltage_2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x421, + scale=0.1, + rounding=1, + allowedtypes=GEN, + ), + AlphaESSModbusSensorEntityDescription( + name="PV Current 2", + key="pv_current_2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x422, + scale=0.1, + rounding=1, + allowedtypes=GEN, + icon="mdi:current-dc", + ), + AlphaESSModbusSensorEntityDescription( + name="PV Power 2", + key="pv_power_2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x423, + unit=REGISTER_S32, + allowedtypes=GEN, + icon="mdi:solar-power-variant", + ), + AlphaESSModbusSensorEntityDescription( + name="PV Voltage 3", + key="pv_voltage_3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x425, + scale=0.1, + rounding=1, + allowedtypes=GEN | MPPT3, + ), + AlphaESSModbusSensorEntityDescription( + name="PV Current 3", + key="pv_current_3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x426, + scale=0.1, + rounding=1, + allowedtypes=GEN | MPPT3, + icon="mdi:current-dc", + ), + AlphaESSModbusSensorEntityDescription( + name="PV Power 3", + key="pv_power_3", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x427, + unit=REGISTER_S32, + allowedtypes=GEN | MPPT3, + icon="mdi:solar-power-variant", + ), + AlphaESSModbusSensorEntityDescription( + name="Inverter Temperature", + key="inverter_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x435, + scale=0.1, + allowedtypes=GEN, + entity_category=EntityCategory.DIAGNOSTIC, + ), + AlphaESSModbusSensorEntityDescription( + name="Run Mode", + key="run_mode", + register=0x440, + scale={ + 0: "Waiting", + 1: "Online", + 2: "UPS Mode", + 3: "Bypass Mode", + 4: "Fault Mode", + 5: "DC Mode", + 6: "Self Test Mode", + 7: "Check Mode", + 8: "Update Master", + 9: "Update Slave", + 10: "Update ARM", + }, + allowedtypes=GEN, + icon="mdi:run", + ), + AlphaESSModbusSensorEntityDescription( + name="Software Master Version", + key="software_master_version", + register=0x640, + unit=REGISTER_STR, + wordcount=5, + allowedtypes=GEN, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:information", + ), + AlphaESSModbusSensorEntityDescription( + name="Software Slave Version", + key="software_slave_version", + register=0x645, + unit=REGISTER_STR, + wordcount=8, + allowedtypes=GEN, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:information", + ), + AlphaESSModbusSensorEntityDescription( + key="system_mode", + register=0x805, + scale={ + 0: "AC Mode", + 1: "DC Mode", + 2: "Hybrid Mode", + }, + allowedtypes=GEN, + internal=True, + ), + AlphaESSModbusSensorEntityDescription( + key="3phase_unbalanced_mode", + register=0x811, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=GEN | X3, + internal=True, + ), + AlphaESSModbusSensorEntityDescription( + key="time_preiod_control", + register=0x84F, + scale={ + 0: "Disabled", + 1: "Charge - Enabled", + 2: "Discharge - Enabled", + 3: "Both - Enabled", + }, + allowedtypes=GEN, + internal=True, ), AlphaESSModbusSensorEntityDescription( - key = "discharge_minimum_soc", - register = 0x850, - allowedtypes = GEN, - internal = True, + key="discharge_minimum_soc", + register=0x850, + allowedtypes=GEN, + internal=True, ), AlphaESSModbusSensorEntityDescription( - key = "discharge_start_1_hours", - register = 0x851, - allowedtypes = GEN, - internal = True, + key="discharge_start_1_hours", + register=0x851, + allowedtypes=GEN, + internal=True, ), AlphaESSModbusSensorEntityDescription( - key = "discharge_stop_1_hours", - register = 0x852, - allowedtypes = GEN, - internal = True, + key="discharge_stop_1_hours", + register=0x852, + allowedtypes=GEN, + internal=True, ), AlphaESSModbusSensorEntityDescription( - key = "discharge_start_2_hours", - register = 0x853, - allowedtypes = GEN, - internal = True, + key="discharge_start_2_hours", + register=0x853, + allowedtypes=GEN, + internal=True, ), AlphaESSModbusSensorEntityDescription( - key = "discharge_stop_2_hours", - register = 0x854, - allowedtypes = GEN, - internal = True, + key="discharge_stop_2_hours", + register=0x854, + allowedtypes=GEN, + internal=True, ), AlphaESSModbusSensorEntityDescription( - key = "charge_target_soc", - register = 0x855, - allowedtypes = GEN, - internal = True, + key="charge_target_soc", + register=0x855, + allowedtypes=GEN, + internal=True, ), AlphaESSModbusSensorEntityDescription( - key = "charge_start_1_hours", - register = 0x856, - allowedtypes = GEN, - internal = True, + key="charge_start_1_hours", + register=0x856, + allowedtypes=GEN, + internal=True, ), AlphaESSModbusSensorEntityDescription( - key = "charge_stop_1_hours", - register = 0x857, - allowedtypes = GEN, - internal = True, + key="charge_stop_1_hours", + register=0x857, + allowedtypes=GEN, + internal=True, ), AlphaESSModbusSensorEntityDescription( - key = "charge_start_2_hours", - register = 0x858, - allowedtypes = GEN, - internal = True, + key="charge_start_2_hours", + register=0x858, + allowedtypes=GEN, + internal=True, ), AlphaESSModbusSensorEntityDescription( - key = "charge_stop_2_hours", - register = 0x859, - allowedtypes = GEN, - internal = True, + key="charge_stop_2_hours", + register=0x859, + allowedtypes=GEN, + internal=True, ), AlphaESSModbusSensorEntityDescription( - key = "discharge_start_1_mins", - register = 0x85A, - allowedtypes = GEN, - internal = True, + key="discharge_start_1_mins", + register=0x85A, + allowedtypes=GEN, + internal=True, ), AlphaESSModbusSensorEntityDescription( - key = "discharge_stop_1_mins", - register = 0x85B, - allowedtypes = GEN, - internal = True, + key="discharge_stop_1_mins", + register=0x85B, + allowedtypes=GEN, + internal=True, ), AlphaESSModbusSensorEntityDescription( - key = "discharge_start_2_mins", - register = 0x85C, - allowedtypes = GEN, - internal = True, + key="discharge_start_2_mins", + register=0x85C, + allowedtypes=GEN, + internal=True, ), AlphaESSModbusSensorEntityDescription( - key = "discharge_stop_2_mins", - register = 0x85D, - allowedtypes = GEN, - internal = True, + key="discharge_stop_2_mins", + register=0x85D, + allowedtypes=GEN, + internal=True, ), AlphaESSModbusSensorEntityDescription( - key = "charge_start_1_mins", - register = 0x85E, - allowedtypes = GEN, - internal = True, + key="charge_start_1_mins", + register=0x85E, + allowedtypes=GEN, + internal=True, ), AlphaESSModbusSensorEntityDescription( - key = "charge_stop_1_mins", - register = 0x85F, - allowedtypes = GEN, - internal = True, + key="charge_stop_1_mins", + register=0x85F, + allowedtypes=GEN, + internal=True, ), AlphaESSModbusSensorEntityDescription( - key = "charge_start_2_mins", - register = 0x860, - allowedtypes = GEN, - internal = True, + key="charge_start_2_mins", + register=0x860, + allowedtypes=GEN, + internal=True, ), AlphaESSModbusSensorEntityDescription( - key = "charge_stop_2_mins", - register = 0x861, - allowedtypes = GEN, - internal = True, + key="charge_stop_2_mins", + register=0x861, + allowedtypes=GEN, + internal=True, ), - ] # ============================ plugin declaration ================================================= + @dataclass class alphaess_plugin(plugin_base): async def async_determineInverterType(self, hub, configdict): - #global SENSOR_TYPES + # global SENSOR_TYPES _LOGGER.info(f"{hub.name}: trying to determine inverter type") - seriesnumber = await async_read_serialnr(hub, 0x64A) + seriesnumber = await async_read_serialnr(hub, 0x64A) if not seriesnumber: _LOGGER.error(f"{hub.name}: cannot find any serial number(s)") seriesnumber = "unknown" # derive invertertupe from seriiesnumber - if seriesnumber.startswith('XYZ'): - invertertype = GEN # Unknown AlphaESS + if seriesnumber.startswith("XYZ"): + invertertype = GEN # Unknown AlphaESS self.inverter_model = "Unknown" - elif seriesnumber.startswith('ZYX'): - invertertype = MAX | GEN2 | MPPT5 # Unknown AlphaESS + elif seriesnumber.startswith("ZYX"): + invertertype = MAX | GEN2 | MPPT5 # Unknown AlphaESS self.inverter_model = "Unknown" else: invertertype = 0 _LOGGER.error(f"unrecognized inverter type - serial number : {seriesnumber}") - + if invertertype > 0: read_eps = configdict.get(CONF_READ_EPS, DEFAULT_READ_EPS) read_dcb = configdict.get(CONF_READ_DCB, DEFAULT_READ_DCB) read_pm = configdict.get(CONF_READ_PM, DEFAULT_READ_PM) - if read_eps: invertertype = invertertype | EPS - if read_dcb: invertertype = invertertype | DCB - if read_pm: invertertype = invertertype | PM + if read_eps: + invertertype = invertertype | EPS + if read_dcb: + invertertype = invertertype | DCB + if read_pm: + invertertype = invertertype | PM return invertertype - def matchInverterWithMask (self, inverterspec, entitymask, serialnumber = 'not relevant', blacklist = None): + def matchInverterWithMask(self, inverterspec, entitymask, serialnumber="not relevant", blacklist=None): # returns true if the entity needs to be created for an inverter - genmatch = ((inverterspec & entitymask & ALL_GEN_GROUP) != 0) or (entitymask & ALL_GEN_GROUP == 0) - xmatch = ((inverterspec & entitymask & ALL_X_GROUP) != 0) or (entitymask & ALL_X_GROUP == 0) + genmatch = ((inverterspec & entitymask & ALL_GEN_GROUP) != 0) or (entitymask & ALL_GEN_GROUP == 0) + xmatch = ((inverterspec & entitymask & ALL_X_GROUP) != 0) or (entitymask & ALL_X_GROUP == 0) hybmatch = ((inverterspec & entitymask & ALL_TYPE_GROUP) != 0) or (entitymask & ALL_TYPE_GROUP == 0) - epsmatch = ((inverterspec & entitymask & ALL_EPS_GROUP) != 0) or (entitymask & ALL_EPS_GROUP == 0) - dcbmatch = ((inverterspec & entitymask & ALL_DCB_GROUP) != 0) or (entitymask & ALL_DCB_GROUP == 0) - mpptmatch = ((inverterspec & entitymask & ALL_MPPT_GROUP) != 0) or (entitymask & ALL_MPPT_GROUP == 0) - pmmatch = ((inverterspec & entitymask & ALL_PM_GROUP) != 0) or (entitymask & ALL_PM_GROUP == 0) + epsmatch = ((inverterspec & entitymask & ALL_EPS_GROUP) != 0) or (entitymask & ALL_EPS_GROUP == 0) + dcbmatch = ((inverterspec & entitymask & ALL_DCB_GROUP) != 0) or (entitymask & ALL_DCB_GROUP == 0) + mpptmatch = ((inverterspec & entitymask & ALL_MPPT_GROUP) != 0) or (entitymask & ALL_MPPT_GROUP == 0) + pmmatch = ((inverterspec & entitymask & ALL_PM_GROUP) != 0) or (entitymask & ALL_PM_GROUP == 0) blacklisted = False if blacklist: for start in blacklist: - if serialnumber.startswith(start) : blacklisted = True - return (genmatch and xmatch and hybmatch and epsmatch and dcbmatch and mpptmatch and pmmatch) and not blacklisted + if serialnumber.startswith(start): + blacklisted = True + return ( + genmatch and xmatch and hybmatch and epsmatch and dcbmatch and mpptmatch and pmmatch + ) and not blacklisted def getSoftwareVersion(self, new_data): return new_data.get("software_version", None) @@ -1123,33 +1150,53 @@ def localDataCallback(self, hub): if config_scale_entity and config_scale_entity.enabled: new_read_scale = hub.data.get("config_export_control_limit_readscale") if new_read_scale != None: - _LOGGER.info(f"local data update callback for read_scale: {new_read_scale} enabled: {config_scale_entity.enabled}") + _LOGGER.info( + f"local data update callback for read_scale: {new_read_scale} enabled: {config_scale_entity.enabled}" + ) number_entity = hub.numberEntities.get("export_control_user_limit") sensor_entity = hub.sensorEntities.get("export_control_user_limit") - if number_entity: number_entity.entity_description = replace(number_entity.entity_description, read_scale = new_read_scale, ) - if sensor_entity: sensor_entity.entity_description = replace(sensor_entity.entity_description, read_scale = new_read_scale, ) + if number_entity: + number_entity.entity_description = replace( + number_entity.entity_description, + read_scale=new_read_scale, + ) + if sensor_entity: + sensor_entity.entity_description = replace( + sensor_entity.entity_description, + read_scale=new_read_scale, + ) config_maxexport_entity = hub.numberEntities.get("config_max_export") if config_maxexport_entity and config_maxexport_entity.enabled: new_max_export = hub.data.get("config_max_export") if new_max_export != None: - for key in ["remotecontrol_active_power", "remotecontrol_import_limit", "export_control_user_limit", "generator_max_charge"]: + for key in [ + "remotecontrol_active_power", + "remotecontrol_import_limit", + "export_control_user_limit", + "generator_max_charge", + ]: number_entity = hub.numberEntities.get(key) if number_entity: number_entity._attr_native_max_value = new_max_export # update description also, not sure whether needed or not - number_entity.entity_description = replace(number_entity.entity_description, native_max_value = new_max_export, ) + number_entity.entity_description = replace( + number_entity.entity_description, + native_max_value=new_max_export, + ) _LOGGER.info(f"local data update callback for entity: {key} new limit: {new_max_export}") + plugin_instance = alphaess_plugin( - plugin_name = 'AlphaESS', - plugin_manufacturer = 'Alpha ESS Co., Ltd.', - SENSOR_TYPES = SENSOR_TYPES_MAIN, - NUMBER_TYPES = NUMBER_TYPES, - BUTTON_TYPES = BUTTON_TYPES, - SELECT_TYPES = SELECT_TYPES, - block_size = 100, - order16 = Endian.BIG, - order32 = Endian.BIG, - auto_block_ignore_readerror = True - ) \ No newline at end of file + plugin_name="AlphaESS", + plugin_manufacturer="Alpha ESS Co., Ltd.", + SENSOR_TYPES=SENSOR_TYPES_MAIN, + NUMBER_TYPES=NUMBER_TYPES, + BUTTON_TYPES=BUTTON_TYPES, + SELECT_TYPES=SELECT_TYPES, + SWITCH_TYPES=[], + block_size=100, + order16=Endian.BIG, + order32=Endian.BIG, + auto_block_ignore_readerror=True, +) diff --git a/custom_components/solax_modbus/plugin_growatt.py b/custom_components/solax_modbus/plugin_growatt.py index 92a1b0b3..5bb80486 100644 --- a/custom_components/solax_modbus/plugin_growatt.py +++ b/custom_components/solax_modbus/plugin_growatt.py @@ -6039,6 +6039,7 @@ def matchInverterWithMask (self, inverterspec, entitymask, serialnumber = 'not r NUMBER_TYPES = NUMBER_TYPES, BUTTON_TYPES = BUTTON_TYPES, SELECT_TYPES = SELECT_TYPES, + SWITCH_TYPES= [], block_size = 100, order16 = Endian.BIG, order32 = Endian.BIG, diff --git a/custom_components/solax_modbus/plugin_sofar.py b/custom_components/solax_modbus/plugin_sofar.py index 9f004519..65662c70 100644 --- a/custom_components/solax_modbus/plugin_sofar.py +++ b/custom_components/solax_modbus/plugin_sofar.py @@ -20,46 +20,47 @@ An entity can be declared multiple times (with different bitmasks) if the parameters are different for each inverter type """ -GEN = 0x0001 # base generation for MIC, PV, AC -GEN2 = 0x0002 -GEN3 = 0x0004 -GEN4 = 0x0008 -ALL_GEN_GROUP = GEN2 | GEN3 | GEN4 | GEN - -X1 = 0x0100 -X3 = 0x0200 -ALL_X_GROUP = X1 | X3 - -PV = 0x0400 # Needs further work on PV Only Inverters -AC = 0x0800 -HYBRID = 0x1000 -MIC = 0x2000 +GEN = 0x0001 # base generation for MIC, PV, AC +GEN2 = 0x0002 +GEN3 = 0x0004 +GEN4 = 0x0008 +ALL_GEN_GROUP = GEN2 | GEN3 | GEN4 | GEN + +X1 = 0x0100 +X3 = 0x0200 +ALL_X_GROUP = X1 | X3 + +PV = 0x0400 # Needs further work on PV Only Inverters +AC = 0x0800 +HYBRID = 0x1000 +MIC = 0x2000 ALL_TYPE_GROUP = PV | AC | HYBRID | MIC -EPS = 0x8000 -ALL_EPS_GROUP = EPS +EPS = 0x8000 +ALL_EPS_GROUP = EPS -DCB = 0x10000 # dry contact box - gen4 -ALL_DCB_GROUP = DCB +DCB = 0x10000 # dry contact box - gen4 +ALL_DCB_GROUP = DCB -PM = 0x20000 +PM = 0x20000 ALL_PM_GROUP = PM -MPPT3 = 0x40000 -MPPT4 = 0x80000 -MPPT6 = 0x100000 -MPPT8 = 0x200000 -MPPT10 = 0x400000 +MPPT3 = 0x40000 +MPPT4 = 0x80000 +MPPT6 = 0x100000 +MPPT8 = 0x200000 +MPPT10 = 0x400000 ALL_MPPT_GROUP = MPPT3 | MPPT4 | MPPT6 | MPPT8 | MPPT10 -BAT_BTS = 0x1000000 +BAT_BTS = 0x1000000 -ALLDEFAULT = 0 # should be equivalent to HYBRID | AC | GEN2 | GEN3 | GEN4 | X1 | X3 +ALLDEFAULT = 0 # should be equivalent to HYBRID | AC | GEN2 | GEN3 | GEN4 | X1 | X3 # ======================= end of bitmask handling code ============================================= # ====================== find inverter type and details =========================================== + async def async_read_serialnr(hub, address, swapbytes): res = None try: @@ -68,59 +69,89 @@ async def async_read_serialnr(hub, address, swapbytes): decoder = BinaryPayloadDecoder.fromRegisters(inverter_data.registers, byteorder=Endian.BIG) res = decoder.decode_string(14).decode("ascii") if swapbytes: - ba = bytearray(res,"ascii") # convert to bytearray for swapping - ba[0::2], ba[1::2] = ba[1::2], ba[0::2] # swap bytes ourselves - due to bug in Endian.LITTLE ? - res = str(ba, "ascii") # convert back to string + ba = bytearray(res, "ascii") # convert to bytearray for swapping + ba[0::2], ba[1::2] = ba[1::2], ba[0::2] # swap bytes ourselves - due to bug in Endian.LITTLE ? + res = str(ba, "ascii") # convert back to string hub.seriesnumber = res - except Exception as ex: _LOGGER.warning(f"{hub.name}: attempt to read serialnumber failed at 0x{address:x}", exc_info=True) - if not res: _LOGGER.warning(f"{hub.name}: reading serial number from address 0x{address:x} failed; other address may succeed") + except Exception as ex: + _LOGGER.warning(f"{hub.name}: attempt to read serialnumber failed at 0x{address:x}", exc_info=True) + if not res: + _LOGGER.warning( + f"{hub.name}: reading serial number from address 0x{address:x} failed; other address may succeed" + ) _LOGGER.info(f"Read {hub.name} 0x{address:x} serial number: {res}, swapped: {swapbytes}") - #return 'SP1ES2' + # return 'SP1ES2' return res + # ================================================================================================= + @dataclass class SofarModbusButtonEntityDescription(BaseModbusButtonEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice - #write_method = WRITE_MULTISINGLE_MODBUS + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + # write_method = WRITE_MULTISINGLE_MODBUS + @dataclass class SofarModbusNumberEntityDescription(BaseModbusNumberEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice - #write_method = WRITE_MULTISINGLE_MODBUS + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + # write_method = WRITE_MULTISINGLE_MODBUS + @dataclass class SofarModbusSelectEntityDescription(BaseModbusSelectEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice - #write_method = WRITE_MULTISINGLE_MODBUS + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + # write_method = WRITE_MULTISINGLE_MODBUS + @dataclass class SofarModbusSensorEntityDescription(BaseModbusSensorEntityDescription): """A class that describes Sofar Modbus sensor entities.""" - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice - #order16: int = Endian.BIG - #order32: int = Endian.BIG + + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + # order16: int = Endian.BIG + # order32: int = Endian.BIG unit: int = REGISTER_U16 - register_type: int= REG_HOLDING + register_type: int = REG_HOLDING + # ====================================== Computed value functions ================================================= + def value_function_passivemode(initval, descr, datadict): - return [ (REGISTER_S32, datadict.get('passive_mode_grid_power', 0)), - (REGISTER_S32, datadict.get('passive_mode_battery_power_min', 0)), - (REGISTER_S32, datadict.get('passive_mode_battery_power_max', 0)), - ] + return [ + (REGISTER_S32, datadict.get("passive_mode_grid_power", 0)), + (REGISTER_S32, datadict.get("passive_mode_battery_power_min", 0)), + (REGISTER_S32, datadict.get("passive_mode_battery_power_max", 0)), + ] + def value_function_passive_timeout(initval, descr, datadict): - return [ ('passive_mode_timeout', datadict.get('passive_mode_timeout', datadict.get('passive_mode_timeout')), ), - ('passive_mode_timeout_action', datadict.get('passive_mode_timeout_action', datadict.get('passive_mode_timeout_action')), ), - ] + return [ + ( + "passive_mode_timeout", + datadict.get("passive_mode_timeout", datadict.get("passive_mode_timeout")), + ), + ( + "passive_mode_timeout_action", + datadict.get("passive_mode_timeout_action", datadict.get("passive_mode_timeout_action")), + ), + ] + def value_function_refluxcontrol(initval, descr, datadict): - return [ ('feedin_limitation_mode', datadict.get('feedin_limitation_mode', datadict.get('feedin_limitation_mode')), ), - ('feedin_max_power', int(datadict.get('feedin_max_power', 0)) / 100, ), - ] + return [ + ( + "feedin_limitation_mode", + datadict.get("feedin_limitation_mode", datadict.get("feedin_limitation_mode")), + ), + ( + "feedin_max_power", + int(datadict.get("feedin_max_power", 0)) / 100, + ), + ] + # TIMING AND TOU DISABLED AS THESE ARE NOT WORKING # def value_function_timingmode(initval, descr, datadict): @@ -143,55 +174,78 @@ def value_function_refluxcontrol(initval, descr, datadict): # ('tou_charge_power', datadict.get('tou_charge_power', 0), ), # ] + def value_function_sync_rtc_ymd_sofar(initval, descr, datadict): now = datetime.now() - return [ (REGISTER_U16, now.year % 100, ), - (REGISTER_U16, now.month, ), - (REGISTER_U16, now.day, ), - (REGISTER_U16, now.hour, ), - (REGISTER_U16, now.minute, ), - (REGISTER_U16, now.second, ), - (REGISTER_U16, 1, ), - ] + return [ + ( + REGISTER_U16, + now.year % 100, + ), + ( + REGISTER_U16, + now.month, + ), + ( + REGISTER_U16, + now.day, + ), + ( + REGISTER_U16, + now.hour, + ), + ( + REGISTER_U16, + now.minute, + ), + ( + REGISTER_U16, + now.second, + ), + ( + REGISTER_U16, + 1, + ), + ] + # ================================= Button Declarations ============================================================ BUTTON_TYPES = [ SofarModbusButtonEntityDescription( - name = "Passive: Update Battery Charge/Discharge", - key = "passive_mode_battery_charge_discharge", - register = 0x1187, - allowedtypes = HYBRID, - write_method = WRITE_MULTI_MODBUS, - value_function = value_function_passivemode, + name="Passive: Update Battery Charge/Discharge", + key="passive_mode_battery_charge_discharge", + register=0x1187, + allowedtypes=HYBRID, + write_method=WRITE_MULTI_MODBUS, + value_function=value_function_passivemode, ), SofarModbusButtonEntityDescription( - name = "Passive: Update Timeout", - key = "passive_mode_update_timeout", - register = 0x1184, - allowedtypes = HYBRID, - write_method = WRITE_MULTI_MODBUS, - value_function = value_function_passive_timeout, + name="Passive: Update Timeout", + key="passive_mode_update_timeout", + register=0x1184, + allowedtypes=HYBRID, + write_method=WRITE_MULTI_MODBUS, + value_function=value_function_passive_timeout, ), # Unlikely to work as Sofar requires writing 7 registers, where the last needs to have the constant value of '1' during a write operation. SofarModbusButtonEntityDescription( - name = "Update System Time", - key = "sync_rtc", - register = 0x1004, - allowedtypes = HYBRID | PV, - write_method = WRITE_MULTI_MODBUS, - icon = "mdi:home-clock", - value_function = value_function_sync_rtc_ymd_sofar, + name="Update System Time", + key="sync_rtc", + register=0x1004, + allowedtypes=HYBRID | PV, + write_method=WRITE_MULTI_MODBUS, + icon="mdi:home-clock", + value_function=value_function_sync_rtc_ymd_sofar, ), SofarModbusButtonEntityDescription( - name = "FeedIn: Update", - key = "feedin_limitation_mode", - register = 0x1023, - allowedtypes = HYBRID, - write_method = WRITE_MULTI_MODBUS, - value_function = value_function_refluxcontrol, + name="FeedIn: Update", + key="feedin_limitation_mode", + register=0x1023, + allowedtypes=HYBRID, + write_method=WRITE_MULTI_MODBUS, + value_function=value_function_refluxcontrol, ), - # TIMING AND TOU DISABLED AS THESE ARE NOT WORKING # SofarModbusButtonEntityDescription( # name = "Timing: Control", @@ -226,75 +280,73 @@ def value_function_sync_rtc_ymd_sofar(initval, descr, datadict): # ================================= Number Declarations ============================================================ NUMBER_TYPES = [ - ### # # Data only number types # ### SofarModbusNumberEntityDescription( - name = "Passive: Desired Grid Power", - key = "passive_mode_grid_power", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = NumberDeviceClass.POWER, - unit = REGISTER_S32, - fmt = "i", - native_max_value = 20000, - native_min_value = -20000, - native_step = 10, - initvalue = 0, - allowedtypes = HYBRID, - prevent_update = True, - write_method = WRITE_DATA_LOCAL, - icon = "mdi:transmission-tower", + name="Passive: Desired Grid Power", + key="passive_mode_grid_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=NumberDeviceClass.POWER, + unit=REGISTER_S32, + fmt="i", + native_max_value=20000, + native_min_value=-20000, + native_step=10, + initvalue=0, + allowedtypes=HYBRID, + prevent_update=True, + write_method=WRITE_DATA_LOCAL, + icon="mdi:transmission-tower", ), SofarModbusNumberEntityDescription( - name = "Passive: Minimum Battery Power", - key = "passive_mode_battery_power_min", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = NumberDeviceClass.POWER, - unit = REGISTER_S32, - fmt = "i", - native_max_value = 20000, - native_min_value = -20000, - native_step = 100, - initvalue = 0, - allowedtypes = HYBRID, - prevent_update = True, - write_method = WRITE_DATA_LOCAL, - icon = "mdi:battery-arrow-down", + name="Passive: Minimum Battery Power", + key="passive_mode_battery_power_min", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=NumberDeviceClass.POWER, + unit=REGISTER_S32, + fmt="i", + native_max_value=20000, + native_min_value=-20000, + native_step=100, + initvalue=0, + allowedtypes=HYBRID, + prevent_update=True, + write_method=WRITE_DATA_LOCAL, + icon="mdi:battery-arrow-down", ), SofarModbusNumberEntityDescription( - name = "Passive: Maximum Battery Power", - key = "passive_mode_battery_power_max", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = NumberDeviceClass.POWER, - unit = REGISTER_S32, - fmt = "i", - native_max_value = 20000, - native_min_value = -20000, - native_step = 100, - initvalue = 0, - allowedtypes = HYBRID, - prevent_update = True, - write_method = WRITE_DATA_LOCAL, - icon = "mdi:battery-arrow-up", + name="Passive: Maximum Battery Power", + key="passive_mode_battery_power_max", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=NumberDeviceClass.POWER, + unit=REGISTER_S32, + fmt="i", + native_max_value=20000, + native_min_value=-20000, + native_step=100, + initvalue=0, + allowedtypes=HYBRID, + prevent_update=True, + write_method=WRITE_DATA_LOCAL, + icon="mdi:battery-arrow-up", ), SofarModbusNumberEntityDescription( - name = "FeedIn: Maximum Power", - key = "feedin_max_power", - unit = REGISTER_U16, - fmt = "i", - native_min_value = 0, - native_max_value = 20000, - native_step = 100, - native_unit_of_measurement = UnitOfPower.WATT, - allowedtypes = HYBRID, - prevent_update = True, - write_method = WRITE_DATA_LOCAL, - icon = "mdi:battery-sync", + name="FeedIn: Maximum Power", + key="feedin_max_power", + unit=REGISTER_U16, + fmt="i", + native_min_value=0, + native_max_value=20000, + native_step=100, + native_unit_of_measurement=UnitOfPower.WATT, + allowedtypes=HYBRID, + prevent_update=True, + write_method=WRITE_DATA_LOCAL, + icon="mdi:battery-sync", ), - # TIMING AND TOU DISABLED AS THESE ARE NOT WORKING # SofarModbusNumberEntityDescription( # name = "Timing: Charge Power", @@ -375,16 +427,16 @@ def value_function_sync_rtc_ymd_sofar(initval, descr, datadict): # ### SofarModbusNumberEntityDescription( - name = "Parallel Address", - key = "parallel_address", - register = 0x1037, - fmt = "i", - native_min_value = 0, - native_max_value = 10, - native_step = 1, - allowedtypes = HYBRID | PV | X3 | PM, - write_method = WRITE_MULTISINGLE_MODBUS, - entity_category = EntityCategory.CONFIG, + name="Parallel Address", + key="parallel_address", + register=0x1037, + fmt="i", + native_min_value=0, + native_max_value=10, + native_step=1, + allowedtypes=HYBRID | PV | X3 | PM, + write_method=WRITE_MULTISINGLE_MODBUS, + entity_category=EntityCategory.CONFIG, ), ] @@ -397,18 +449,17 @@ def value_function_sync_rtc_ymd_sofar(initval, descr, datadict): # ### SofarModbusSelectEntityDescription( - name = "FeedIn: Limitation Mode", - key = "feedin_limitation_mode", - unit = REGISTER_U16, - option_dict = { - 0: "Disabled", - 1: "Enabled - Feed-in limitation", - 2: "Enabled - 3-phase limit", - }, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, + name="FeedIn: Limitation Mode", + key="feedin_limitation_mode", + unit=REGISTER_U16, + option_dict={ + 0: "Disabled", + 1: "Enabled - Feed-in limitation", + 2: "Enabled - 3-phase limit", + }, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, ), - # TIMING AND TOU DISABLED AS THESE ARE NOT WORKING # SofarModbusSelectEntityDescription( # name = "Timing: Charge", @@ -497,38 +548,38 @@ def value_function_sync_rtc_ymd_sofar(initval, descr, datadict): # icon = "mdi:battery-clock", # ), SofarModbusSelectEntityDescription( - name = "Passive: Timeout", - key = "passive_mode_timeout", - unit = REGISTER_U16, - write_method = WRITE_DATA_LOCAL, - option_dict = { - 0: "Disabled", - 300: "5 Minutes", - 600: "10 Minutes", - 900: "15 Minutes", - 1800: "30 Minutes", - 3600: "60 Minutes", - 5400: "90 Minutes", - 7200: "2 Hours", - 10800: "3 Hours", - 14400: "4 Hours", - 18000: "5 Hours", - 21600: "6 Hours", - }, - allowedtypes = HYBRID, - icon = "mdi:timer", + name="Passive: Timeout", + key="passive_mode_timeout", + unit=REGISTER_U16, + write_method=WRITE_DATA_LOCAL, + option_dict={ + 0: "Disabled", + 300: "5 Minutes", + 600: "10 Minutes", + 900: "15 Minutes", + 1800: "30 Minutes", + 3600: "60 Minutes", + 5400: "90 Minutes", + 7200: "2 Hours", + 10800: "3 Hours", + 14400: "4 Hours", + 18000: "5 Hours", + 21600: "6 Hours", + }, + allowedtypes=HYBRID, + icon="mdi:timer", ), SofarModbusSelectEntityDescription( - name = "Passive: Timeout Action", - key = "passive_mode_timeout_action", - unit = REGISTER_U16, - write_method = WRITE_DATA_LOCAL, - option_dict = { - 0: "Force Standby", - 1: "Return to Previous Mode", - }, - allowedtypes = HYBRID, - icon = "mdi:timer-cog", + name="Passive: Timeout Action", + key="passive_mode_timeout_action", + unit=REGISTER_U16, + write_method=WRITE_DATA_LOCAL, + option_dict={ + 0: "Force Standby", + 1: "Return to Previous Mode", + }, + allowedtypes=HYBRID, + icon="mdi:timer-cog", ), ### # @@ -536,18 +587,17 @@ def value_function_sync_rtc_ymd_sofar(initval, descr, datadict): # ### SofarModbusSelectEntityDescription( - name = "EPS Control", - key = "eps_control", - register = 0x1029, - option_dict = { - 0: "Turn Off", - 1: "Turn On, Prohibit Cold Start", - 2: "Turn On, Enable Cold Start", - }, - allowedtypes = HYBRID | X3 | EPS, - write_method = WRITE_MULTISINGLE_MODBUS, + name="EPS Control", + key="eps_control", + register=0x1029, + option_dict={ + 0: "Turn Off", + 1: "Turn On, Prohibit Cold Start", + 2: "Turn On, Enable Cold Start", + }, + allowedtypes=HYBRID | X3 | EPS, + write_method=WRITE_MULTISINGLE_MODBUS, ), - # Does not work. 0x1035, 0x1036, and 0x1037 have to be written in one single chunk # SofarModbusSelectEntityDescription( # name = "Parallel Control", @@ -572,31 +622,31 @@ def value_function_sync_rtc_ymd_sofar(initval, descr, datadict): # write_method = WRITE_MULTISINGLE_MODBUS, # ), SofarModbusSelectEntityDescription( - name = "Remote Switch On Off", - key = "remote_switch_on_off", - register = 0x1104, - option_dict = { - 0: "Off", - 1: "On", - }, - allowedtypes = HYBRID, - write_method = WRITE_MULTISINGLE_MODBUS, + name="Remote Switch On Off", + key="remote_switch_on_off", + register=0x1104, + option_dict={ + 0: "Off", + 1: "On", + }, + allowedtypes=HYBRID, + write_method=WRITE_MULTISINGLE_MODBUS, ), SofarModbusSelectEntityDescription( - name = "Energy Storage Mode", - key = "charger_use_mode", - register = 0x1110, - option_dict = { - 0: "Self Use", - 1: "Time of Use", - 2: "Timing Mode", - 3: "Passive Mode", - 4: "Peak Cut Mode", - 5: "Off-grid Mode", - }, - allowedtypes = HYBRID, - write_method = WRITE_MULTISINGLE_MODBUS, - icon = "mdi:battery-charging-60", + name="Energy Storage Mode", + key="charger_use_mode", + register=0x1110, + option_dict={ + 0: "Self Use", + 1: "Time of Use", + 2: "Timing Mode", + 3: "Passive Mode", + 4: "Peak Cut Mode", + 5: "Off-grid Mode", + }, + allowedtypes=HYBRID, + write_method=WRITE_MULTISINGLE_MODBUS, + icon="mdi:battery-charging-60", ), # Timing Charge Start # Timing Charge End @@ -607,2772 +657,2807 @@ def value_function_sync_rtc_ymd_sofar(initval, descr, datadict): ] - # ================================= Sensor Declarations ============================================================ SENSOR_TYPES: list[SofarModbusSensorEntityDescription] = [ - -### -# -# Real-time Data Area -# -### - SofarModbusSensorEntityDescription( - name = "System State", - key = "system_state", - register = 0x404, - newblock = True, - scale = { 0: "Waiting", - 1: "Checking", - 2: "Grid-connected", - 3: "Emergency Power Supply", - 4: "Recoverable fault", - 5: "Permanent fault", - 6: "Upgrading", - 7: "Self-Charging", }, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Fault 1", - key = "fault_1", - register = 0x405, - scale = { 0: "No error", - 1: "ID01 Grid Over Voltage Protection", - 2: "ID02 Grid Under Voltage Protection", - 4: "ID03 Grid Over Frequency Protection", - 8: "ID04 Grid Under Frequency Protection", - 16: "ID05 Leakage current fault", - 32: "ID06 High penetration error", - 64: "ID07 Low penetration error", - 128: "ID08 Islanding error", - 256: "ID09 Grid voltage transient value overvoltage 1", - 512: "ID10 Grid voltage transient value overvoltage 2", - 1024: "ID11 Grid line voltage error", - 2048: "ID12 Inverter voltage error",}, - allowedtypes = HYBRID | PV, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Fault 2", - key = "fault_2", - register = 0x406, - scale = { 0: "No error", - 1: "ID17 Grid current sampling error", - 2: "ID18 Grid current DC component sampling error (AC side)", - 4: "ID19 Grid voltage sampling error (DC side)", - 8: "ID20 Grid voltage sampling error (AC side)", - 16: "ID21 Leakage current sampling error (DC side)", - 32: "ID22 Leakage current sampling error (AC side)", - 64: "ID23 Load voltage DC component sampling error", - 128: "ID24 DC input current sampling error", - 256: "ID25 DC component sampling error of grid current (DC side)", - 512:"ID26 DC input branch current sampling error", - 4096: "ID29 Leakage current consistency error", - 8192: "ID30 Grid voltage consistency error", - 16384: "ID31 DCI consistency error",}, - allowedtypes = HYBRID | PV, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Fault 3", - key = "fault_3", - register = 0x407, - scale = { 0: "No error", - 1: "ID033 SPI communication error (DC side)", - 2: "ID034 SPI communication error (AC side)", - 4: "ID035 Chip error (DC side)", - 8: "ID036 Chip error (AC side)", - 16: "ID037 Auxiliary power error", - 32: "ID038 Inverter soft start failure", - 256: "ID041 Relay detection failure", - 512: "ID042 Low insulation impedance", - 1024: "ID043 Grounding error", - 2048: "ID044 Input mode setting error", - 4096: "ID045 ID045 CT error", - 8192: "ID046 Input reversal error", - 16384: "ID047 Parallel error", - 32768: "ID048 Serial number error", }, - allowedtypes = HYBRID | PV, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Fault 4", - key = "fault_4", - register = 0x408, - scale = { 0: "No error", - 1: "ID049 Battery temperature protection", - 2: "ID050 Heat sink 1 temperature protection", - 4: "ID051 Heater 2 temperature protection", - 8: "ID052 Heater 3 temperature protection", - 16: "ID053 Heatsink 4 temperature protection", - 32: "ID054 Heatsink 5 temperature protection", - 64: "ID055 Radiator 6 temperature protection", - 256: "ID057 Ambient temperature 1 protection", - 512: "ID058 Ambient temperature 2 protection", - 1024: "ID059 Module 1 temperature protection", - 2048: "ID060 Module 2 temperature protection", - 4096: "ID061 Module 3 temperature protection", - 8192: "ID062 Module temperature difference is too large",}, - allowedtypes = HYBRID | PV, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Fault 5", - key = "fault_5", - register = 0x409, - scale = { 0: "No error", - 1: "ID065 Bus voltage RMS unbalance", - 2: "ID066 Bus voltage transient value unbalance", - 4: "ID067 Undervoltage of busbar during grid connection", - 8: "ID068 Bus bar low voltage", - 16: "ID069 PV overvoltage", - 32: "ID070 Battery over-voltage", - 64: "ID071 LLCBus overvoltage protection", - 128: "ID072 Inverter bus voltage RMS software overvoltage", - 256: "ID073 Inverter bus voltage transient value software overvoltage", - 512: "ID074 Flying Cross Capacitor Overvoltage Protection", - 1024: "ID075 Flying Cross capacitor undervoltage protection",}, - allowedtypes = HYBRID | PV, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Fault 6", - key = "fault_6", - register = 0x040A, - scale = { 0: "No error", - 1: "ID081 Battery overcurrent software protection", - 2: "ID082 Dci overcurrent protection", - 4: "ID083 Output transient current protection", - 8: "ID084 BuckBoost software overcurrent", - 16: "ID085 Output RMS current protection", - 32: "ID086 PV instantaneous current overcurrent software protection", - 64: "ID087 PV parallel uneven current", - 128: "ID088 Output current unbalance", - 256: "ID089 PV software overcurrent protection", - 512: "ID090 Balanced circuit overcurrent protection", - 1024: "ID091 Resonance protection",}, - allowedtypes = HYBRID | PV, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Fault 7", - key = "fault_7", - register = 0x040B, - scale = { 0: "No error", - 1: "ID097 LLC bus hardware overvoltage", - 2: "ID098 Inverter bus hardware overvoltage", - 4: "ID099 BuckBoost hardware overcurrent", - 8: "ID100 Battery hardware overcurrent", - 16: "ID101", - 32: "ID102 PV hardware overcurrent", - 64: "ID103 AC output hardware overcurrent", - 256: "ID105 Power meter error", - 512: "ID106 Serial number model error", - 8192: "ID110 Overload protection 1", - 16384: "ID111 Overload protection 2", - 32768: "ID112 Overload protection 3", }, - allowedtypes = HYBRID | PV, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Fault 8", - key = "fault_8", - register = 0x040C, - scale = { 0: "No error", - 1: "ID113 Overtemperature derating", - 2: "ID114 Frequency down load", - 4: "ID115 Frequency loading", - 8: "ID116 Voltage down load", - 16: "ID117 Voltage loading", - 256: "ID121 Lightning protection failure (DC)", - 512: "ID122 Lightning protection failure (AC)", - 2048: "ID124 Battery low voltage protection", - 4096: "ID125 Battery low voltage shutdown", - 8192: "ID126 Battery low voltage pre-alarm",}, - allowedtypes = HYBRID | PV, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Fault 9", - key = "fault_9", - register = 0x040D, - scale = { 0: "No error", - 1: "ID129 Output hardware overcurrent permanent fault", - 2: "ID130 Bus overvoltage permanent fault", - 4: "ID131 Bus hardware over-voltage permanent fault", - 8: "ID132 PV uneven flow permanent fault", - 16: "ID133 Battery overcurrent permanent fault in EPS mode", - 32: "ID134 Output transient overcurrent permanent fault", - 64: "ID135 Output current unbalance permanent fault", - 256: "ID137 Input mode setting error permanent fault", - 512: "ID138 Input overcurrent permanent fault", - 1024: "ID139 Input hardware overcurrent permanent fault", - 2048: "ID140 Relay permanent fault", - 4096: "ID141 Bus unbalance permanent fault", - 8192: "ID142 Lightning protection permanent fault - DC side", - 16384: "ID143 Lightning protection permanent fault - AC side",}, - allowedtypes = HYBRID | PV, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Fault 10", - key = "fault_10", - register = 0x040E, - scale = { 0: "No error", - 1: "ID145 USB fault", - 2: "ID146 WIFI fault", - 4: "ID147 Bluetooth fault", - 8: "ID148 RTC clock fault", - 16: "ID149 Communication board EEPROM error", - 32: "ID150 Communication board FLASH error", - 128: "ID152 Safety regulation version error", - 256: "ID153 SCI communication error (DC side)", - 512: "ID154 SCI communication error (AC side)", - 1024: "ID155 SCI communication error (convergence board side)", - 2048: "ID156 Software version inconsistency", - 4096: "ID157 Lithium battery 1 communication error", - 8192: "ID158 Li-ion battery 2 communication error", - 16384: "ID159 Lithium battery 3 communication error", - 32768: "ID160 Lithium battery 4 communication failure", }, - allowedtypes = HYBRID | PV, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Fault 11", - key = "fault_11", - register = 0x040F, - scale = { 0: "No error", - 1: "ID161 Forced shutdown", - 2: "ID162 Remote shutdown", - 4: "ID163 Drms0 shutdown", - 16: "ID165 Remote down load", - 32: "ID166 Logic interface down load", - 64: "ID167 Anti-Reverse Flow Downgrade", - 256: "ID169 Fan 1 failure", - 512: "ID170 Fan 2 failure", - 1024: "ID171 Fan 3 failure", - 2048: "ID172 Fan 4 failure", - 4096: "ID173 Fan 5 failure", - 8192: "ID174 Fan 6 failure", - 16384: "ID175 Fan 7 fault", - 32768: "ID176 Meter communication failure", }, - allowedtypes = HYBRID | PV, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Fault 12", - key = "fault_12", - register = 0x0410, - scale = { 0: "No error", - 1: "ID177 BMS over-voltage alarm", - 2: "ID178 BMS undervoltage alarm", - 4: "ID179 BMS high temperature alarm", - 8: "ID180 BMS low temperature alarm", - 16: "ID181 BMS charge/discharge overload alarm", - 32: "ID182 BMS short circuit alarm", - 64: "ID183 BMS version inconsistency", - 128: "ID184 BMS CAN version inconsistency", - 256: "ID185 BMS CAN version is too low", - 4096: "ID189 Arc device communication failure", - 8192: "ID190 DC arc alarm fault", - 16384: "ID191 PID repair failed", - 32768: "ID192 PLC module heartbeat loss", }, - allowedtypes = HYBRID | PV, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Waiting Time", - key = "waiting_time", - native_unit_of_measurement = UnitOfTime.SECONDS, - register = 0x417, - unit = REGISTER_S16, - allowedtypes = HYBRID | PV, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Inverter Temperature 1", - key = "inverter_temperature_1", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x418, - unit = REGISTER_S16, - allowedtypes = HYBRID | PV, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Inverter Temperature 2", - key = "inverter_temperature_2", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x419, - unit = REGISTER_S16, - allowedtypes = HYBRID | PV, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Heatsink Temperature 1", - key = "heatsink_temperature_1", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x41A, - #newblock = True, - unit = REGISTER_S16, - allowedtypes = HYBRID | PV, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Heatsink Temperature 2", - key = "heatsink_temperature_2", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x41B, - unit = REGISTER_S16, - allowedtypes = HYBRID | PV, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Module Temperature 1", - key = "module_temperature_1", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x420, - unit = REGISTER_S16, - allowedtypes = HYBRID | PV, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Module Temperature 2", - key = "module_temperature_2", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x421, - unit = REGISTER_S16, - allowedtypes = HYBRID | PV, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "System Time", - key = "rtc", - register = 0x42C, - unit = REGISTER_WORDS, - wordcount = 6, - scale = value_function_rtc_ymd, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | PV, - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:clock", - ), - SofarModbusSensorEntityDescription( - name = "Serial Number", - key = "serial_number", - register = 0x445, - newblock = True, - unit = REGISTER_STR, + ### + # + # Real-time Data Area + # + ### + SofarModbusSensorEntityDescription( + name="System State", + key="system_state", + register=0x404, + newblock=True, + scale={ + 0: "Waiting", + 1: "Checking", + 2: "Grid-connected", + 3: "Emergency Power Supply", + 4: "Recoverable fault", + 5: "Permanent fault", + 6: "Upgrading", + 7: "Self-Charging", + }, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Fault 1", + key="fault_1", + register=0x405, + scale={ + 0: "No error", + 1: "ID01 Grid Over Voltage Protection", + 2: "ID02 Grid Under Voltage Protection", + 4: "ID03 Grid Over Frequency Protection", + 8: "ID04 Grid Under Frequency Protection", + 16: "ID05 Leakage current fault", + 32: "ID06 High penetration error", + 64: "ID07 Low penetration error", + 128: "ID08 Islanding error", + 256: "ID09 Grid voltage transient value overvoltage 1", + 512: "ID10 Grid voltage transient value overvoltage 2", + 1024: "ID11 Grid line voltage error", + 2048: "ID12 Inverter voltage error", + }, + allowedtypes=HYBRID | PV, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Fault 2", + key="fault_2", + register=0x406, + scale={ + 0: "No error", + 1: "ID17 Grid current sampling error", + 2: "ID18 Grid current DC component sampling error (AC side)", + 4: "ID19 Grid voltage sampling error (DC side)", + 8: "ID20 Grid voltage sampling error (AC side)", + 16: "ID21 Leakage current sampling error (DC side)", + 32: "ID22 Leakage current sampling error (AC side)", + 64: "ID23 Load voltage DC component sampling error", + 128: "ID24 DC input current sampling error", + 256: "ID25 DC component sampling error of grid current (DC side)", + 512: "ID26 DC input branch current sampling error", + 4096: "ID29 Leakage current consistency error", + 8192: "ID30 Grid voltage consistency error", + 16384: "ID31 DCI consistency error", + }, + allowedtypes=HYBRID | PV, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Fault 3", + key="fault_3", + register=0x407, + scale={ + 0: "No error", + 1: "ID033 SPI communication error (DC side)", + 2: "ID034 SPI communication error (AC side)", + 4: "ID035 Chip error (DC side)", + 8: "ID036 Chip error (AC side)", + 16: "ID037 Auxiliary power error", + 32: "ID038 Inverter soft start failure", + 256: "ID041 Relay detection failure", + 512: "ID042 Low insulation impedance", + 1024: "ID043 Grounding error", + 2048: "ID044 Input mode setting error", + 4096: "ID045 ID045 CT error", + 8192: "ID046 Input reversal error", + 16384: "ID047 Parallel error", + 32768: "ID048 Serial number error", + }, + allowedtypes=HYBRID | PV, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Fault 4", + key="fault_4", + register=0x408, + scale={ + 0: "No error", + 1: "ID049 Battery temperature protection", + 2: "ID050 Heat sink 1 temperature protection", + 4: "ID051 Heater 2 temperature protection", + 8: "ID052 Heater 3 temperature protection", + 16: "ID053 Heatsink 4 temperature protection", + 32: "ID054 Heatsink 5 temperature protection", + 64: "ID055 Radiator 6 temperature protection", + 256: "ID057 Ambient temperature 1 protection", + 512: "ID058 Ambient temperature 2 protection", + 1024: "ID059 Module 1 temperature protection", + 2048: "ID060 Module 2 temperature protection", + 4096: "ID061 Module 3 temperature protection", + 8192: "ID062 Module temperature difference is too large", + }, + allowedtypes=HYBRID | PV, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Fault 5", + key="fault_5", + register=0x409, + scale={ + 0: "No error", + 1: "ID065 Bus voltage RMS unbalance", + 2: "ID066 Bus voltage transient value unbalance", + 4: "ID067 Undervoltage of busbar during grid connection", + 8: "ID068 Bus bar low voltage", + 16: "ID069 PV overvoltage", + 32: "ID070 Battery over-voltage", + 64: "ID071 LLCBus overvoltage protection", + 128: "ID072 Inverter bus voltage RMS software overvoltage", + 256: "ID073 Inverter bus voltage transient value software overvoltage", + 512: "ID074 Flying Cross Capacitor Overvoltage Protection", + 1024: "ID075 Flying Cross capacitor undervoltage protection", + }, + allowedtypes=HYBRID | PV, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Fault 6", + key="fault_6", + register=0x040A, + scale={ + 0: "No error", + 1: "ID081 Battery overcurrent software protection", + 2: "ID082 Dci overcurrent protection", + 4: "ID083 Output transient current protection", + 8: "ID084 BuckBoost software overcurrent", + 16: "ID085 Output RMS current protection", + 32: "ID086 PV instantaneous current overcurrent software protection", + 64: "ID087 PV parallel uneven current", + 128: "ID088 Output current unbalance", + 256: "ID089 PV software overcurrent protection", + 512: "ID090 Balanced circuit overcurrent protection", + 1024: "ID091 Resonance protection", + }, + allowedtypes=HYBRID | PV, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Fault 7", + key="fault_7", + register=0x040B, + scale={ + 0: "No error", + 1: "ID097 LLC bus hardware overvoltage", + 2: "ID098 Inverter bus hardware overvoltage", + 4: "ID099 BuckBoost hardware overcurrent", + 8: "ID100 Battery hardware overcurrent", + 16: "ID101", + 32: "ID102 PV hardware overcurrent", + 64: "ID103 AC output hardware overcurrent", + 256: "ID105 Power meter error", + 512: "ID106 Serial number model error", + 8192: "ID110 Overload protection 1", + 16384: "ID111 Overload protection 2", + 32768: "ID112 Overload protection 3", + }, + allowedtypes=HYBRID | PV, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Fault 8", + key="fault_8", + register=0x040C, + scale={ + 0: "No error", + 1: "ID113 Overtemperature derating", + 2: "ID114 Frequency down load", + 4: "ID115 Frequency loading", + 8: "ID116 Voltage down load", + 16: "ID117 Voltage loading", + 256: "ID121 Lightning protection failure (DC)", + 512: "ID122 Lightning protection failure (AC)", + 2048: "ID124 Battery low voltage protection", + 4096: "ID125 Battery low voltage shutdown", + 8192: "ID126 Battery low voltage pre-alarm", + }, + allowedtypes=HYBRID | PV, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Fault 9", + key="fault_9", + register=0x040D, + scale={ + 0: "No error", + 1: "ID129 Output hardware overcurrent permanent fault", + 2: "ID130 Bus overvoltage permanent fault", + 4: "ID131 Bus hardware over-voltage permanent fault", + 8: "ID132 PV uneven flow permanent fault", + 16: "ID133 Battery overcurrent permanent fault in EPS mode", + 32: "ID134 Output transient overcurrent permanent fault", + 64: "ID135 Output current unbalance permanent fault", + 256: "ID137 Input mode setting error permanent fault", + 512: "ID138 Input overcurrent permanent fault", + 1024: "ID139 Input hardware overcurrent permanent fault", + 2048: "ID140 Relay permanent fault", + 4096: "ID141 Bus unbalance permanent fault", + 8192: "ID142 Lightning protection permanent fault - DC side", + 16384: "ID143 Lightning protection permanent fault - AC side", + }, + allowedtypes=HYBRID | PV, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Fault 10", + key="fault_10", + register=0x040E, + scale={ + 0: "No error", + 1: "ID145 USB fault", + 2: "ID146 WIFI fault", + 4: "ID147 Bluetooth fault", + 8: "ID148 RTC clock fault", + 16: "ID149 Communication board EEPROM error", + 32: "ID150 Communication board FLASH error", + 128: "ID152 Safety regulation version error", + 256: "ID153 SCI communication error (DC side)", + 512: "ID154 SCI communication error (AC side)", + 1024: "ID155 SCI communication error (convergence board side)", + 2048: "ID156 Software version inconsistency", + 4096: "ID157 Lithium battery 1 communication error", + 8192: "ID158 Li-ion battery 2 communication error", + 16384: "ID159 Lithium battery 3 communication error", + 32768: "ID160 Lithium battery 4 communication failure", + }, + allowedtypes=HYBRID | PV, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Fault 11", + key="fault_11", + register=0x040F, + scale={ + 0: "No error", + 1: "ID161 Forced shutdown", + 2: "ID162 Remote shutdown", + 4: "ID163 Drms0 shutdown", + 16: "ID165 Remote down load", + 32: "ID166 Logic interface down load", + 64: "ID167 Anti-Reverse Flow Downgrade", + 256: "ID169 Fan 1 failure", + 512: "ID170 Fan 2 failure", + 1024: "ID171 Fan 3 failure", + 2048: "ID172 Fan 4 failure", + 4096: "ID173 Fan 5 failure", + 8192: "ID174 Fan 6 failure", + 16384: "ID175 Fan 7 fault", + 32768: "ID176 Meter communication failure", + }, + allowedtypes=HYBRID | PV, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Fault 12", + key="fault_12", + register=0x0410, + scale={ + 0: "No error", + 1: "ID177 BMS over-voltage alarm", + 2: "ID178 BMS undervoltage alarm", + 4: "ID179 BMS high temperature alarm", + 8: "ID180 BMS low temperature alarm", + 16: "ID181 BMS charge/discharge overload alarm", + 32: "ID182 BMS short circuit alarm", + 64: "ID183 BMS version inconsistency", + 128: "ID184 BMS CAN version inconsistency", + 256: "ID185 BMS CAN version is too low", + 4096: "ID189 Arc device communication failure", + 8192: "ID190 DC arc alarm fault", + 16384: "ID191 PID repair failed", + 32768: "ID192 PLC module heartbeat loss", + }, + allowedtypes=HYBRID | PV, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Waiting Time", + key="waiting_time", + native_unit_of_measurement=UnitOfTime.SECONDS, + register=0x417, + unit=REGISTER_S16, + allowedtypes=HYBRID | PV, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Inverter Temperature 1", + key="inverter_temperature_1", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x418, + unit=REGISTER_S16, + allowedtypes=HYBRID | PV, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Inverter Temperature 2", + key="inverter_temperature_2", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x419, + unit=REGISTER_S16, + allowedtypes=HYBRID | PV, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Heatsink Temperature 1", + key="heatsink_temperature_1", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x41A, + # newblock = True, + unit=REGISTER_S16, + allowedtypes=HYBRID | PV, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Heatsink Temperature 2", + key="heatsink_temperature_2", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x41B, + unit=REGISTER_S16, + allowedtypes=HYBRID | PV, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Module Temperature 1", + key="module_temperature_1", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x420, + unit=REGISTER_S16, + allowedtypes=HYBRID | PV, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Module Temperature 2", + key="module_temperature_2", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x421, + unit=REGISTER_S16, + allowedtypes=HYBRID | PV, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="System Time", + key="rtc", + register=0x42C, + unit=REGISTER_WORDS, + wordcount=6, + scale=value_function_rtc_ymd, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | PV, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:clock", + ), + SofarModbusSensorEntityDescription( + name="Serial Number", + key="serial_number", + register=0x445, + newblock=True, + unit=REGISTER_STR, wordcount=7, - entity_category = EntityCategory.DIAGNOSTIC, - allowedtypes = HYBRID | PV, + entity_category=EntityCategory.DIAGNOSTIC, + allowedtypes=HYBRID | PV, ), SofarModbusSensorEntityDescription( - name = "Hardware Version", - key = "hardware_version", - register = 0x44D, - unit = REGISTER_STR, + name="Hardware Version", + key="hardware_version", + register=0x44D, + unit=REGISTER_STR, wordcount=2, - entity_category = EntityCategory.DIAGNOSTIC, - allowedtypes = HYBRID | PV, + entity_category=EntityCategory.DIAGNOSTIC, + allowedtypes=HYBRID | PV, ), SofarModbusSensorEntityDescription( - name = "Software Version", - key = "software_version", - register = 0x44F, - unit = REGISTER_STR, + name="Software Version", + key="software_version", + register=0x44F, + unit=REGISTER_STR, wordcount=12, - entity_category = EntityCategory.DIAGNOSTIC, - allowedtypes = HYBRID | PV, - ), -### -# -# On Grid Output -# -### - SofarModbusSensorEntityDescription( - name = "Grid Frequency", - key = "grid_frequency", - native_unit_of_measurement = UnitOfFrequency.HERTZ, - device_class = SensorDeviceClass.FREQUENCY, - register = 0x484, - newblock = True, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Active Power Output Total", - key = "active_power_output_total", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x485, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Reactive Power Output Total", - key = "reactive Power_output_total", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x486, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Apparent Power Output Total", - key = "apparent_power_output_total", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x487, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Active Power PCC Total", - key = "active_power_pcc_total", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x488, - unit = REGISTER_S16, - scan_group = SCAN_GROUP_FAST, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Reactive Power PCC Total", - key = "reactive Power_pcc_total", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x489, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Apparent Power PCC Total", - key = "apparent_power_pcc_total", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x48A, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Voltage L1", - key = "voltage_l1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x48D, - scan_group = SCAN_GROUP_FAST, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Current Output L1", - key = "current_output_l1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x48E, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Active Power Output L1", - key = "active_power_output_l1", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - register = 0x48F, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Reactive Power Output L1", - key = "reactive Power_output_l1", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - register = 0x490, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Power Factor Output L1", - key = "power_factor_output_l1", - device_class = SensorDeviceClass.POWER_FACTOR, - native_unit_of_measurement = None, - state_class = SensorStateClass.MEASUREMENT, - register = 0x491, - unit = REGISTER_S16, - scale = 0.001, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Current PCC L1", - key = "current_pcc_l1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x492, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Active Power PCC L1", - key = "active_power_pcc_l1", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - register = 0x493, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Reactive Power PCC L1", - key = "reactive Power_pcc_l1", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - register = 0x494, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Power Factor PCC L1", - key = "power_factor_pcc_l1", - device_class = SensorDeviceClass.POWER_FACTOR, - native_unit_of_measurement = None, - state_class = SensorStateClass.MEASUREMENT, - register = 0x495, - unit = REGISTER_S16, - scale = 0.001, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Voltage L2", - key = "voltage_l2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x498, - scan_group = SCAN_GROUP_FAST, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Current Output L2", - key = "current_output_l2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x499, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Active Power Output L2", - key = "active_power_output_l2", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - register = 0x49A, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Reactive Power Output L2", - key = "reactive Power_output_l2", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - register = 0x49B, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Power Factor Output L2", - key = "power_factor_output_l2", - device_class = SensorDeviceClass.POWER_FACTOR, - native_unit_of_measurement = None, - state_class = SensorStateClass.MEASUREMENT, - register = 0x49C, - unit = REGISTER_S16, - scale = 0.001, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Current PCC L2", - key = "current_pcc_l2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x49D, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Active Power PCC L2", - key = "active_power_pcc_l2", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - register = 0x49E, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Reactive Power PCC L2", - key = "reactive Power_pcc_l2", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - register = 0x49F, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Power Factor PCC L2", - key = "power_factor_pcc_l2", - device_class = SensorDeviceClass.POWER_FACTOR, - native_unit_of_measurement = None, - state_class = SensorStateClass.MEASUREMENT, - register = 0x4A0, - unit = REGISTER_S16, - scale = 0.001, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Voltage L3", - key = "voltage_l3", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x4A3, - scan_group = SCAN_GROUP_FAST, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Current Output L3", - key = "current_output_l3", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x4A4, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Active Power Output L3", - key = "active_power_output_l3", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - register = 0x4A5, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Reactive Power Output L3", - key = "reactive Power_output_l3", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - register = 0x4A6, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Power Factor Output L3", - key = "power_factor_output_l3", - device_class = SensorDeviceClass.POWER_FACTOR, - native_unit_of_measurement = None, - state_class = SensorStateClass.MEASUREMENT, - register = 0x4A7, - unit = REGISTER_S16, - scale = 0.001, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Current PCC L3", - key = "current_pcc_l3", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x4A8, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Active Power PCC L3", - key = "active_power_pcc_l3", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - register = 0x4A9, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Reactive Power PCC L3", - key = "reactive Power_pcc_l3", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - register = 0x4AA, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Power Factor PCC L3", - key = "power_factor_pcc_l3", - device_class = SensorDeviceClass.POWER_FACTOR, - native_unit_of_measurement = None, - state_class = SensorStateClass.MEASUREMENT, - register = 0x4AB, - unit = REGISTER_S16, - scale = 0.001, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Active Power PV Ext", - key = "active_power_pv_ext", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x4AE, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Active Power Load Sys", - key = "active_power_load_sys", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x4AF, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Voltage Phase L1N", - key = "voltage_phase_l1n", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x4B0, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Current Output L1N", - key = "current_output_l1n", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x4B1, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Active Power Output L1N", - key = "active_power_output_l1n", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - register = 0x4B2, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Current PCC L1N", - key = "current_pcc_l1n", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x4B3, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Active Power PCC L1N", - key = "active_power_pcc_l1n", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - register = 0x4B4, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Voltage Phase L2N", - key = "voltage_phase_l2n", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x4B5, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Current Output L2N", - key = "current_output_l2n", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x4B6, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Active Power Output L2N", - key = "active_power_output_l2n", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - register = 0x4B7, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Current PCC L2N", - key = "current_pcc_l2n", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x4B8, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Active Power PCC L2N", - key = "active_power_pcc_l2n", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - register = 0x4B9, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Voltage Line L1", - key = "voltage_line_l1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x4BA, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Voltage Line L2", - key = "voltage_line_l2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x4BB, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Voltage Line L3", - key = "voltage_line_l3", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x4BC, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | PV, - ), -### -# -# Off Grid Output (0x0500-0x057F) -# -### - SofarModbusSensorEntityDescription( - name = "Active Power Off-Grid Total", - key = "active_power_offgrid_total", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x504, - #newblock = True, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Reactive Power Off-Grid Total", - key = "reactive Power_offgrid_total", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - register = 0x505, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Apparent Power Off-Grid Total", - key = "apparent_power_offgrid_total", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x506, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid Frequency", - key = "offgrid_frequency", - native_unit_of_measurement = UnitOfFrequency.HERTZ, - device_class = SensorDeviceClass.FREQUENCY, - register = 0x507, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid Voltage L1", - key = "offgrid_voltage_l1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x50A, - scan_group = SCAN_GROUP_FAST, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid Current Output L1", - key = "offgrid_current_output_l1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x50B, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid Active Power Output L1", - key = "offgrid_active_power_output_l1", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - register = 0x50C, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid Reactive Power Output L1", - key = "offgrid_reactive Power_output_l1", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - register = 0x50D, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid Apparent Power Output L1", - key = "offgrid_apparent_power_output_l1", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - register = 0x50E, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid LoadPeakRatio L1", - key = "offgrid_loadpeakratio_l1", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - register = 0x50F, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid Voltage L2", - key = "offgrid_voltage_l2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x512, - scan_group = SCAN_GROUP_FAST, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid Current Output L2", - key = "offgrid_current_output_l2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x513, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid Active Power Output L2", - key = "offgrid_active_power_output_l2", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - register = 0x514, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid Reactive Power Output L2", - key = "offgrid_reactive Power_output_l2", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - register = 0x515, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid Apparent Power Output L2", - key = "offgrid_apparent_power_output_l2", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - register = 0x516, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid LoadPeakRatio L2", - key = "offgrid_loadpeakratio_l2", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - register = 0x517, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid Voltage L3", - key = "offgrid_voltage_l3", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x51A, - scan_group = SCAN_GROUP_FAST, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid Current Output L3", - key = "offgrid_current_output_l3", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x51B, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid Active Power Output L3", - key = "offgrid_active_power_output_l3", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - register = 0x51C, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid Reactive Power Output L3", - key = "offgrid_reactive Power_output_l3", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - register = 0x51D, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid Apparent Power Output L3", - key = "offgrid_apparent_power_output_l3", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - register = 0x51E, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid LoadPeakRatio L3", - key = "offgrid_loadpeakratio_l3", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - register = 0x51F, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid Voltage Output L1N", - key = "offgrid_voltage_output_l1n", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x522, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid Current Output L1N", - key = "offgrid_current_output_l1n", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x523, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid Active Power Output L1N", - key = "offgrid_active_power_output_l1n", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - register = 0x524, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid Voltage Output L2N", - key = "offgrid_voltage_output_l2n", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x525, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid Current Output L2N", - key = "offgrid_current_output_l2n", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x526, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Off-Grid Active Power Output L2N", - key = "offgrid_active_power_output_l2n", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - register = 0x527, - newblock = True, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X3 | EPS, - ), -### -# -# PV Input (0x0580-0x05FF) -# -### - SofarModbusSensorEntityDescription( - name = "PV Voltage 1", - key = "pv_voltage_1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x584, - newblock = True, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | PV | GEN, - ), - SofarModbusSensorEntityDescription( - name = "PV Current 1", - key = "pv_current_1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x585, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV | GEN, - ), - SofarModbusSensorEntityDescription( - name = "PV Power 1", - key = "pv_power_1", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x586, - scan_group = SCAN_GROUP_FAST, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV | GEN, - ), - SofarModbusSensorEntityDescription( - name = "PV Voltage 2", - key = "pv_voltage_2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x587, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | PV | GEN, - ), - SofarModbusSensorEntityDescription( - name = "PV Current 2", - key = "pv_current_2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x588, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV | GEN, - ), - SofarModbusSensorEntityDescription( - name = "PV Power 2", - key = "pv_power_2", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x589, - scan_group = SCAN_GROUP_FAST, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV | GEN, - ), - SofarModbusSensorEntityDescription( - name = "PV Voltage 3", - key = "pv_voltage_3", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x58A, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | PV | GEN | ALL_MPPT_GROUP, - ), - SofarModbusSensorEntityDescription( - name = "PV Current 3", - key = "pv_current_3", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x58B, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV | GEN | ALL_MPPT_GROUP, - ), - SofarModbusSensorEntityDescription( - name = "PV Power 3", - key = "pv_power_3", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x58C, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV | GEN | ALL_MPPT_GROUP, - ), - SofarModbusSensorEntityDescription( - name = "PV Voltage 4", - key = "pv_voltage_4", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x58D, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | PV | GEN | MPPT4 | MPPT6 | MPPT8 | MPPT10, - ), - SofarModbusSensorEntityDescription( - name = "PV Current 4", - key = "pv_current_4", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x58E, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV | GEN | MPPT4 | MPPT6 | MPPT8 | MPPT10, - ), - SofarModbusSensorEntityDescription( - name = "PV Power 4", - key = "pv_power_4", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x58F, - newblock = True, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV | GEN | MPPT4 | MPPT6 | MPPT8 | MPPT10, - ), - SofarModbusSensorEntityDescription( - name = "PV Voltage 5", - key = "pv_voltage_5", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x590, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | PV | GEN | MPPT6 | MPPT8 | MPPT10, - ), - SofarModbusSensorEntityDescription( - name = "PV Current 5", - key = "pv_current_5", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x591, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV | GEN | MPPT6 | MPPT8 | MPPT10, - ), - SofarModbusSensorEntityDescription( - name = "PV Power 5", - key = "pv_power_5", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x592, - newblock = True, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV | GEN | MPPT6 | MPPT8 | MPPT10, - ), - SofarModbusSensorEntityDescription( - name = "PV Voltage 6", - key = "pv_voltage_6", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x593, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | PV | GEN | MPPT6 | MPPT8 | MPPT10, - ), - SofarModbusSensorEntityDescription( - name = "PV Current 6", - key = "pv_current_6", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x594, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV | GEN | MPPT6 | MPPT8 | MPPT10, - ), - SofarModbusSensorEntityDescription( - name = "PV Power 6", - key = "pv_power_6", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x594, - newblock = True, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV | GEN | MPPT6 | MPPT8 | MPPT10, - ), - SofarModbusSensorEntityDescription( - name = "PV Voltage 7", - key = "pv_voltage_7", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x596, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | PV | GEN | MPPT8 | MPPT10, - ), - SofarModbusSensorEntityDescription( - name = "PV Current 7", - key = "pv_current_7", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x597, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV | GEN | MPPT8 | MPPT10, - ), - SofarModbusSensorEntityDescription( - name = "PV Power 7", - key = "pv_power_7", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x598, - newblock = True, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV | GEN | MPPT8 | MPPT10, - ), - SofarModbusSensorEntityDescription( - name = "PV Voltage 8", - key = "pv_voltage_8", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x599, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | PV | GEN | MPPT8 | MPPT10, - ), - SofarModbusSensorEntityDescription( - name = "PV Current 8", - key = "pv_current_8", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x59A, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV | GEN | MPPT8 | MPPT10, - ), - SofarModbusSensorEntityDescription( - name = "PV Power 8", - key = "pv_power_8", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x59B, - newblock = True, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV | GEN | MPPT8 | MPPT10, - ), - SofarModbusSensorEntityDescription( - name = "PV Voltage 9", - key = "pv_voltage_9", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x59C, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | PV | GEN | MPPT10, - ), - SofarModbusSensorEntityDescription( - name = "PV Current 9", - key = "pv_current_9", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x59D, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV | GEN | MPPT10, - ), - SofarModbusSensorEntityDescription( - name = "PV Power 9", - key = "pv_power_9", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x59E, - newblock = True, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV | GEN | MPPT10, - ), - SofarModbusSensorEntityDescription( - name = "PV Voltage 10", - key = "pv_voltage_10", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x59F, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | PV | GEN | MPPT10, - ), - SofarModbusSensorEntityDescription( - name = "PV Current 10", - key = "pv_current_10", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x5A0, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV | GEN | MPPT10, - ), - SofarModbusSensorEntityDescription( - name = "PV Power 10", - key = "pv_power_10", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x5A1, - newblock = True, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV | GEN | MPPT10, - ), - SofarModbusSensorEntityDescription( - name = "PV Power Total", - key = "pv_power_total", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x5C4, - newblock = True, - scale = 0.1, - rounding = 1, - #entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "PV Power Total", - key = "pv_power_total", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x5C4, - newblock = True, - scale = 0.01, - rounding = 2, - #entity_registry_enabled_default = False, - allowedtypes = PV | GEN, - ), -### -# -# Battery Input (0x0600-0x067F) -# -### - SofarModbusSensorEntityDescription( - name = "Battery Voltage 1", - key = "battery_voltage_1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x604, - newblock = True, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - ), - SofarModbusSensorEntityDescription( - name = "Battery Current 1", - key = "battery_current_1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x605, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID, - ), - SofarModbusSensorEntityDescription( - name = "Battery Power 1", - key = "battery_power_1", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x606, - unit = REGISTER_S16, - scan_group = SCAN_GROUP_FAST, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID, - ), - SofarModbusSensorEntityDescription( - name = "Battery Temperature 1", - key = "battery_temperature_1", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x607, - unit = REGISTER_S16, - allowedtypes = HYBRID, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Capacity 1", - key = "battery_capacity_1", - native_unit_of_measurement = PERCENTAGE, - state_class = SensorStateClass.MEASUREMENT, + entity_category=EntityCategory.DIAGNOSTIC, + allowedtypes=HYBRID | PV, + ), + ### + # + # On Grid Output + # + ### + SofarModbusSensorEntityDescription( + name="Grid Frequency", + key="grid_frequency", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + device_class=SensorDeviceClass.FREQUENCY, + register=0x484, + newblock=True, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Active Power Output Total", + key="active_power_output_total", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x485, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Reactive Power Output Total", + key="reactive Power_output_total", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x486, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Apparent Power Output Total", + key="apparent_power_output_total", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x487, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Active Power PCC Total", + key="active_power_pcc_total", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x488, + unit=REGISTER_S16, + scan_group=SCAN_GROUP_FAST, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Reactive Power PCC Total", + key="reactive Power_pcc_total", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x489, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Apparent Power PCC Total", + key="apparent_power_pcc_total", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x48A, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Voltage L1", + key="voltage_l1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x48D, + scan_group=SCAN_GROUP_FAST, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Current Output L1", + key="current_output_l1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x48E, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Active Power Output L1", + key="active_power_output_l1", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=0x48F, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Reactive Power Output L1", + key="reactive Power_output_l1", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=0x490, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Power Factor Output L1", + key="power_factor_output_l1", + device_class=SensorDeviceClass.POWER_FACTOR, + native_unit_of_measurement=None, + state_class=SensorStateClass.MEASUREMENT, + register=0x491, + unit=REGISTER_S16, + scale=0.001, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Current PCC L1", + key="current_pcc_l1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x492, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Active Power PCC L1", + key="active_power_pcc_l1", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=0x493, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Reactive Power PCC L1", + key="reactive Power_pcc_l1", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=0x494, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Power Factor PCC L1", + key="power_factor_pcc_l1", + device_class=SensorDeviceClass.POWER_FACTOR, + native_unit_of_measurement=None, + state_class=SensorStateClass.MEASUREMENT, + register=0x495, + unit=REGISTER_S16, + scale=0.001, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Voltage L2", + key="voltage_l2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x498, + scan_group=SCAN_GROUP_FAST, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Current Output L2", + key="current_output_l2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x499, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Active Power Output L2", + key="active_power_output_l2", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=0x49A, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Reactive Power Output L2", + key="reactive Power_output_l2", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=0x49B, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Power Factor Output L2", + key="power_factor_output_l2", + device_class=SensorDeviceClass.POWER_FACTOR, + native_unit_of_measurement=None, + state_class=SensorStateClass.MEASUREMENT, + register=0x49C, + unit=REGISTER_S16, + scale=0.001, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Current PCC L2", + key="current_pcc_l2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x49D, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Active Power PCC L2", + key="active_power_pcc_l2", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=0x49E, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Reactive Power PCC L2", + key="reactive Power_pcc_l2", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=0x49F, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Power Factor PCC L2", + key="power_factor_pcc_l2", + device_class=SensorDeviceClass.POWER_FACTOR, + native_unit_of_measurement=None, + state_class=SensorStateClass.MEASUREMENT, + register=0x4A0, + unit=REGISTER_S16, + scale=0.001, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Voltage L3", + key="voltage_l3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x4A3, + scan_group=SCAN_GROUP_FAST, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Current Output L3", + key="current_output_l3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x4A4, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Active Power Output L3", + key="active_power_output_l3", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=0x4A5, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Reactive Power Output L3", + key="reactive Power_output_l3", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=0x4A6, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Power Factor Output L3", + key="power_factor_output_l3", + device_class=SensorDeviceClass.POWER_FACTOR, + native_unit_of_measurement=None, + state_class=SensorStateClass.MEASUREMENT, + register=0x4A7, + unit=REGISTER_S16, + scale=0.001, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Current PCC L3", + key="current_pcc_l3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x4A8, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Active Power PCC L3", + key="active_power_pcc_l3", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=0x4A9, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Reactive Power PCC L3", + key="reactive Power_pcc_l3", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=0x4AA, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Power Factor PCC L3", + key="power_factor_pcc_l3", + device_class=SensorDeviceClass.POWER_FACTOR, + native_unit_of_measurement=None, + state_class=SensorStateClass.MEASUREMENT, + register=0x4AB, + unit=REGISTER_S16, + scale=0.001, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Active Power PV Ext", + key="active_power_pv_ext", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x4AE, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Active Power Load Sys", + key="active_power_load_sys", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x4AF, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Voltage Phase L1N", + key="voltage_phase_l1n", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x4B0, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Current Output L1N", + key="current_output_l1n", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x4B1, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Active Power Output L1N", + key="active_power_output_l1n", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=0x4B2, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Current PCC L1N", + key="current_pcc_l1n", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x4B3, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Active Power PCC L1N", + key="active_power_pcc_l1n", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=0x4B4, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Voltage Phase L2N", + key="voltage_phase_l2n", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x4B5, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Current Output L2N", + key="current_output_l2n", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x4B6, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Active Power Output L2N", + key="active_power_output_l2n", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=0x4B7, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Current PCC L2N", + key="current_pcc_l2n", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x4B8, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Active Power PCC L2N", + key="active_power_pcc_l2n", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=0x4B9, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Voltage Line L1", + key="voltage_line_l1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x4BA, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Voltage Line L2", + key="voltage_line_l2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x4BB, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Voltage Line L3", + key="voltage_line_l3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x4BC, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | PV, + ), + ### + # + # Off Grid Output (0x0500-0x057F) + # + ### + SofarModbusSensorEntityDescription( + name="Active Power Off-Grid Total", + key="active_power_offgrid_total", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x504, + # newblock = True, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Reactive Power Off-Grid Total", + key="reactive Power_offgrid_total", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=0x505, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Apparent Power Off-Grid Total", + key="apparent_power_offgrid_total", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x506, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid Frequency", + key="offgrid_frequency", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + device_class=SensorDeviceClass.FREQUENCY, + register=0x507, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid Voltage L1", + key="offgrid_voltage_l1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x50A, + scan_group=SCAN_GROUP_FAST, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid Current Output L1", + key="offgrid_current_output_l1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x50B, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid Active Power Output L1", + key="offgrid_active_power_output_l1", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=0x50C, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid Reactive Power Output L1", + key="offgrid_reactive Power_output_l1", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=0x50D, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid Apparent Power Output L1", + key="offgrid_apparent_power_output_l1", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=0x50E, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid LoadPeakRatio L1", + key="offgrid_loadpeakratio_l1", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=0x50F, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid Voltage L2", + key="offgrid_voltage_l2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x512, + scan_group=SCAN_GROUP_FAST, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid Current Output L2", + key="offgrid_current_output_l2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x513, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid Active Power Output L2", + key="offgrid_active_power_output_l2", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=0x514, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid Reactive Power Output L2", + key="offgrid_reactive Power_output_l2", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=0x515, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid Apparent Power Output L2", + key="offgrid_apparent_power_output_l2", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=0x516, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid LoadPeakRatio L2", + key="offgrid_loadpeakratio_l2", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=0x517, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid Voltage L3", + key="offgrid_voltage_l3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x51A, + scan_group=SCAN_GROUP_FAST, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid Current Output L3", + key="offgrid_current_output_l3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x51B, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid Active Power Output L3", + key="offgrid_active_power_output_l3", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=0x51C, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid Reactive Power Output L3", + key="offgrid_reactive Power_output_l3", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=0x51D, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid Apparent Power Output L3", + key="offgrid_apparent_power_output_l3", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=0x51E, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid LoadPeakRatio L3", + key="offgrid_loadpeakratio_l3", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=0x51F, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid Voltage Output L1N", + key="offgrid_voltage_output_l1n", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x522, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid Current Output L1N", + key="offgrid_current_output_l1n", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x523, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid Active Power Output L1N", + key="offgrid_active_power_output_l1n", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=0x524, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid Voltage Output L2N", + key="offgrid_voltage_output_l2n", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x525, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid Current Output L2N", + key="offgrid_current_output_l2n", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x526, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Off-Grid Active Power Output L2N", + key="offgrid_active_power_output_l2n", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=0x527, + newblock=True, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3 | EPS, + ), + ### + # + # PV Input (0x0580-0x05FF) + # + ### + SofarModbusSensorEntityDescription( + name="PV Voltage 1", + key="pv_voltage_1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x584, + newblock=True, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | PV | GEN, + ), + SofarModbusSensorEntityDescription( + name="PV Current 1", + key="pv_current_1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x585, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV | GEN, + ), + SofarModbusSensorEntityDescription( + name="PV Power 1", + key="pv_power_1", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x586, + scan_group=SCAN_GROUP_FAST, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV | GEN, + ), + SofarModbusSensorEntityDescription( + name="PV Voltage 2", + key="pv_voltage_2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x587, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | PV | GEN, + ), + SofarModbusSensorEntityDescription( + name="PV Current 2", + key="pv_current_2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x588, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV | GEN, + ), + SofarModbusSensorEntityDescription( + name="PV Power 2", + key="pv_power_2", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x589, + scan_group=SCAN_GROUP_FAST, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV | GEN, + ), + SofarModbusSensorEntityDescription( + name="PV Voltage 3", + key="pv_voltage_3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x58A, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | PV | GEN | ALL_MPPT_GROUP, + ), + SofarModbusSensorEntityDescription( + name="PV Current 3", + key="pv_current_3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x58B, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV | GEN | ALL_MPPT_GROUP, + ), + SofarModbusSensorEntityDescription( + name="PV Power 3", + key="pv_power_3", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x58C, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV | GEN | ALL_MPPT_GROUP, + ), + SofarModbusSensorEntityDescription( + name="PV Voltage 4", + key="pv_voltage_4", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x58D, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | PV | GEN | MPPT4 | MPPT6 | MPPT8 | MPPT10, + ), + SofarModbusSensorEntityDescription( + name="PV Current 4", + key="pv_current_4", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x58E, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV | GEN | MPPT4 | MPPT6 | MPPT8 | MPPT10, + ), + SofarModbusSensorEntityDescription( + name="PV Power 4", + key="pv_power_4", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x58F, + newblock=True, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV | GEN | MPPT4 | MPPT6 | MPPT8 | MPPT10, + ), + SofarModbusSensorEntityDescription( + name="PV Voltage 5", + key="pv_voltage_5", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x590, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | PV | GEN | MPPT6 | MPPT8 | MPPT10, + ), + SofarModbusSensorEntityDescription( + name="PV Current 5", + key="pv_current_5", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x591, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV | GEN | MPPT6 | MPPT8 | MPPT10, + ), + SofarModbusSensorEntityDescription( + name="PV Power 5", + key="pv_power_5", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x592, + newblock=True, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV | GEN | MPPT6 | MPPT8 | MPPT10, + ), + SofarModbusSensorEntityDescription( + name="PV Voltage 6", + key="pv_voltage_6", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x593, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | PV | GEN | MPPT6 | MPPT8 | MPPT10, + ), + SofarModbusSensorEntityDescription( + name="PV Current 6", + key="pv_current_6", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x594, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV | GEN | MPPT6 | MPPT8 | MPPT10, + ), + SofarModbusSensorEntityDescription( + name="PV Power 6", + key="pv_power_6", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x594, + newblock=True, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV | GEN | MPPT6 | MPPT8 | MPPT10, + ), + SofarModbusSensorEntityDescription( + name="PV Voltage 7", + key="pv_voltage_7", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x596, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | PV | GEN | MPPT8 | MPPT10, + ), + SofarModbusSensorEntityDescription( + name="PV Current 7", + key="pv_current_7", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x597, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV | GEN | MPPT8 | MPPT10, + ), + SofarModbusSensorEntityDescription( + name="PV Power 7", + key="pv_power_7", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x598, + newblock=True, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV | GEN | MPPT8 | MPPT10, + ), + SofarModbusSensorEntityDescription( + name="PV Voltage 8", + key="pv_voltage_8", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x599, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | PV | GEN | MPPT8 | MPPT10, + ), + SofarModbusSensorEntityDescription( + name="PV Current 8", + key="pv_current_8", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x59A, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV | GEN | MPPT8 | MPPT10, + ), + SofarModbusSensorEntityDescription( + name="PV Power 8", + key="pv_power_8", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x59B, + newblock=True, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV | GEN | MPPT8 | MPPT10, + ), + SofarModbusSensorEntityDescription( + name="PV Voltage 9", + key="pv_voltage_9", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x59C, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | PV | GEN | MPPT10, + ), + SofarModbusSensorEntityDescription( + name="PV Current 9", + key="pv_current_9", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x59D, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV | GEN | MPPT10, + ), + SofarModbusSensorEntityDescription( + name="PV Power 9", + key="pv_power_9", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x59E, + newblock=True, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV | GEN | MPPT10, + ), + SofarModbusSensorEntityDescription( + name="PV Voltage 10", + key="pv_voltage_10", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x59F, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | PV | GEN | MPPT10, + ), + SofarModbusSensorEntityDescription( + name="PV Current 10", + key="pv_current_10", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x5A0, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV | GEN | MPPT10, + ), + SofarModbusSensorEntityDescription( + name="PV Power 10", + key="pv_power_10", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x5A1, + newblock=True, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV | GEN | MPPT10, + ), + SofarModbusSensorEntityDescription( + name="PV Power Total", + key="pv_power_total", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x5C4, + newblock=True, + scale=0.1, + rounding=1, + # entity_registry_enabled_default = False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="PV Power Total", + key="pv_power_total", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x5C4, + newblock=True, + scale=0.01, + rounding=2, + # entity_registry_enabled_default = False, + allowedtypes=PV | GEN, + ), + ### + # + # Battery Input (0x0600-0x067F) + # + ### + SofarModbusSensorEntityDescription( + name="Battery Voltage 1", + key="battery_voltage_1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x604, + newblock=True, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + ), + SofarModbusSensorEntityDescription( + name="Battery Current 1", + key="battery_current_1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x605, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=HYBRID, + ), + SofarModbusSensorEntityDescription( + name="Battery Power 1", + key="battery_power_1", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x606, + unit=REGISTER_S16, + scan_group=SCAN_GROUP_FAST, + scale=0.01, + rounding=2, + allowedtypes=HYBRID, + ), + SofarModbusSensorEntityDescription( + name="Battery Temperature 1", + key="battery_temperature_1", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x607, + unit=REGISTER_S16, + allowedtypes=HYBRID, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Capacity 1", + key="battery_capacity_1", + native_unit_of_measurement=PERCENTAGE, + state_class=SensorStateClass.MEASUREMENT, # device_class = SensorDeviceClass.BATTERY, - register = 0x608, - allowedtypes = HYBRID, - ), - SofarModbusSensorEntityDescription( - name = "Battery State of Health 1", - key = "battery_state_of_health_1", - register = 0x609, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = HYBRID, - icon = "mdi:battery-heart", - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Charge Cycle 1", - key = "battery_charge_cycle_1", - state_class = SensorStateClass.MEASUREMENT, - register = 0x60A, - allowedtypes = HYBRID, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Voltage 2", - key = "battery_voltage_2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x60B, - newblock = True, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - ), - SofarModbusSensorEntityDescription( - name = "Battery Current 2", - key = "battery_current_2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x60C, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - ), - SofarModbusSensorEntityDescription( - name = "Battery Power 2", - key = "battery_power_2", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x60D, - unit = REGISTER_S16, - scan_group = SCAN_GROUP_FAST, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - ), - SofarModbusSensorEntityDescription( - name = "Battery Temperature 2", - key = "battery_temperature_2", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x60E, - unit = REGISTER_S16, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Capacity 2", - key = "battery_capacity_2", - native_unit_of_measurement = PERCENTAGE, + register=0x608, + allowedtypes=HYBRID, + ), + SofarModbusSensorEntityDescription( + name="Battery State of Health 1", + key="battery_state_of_health_1", + register=0x609, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=HYBRID, + icon="mdi:battery-heart", + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Charge Cycle 1", + key="battery_charge_cycle_1", + state_class=SensorStateClass.MEASUREMENT, + register=0x60A, + allowedtypes=HYBRID, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Voltage 2", + key="battery_voltage_2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x60B, + newblock=True, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + ), + SofarModbusSensorEntityDescription( + name="Battery Current 2", + key="battery_current_2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x60C, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + ), + SofarModbusSensorEntityDescription( + name="Battery Power 2", + key="battery_power_2", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x60D, + unit=REGISTER_S16, + scan_group=SCAN_GROUP_FAST, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + ), + SofarModbusSensorEntityDescription( + name="Battery Temperature 2", + key="battery_temperature_2", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x60E, + unit=REGISTER_S16, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Capacity 2", + key="battery_capacity_2", + native_unit_of_measurement=PERCENTAGE, # device_class = SensorDeviceClass.BATTERY, - state_class = SensorStateClass.MEASUREMENT, - register = 0x60F, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - ), - SofarModbusSensorEntityDescription( - name = "Battery State of Health 2", - key = "battery_state_of_health_2", - register = 0x610, - native_unit_of_measurement = PERCENTAGE, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-heart", - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Charge Cycle 2", - key = "battery_charge_cycle_2", - state_class = SensorStateClass.MEASUREMENT, - register = 0x611, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Voltage 3", - key = "battery_voltage_3", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x612, - newblock = True, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery Current 3", - key = "battery_current_3", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x613, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery Power 3", - key = "battery_power_3", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x614, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery Temperature 3", - key = "battery_temperature_3", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x615, - unit = REGISTER_S16, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Capacity 3", - key = "battery_capacity_3", - native_unit_of_measurement = PERCENTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=0x60F, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + ), + SofarModbusSensorEntityDescription( + name="Battery State of Health 2", + key="battery_state_of_health_2", + register=0x610, + native_unit_of_measurement=PERCENTAGE, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-heart", + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Charge Cycle 2", + key="battery_charge_cycle_2", + state_class=SensorStateClass.MEASUREMENT, + register=0x611, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Voltage 3", + key="battery_voltage_3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x612, + newblock=True, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery Current 3", + key="battery_current_3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x613, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery Power 3", + key="battery_power_3", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x614, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery Temperature 3", + key="battery_temperature_3", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x615, + unit=REGISTER_S16, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Capacity 3", + key="battery_capacity_3", + native_unit_of_measurement=PERCENTAGE, # device_class = SensorDeviceClass.BATTERY, - state_class = SensorStateClass.MEASUREMENT, - register = 0x616, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery State of Health 3", - key = "battery_state_of_health_3", - register = 0x617, - native_unit_of_measurement = PERCENTAGE, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - icon = "mdi:battery-heart", - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Charge Cycle 3", - key = "battery_charge_cycle_3", - state_class = SensorStateClass.MEASUREMENT, - register = 0x618, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Voltage 4", - key = "battery_voltage_4", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x619, - newblock = True, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery Current 4", - key = "battery_current_4", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x61A, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery Power 4", - key = "battery_power_4", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x61B, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery Temperature 4", - key = "battery_temperature_4", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x61C, - unit = REGISTER_S16, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Capacity 4", - key = "battery_capacity_4", - native_unit_of_measurement = PERCENTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=0x616, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery State of Health 3", + key="battery_state_of_health_3", + register=0x617, + native_unit_of_measurement=PERCENTAGE, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + icon="mdi:battery-heart", + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Charge Cycle 3", + key="battery_charge_cycle_3", + state_class=SensorStateClass.MEASUREMENT, + register=0x618, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Voltage 4", + key="battery_voltage_4", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x619, + newblock=True, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery Current 4", + key="battery_current_4", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x61A, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery Power 4", + key="battery_power_4", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x61B, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery Temperature 4", + key="battery_temperature_4", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x61C, + unit=REGISTER_S16, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Capacity 4", + key="battery_capacity_4", + native_unit_of_measurement=PERCENTAGE, # device_class = SensorDeviceClass.BATTERY, - state_class = SensorStateClass.MEASUREMENT, - register = 0x61D, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery State of Health 4", - key = "battery_state_of_health_4", - register = 0x61E, - native_unit_of_measurement = PERCENTAGE, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - icon = "mdi:battery-heart", - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Charge Cycle 4", - key = "battery_charge_cycle_4", - state_class = SensorStateClass.MEASUREMENT, - register = 0x61F, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Voltage 5", - key = "battery_voltage_5", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x620, - newblock = True, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery Current 5", - key = "battery_current_5", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x621, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery Power 5", - key = "battery_power_5", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x622, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery Temperature 5", - key = "battery_temperature_5", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x623, - unit = REGISTER_S16, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Capacity 5", - key = "battery_capacity_5", - native_unit_of_measurement = PERCENTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=0x61D, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery State of Health 4", + key="battery_state_of_health_4", + register=0x61E, + native_unit_of_measurement=PERCENTAGE, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + icon="mdi:battery-heart", + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Charge Cycle 4", + key="battery_charge_cycle_4", + state_class=SensorStateClass.MEASUREMENT, + register=0x61F, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Voltage 5", + key="battery_voltage_5", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x620, + newblock=True, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery Current 5", + key="battery_current_5", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x621, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery Power 5", + key="battery_power_5", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x622, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery Temperature 5", + key="battery_temperature_5", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x623, + unit=REGISTER_S16, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Capacity 5", + key="battery_capacity_5", + native_unit_of_measurement=PERCENTAGE, # device_class = SensorDeviceClass.BATTERY, - state_class = SensorStateClass.MEASUREMENT, - register = 0x624, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery State of Health 5", - key = "battery_state_of_health_5", - register = 0x625, - native_unit_of_measurement = PERCENTAGE, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - icon = "mdi:battery-heart", - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Charge Cycle 5", - key = "battery_charge_cycle_5", - state_class = SensorStateClass.MEASUREMENT, - register = 0x626, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Voltage 6", - key = "battery_voltage_6", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x627, - newblock = True, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery Current 6", - key = "battery_current_6", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x628, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery Power 6", - key = "battery_power_6", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x629, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery Temperature 6", - key = "battery_temperature_6", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x62A, - unit = REGISTER_S16, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Capacity 6", - key = "battery_capacity_6", - native_unit_of_measurement = PERCENTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=0x624, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery State of Health 5", + key="battery_state_of_health_5", + register=0x625, + native_unit_of_measurement=PERCENTAGE, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + icon="mdi:battery-heart", + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Charge Cycle 5", + key="battery_charge_cycle_5", + state_class=SensorStateClass.MEASUREMENT, + register=0x626, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Voltage 6", + key="battery_voltage_6", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x627, + newblock=True, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery Current 6", + key="battery_current_6", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x628, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery Power 6", + key="battery_power_6", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x629, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery Temperature 6", + key="battery_temperature_6", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x62A, + unit=REGISTER_S16, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Capacity 6", + key="battery_capacity_6", + native_unit_of_measurement=PERCENTAGE, # device_class = SensorDeviceClass.BATTERY, - state_class = SensorStateClass.MEASUREMENT, - register = 0x62B, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery State of Health 6", - key = "battery_state_of_health_6", - register = 0x62C, - native_unit_of_measurement = PERCENTAGE, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - icon = "mdi:battery-heart", - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Charge Cycle 6", - key = "battery_charge_cycle_6", - state_class = SensorStateClass.MEASUREMENT, - register = 0x62D, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Voltage 7", - key = "battery_voltage_7", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x62E, - newblock = True, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery Current 7", - key = "battery_current_7", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x62F, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery Power 7", - key = "battery_power_7", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x630, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery Temperature 7", - key = "battery_temperature_7", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x631, - unit = REGISTER_S16, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Capacity 7", - key = "battery_capacity_7", - native_unit_of_measurement = PERCENTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=0x62B, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery State of Health 6", + key="battery_state_of_health_6", + register=0x62C, + native_unit_of_measurement=PERCENTAGE, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + icon="mdi:battery-heart", + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Charge Cycle 6", + key="battery_charge_cycle_6", + state_class=SensorStateClass.MEASUREMENT, + register=0x62D, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Voltage 7", + key="battery_voltage_7", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x62E, + newblock=True, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery Current 7", + key="battery_current_7", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x62F, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery Power 7", + key="battery_power_7", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x630, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery Temperature 7", + key="battery_temperature_7", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x631, + unit=REGISTER_S16, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Capacity 7", + key="battery_capacity_7", + native_unit_of_measurement=PERCENTAGE, # device_class = SensorDeviceClass.BATTERY, - state_class = SensorStateClass.MEASUREMENT, - register = 0x632, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery State of Health 7", - key = "battery_state_of_health_7", - register = 0x633, - native_unit_of_measurement = PERCENTAGE, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - icon = "mdi:battery-heart", - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Charge Cycle 7", - key = "battery_charge_cycle_7", - state_class = SensorStateClass.MEASUREMENT, - register = 0x634, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Voltage 8", - key = "battery_voltage_8", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x635, - newblock = True, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery Current 8", - key = "battery_current_8", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x636, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery Power 8", - key = "battery_power_8", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x637, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery Temperature 8", - key = "battery_temperature_8", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x638, - unit = REGISTER_S16, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Capacity 8", - key = "battery_capacity_8", - native_unit_of_measurement = PERCENTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=0x632, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery State of Health 7", + key="battery_state_of_health_7", + register=0x633, + native_unit_of_measurement=PERCENTAGE, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + icon="mdi:battery-heart", + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Charge Cycle 7", + key="battery_charge_cycle_7", + state_class=SensorStateClass.MEASUREMENT, + register=0x634, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Voltage 8", + key="battery_voltage_8", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x635, + newblock=True, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery Current 8", + key="battery_current_8", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x636, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery Power 8", + key="battery_power_8", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x637, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery Temperature 8", + key="battery_temperature_8", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x638, + unit=REGISTER_S16, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Capacity 8", + key="battery_capacity_8", + native_unit_of_measurement=PERCENTAGE, # device_class = SensorDeviceClass.BATTERY, - state_class = SensorStateClass.MEASUREMENT, - register = 0x639, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - ), - SofarModbusSensorEntityDescription( - name = "Battery State of Health 8", - key = "battery_state_of_health_8", - register = 0x63A, - native_unit_of_measurement = PERCENTAGE, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - icon = "mdi:battery-heart", - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Charge Cycle 8", - key = "battery_charge_cycle_8", - state_class = SensorStateClass.MEASUREMENT, - register = 0x63B, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Battery Power Total", - key = "battery_power_total", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x667, - newblock = True, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - ), - SofarModbusSensorEntityDescription( - name = "Battery Capacity Total", - key = "battery_capacity_total", - native_unit_of_measurement = PERCENTAGE, - device_class = SensorDeviceClass.BATTERY, - state_class = SensorStateClass.MEASUREMENT, - register = 0x668, - allowedtypes = HYBRID, - ), - SofarModbusSensorEntityDescription( - name = "Battery State of Health Total", - key = "battery_state_of_health_total", - register = 0x669, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = HYBRID, - icon = "mdi:battery-heart", - entity_category = EntityCategory.DIAGNOSTIC, - ), -### -# -# Electric Power (0x0680-0x06BF) -# -### - SofarModbusSensorEntityDescription( - name = "Solar Generation Today", - key = "solar_generation_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x684, - newblock = True, - unit = REGISTER_U32, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Solar Generation Total", - key = "solar_generation_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x686, - unit = REGISTER_U32, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Load Consumption Today", - key = "load_consumption_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x688, - unit = REGISTER_U32, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Load Consumption Total", - key = "load_consumption_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x68A, - unit = REGISTER_U32, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | PV, - ), - SofarModbusSensorEntityDescription( - name = "Import Energy Today", - key = "import_energy_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x68C, - unit = REGISTER_U32, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - icon = "mdi:home-import-outline", - ), - SofarModbusSensorEntityDescription( - name = "Import Energy Total", - key = "import_energy_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x68E, - unit = REGISTER_U32, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | PV, - icon = "mdi:home-import-outline", - ), - SofarModbusSensorEntityDescription( - name = "Export Energy Today", - key = "export_energy_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x690, - unit = REGISTER_U32, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | PV, - icon = "mdi:home-export-outline", - ), - SofarModbusSensorEntityDescription( - name = "Export Energy Total", - key = "export_energy_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x692, - unit = REGISTER_U32, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | PV, - icon = "mdi:home-export-outline", - ), - SofarModbusSensorEntityDescription( - name = "Battery Input Energy Today", - key = "battery_input_energy_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x694, - unit = REGISTER_U32, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID, - icon = "mdi:battery-arrow-up", - ), - SofarModbusSensorEntityDescription( - name = "Battery Input Energy Total", - key = "battery_input_energy_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x696, - unit = REGISTER_U32, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - icon = "mdi:battery-arrow-up", - ), - SofarModbusSensorEntityDescription( - name = "Battery Output Energy Today", - key = "battery_output_energy_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x698, - unit = REGISTER_U32, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID, - icon = "mdi:battery-arrow-down", - ), - SofarModbusSensorEntityDescription( - name = "Battery Output Energy Total", - key = "battery_output_energy_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x69A, - unit = REGISTER_U32, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - icon = "mdi:battery-arrow-down", - ), -### -# -# Basic Parameter Configuration (0x1000-0x10FF) -# -### - SofarModbusSensorEntityDescription( - name = "FeedIn: Limitation Mode", - key = "feedin_limitation_mode", - register = 0x1023, - scale = { 0: "Disabled", - 1: "Enabled - Feed-in limitation", - 2: "Enabled - 3-phase limit" }, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - ), - SofarModbusSensorEntityDescription( - name = "FeedIn: Maximum Power", - key = "feedin_max_power", - register = 0x1024, - scale = 100, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - ), - SofarModbusSensorEntityDescription( - name = "EPS Control", - key = "eps_control", - register = 0x1029, - newblock = True, - scale = { 0: "Turn Off", - 1: "Turn On, Prohibit Cold Start", - 2: "Turn On, Enable Cold Start", }, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | X3 | EPS, - ), - SofarModbusSensorEntityDescription( - name = "Battery Active Control", - key = "battery_active_control", - register = 0x102B, - scale = { 0: "Disabled", - 1: "Enabled", }, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - ), - SofarModbusSensorEntityDescription( - name = "Parallel Control", - key = "parallel_control", - register = 0x1035, - scale = { 0: "Disabled", - 1: "Enabled", }, - allowedtypes = HYBRID | PV | X3 | PM, - ), - SofarModbusSensorEntityDescription( - name = "Parallel Master-Salve", - key = "parallel_masterslave", - register = 0x1036, - scale = { 0: "Slave", - 1: "Master", }, - allowedtypes = HYBRID | PV | X3 | PM, - ), - SofarModbusSensorEntityDescription( - name = "Parallel Address", - key = "parallel_address", - register = 0x1037, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | PV | X3 | PM, - ), - -### -# -# Battery Configuration (0x1044-0x105A) -# Read-only for now. On write all 23 registers would need to be set in one chunk. -# -### - SofarModbusSensorEntityDescription( - name = "BatConfig: ID", - key = "bat_config_id", - register = 0x1044, - newblock = True, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-check-outline", - ), - SofarModbusSensorEntityDescription( - name = "BatConfig: Address 1", - key = "bat_config_address_1", - register = 0x1045, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-check-outline", - ), - SofarModbusSensorEntityDescription( - name = "BatConfig: Protocol", - key = "bat_config_protocol", - register = 0x1046, - scale = { 0: "First Flight built-in BMS/Default", - 1: "Pie Energy protocol/PYLON", - 2: "First Flight protocol/GENERAL", - 3: "AMASS", - 4: "LG", - 5: "AlphaESS", - 6: "CATL", - 7: "WECO", - 8: "Fronus", - 9: "EMS", - 10: "Nilar", - 11: "BTS 5K", - 11: "Move for",}, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-check-outline", - ), - SofarModbusSensorEntityDescription( - name = "BatConfig: Overvoltage Protection", - key = "bat_config_overvoltage_protection", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - register = 0x1047, - scale = 0.1, - rounding = 1, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-check-outline", - ), - SofarModbusSensorEntityDescription( - name = "BatConfig: Charging Voltage", - key = "bat_config_charging_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - register = 0x1048, - scale = 0.1, - rounding = 1, - entity_category = EntityCategory.DIAGNOSTIC, - allowedtypes = HYBRID, - icon = "mdi:battery-check-outline", - ), - SofarModbusSensorEntityDescription( - name = "BatConfig: Undervoltage Protection", - key = "bat_config_undervoltage_protection", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - register = 0x1049, - scale = 0.1, - rounding = 1, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-check-outline", - ), - SofarModbusSensorEntityDescription( - name = "BatConfig: Minimum Discharge Voltage", - key = "bat_config_minimum_discharge_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - register = 0x104A, - scale = 0.1, - rounding = 1, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-check-outline", - ), - SofarModbusSensorEntityDescription( - name = "BatConfig: Maximum Charge Current Limit", - key = "bat_config_maximum_charge_current_limit", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - register = 0x104B, - scale = 0.01, - rounding = 2, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-check-outline", - ), - SofarModbusSensorEntityDescription( - name = "BatConfig: Maximum Discharge Current Limit", - key = "bat_config_maximum_discharge_current_limit", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - register = 0x104C, - scale = 0.01, - rounding = 2, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-check-outline", - ), - SofarModbusSensorEntityDescription( - name = "BatConfig: Depth of Discharge", - key = "bat_config_depth_of_discharge", - native_unit_of_measurement = PERCENTAGE, - register = 0x104D, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-check-outline", - ), - SofarModbusSensorEntityDescription( - name = "BatConfig: End of Discharge", - key = "bat_config_end_of_discharge", - native_unit_of_measurement = PERCENTAGE, - register = 0x104E, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-check-outline", - ), - SofarModbusSensorEntityDescription( - name = "BatConfig: Capacity", - key = "bat_config_capacity", - native_unit_of_measurement = "Ah", - register = 0x104F, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-check-outline", - ), - SofarModbusSensorEntityDescription( - name = "BatConfig: Rated Battery Voltage", - key = "bat_config_rated_battery_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - register = 0x1050, - scale = 0.1, - rounding = 1, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-check-outline", - ), - SofarModbusSensorEntityDescription( - name = "BatConfig: Cell Type", - key = "bat_config_cell_type", - register = 0x1051, - scale = { 0: "Lead acid", - 1: "Lithium iron phosphate", - 2: "Ternary", - 3: "Lithium titanate", - 4: "AGM", - 5: "Gel", - 6: "Flooded", }, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-check-outline", - ), - SofarModbusSensorEntityDescription( - name = "BatConfig: EPS Buffer", - key = "bat_config_eps_buffer", - native_unit_of_measurement = PERCENTAGE, - register = 0x1052, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-check-outline", + state_class=SensorStateClass.MEASUREMENT, + register=0x639, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + ), + SofarModbusSensorEntityDescription( + name="Battery State of Health 8", + key="battery_state_of_health_8", + register=0x63A, + native_unit_of_measurement=PERCENTAGE, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + icon="mdi:battery-heart", + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Charge Cycle 8", + key="battery_charge_cycle_8", + state_class=SensorStateClass.MEASUREMENT, + register=0x63B, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Battery Power Total", + key="battery_power_total", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x667, + newblock=True, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + ), + SofarModbusSensorEntityDescription( + name="Battery Capacity Total", + key="battery_capacity_total", + native_unit_of_measurement=PERCENTAGE, + device_class=SensorDeviceClass.BATTERY, + state_class=SensorStateClass.MEASUREMENT, + register=0x668, + allowedtypes=HYBRID, + ), + SofarModbusSensorEntityDescription( + name="Battery State of Health Total", + key="battery_state_of_health_total", + register=0x669, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=HYBRID, + icon="mdi:battery-heart", + entity_category=EntityCategory.DIAGNOSTIC, + ), + ### + # + # Electric Power (0x0680-0x06BF) + # + ### + SofarModbusSensorEntityDescription( + name="Solar Generation Today", + key="solar_generation_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x684, + newblock=True, + unit=REGISTER_U32, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Solar Generation Total", + key="solar_generation_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x686, + unit=REGISTER_U32, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Load Consumption Today", + key="load_consumption_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x688, + unit=REGISTER_U32, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Load Consumption Total", + key="load_consumption_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x68A, + unit=REGISTER_U32, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | PV, + ), + SofarModbusSensorEntityDescription( + name="Import Energy Today", + key="import_energy_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x68C, + unit=REGISTER_U32, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + icon="mdi:home-import-outline", + ), + SofarModbusSensorEntityDescription( + name="Import Energy Total", + key="import_energy_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x68E, + unit=REGISTER_U32, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | PV, + icon="mdi:home-import-outline", + ), + SofarModbusSensorEntityDescription( + name="Export Energy Today", + key="export_energy_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x690, + unit=REGISTER_U32, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | PV, + icon="mdi:home-export-outline", + ), + SofarModbusSensorEntityDescription( + name="Export Energy Total", + key="export_energy_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x692, + unit=REGISTER_U32, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | PV, + icon="mdi:home-export-outline", + ), + SofarModbusSensorEntityDescription( + name="Battery Input Energy Today", + key="battery_input_energy_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x694, + unit=REGISTER_U32, + scale=0.01, + rounding=2, + allowedtypes=HYBRID, + icon="mdi:battery-arrow-up", + ), + SofarModbusSensorEntityDescription( + name="Battery Input Energy Total", + key="battery_input_energy_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x696, + unit=REGISTER_U32, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + icon="mdi:battery-arrow-up", + ), + SofarModbusSensorEntityDescription( + name="Battery Output Energy Today", + key="battery_output_energy_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x698, + unit=REGISTER_U32, + scale=0.01, + rounding=2, + allowedtypes=HYBRID, + icon="mdi:battery-arrow-down", + ), + SofarModbusSensorEntityDescription( + name="Battery Output Energy Total", + key="battery_output_energy_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x69A, + unit=REGISTER_U32, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + icon="mdi:battery-arrow-down", + ), + ### + # + # Basic Parameter Configuration (0x1000-0x10FF) + # + ### + SofarModbusSensorEntityDescription( + name="FeedIn: Limitation Mode", + key="feedin_limitation_mode", + register=0x1023, + scale={0: "Disabled", 1: "Enabled - Feed-in limitation", 2: "Enabled - 3-phase limit"}, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + ), + SofarModbusSensorEntityDescription( + name="FeedIn: Maximum Power", + key="feedin_max_power", + register=0x1024, + scale=100, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + ), + SofarModbusSensorEntityDescription( + name="EPS Control", + key="eps_control", + register=0x1029, + newblock=True, + scale={ + 0: "Turn Off", + 1: "Turn On, Prohibit Cold Start", + 2: "Turn On, Enable Cold Start", + }, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | X3 | EPS, + ), + SofarModbusSensorEntityDescription( + name="Battery Active Control", + key="battery_active_control", + register=0x102B, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + ), + SofarModbusSensorEntityDescription( + name="Parallel Control", + key="parallel_control", + register=0x1035, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=HYBRID | PV | X3 | PM, + ), + SofarModbusSensorEntityDescription( + name="Parallel Master-Salve", + key="parallel_masterslave", + register=0x1036, + scale={ + 0: "Slave", + 1: "Master", + }, + allowedtypes=HYBRID | PV | X3 | PM, + ), + SofarModbusSensorEntityDescription( + name="Parallel Address", + key="parallel_address", + register=0x1037, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | PV | X3 | PM, + ), + ### + # + # Battery Configuration (0x1044-0x105A) + # Read-only for now. On write all 23 registers would need to be set in one chunk. + # + ### + SofarModbusSensorEntityDescription( + name="BatConfig: ID", + key="bat_config_id", + register=0x1044, + newblock=True, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-check-outline", + ), + SofarModbusSensorEntityDescription( + name="BatConfig: Address 1", + key="bat_config_address_1", + register=0x1045, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-check-outline", + ), + SofarModbusSensorEntityDescription( + name="BatConfig: Protocol", + key="bat_config_protocol", + register=0x1046, + scale={ + 0: "First Flight built-in BMS/Default", + 1: "Pie Energy protocol/PYLON", + 2: "First Flight protocol/GENERAL", + 3: "AMASS", + 4: "LG", + 5: "AlphaESS", + 6: "CATL", + 7: "WECO", + 8: "Fronus", + 9: "EMS", + 10: "Nilar", + 11: "BTS 5K", + 11: "Move for", + }, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-check-outline", + ), + SofarModbusSensorEntityDescription( + name="BatConfig: Overvoltage Protection", + key="bat_config_overvoltage_protection", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + register=0x1047, + scale=0.1, + rounding=1, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-check-outline", + ), + SofarModbusSensorEntityDescription( + name="BatConfig: Charging Voltage", + key="bat_config_charging_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + register=0x1048, + scale=0.1, + rounding=1, + entity_category=EntityCategory.DIAGNOSTIC, + allowedtypes=HYBRID, + icon="mdi:battery-check-outline", + ), + SofarModbusSensorEntityDescription( + name="BatConfig: Undervoltage Protection", + key="bat_config_undervoltage_protection", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + register=0x1049, + scale=0.1, + rounding=1, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-check-outline", + ), + SofarModbusSensorEntityDescription( + name="BatConfig: Minimum Discharge Voltage", + key="bat_config_minimum_discharge_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + register=0x104A, + scale=0.1, + rounding=1, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-check-outline", + ), + SofarModbusSensorEntityDescription( + name="BatConfig: Maximum Charge Current Limit", + key="bat_config_maximum_charge_current_limit", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + register=0x104B, + scale=0.01, + rounding=2, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-check-outline", + ), + SofarModbusSensorEntityDescription( + name="BatConfig: Maximum Discharge Current Limit", + key="bat_config_maximum_discharge_current_limit", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + register=0x104C, + scale=0.01, + rounding=2, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-check-outline", + ), + SofarModbusSensorEntityDescription( + name="BatConfig: Depth of Discharge", + key="bat_config_depth_of_discharge", + native_unit_of_measurement=PERCENTAGE, + register=0x104D, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-check-outline", + ), + SofarModbusSensorEntityDescription( + name="BatConfig: End of Discharge", + key="bat_config_end_of_discharge", + native_unit_of_measurement=PERCENTAGE, + register=0x104E, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-check-outline", + ), + SofarModbusSensorEntityDescription( + name="BatConfig: Capacity", + key="bat_config_capacity", + native_unit_of_measurement="Ah", + register=0x104F, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-check-outline", + ), + SofarModbusSensorEntityDescription( + name="BatConfig: Rated Battery Voltage", + key="bat_config_rated_battery_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + register=0x1050, + scale=0.1, + rounding=1, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-check-outline", + ), + SofarModbusSensorEntityDescription( + name="BatConfig: Cell Type", + key="bat_config_cell_type", + register=0x1051, + scale={ + 0: "Lead acid", + 1: "Lithium iron phosphate", + 2: "Ternary", + 3: "Lithium titanate", + 4: "AGM", + 5: "Gel", + 6: "Flooded", + }, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-check-outline", + ), + SofarModbusSensorEntityDescription( + name="BatConfig: EPS Buffer", + key="bat_config_eps_buffer", + native_unit_of_measurement=PERCENTAGE, + register=0x1052, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-check-outline", ), # 0x1053 BatConfig_Control skipped for now. Only useful when writing SofarModbusSensorEntityDescription( - name = "BatConfig: Address 2", - key = "bat_config_address_2", - register = 0x1054, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-check-outline", - ), - SofarModbusSensorEntityDescription( - name = "BatConfig: Address 3", - key = "bat_config_address_3", - register = 0x1055, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-check-outline", - ), - SofarModbusSensorEntityDescription( - name = "BatConfig: Address 4", - key = "bat_config_address_4", - register = 0x1056, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-check-outline", - ), - SofarModbusSensorEntityDescription( - name = "BatConfig: Lead Acid Battery Temperature Compensation Factor", - key = "bat_config_tempco", - native_unit_of_measurement = "mV/Cell", - register = 0x1057, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-check-outline", - ), - SofarModbusSensorEntityDescription( - name = "BatConfig: Lead Acid Battery Recovery Buffer", - key = "bat_config_rated_battery_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - register = 0x1058, - scale = 0.1, - rounding = 1, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-check-outline", - ), - SofarModbusSensorEntityDescription( - name = "BatConfig: Lead Acid Battery Float Voltage", - key = "bat_config_voltage_float", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - register = 0x105A, - scale = 0.1, - rounding = 1, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-check-outline", - ), - -### -# -# Remote Control (0x1100-0x12FF) -# -### - SofarModbusSensorEntityDescription( - name = "Remote Switch On Off", - key = "remote_switch_on_off", - register = 0x1104, - newblock = True, - scale = { 0: "Off", - 1: "On", }, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - ), - SofarModbusSensorEntityDescription( - name = "Charger Use Mode", - key = "charger_use_mode", - register = 0x1110, - scale = { 0: "Self Use", - 1: "Time of Use", - 2: "Timing Mode", - 3: "Passive Mode", - 4: "Peak Cut Mode", - 5: "Off-grid Mode", }, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, + name="BatConfig: Address 2", + key="bat_config_address_2", + register=0x1054, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-check-outline", + ), + SofarModbusSensorEntityDescription( + name="BatConfig: Address 3", + key="bat_config_address_3", + register=0x1055, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-check-outline", + ), + SofarModbusSensorEntityDescription( + name="BatConfig: Address 4", + key="bat_config_address_4", + register=0x1056, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-check-outline", + ), + SofarModbusSensorEntityDescription( + name="BatConfig: Lead Acid Battery Temperature Compensation Factor", + key="bat_config_tempco", + native_unit_of_measurement="mV/Cell", + register=0x1057, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-check-outline", + ), + SofarModbusSensorEntityDescription( + name="BatConfig: Lead Acid Battery Recovery Buffer", + key="bat_config_rated_battery_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + register=0x1058, + scale=0.1, + rounding=1, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-check-outline", + ), + SofarModbusSensorEntityDescription( + name="BatConfig: Lead Acid Battery Float Voltage", + key="bat_config_voltage_float", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + register=0x105A, + scale=0.1, + rounding=1, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-check-outline", + ), + ### + # + # Remote Control (0x1100-0x12FF) + # + ### + SofarModbusSensorEntityDescription( + name="Remote Switch On Off", + key="remote_switch_on_off", + register=0x1104, + newblock=True, + scale={ + 0: "Off", + 1: "On", + }, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + ), + SofarModbusSensorEntityDescription( + name="Charger Use Mode", + key="charger_use_mode", + register=0x1110, + scale={ + 0: "Self Use", + 1: "Time of Use", + 2: "Timing Mode", + 3: "Passive Mode", + 4: "Peak Cut Mode", + 5: "Off-grid Mode", + }, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, ), - # TIMING AND TOU DISABLED AS THESE ARE NOT WORKING # SofarModbusSensorEntityDescription( # name = "Timing: ID", @@ -3524,65 +3609,68 @@ def value_function_sync_rtc_ymd_sofar(initval, descr, datadict): # entity_registry_enabled_default = False, # allowedtypes = HYBRID, # ), - SofarModbusSensorEntityDescription( - name = "Update System Time Operation Result", - key = "sync_rtc_result", - register = 0x100A, - scale = { 0: "Successful", - 1: "Operation in progress", - 2: "Enabled - Discharging", - 4: "Disabled", - 65531: "Operation failed, controller refused to respond", - 65532: "Operation failed, no response from the controller", - 65533: "Operation failed, current function disabled", - 65534: "Operation failed, parameter access failed", - 65535: "Operation failed, input parameters incorrect", }, - allowedtypes = HYBRID, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "RO: Passive: Timeout", - key = "ro_passive_mode_timeout", - register = 0x1184, - allowedtypes = HYBRID, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Passive: Timeout Action", - key = "ro_passive_mode_timeout_action", - register = 0x1185, - scale = { 0: "Force Standby", - 1: "Return to Previous Mode", }, - allowedtypes = HYBRID, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Passive: Desired Grid Power", - key = "passive_mode_grid_power", - unit = REGISTER_S32, - entity_registry_enabled_default = False, - register = 0x1187, - allowedtypes = HYBRID, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Passive: Minimum Battery Power", - key = "passive_mode_battery_power_min", - unit = REGISTER_S32, - register = 0x1189, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarModbusSensorEntityDescription( - name = "Passive: Maximum Battery Power", - key = "passive_mode_battery_power_max", - unit = REGISTER_S32, - register = 0x118B, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.DIAGNOSTIC, + name="Update System Time Operation Result", + key="sync_rtc_result", + register=0x100A, + scale={ + 0: "Successful", + 1: "Operation in progress", + 2: "Enabled - Discharging", + 4: "Disabled", + 65531: "Operation failed, controller refused to respond", + 65532: "Operation failed, no response from the controller", + 65533: "Operation failed, current function disabled", + 65534: "Operation failed, parameter access failed", + 65535: "Operation failed, input parameters incorrect", + }, + allowedtypes=HYBRID, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="RO: Passive: Timeout", + key="ro_passive_mode_timeout", + register=0x1184, + allowedtypes=HYBRID, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Passive: Timeout Action", + key="ro_passive_mode_timeout_action", + register=0x1185, + scale={ + 0: "Force Standby", + 1: "Return to Previous Mode", + }, + allowedtypes=HYBRID, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Passive: Desired Grid Power", + key="passive_mode_grid_power", + unit=REGISTER_S32, + entity_registry_enabled_default=False, + register=0x1187, + allowedtypes=HYBRID, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Passive: Minimum Battery Power", + key="passive_mode_battery_power_min", + unit=REGISTER_S32, + register=0x1189, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarModbusSensorEntityDescription( + name="Passive: Maximum Battery Power", + key="passive_mode_battery_power_max", + unit=REGISTER_S32, + register=0x118B, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.DIAGNOSTIC, ), ] @@ -3620,183 +3708,183 @@ def value_function_sync_rtc_ymd_sofar(initval, descr, datadict): # allowedtypes = BAT_BTS, # ), SofarModbusSensorEntityDescription( - name = "BMS Version", - key = "bms_version", - native_unit_of_measurement = None, - state_class = SensorStateClass.MEASUREMENT, - entity_category = EntityCategory.DIAGNOSTIC, - register = 0x900B, - allowedtypes = BAT_BTS, - ), - SofarModbusSensorEntityDescription( - name = "Realtime Capacity", - key = "realtime_capacity", - native_unit_of_measurement = PERCENTAGE, - device_class = SensorDeviceClass.BATTERY, - register = 0x900E, - scale = 0.1, - allowedtypes = BAT_BTS, - ), - SofarModbusSensorEntityDescription( - name = "Total Voltage", - key = "total_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x900F, - scale = 0.1, - allowedtypes = BAT_BTS, - ), - SofarModbusSensorEntityDescription( - name = "Total Current", - key = "total_current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x9010, - unit = REGISTER_S16, - scale = 0.1, - allowedtypes = BAT_BTS, - ), - SofarModbusSensorEntityDescription( - name = "SOC", - key = "soc", - native_unit_of_measurement = PERCENTAGE, - device_class = SensorDeviceClass.BATTERY, - register = 0x9012, - allowedtypes = BAT_BTS, - ), - SofarModbusSensorEntityDescription( - name = "SOH", - key = "soh", - native_unit_of_measurement = PERCENTAGE, - device_class = SensorDeviceClass.BATTERY, - register = 0x9013, - allowedtypes = BAT_BTS, - ), - SofarModbusSensorEntityDescription( - name = "Pack ID", - key = "pack_id", - newblock = True, - register = 0x9044, - allowedtypes = BAT_BTS, - ), - SofarModbusSensorEntityDescription( - name = "Pack Time", - key = "pack_time", - register = 0x9045, - unit = REGISTER_S32, - wordcount = 1, - scale = value_function_2byte_timestamp, - entity_category = EntityCategory.DIAGNOSTIC, - allowedtypes = BAT_BTS, - icon = "mdi:clock", - ), - SofarModbusSensorEntityDescription( - name = "Pack Serial Number", - key = "pack_serial_number", - register = 0x9048, - newblock = True, - unit = REGISTER_STR, + name="BMS Version", + key="bms_version", + native_unit_of_measurement=None, + state_class=SensorStateClass.MEASUREMENT, + entity_category=EntityCategory.DIAGNOSTIC, + register=0x900B, + allowedtypes=BAT_BTS, + ), + SofarModbusSensorEntityDescription( + name="Realtime Capacity", + key="realtime_capacity", + native_unit_of_measurement=PERCENTAGE, + device_class=SensorDeviceClass.BATTERY, + register=0x900E, + scale=0.1, + allowedtypes=BAT_BTS, + ), + SofarModbusSensorEntityDescription( + name="Total Voltage", + key="total_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x900F, + scale=0.1, + allowedtypes=BAT_BTS, + ), + SofarModbusSensorEntityDescription( + name="Total Current", + key="total_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x9010, + unit=REGISTER_S16, + scale=0.1, + allowedtypes=BAT_BTS, + ), + SofarModbusSensorEntityDescription( + name="SOC", + key="soc", + native_unit_of_measurement=PERCENTAGE, + device_class=SensorDeviceClass.BATTERY, + register=0x9012, + allowedtypes=BAT_BTS, + ), + SofarModbusSensorEntityDescription( + name="SOH", + key="soh", + native_unit_of_measurement=PERCENTAGE, + device_class=SensorDeviceClass.BATTERY, + register=0x9013, + allowedtypes=BAT_BTS, + ), + SofarModbusSensorEntityDescription( + name="Pack ID", + key="pack_id", + newblock=True, + register=0x9044, + allowedtypes=BAT_BTS, + ), + SofarModbusSensorEntityDescription( + name="Pack Time", + key="pack_time", + register=0x9045, + unit=REGISTER_S32, + wordcount=1, + scale=value_function_2byte_timestamp, + entity_category=EntityCategory.DIAGNOSTIC, + allowedtypes=BAT_BTS, + icon="mdi:clock", + ), + SofarModbusSensorEntityDescription( + name="Pack Serial Number", + key="pack_serial_number", + register=0x9048, + newblock=True, + unit=REGISTER_STR, wordcount=9, - entity_category = EntityCategory.DIAGNOSTIC, - allowedtypes = BAT_BTS, - ), - SofarModbusSensorEntityDescription( - name = "cell {} voltage", - key = "cell_{}_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x9051, - scale = 0.001, - rounding = 3, - allowedtypes = BAT_BTS, - value_series = 16 - ), - SofarModbusSensorEntityDescription( - name = "cell min voltage", - key = "cell_min_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x9069, - scale = 0.001, - rounding = 3, - allowedtypes = BAT_BTS, - ), - SofarModbusSensorEntityDescription( - name = "cell max voltage", - key = "cell_max_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x906A, - scale = 0.001, - rounding = 3, - allowedtypes = BAT_BTS, - ), - SofarModbusSensorEntityDescription( - name = "Pack Temperature {}", - key = "pack_temperature_{}", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x906B, - unit = REGISTER_S16, - scale = 0.1, - allowedtypes = BAT_BTS, - value_series = 4 - ), - SofarModbusSensorEntityDescription( - name = "Pack Temperature MOS", - key = "pack_temperature_mos", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x906F, - unit = REGISTER_S16, - scale = 0.1, - allowedtypes = BAT_BTS, - ), - SofarModbusSensorEntityDescription( - name = "Pack Temperature Env", - key = "pack_temperature_env", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x9070, - unit = REGISTER_S16, - scale = 0.1, - allowedtypes = BAT_BTS, - ), - SofarModbusSensorEntityDescription( - name = "Pack Current", - key = "pack_current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x9071, - unit = REGISTER_S16, - scale = 0.1, - allowedtypes = BAT_BTS, - ), - SofarModbusSensorEntityDescription( - name = "Pack remaining capacity", - key = "pack_remaining_capacity", - native_unit_of_measurement = "Ah", - register = 0x9072, - scale = 0.1, - allowedtypes = BAT_BTS, - ), - SofarModbusSensorEntityDescription( - name = "Pack Full charge capacity", - key = "pack_full_charge_capacity", - native_unit_of_measurement = "Ah", - register = 0x9073, - scale = 0.1, - allowedtypes = BAT_BTS, - ), - SofarModbusSensorEntityDescription( - name = "Pack Cycles", - key = "pack_cycles", - register = 0x9074, - entity_category = EntityCategory.DIAGNOSTIC, - allowedtypes = BAT_BTS, + entity_category=EntityCategory.DIAGNOSTIC, + allowedtypes=BAT_BTS, + ), + SofarModbusSensorEntityDescription( + name="cell {} voltage", + key="cell_{}_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x9051, + scale=0.001, + rounding=3, + allowedtypes=BAT_BTS, + value_series=16, + ), + SofarModbusSensorEntityDescription( + name="cell min voltage", + key="cell_min_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x9069, + scale=0.001, + rounding=3, + allowedtypes=BAT_BTS, + ), + SofarModbusSensorEntityDescription( + name="cell max voltage", + key="cell_max_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x906A, + scale=0.001, + rounding=3, + allowedtypes=BAT_BTS, + ), + SofarModbusSensorEntityDescription( + name="Pack Temperature {}", + key="pack_temperature_{}", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x906B, + unit=REGISTER_S16, + scale=0.1, + allowedtypes=BAT_BTS, + value_series=4, + ), + SofarModbusSensorEntityDescription( + name="Pack Temperature MOS", + key="pack_temperature_mos", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x906F, + unit=REGISTER_S16, + scale=0.1, + allowedtypes=BAT_BTS, + ), + SofarModbusSensorEntityDescription( + name="Pack Temperature Env", + key="pack_temperature_env", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x9070, + unit=REGISTER_S16, + scale=0.1, + allowedtypes=BAT_BTS, + ), + SofarModbusSensorEntityDescription( + name="Pack Current", + key="pack_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x9071, + unit=REGISTER_S16, + scale=0.1, + allowedtypes=BAT_BTS, + ), + SofarModbusSensorEntityDescription( + name="Pack remaining capacity", + key="pack_remaining_capacity", + native_unit_of_measurement="Ah", + register=0x9072, + scale=0.1, + allowedtypes=BAT_BTS, + ), + SofarModbusSensorEntityDescription( + name="Pack Full charge capacity", + key="pack_full_charge_capacity", + native_unit_of_measurement="Ah", + register=0x9073, + scale=0.1, + allowedtypes=BAT_BTS, + ), + SofarModbusSensorEntityDescription( + name="Pack Cycles", + key="pack_cycles", + register=0x9074, + entity_category=EntityCategory.DIAGNOSTIC, + allowedtypes=BAT_BTS, ), # SofarModbusSensorEntityDescription( # name = "Pack SOC", @@ -3808,16 +3896,15 @@ def value_function_sync_rtc_ymd_sofar(initval, descr, datadict): # ), ] + @dataclass class battery_config(base_battery_config): - def __init__( - self - ): + def __init__(self): self.battery_sensor_type = BATTERY_SENSOR_TYPES self.battery_sensor_name_prefix = "Battery {batt-nr}/{pack-nr} " self.battery_sensor_key_prefix = "battery_{batt-nr}_{pack-nr}_" - bapack_number_address = 0x900d + bapack_number_address = 0x900D bms_inquire_address = 0x9020 bms_check_address = 0x9044 batt_pack_serial_address = 0x9048 @@ -3825,8 +3912,8 @@ def __init__( batt_pack_model_address = 0x9007 batt_pack_model_len = 4 - number_cels_in_parallel: int = None # number of battery pack cells in parallel - number_strings: int = None # number of strings of all battery packs + number_cels_in_parallel: int = None # number of battery pack cells in parallel + number_strings: int = None # number of strings of all battery packs batt_pack_serials = {} selected_batt_nr: int = None selected_batt_pack_nr: int = None @@ -3850,7 +3937,9 @@ async def select_battery(self, hub, batt_nr: int, batt_pack_nr: int): faulty_nr = 0 payload = faulty_nr << 12 | batt_pack_nr << 8 | batt_nr _LOGGER.debug(f"select batt-nr: {batt_nr} batt-pack: {batt_pack_nr} {hex(payload)}") - await hub.async_write_registers_single(unit=hub._modbus_addr, address=self.bms_inquire_address, payload=payload) + await hub.async_write_registers_single( + unit=hub._modbus_addr, address=self.bms_inquire_address, payload=payload + ) await asyncio.sleep(0.3) self.selected_batt_nr = batt_nr self.selected_batt_pack_nr = batt_pack_nr @@ -3865,7 +3954,9 @@ async def get_batt_pack_serial(self, hub, batt_nr: int, batt_pack_nr: int): async def get_batt_pack_model(self, hub): try: - inverter_data = await hub.async_read_holding_registers(unit=hub._modbus_addr, address=self.batt_pack_model_address, count=self.batt_pack_model_len) + inverter_data = await hub.async_read_holding_registers( + unit=hub._modbus_addr, address=self.batt_pack_model_address, count=self.batt_pack_model_len + ) if not inverter_data.isError(): decoder = BinaryPayloadDecoder.fromRegisters(inverter_data.registers, byteorder=Endian.BIG) serial = str(decoder.decode_string(self.batt_pack_model_len * 2).decode("ascii")) @@ -3881,7 +3972,6 @@ async def get_batt_pack_sw_version(self, hub, new_data, key_prefix): return None return f"BMS: V{new_data[sw_version_key]}" - async def check_battery_on_start(self, hub, old_data, key_prefix, batt_nr: int, batt_pack_nr: int): if not self.batt_pack_serials.__contains__(batt_nr): return False @@ -3890,8 +3980,10 @@ async def check_battery_on_start(self, hub, old_data, key_prefix, batt_nr: int, faulty_nr = 0 payload = faulty_nr << 12 | batt_pack_nr << 8 | batt_nr - for retry in range(0,10): - inverter_data = await hub.async_read_holding_registers(unit=hub._modbus_addr, address=self.bms_check_address, count=1) + for retry in range(0, 10): + inverter_data = await hub.async_read_holding_registers( + unit=hub._modbus_addr, address=self.bms_check_address, count=1 + ) if not inverter_data.isError(): decoder = BinaryPayloadDecoder.fromRegisters(inverter_data.registers, byteorder=Endian.BIG) readed = decoder.decode_16bit_uint() @@ -3914,7 +4006,9 @@ async def check_battery_on_end(self, hub, old_data, new_data, key_prefix, batt_n faulty_nr = 0 compare_value = faulty_nr << 12 | batt_pack_nr << 8 | batt_nr - inverter_data = await hub.async_read_holding_registers(unit=hub._modbus_addr, address=self.bms_check_address, count=1) + inverter_data = await hub.async_read_holding_registers( + unit=hub._modbus_addr, address=self.bms_check_address, count=1 + ) if not inverter_data.isError(): decoder = BinaryPayloadDecoder.fromRegisters(inverter_data.registers, byteorder=Endian.BIG) new_value = decoder.decode_16bit_uint() @@ -3935,12 +4029,15 @@ async def check_battery_on_end(self, hub, old_data, new_data, key_prefix, batt_n async def _determine_bat_quantitys(self, hub): res = None try: - inverter_data = await hub.async_read_holding_registers(unit=hub._modbus_addr, address=self.bapack_number_address, count=1) + inverter_data = await hub.async_read_holding_registers( + unit=hub._modbus_addr, address=self.bapack_number_address, count=1 + ) if not inverter_data.isError(): decoder = BinaryPayloadDecoder.fromRegisters(inverter_data.registers, byteorder=Endian.BIG) self.number_cels_in_parallel = decoder.decode_8bit_int() self.number_strings = decoder.decode_8bit_int() - except Exception as ex: _LOGGER.warning(f"{hub.name}: attempt to read BaPack number failed at 0x{address:x}", exc_info=True) + except Exception as ex: + _LOGGER.warning(f"{hub.name}: attempt to read BaPack number failed at 0x{address:x}", exc_info=True) async def init_batt_pack_serials(self, hub): retry = 0 @@ -3961,17 +4058,20 @@ async def init_batt_pack_serials(self, hub): _LOGGER.info(f"serials {self.batt_pack_serials}") async def _determinate_batt_pack_serial(self, hub): - inverter_data = await hub.async_read_holding_registers(unit=hub._modbus_addr, address=self.batt_pack_serial_address, count=self.batt_pack_serial_len) + inverter_data = await hub.async_read_holding_registers( + unit=hub._modbus_addr, address=self.batt_pack_serial_address, count=self.batt_pack_serial_len + ) if not inverter_data.isError(): decoder = BinaryPayloadDecoder.fromRegisters(inverter_data.registers, byteorder=Endian.BIG) serial = str(decoder.decode_string(self.batt_pack_serial_len * 2).decode("ascii")) return serial + # ============================ plugin declaration ================================================= + @dataclass class sofar_plugin(plugin_base): - """ def isAwake(self, datadict): return (datadict.get('run_mode', None) == 'Normal Mode') @@ -3988,58 +4088,58 @@ async def async_determineInverterType(self, hub, configdict): seriesnumber = "unknown" # derive invertertype from seriiesnumber - if seriesnumber.startswith('SP1ES120N6'): - invertertype = HYBRID | X3 # HYD20KTL-3P no PV + if seriesnumber.startswith("SP1ES120N6"): + invertertype = HYBRID | X3 # HYD20KTL-3P no PV self.inverter_model = "HYD20KTL-3P" - elif seriesnumber.startswith('SP1'): - invertertype = HYBRID | X3 | GEN | BAT_BTS # HYDxxKTL-3P + elif seriesnumber.startswith("SP1"): + invertertype = HYBRID | X3 | GEN | BAT_BTS # HYDxxKTL-3P self.inverter_model = "HYDxxKTL-3P" - elif seriesnumber.startswith('SP2'): - invertertype = HYBRID | X3 | GEN | BAT_BTS # HYDxxKTL-3P 2nd type + elif seriesnumber.startswith("SP2"): + invertertype = HYBRID | X3 | GEN | BAT_BTS # HYDxxKTL-3P 2nd type self.inverter_model = f"HYD{seriesnumber[6:8]}KTL-3P 2nd" - elif seriesnumber.startswith('ZP1'): - invertertype = HYBRID | X3 | GEN # Azzurro HYDxx ZSS + elif seriesnumber.startswith("ZP1"): + invertertype = HYBRID | X3 | GEN # Azzurro HYDxx ZSS self.inverter_model = "HYDxx ZSS" - elif seriesnumber.startswith('ZP2'): - invertertype = HYBRID | X3 | GEN # Azzurro HYDxx ZSS + elif seriesnumber.startswith("ZP2"): + invertertype = HYBRID | X3 | GEN # Azzurro HYDxx ZSS self.inverter_model = "HYDxx ZSS" - elif seriesnumber.startswith('SM2E'): - invertertype = HYBRID | X1 | GEN # HYDxxxxES, Not actually X3, needs changing + elif seriesnumber.startswith("SM2E"): + invertertype = HYBRID | X1 | GEN # HYDxxxxES, Not actually X3, needs changing self.inverter_model = "HYDxxxxES" - elif seriesnumber.startswith('ZM2E'): - invertertype = HYBRID | X1 | GEN # HYDxxxxKTL ZCS HP, Single Phase + elif seriesnumber.startswith("ZM2E"): + invertertype = HYBRID | X1 | GEN # HYDxxxxKTL ZCS HP, Single Phase self.inverter_model = "HYDxxxxKTL ZCS HP" - elif seriesnumber.startswith('SH3E'): - invertertype = PV | X1 | GEN # 4.6 KTLM-G3 + elif seriesnumber.startswith("SH3E"): + invertertype = PV | X1 | GEN # 4.6 KTLM-G3 self.inverter_model = "4.6 KTLM-G3" - elif seriesnumber.startswith('SS2E'): - invertertype = PV | X3 | GEN # 4.4 KTLX-G3 + elif seriesnumber.startswith("SS2E"): + invertertype = PV | X3 | GEN # 4.4 KTLX-G3 self.inverter_model = "4.4 KTLX-G3" - elif seriesnumber.startswith('ZS2E'): - invertertype = PV | X3 | GEN # 12 Azzurro KTL-V3 + elif seriesnumber.startswith("ZS2E"): + invertertype = PV | X3 | GEN # 12 Azzurro KTL-V3 self.inverter_model = "12 Azzurro KTL-V3" - elif seriesnumber.startswith('SQ1ES1'): - invertertype = PV | X3 | GEN | MPPT10 # 100kW KTLX-G4 + elif seriesnumber.startswith("SQ1ES1"): + invertertype = PV | X3 | GEN | MPPT10 # 100kW KTLX-G4 self.inverter_model = "100kW KTLX-G4" - elif seriesnumber.startswith('SA1'): - invertertype = PV | X1 # Older Might be single - elif seriesnumber.startswith('SB1'): - invertertype = PV | X1 # Older Might be single - elif seriesnumber.startswith('SC1'): - invertertype = PV | X3 # Older Probably 3phase - elif seriesnumber.startswith('SD1'): - invertertype = PV | X3 # Older Probably 3phase - elif seriesnumber.startswith('SF4'): - invertertype = PV | X3 # Older Probably 3phase - elif seriesnumber.startswith('SH1'): - invertertype = HYBRID | X3 | GEN | BAT_BTS # HYD5...8KTL-3P + elif seriesnumber.startswith("SA1"): + invertertype = PV | X1 # Older Might be single + elif seriesnumber.startswith("SB1"): + invertertype = PV | X1 # Older Might be single + elif seriesnumber.startswith("SC1"): + invertertype = PV | X3 # Older Probably 3phase + elif seriesnumber.startswith("SD1"): + invertertype = PV | X3 # Older Probably 3phase + elif seriesnumber.startswith("SF4"): + invertertype = PV | X3 # Older Probably 3phase + elif seriesnumber.startswith("SH1"): + invertertype = HYBRID | X3 | GEN | BAT_BTS # HYD5...8KTL-3P self.inverter_model = "HYD5...8KTL-3P" - elif seriesnumber.startswith('SL1'): - invertertype = PV | X3 # Older Probably 3phase - elif seriesnumber.startswith('SJ2'): - invertertype = PV | X3 # Older Probably 3phase - #elif seriesnumber.startswith('SM1E'): plugin_sofar_old - #elif seriesnumber.startswith('ZM1E'): plugin_sofar_old + elif seriesnumber.startswith("SL1"): + invertertype = PV | X3 # Older Probably 3phase + elif seriesnumber.startswith("SJ2"): + invertertype = PV | X3 # Older Probably 3phase + # elif seriesnumber.startswith('SM1E'): plugin_sofar_old + # elif seriesnumber.startswith('ZM1E'): plugin_sofar_old else: invertertype = 0 @@ -4049,26 +4149,32 @@ async def async_determineInverterType(self, hub, configdict): read_eps = configdict.get(CONF_READ_EPS, DEFAULT_READ_EPS) read_dcb = configdict.get(CONF_READ_DCB, DEFAULT_READ_DCB) read_pm = configdict.get(CONF_READ_PM, DEFAULT_READ_PM) - if read_eps: invertertype = invertertype | EPS - if read_dcb: invertertype = invertertype | DCB - if read_pm: invertertype = invertertype | PM + if read_eps: + invertertype = invertertype | EPS + if read_dcb: + invertertype = invertertype | DCB + if read_pm: + invertertype = invertertype | PM return invertertype - def matchInverterWithMask (self, inverterspec, entitymask, serialnumber = 'not relevant', blacklist = None): + def matchInverterWithMask(self, inverterspec, entitymask, serialnumber="not relevant", blacklist=None): # returns true if the entity needs to be created for an inverter - genmatch = ((inverterspec & entitymask & ALL_GEN_GROUP) != 0) or (entitymask & ALL_GEN_GROUP == 0) - xmatch = ((inverterspec & entitymask & ALL_X_GROUP) != 0) or (entitymask & ALL_X_GROUP == 0) + genmatch = ((inverterspec & entitymask & ALL_GEN_GROUP) != 0) or (entitymask & ALL_GEN_GROUP == 0) + xmatch = ((inverterspec & entitymask & ALL_X_GROUP) != 0) or (entitymask & ALL_X_GROUP == 0) hybmatch = ((inverterspec & entitymask & ALL_TYPE_GROUP) != 0) or (entitymask & ALL_TYPE_GROUP == 0) - epsmatch = ((inverterspec & entitymask & ALL_EPS_GROUP) != 0) or (entitymask & ALL_EPS_GROUP == 0) - dcbmatch = ((inverterspec & entitymask & ALL_DCB_GROUP) != 0) or (entitymask & ALL_DCB_GROUP == 0) - pmmatch = ((inverterspec & entitymask & ALL_PM_GROUP) != 0) or (entitymask & ALL_PM_GROUP == 0) - mpptmatch = ((inverterspec & entitymask & ALL_MPPT_GROUP) != 0) or (entitymask & ALL_MPPT_GROUP == 0) + epsmatch = ((inverterspec & entitymask & ALL_EPS_GROUP) != 0) or (entitymask & ALL_EPS_GROUP == 0) + dcbmatch = ((inverterspec & entitymask & ALL_DCB_GROUP) != 0) or (entitymask & ALL_DCB_GROUP == 0) + pmmatch = ((inverterspec & entitymask & ALL_PM_GROUP) != 0) or (entitymask & ALL_PM_GROUP == 0) + mpptmatch = ((inverterspec & entitymask & ALL_MPPT_GROUP) != 0) or (entitymask & ALL_MPPT_GROUP == 0) blacklisted = False if blacklist: for start in blacklist: - if serialnumber.startswith(start) : blacklisted = True - return (genmatch and xmatch and hybmatch and epsmatch and dcbmatch and pmmatch and mpptmatch) and not blacklisted + if serialnumber.startswith(start): + blacklisted = True + return ( + genmatch and xmatch and hybmatch and epsmatch and dcbmatch and pmmatch and mpptmatch + ) and not blacklisted def getSoftwareVersion(self, new_data): return new_data.get("software_version", None) @@ -4076,16 +4182,18 @@ def getSoftwareVersion(self, new_data): def getHardwareVersion(self, new_data): return new_data.get("hardware_version", None) + plugin_instance = sofar_plugin( - plugin_name = 'Sofar', - plugin_manufacturer = 'Sofar Solar', - SENSOR_TYPES = SENSOR_TYPES, - NUMBER_TYPES = NUMBER_TYPES, - BUTTON_TYPES = BUTTON_TYPES, - SELECT_TYPES = SELECT_TYPES, - BATTERY_CONFIG = battery_config(), - block_size = 100, - order16 = Endian.BIG, - order32 = Endian.BIG, - auto_block_ignore_readerror = True - ) + plugin_name="Sofar", + plugin_manufacturer="Sofar Solar", + SENSOR_TYPES=SENSOR_TYPES, + NUMBER_TYPES=NUMBER_TYPES, + BUTTON_TYPES=BUTTON_TYPES, + SELECT_TYPES=SELECT_TYPES, + SWITCH_TYPES=[], + BATTERY_CONFIG=battery_config(), + block_size=100, + order16=Endian.BIG, + order32=Endian.BIG, + auto_block_ignore_readerror=True, +) diff --git a/custom_components/solax_modbus/plugin_sofar_old.py b/custom_components/solax_modbus/plugin_sofar_old.py index 93936ebf..370743f9 100644 --- a/custom_components/solax_modbus/plugin_sofar_old.py +++ b/custom_components/solax_modbus/plugin_sofar_old.py @@ -20,39 +20,41 @@ An entity can be declared multiple times (with different bitmasks) if the parameters are different for each inverter type """ -GEN = 0x0001 # base generation for MIC, PV, AC -GEN2 = 0x0002 -GEN3 = 0x0004 -GEN4 = 0x0008 -ALL_GEN_GROUP = GEN2 | GEN3 | GEN4 | GEN +GEN = 0x0001 # base generation for MIC, PV, AC +GEN2 = 0x0002 +GEN3 = 0x0004 +GEN4 = 0x0008 +ALL_GEN_GROUP = GEN2 | GEN3 | GEN4 | GEN -X1 = 0x0100 -X3 = 0x0200 -ALL_X_GROUP = X1 | X3 +X1 = 0x0100 +X3 = 0x0200 +ALL_X_GROUP = X1 | X3 -PV = 0x0400 # Needs further work on PV Only Inverters -AC = 0x0800 -HYBRID = 0x1000 -MIC = 0x2000 +PV = 0x0400 # Needs further work on PV Only Inverters +AC = 0x0800 +HYBRID = 0x1000 +MIC = 0x2000 ALL_TYPE_GROUP = PV | AC | HYBRID | MIC -EPS = 0x8000 -ALL_EPS_GROUP = EPS +EPS = 0x8000 +ALL_EPS_GROUP = EPS -DCB = 0x10000 # dry contact box - gen4 -ALL_DCB_GROUP = DCB +DCB = 0x10000 # dry contact box - gen4 +ALL_DCB_GROUP = DCB -PM = 0x20000 +PM = 0x20000 ALL_PM_GROUP = PM -ALLDEFAULT = 0 # should be equivalent to HYBRID | AC | GEN2 | GEN3 | GEN4 | X1 | X3 +ALLDEFAULT = 0 # should be equivalent to HYBRID | AC | GEN2 | GEN3 | GEN4 | X1 | X3 # ======================= end of bitmask handling code ============================================= # ====================== find inverter type and details =========================================== + def remove_special_chars(input_str): - return re.sub(r'[^A-z0-9 -]', '', input_str) + return re.sub(r"[^A-z0-9 -]", "", input_str) + async def async_read_serialnr(hub, address, swapbytes): res = None @@ -62,38 +64,49 @@ async def async_read_serialnr(hub, address, swapbytes): decoder = BinaryPayloadDecoder.fromRegisters(inverter_data.registers, byteorder=Endian.BIG) res = decoder.decode_string(12).decode("ascii") if swapbytes: - ba = bytearray(res,"ascii") # convert to bytearray for swapping - ba[0::2], ba[1::2] = ba[1::2], ba[0::2] # swap bytes ourselves - due to bug in Endian.LITTLE ? - res = str(ba, "ascii") # convert back to string + ba = bytearray(res, "ascii") # convert to bytearray for swapping + ba[0::2], ba[1::2] = ba[1::2], ba[0::2] # swap bytes ourselves - due to bug in Endian.LITTLE ? + res = str(ba, "ascii") # convert back to string res = remove_special_chars(res) hub.seriesnumber = res - except Exception as ex: _LOGGER.warning(f"{hub.name}: attempt to read serialnumber failed at 0x{address:x}", exc_info=True) - if not res: _LOGGER.warning(f"{hub.name}: reading serial number from address 0x{address:x} failed; other address may succeed") + except Exception as ex: + _LOGGER.warning(f"{hub.name}: attempt to read serialnumber failed at 0x{address:x}", exc_info=True) + if not res: + _LOGGER.warning( + f"{hub.name}: reading serial number from address 0x{address:x} failed; other address may succeed" + ) _LOGGER.info(f"Read {hub.name} 0x{address:x} serial number: {res}, swapped: {swapbytes}") return res + # ================================================================================================= + @dataclass class SofarOldModbusButtonEntityDescription(BaseModbusButtonEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class SofarOldModbusNumberEntityDescription(BaseModbusNumberEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class SofarOldModbusSelectEntityDescription(BaseModbusSelectEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class SofarOldModbusSensorEntityDescription(BaseModbusSensorEntityDescription): """A class that describes Sofar Modbus sensor entities.""" - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice - #order16: int = Endian.BIG - #order32: int = Endian.BIG + + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + # order16: int = Endian.BIG + # order32: int = Endian.BIG unit: int = REGISTER_U16 - register_type: int= REG_HOLDING + register_type: int = REG_HOLDING + # ================================= Button Declarations ============================================================ @@ -102,617 +115,620 @@ class SofarOldModbusSensorEntityDescription(BaseModbusSensorEntityDescription): SELECT_TYPES = [] SENSOR_TYPES: list[SofarOldModbusSensorEntityDescription] = [ - -### -# -# Holding Registers -# -### + ### + # + # Holding Registers + # + ### # Start of Single Phase SofarOldModbusSensorEntityDescription( - name = "Run Mode", - key = "run_mode", - register = 0x0, - scale = { 0: "Waiting", - 1: "Checking", - 2: "Normal Mode", - 3: "Fault", - 4: "Permanent Fault Mode", }, - allowedtypes = PV, - icon = "mdi:run", - ), - SofarOldModbusSensorEntityDescription( - name = "PV Voltage 1", - key = "pv_voltage_1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x6, - scale = 0.1, - rounding = 1, - allowedtypes = PV, - ), - SofarOldModbusSensorEntityDescription( - name = "PV Current 1", - key = "pv_current_1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x7, - scale = 0.01, - rounding = 2, - allowedtypes = PV, - icon = "mdi:current-dc", - ), - SofarOldModbusSensorEntityDescription( - name = "PV Power", - key = "pv_power", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0xA, - scale = 0.01, - rounding = 2, - allowedtypes = PV | X1, - icon = "mdi:solar-power-variant", - ), - SofarOldModbusSensorEntityDescription( - name = "ActivePower", - key = "activepower", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0xC, - scale = 0.01, - rounding = 2, - allowedtypes = PV | X1, - ), - SofarOldModbusSensorEntityDescription( - name = "ReactivePower", - key = "reactivepower", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - register = 0xD, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = PV | X1, - ), - SofarOldModbusSensorEntityDescription( - name = "Grid Frequency", - key = "grid_frequency", - native_unit_of_measurement = UnitOfFrequency.HERTZ, - device_class = SensorDeviceClass.FREQUENCY, - register = 0xE, - scale = 0.01, - rounding = 2, - allowedtypes = PV | X1, - ), - SofarOldModbusSensorEntityDescription( - name = "Voltage", - key = "voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0xF, - scale = 0.1, - rounding = 1, - allowedtypes = PV | X1, - ), - SofarOldModbusSensorEntityDescription( - name = "Current", - key = "current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x10, - scale = 0.01, - rounding = 2, - allowedtypes = PV | X1, - ), - SofarOldModbusSensorEntityDescription( - name = "Total Production", - key = "total_production", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x15, - unit = REGISTER_U32, - allowedtypes = PV | X1, - ), - SofarOldModbusSensorEntityDescription( - name = "Total Time", - key = "total_time", - native_unit_of_measurement = UnitOfTime.HOURS, - register = 0x17, - unit = REGISTER_U32, - allowedtypes = PV | X1, - ), - SofarOldModbusSensorEntityDescription( - name = "Today Production", - key = "today_production", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x19, - scale = 0.01, - rounding = 2, - allowedtypes = PV | X1, - ), - SofarOldModbusSensorEntityDescription( - name = "Today Time", - key = "today_time", - native_unit_of_measurement = UnitOfTime.MINUTES, - register = 0x1A, - allowedtypes = PV | X1, - ), - SofarOldModbusSensorEntityDescription( - name = "Inverter Heatsink Temperature ", - key = "inverter_heatsink_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x1B, - unit = REGISTER_S16, - #entity_registry_enabled_default = False, - allowedtypes = PV, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarOldModbusSensorEntityDescription( - name = "Inverter Inner Temperature ", - key = "inverter_inner_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x1C, - unit = REGISTER_S16, - #entity_registry_enabled_default = False, - allowedtypes = PV, - entity_category = EntityCategory.DIAGNOSTIC, + name="Run Mode", + key="run_mode", + register=0x0, + scale={ + 0: "Waiting", + 1: "Checking", + 2: "Normal Mode", + 3: "Fault", + 4: "Permanent Fault Mode", + }, + allowedtypes=PV, + icon="mdi:run", + ), + SofarOldModbusSensorEntityDescription( + name="PV Voltage 1", + key="pv_voltage_1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x6, + scale=0.1, + rounding=1, + allowedtypes=PV, + ), + SofarOldModbusSensorEntityDescription( + name="PV Current 1", + key="pv_current_1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x7, + scale=0.01, + rounding=2, + allowedtypes=PV, + icon="mdi:current-dc", + ), + SofarOldModbusSensorEntityDescription( + name="PV Power", + key="pv_power", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0xA, + scale=0.01, + rounding=2, + allowedtypes=PV | X1, + icon="mdi:solar-power-variant", + ), + SofarOldModbusSensorEntityDescription( + name="ActivePower", + key="activepower", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0xC, + scale=0.01, + rounding=2, + allowedtypes=PV | X1, + ), + SofarOldModbusSensorEntityDescription( + name="ReactivePower", + key="reactivepower", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=0xD, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=PV | X1, + ), + SofarOldModbusSensorEntityDescription( + name="Grid Frequency", + key="grid_frequency", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + device_class=SensorDeviceClass.FREQUENCY, + register=0xE, + scale=0.01, + rounding=2, + allowedtypes=PV | X1, + ), + SofarOldModbusSensorEntityDescription( + name="Voltage", + key="voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0xF, + scale=0.1, + rounding=1, + allowedtypes=PV | X1, + ), + SofarOldModbusSensorEntityDescription( + name="Current", + key="current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x10, + scale=0.01, + rounding=2, + allowedtypes=PV | X1, + ), + SofarOldModbusSensorEntityDescription( + name="Total Production", + key="total_production", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x15, + unit=REGISTER_U32, + allowedtypes=PV | X1, + ), + SofarOldModbusSensorEntityDescription( + name="Total Time", + key="total_time", + native_unit_of_measurement=UnitOfTime.HOURS, + register=0x17, + unit=REGISTER_U32, + allowedtypes=PV | X1, + ), + SofarOldModbusSensorEntityDescription( + name="Today Production", + key="today_production", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x19, + scale=0.01, + rounding=2, + allowedtypes=PV | X1, + ), + SofarOldModbusSensorEntityDescription( + name="Today Time", + key="today_time", + native_unit_of_measurement=UnitOfTime.MINUTES, + register=0x1A, + allowedtypes=PV | X1, + ), + SofarOldModbusSensorEntityDescription( + name="Inverter Heatsink Temperature ", + key="inverter_heatsink_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x1B, + unit=REGISTER_S16, + # entity_registry_enabled_default = False, + allowedtypes=PV, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarOldModbusSensorEntityDescription( + name="Inverter Inner Temperature ", + key="inverter_inner_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x1C, + unit=REGISTER_S16, + # entity_registry_enabled_default = False, + allowedtypes=PV, + entity_category=EntityCategory.DIAGNOSTIC, ), # End of Single Phase # # Start of 3Phase PV SofarOldModbusSensorEntityDescription( - name = "PV Voltage 2", - key = "pv_voltage_2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x8, - scale = 0.1, - rounding = 1, - allowedtypes = PV | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "PV Current 2", - key = "pv_current_2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x9, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = PV | X3, - icon = "mdi:current-dc", - ), - SofarOldModbusSensorEntityDescription( - name = "PV Voltage 3", - key = "pv_voltage_3", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0xA, - scale = 0.1, - rounding = 1, - allowedtypes = PV | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "PV Current 3", - key = "pv_current_3", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0xB, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = PV | X3, - icon = "mdi:current-dc", - ), - SofarOldModbusSensorEntityDescription( - name = "PV Power 1", - key = "pv_power_1", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0xC, - scale = 0.01, - rounding = 2, - allowedtypes = PV | X3, - icon = "mdi:solar-power-variant", - ), - SofarOldModbusSensorEntityDescription( - name = "PV Power 2", - key = "pv_power_2", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0xD, - scale = 0.01, - rounding = 2, - allowedtypes = PV | X3, - icon = "mdi:solar-power-variant", - ), - SofarOldModbusSensorEntityDescription( - name = "PV Power 3", - key = "pv_power_3", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0xE, - scale = 0.01, - rounding = 2, - allowedtypes = PV | X3, - icon = "mdi:solar-power-variant", - ), - SofarOldModbusSensorEntityDescription( - name = "ActivePower", - key = "activepower", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - register = 0xF, - scale = 0.01, - rounding = 2, - allowedtypes = PV | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "ReactivePower", - key = "reactivepower", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - register = 0x10, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = PV | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "Grid Frequency", - key = "grid_frequency", - native_unit_of_measurement = UnitOfFrequency.HERTZ, - device_class = SensorDeviceClass.FREQUENCY, - register = 0x11, - scale = 0.01, - rounding = 2, - allowedtypes = PV | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "Voltage R", - key = "voltage_r", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x12, - scale = 0.1, - rounding = 1, - allowedtypes = PV | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "Current R", - key = "current_r", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x14, - scale = 0.01, - rounding = 2, - allowedtypes = PV | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "Voltage S", - key = "voltage_s", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x14, - scale = 0.1, - rounding = 1, - allowedtypes = PV | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "Current S", - key = "current_s", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x15, - scale = 0.01, - rounding = 2, - allowedtypes = PV | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "Voltage T", - key = "voltage_t", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x16, - scale = 0.1, - rounding = 1, - allowedtypes = PV | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "Current T", - key = "current_t", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x17, - scale = 0.01, - rounding = 2, - allowedtypes = PV | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "Total Production", - key = "total_production", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - register = 0x18, - unit = REGISTER_U32, - allowedtypes = PV | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "Total Time", - key = "total_time", - native_unit_of_measurement = UnitOfTime.HOURS, - register = 0x1A, - unit = REGISTER_U32, - allowedtypes = PV | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "Today Production", - key = "today_production", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - register = 0x1C, - scale = 0.01, - rounding = 2, - allowedtypes = PV | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "Today Time", - key = "today_time", - native_unit_of_measurement = UnitOfTime.MINUTES, - register = 0x1D, - allowedtypes = PV | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "Inverter Heatsink Temperature ", - key = "inverter_heatsink_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x1E, - unit = REGISTER_S16, - entity_registry_enabled_default = False, - allowedtypes = PV | X3, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarOldModbusSensorEntityDescription( - name = "Inverter Inner Temperature ", - key = "inverter_inner_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x1F, - unit = REGISTER_S16, - entity_registry_enabled_default = False, - allowedtypes = PV | X3, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarOldModbusSensorEntityDescription( - name = "Bus Voltage", - key = "bus_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x20, - scale = 0.1, - rounding = 1, - allowedtypes = PV | X3, + name="PV Voltage 2", + key="pv_voltage_2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x8, + scale=0.1, + rounding=1, + allowedtypes=PV | X3, + ), + SofarOldModbusSensorEntityDescription( + name="PV Current 2", + key="pv_current_2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x9, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=PV | X3, + icon="mdi:current-dc", + ), + SofarOldModbusSensorEntityDescription( + name="PV Voltage 3", + key="pv_voltage_3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0xA, + scale=0.1, + rounding=1, + allowedtypes=PV | X3, + ), + SofarOldModbusSensorEntityDescription( + name="PV Current 3", + key="pv_current_3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0xB, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=PV | X3, + icon="mdi:current-dc", + ), + SofarOldModbusSensorEntityDescription( + name="PV Power 1", + key="pv_power_1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0xC, + scale=0.01, + rounding=2, + allowedtypes=PV | X3, + icon="mdi:solar-power-variant", + ), + SofarOldModbusSensorEntityDescription( + name="PV Power 2", + key="pv_power_2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0xD, + scale=0.01, + rounding=2, + allowedtypes=PV | X3, + icon="mdi:solar-power-variant", + ), + SofarOldModbusSensorEntityDescription( + name="PV Power 3", + key="pv_power_3", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0xE, + scale=0.01, + rounding=2, + allowedtypes=PV | X3, + icon="mdi:solar-power-variant", + ), + SofarOldModbusSensorEntityDescription( + name="ActivePower", + key="activepower", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + register=0xF, + scale=0.01, + rounding=2, + allowedtypes=PV | X3, + ), + SofarOldModbusSensorEntityDescription( + name="ReactivePower", + key="reactivepower", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=0x10, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=PV | X3, + ), + SofarOldModbusSensorEntityDescription( + name="Grid Frequency", + key="grid_frequency", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + device_class=SensorDeviceClass.FREQUENCY, + register=0x11, + scale=0.01, + rounding=2, + allowedtypes=PV | X3, + ), + SofarOldModbusSensorEntityDescription( + name="Voltage R", + key="voltage_r", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x12, + scale=0.1, + rounding=1, + allowedtypes=PV | X3, + ), + SofarOldModbusSensorEntityDescription( + name="Current R", + key="current_r", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x14, + scale=0.01, + rounding=2, + allowedtypes=PV | X3, + ), + SofarOldModbusSensorEntityDescription( + name="Voltage S", + key="voltage_s", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x14, + scale=0.1, + rounding=1, + allowedtypes=PV | X3, + ), + SofarOldModbusSensorEntityDescription( + name="Current S", + key="current_s", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x15, + scale=0.01, + rounding=2, + allowedtypes=PV | X3, + ), + SofarOldModbusSensorEntityDescription( + name="Voltage T", + key="voltage_t", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x16, + scale=0.1, + rounding=1, + allowedtypes=PV | X3, + ), + SofarOldModbusSensorEntityDescription( + name="Current T", + key="current_t", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x17, + scale=0.01, + rounding=2, + allowedtypes=PV | X3, + ), + SofarOldModbusSensorEntityDescription( + name="Total Production", + key="total_production", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + register=0x18, + unit=REGISTER_U32, + allowedtypes=PV | X3, + ), + SofarOldModbusSensorEntityDescription( + name="Total Time", + key="total_time", + native_unit_of_measurement=UnitOfTime.HOURS, + register=0x1A, + unit=REGISTER_U32, + allowedtypes=PV | X3, + ), + SofarOldModbusSensorEntityDescription( + name="Today Production", + key="today_production", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + register=0x1C, + scale=0.01, + rounding=2, + allowedtypes=PV | X3, + ), + SofarOldModbusSensorEntityDescription( + name="Today Time", + key="today_time", + native_unit_of_measurement=UnitOfTime.MINUTES, + register=0x1D, + allowedtypes=PV | X3, + ), + SofarOldModbusSensorEntityDescription( + name="Inverter Heatsink Temperature ", + key="inverter_heatsink_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x1E, + unit=REGISTER_S16, + entity_registry_enabled_default=False, + allowedtypes=PV | X3, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarOldModbusSensorEntityDescription( + name="Inverter Inner Temperature ", + key="inverter_inner_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x1F, + unit=REGISTER_S16, + entity_registry_enabled_default=False, + allowedtypes=PV | X3, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarOldModbusSensorEntityDescription( + name="Bus Voltage", + key="bus_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x20, + scale=0.1, + rounding=1, + allowedtypes=PV | X3, ), # End of 3Phase PV # # Start of AC SofarOldModbusSensorEntityDescription( - name = "Run Mode", - key = "run_mode", - register = 0x200, - scale = { 0: "Waiting", - 1: "Checking", - 2: "Normal Mode", - 3: "Checking Discharge", - 4: "Discharge Mode", - 5: "EPS Mode", - 6: "Fault", - 7: "Permanent Fault Mode", }, - allowedtypes = AC | HYBRID, - icon = "mdi:run", - ), - SofarOldModbusSensorEntityDescription( - name = "Voltage R", - key = "voltage_r", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x206, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID, - ), - SofarOldModbusSensorEntityDescription( - name = "Current R", - key = "current_r", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x207, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID, - ), - SofarOldModbusSensorEntityDescription( - name = "Voltage S", - key = "voltage_s", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x208, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "Current S", - key = "current_s", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x209, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "Voltage T", - key = "voltage_t", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x20A, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "Current T", - key = "current_t", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x20B, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "Grid Frequency", - key = "grid_frequency", - native_unit_of_measurement = UnitOfFrequency.HERTZ, - device_class = SensorDeviceClass.FREQUENCY, - register = 0x20C, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID, - ), - SofarOldModbusSensorEntityDescription( - name = "Battery Power Charge", - key = "battery_power_charge", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x20D, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID, - ), - SofarOldModbusSensorEntityDescription( - name = "Battery Input Energy", - key = "battery_input_energy", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - value_function = value_function_battery_input, - allowedtypes = AC | HYBRID, - icon = "mdi:battery-arrow-up", - ), - SofarOldModbusSensorEntityDescription( - name = "Battery Output Energy", - key = "battery_output_energy", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - value_function = value_function_battery_output, - allowedtypes = AC | HYBRID, - icon = "mdi:battery-arrow-down", - ), - SofarOldModbusSensorEntityDescription( - name = "Battery Voltage Charge", - key = "battery_voltage_charge", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x20E, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID, - ), - SofarOldModbusSensorEntityDescription( - name = "Battery Current Charge", - key = "battery_current_charge", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x20F, - scale = 0.01, - rounding = 2, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID, - icon = "mdi:current-dc", - ), - SofarOldModbusSensorEntityDescription( - name = "Battery Capacity", - key = "battery_capacity_charge", - native_unit_of_measurement = PERCENTAGE, - device_class = SensorDeviceClass.BATTERY, - register = 0x210, - allowedtypes = AC | HYBRID, - ), - SofarOldModbusSensorEntityDescription( - name = "Battery Temperature", - key = "battery_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x211, - allowedtypes = AC | HYBRID, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarOldModbusSensorEntityDescription( - name = "Measured Power", - key = "measured_power", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x212, - unit = REGISTER_S16, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID, - ), - SofarOldModbusSensorEntityDescription( - name = "Grid Import", - key = "grid_import", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - value_function = value_function_grid_import, - allowedtypes = AC | HYBRID, - icon = "mdi:home-import-outline", - ), - SofarOldModbusSensorEntityDescription( - name = "Grid Export", - key = "grid_export", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - value_function = value_function_grid_export, - allowedtypes = AC | HYBRID, - icon = "mdi:home-export-outline", - ), - SofarOldModbusSensorEntityDescription( - name = "House Load", - key = "house_load", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x213, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID, + name="Run Mode", + key="run_mode", + register=0x200, + scale={ + 0: "Waiting", + 1: "Checking", + 2: "Normal Mode", + 3: "Checking Discharge", + 4: "Discharge Mode", + 5: "EPS Mode", + 6: "Fault", + 7: "Permanent Fault Mode", + }, + allowedtypes=AC | HYBRID, + icon="mdi:run", + ), + SofarOldModbusSensorEntityDescription( + name="Voltage R", + key="voltage_r", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x206, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID, + ), + SofarOldModbusSensorEntityDescription( + name="Current R", + key="current_r", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x207, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID, + ), + SofarOldModbusSensorEntityDescription( + name="Voltage S", + key="voltage_s", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x208, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | X3, + ), + SofarOldModbusSensorEntityDescription( + name="Current S", + key="current_s", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x209, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID | X3, + ), + SofarOldModbusSensorEntityDescription( + name="Voltage T", + key="voltage_t", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x20A, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | X3, + ), + SofarOldModbusSensorEntityDescription( + name="Current T", + key="current_t", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x20B, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID | X3, + ), + SofarOldModbusSensorEntityDescription( + name="Grid Frequency", + key="grid_frequency", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + device_class=SensorDeviceClass.FREQUENCY, + register=0x20C, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID, + ), + SofarOldModbusSensorEntityDescription( + name="Battery Power Charge", + key="battery_power_charge", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x20D, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID, + ), + SofarOldModbusSensorEntityDescription( + name="Battery Input Energy", + key="battery_input_energy", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + value_function=value_function_battery_input, + allowedtypes=AC | HYBRID, + icon="mdi:battery-arrow-up", + ), + SofarOldModbusSensorEntityDescription( + name="Battery Output Energy", + key="battery_output_energy", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + value_function=value_function_battery_output, + allowedtypes=AC | HYBRID, + icon="mdi:battery-arrow-down", + ), + SofarOldModbusSensorEntityDescription( + name="Battery Voltage Charge", + key="battery_voltage_charge", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x20E, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID, + ), + SofarOldModbusSensorEntityDescription( + name="Battery Current Charge", + key="battery_current_charge", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x20F, + scale=0.01, + rounding=2, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID, + icon="mdi:current-dc", + ), + SofarOldModbusSensorEntityDescription( + name="Battery Capacity", + key="battery_capacity_charge", + native_unit_of_measurement=PERCENTAGE, + device_class=SensorDeviceClass.BATTERY, + register=0x210, + allowedtypes=AC | HYBRID, + ), + SofarOldModbusSensorEntityDescription( + name="Battery Temperature", + key="battery_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x211, + allowedtypes=AC | HYBRID, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarOldModbusSensorEntityDescription( + name="Measured Power", + key="measured_power", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x212, + unit=REGISTER_S16, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID, + ), + SofarOldModbusSensorEntityDescription( + name="Grid Import", + key="grid_import", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + value_function=value_function_grid_import, + allowedtypes=AC | HYBRID, + icon="mdi:home-import-outline", + ), + SofarOldModbusSensorEntityDescription( + name="Grid Export", + key="grid_export", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + value_function=value_function_grid_export, + allowedtypes=AC | HYBRID, + icon="mdi:home-export-outline", + ), + SofarOldModbusSensorEntityDescription( + name="House Load", + key="house_load", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x213, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID, ), #### # @@ -720,331 +736,330 @@ class SofarOldModbusSensorEntityDescription(BaseModbusSensorEntityDescription): # #### SofarOldModbusSensorEntityDescription( - name = "Generation Power", - key = "generation_power", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x215, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID, - ), - SofarOldModbusSensorEntityDescription( - name = "EPS Voltage", - key = "eps_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x216, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | EPS, - ), - SofarOldModbusSensorEntityDescription( - name = "EPS Power", - key = "eps_power", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x217, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID | EPS, - ), - SofarOldModbusSensorEntityDescription( - name = "Generation Today", - key = "generation_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x218, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID, - ), - SofarOldModbusSensorEntityDescription( - name = "Export Energy Today", - key = "export_energy_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x219, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID, - icon = "mdi:home-export-outline", - ), - SofarOldModbusSensorEntityDescription( - name = "Import Energy Today", - key = "import_energy_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x21A, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID, - icon = "mdi:home-import-outline", - ), - SofarOldModbusSensorEntityDescription( - name = "Consumption Today", - key = "consumption_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x21B, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID, + name="Generation Power", + key="generation_power", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x215, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID, + ), + SofarOldModbusSensorEntityDescription( + name="EPS Voltage", + key="eps_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x216, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | EPS, + ), + SofarOldModbusSensorEntityDescription( + name="EPS Power", + key="eps_power", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x217, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID | EPS, + ), + SofarOldModbusSensorEntityDescription( + name="Generation Today", + key="generation_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x218, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID, + ), + SofarOldModbusSensorEntityDescription( + name="Export Energy Today", + key="export_energy_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x219, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID, + icon="mdi:home-export-outline", + ), + SofarOldModbusSensorEntityDescription( + name="Import Energy Today", + key="import_energy_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x21A, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID, + icon="mdi:home-import-outline", + ), + SofarOldModbusSensorEntityDescription( + name="Consumption Today", + key="consumption_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x21B, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID, ), # SofarOldModbusSensorEntityDescription( - name = "Generation Total", - key = "generation_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x21C, - unit = REGISTER_U32, - allowedtypes = AC | HYBRID, - ), - SofarOldModbusSensorEntityDescription( - name = "Export Energy Total", - key = "export_energy_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x21E, - unit = REGISTER_U32, - allowedtypes = AC | HYBRID, - icon = "mdi:home-export-outline", - ), - SofarOldModbusSensorEntityDescription( - name = "Import Energy Total", - key = "import_energy_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x220, - unit = REGISTER_U32, - allowedtypes = AC | HYBRID, - icon = "mdi:home-import-outline", - ), - SofarOldModbusSensorEntityDescription( - name = "Consumption Total", - key = "consumption_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x222, - unit = REGISTER_U32, - allowedtypes = AC | HYBRID, - ), - SofarOldModbusSensorEntityDescription( - name = "Battery Charge Cycle", - key = "battery_charge_cycle", - register = 0x22C, - allowedtypes = AC | HYBRID, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarOldModbusSensorEntityDescription( - name = "Grid Voltage R", - key = "grid_voltage_r", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x230, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID, - ), - SofarOldModbusSensorEntityDescription( - name = "Grid Current R", - key = "grid_current_r", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x231, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID, - ), - SofarOldModbusSensorEntityDescription( - name = "Grid Voltage S", - key = "grid_voltage_s", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x232, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "Grid Current S", - key = "grid_current_s", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x233, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "Grid Voltage T", - key = "grid_voltage_t", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x234, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "Grid Current T", - key = "grid_current_t", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x235, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID | X3, - ), - SofarOldModbusSensorEntityDescription( - name = "Inverter Inner Temperature ", - key = "inverter_inner_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x238, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarOldModbusSensorEntityDescription( - name = "Inverter Heatsink Temperature ", - key = "inverter_heatsink_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x239, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SofarOldModbusSensorEntityDescription( - name = "Generation Time Today", - key = "generation_time_today", - native_unit_of_measurement = UnitOfTime.MINUTES, - register = 0x242, - allowedtypes = AC | HYBRID, - ), - SofarOldModbusSensorEntityDescription( - name = "Generation Time Today", - key = "generation_time_today", - native_unit_of_measurement = UnitOfTime.HOURS, - register = 0x244, - unit = REGISTER_U32, - allowedtypes = AC | HYBRID, - ), - SofarOldModbusSensorEntityDescription( - name = "PV Voltage 1", - key = "pv_oltage_1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x250, - newblock = True, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - ), - SofarOldModbusSensorEntityDescription( - name = "PV Current 1", - key = "pv_current_1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x251, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID, - ), - SofarOldModbusSensorEntityDescription( - name = "PV Power 1", - key = "pv_power_1", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x252, - scale = 10, - allowedtypes = HYBRID, - ), - SofarOldModbusSensorEntityDescription( - name = "PV Voltage 2", - key = "pv_oltage_2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x253, - newblock = True, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - ), - SofarOldModbusSensorEntityDescription( - name = "PV Current 2", - key = "pv_current_2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x254, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID, - ), - SofarOldModbusSensorEntityDescription( - name = "PV Power 2", - key = "pv_power_2", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x255, - scale = 10, - allowedtypes = HYBRID, - ), - SofarOldModbusSensorEntityDescription( - name = "PV Power Total", - key = "pv_power_total", - value_function= value_function_pv_power_total, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - allowedtypes = HYBRID, - icon = "mdi:solar-power-variant", - sleepmode = SLEEPMODE_ZERO, - ), -### -# -# Holding Registers -# -### - SofarOldModbusSensorEntityDescription( - name = "Serial Number", - key = "serial_number", - register = 0x2002, - register_type = REG_INPUT, - unit = REGISTER_STR, - wordcount = 6, - allowedtypes = ALLDEFAULT, - ), - SofarOldModbusSensorEntityDescription( - name = "Battery Minimum Capacity", - key = "battery_minimum_capacity", - register = 0x104D, - register_type = REG_INPUT, - allowedtypes = AC, - icon = "mdi:battery-sync", + name="Generation Total", + key="generation_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x21C, + unit=REGISTER_U32, + allowedtypes=AC | HYBRID, + ), + SofarOldModbusSensorEntityDescription( + name="Export Energy Total", + key="export_energy_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x21E, + unit=REGISTER_U32, + allowedtypes=AC | HYBRID, + icon="mdi:home-export-outline", + ), + SofarOldModbusSensorEntityDescription( + name="Import Energy Total", + key="import_energy_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x220, + unit=REGISTER_U32, + allowedtypes=AC | HYBRID, + icon="mdi:home-import-outline", + ), + SofarOldModbusSensorEntityDescription( + name="Consumption Total", + key="consumption_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x222, + unit=REGISTER_U32, + allowedtypes=AC | HYBRID, + ), + SofarOldModbusSensorEntityDescription( + name="Battery Charge Cycle", + key="battery_charge_cycle", + register=0x22C, + allowedtypes=AC | HYBRID, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarOldModbusSensorEntityDescription( + name="Grid Voltage R", + key="grid_voltage_r", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x230, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID, + ), + SofarOldModbusSensorEntityDescription( + name="Grid Current R", + key="grid_current_r", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x231, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID, + ), + SofarOldModbusSensorEntityDescription( + name="Grid Voltage S", + key="grid_voltage_s", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x232, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | X3, + ), + SofarOldModbusSensorEntityDescription( + name="Grid Current S", + key="grid_current_s", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x233, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID | X3, + ), + SofarOldModbusSensorEntityDescription( + name="Grid Voltage T", + key="grid_voltage_t", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x234, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | X3, + ), + SofarOldModbusSensorEntityDescription( + name="Grid Current T", + key="grid_current_t", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x235, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID | X3, + ), + SofarOldModbusSensorEntityDescription( + name="Inverter Inner Temperature ", + key="inverter_inner_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x238, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarOldModbusSensorEntityDescription( + name="Inverter Heatsink Temperature ", + key="inverter_heatsink_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x239, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SofarOldModbusSensorEntityDescription( + name="Generation Time Today", + key="generation_time_today", + native_unit_of_measurement=UnitOfTime.MINUTES, + register=0x242, + allowedtypes=AC | HYBRID, + ), + SofarOldModbusSensorEntityDescription( + name="Generation Time Today", + key="generation_time_today", + native_unit_of_measurement=UnitOfTime.HOURS, + register=0x244, + unit=REGISTER_U32, + allowedtypes=AC | HYBRID, + ), + SofarOldModbusSensorEntityDescription( + name="PV Voltage 1", + key="pv_oltage_1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x250, + newblock=True, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + ), + SofarOldModbusSensorEntityDescription( + name="PV Current 1", + key="pv_current_1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x251, + scale=0.01, + rounding=2, + allowedtypes=HYBRID, + ), + SofarOldModbusSensorEntityDescription( + name="PV Power 1", + key="pv_power_1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x252, + scale=10, + allowedtypes=HYBRID, + ), + SofarOldModbusSensorEntityDescription( + name="PV Voltage 2", + key="pv_oltage_2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x253, + newblock=True, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + ), + SofarOldModbusSensorEntityDescription( + name="PV Current 2", + key="pv_current_2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x254, + scale=0.01, + rounding=2, + allowedtypes=HYBRID, + ), + SofarOldModbusSensorEntityDescription( + name="PV Power 2", + key="pv_power_2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x255, + scale=10, + allowedtypes=HYBRID, + ), + SofarOldModbusSensorEntityDescription( + name="PV Power Total", + key="pv_power_total", + value_function=value_function_pv_power_total, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + allowedtypes=HYBRID, + icon="mdi:solar-power-variant", + sleepmode=SLEEPMODE_ZERO, + ), + ### + # + # Holding Registers + # + ### + SofarOldModbusSensorEntityDescription( + name="Serial Number", + key="serial_number", + register=0x2002, + register_type=REG_INPUT, + unit=REGISTER_STR, + wordcount=6, + allowedtypes=ALLDEFAULT, + ), + SofarOldModbusSensorEntityDescription( + name="Battery Minimum Capacity", + key="battery_minimum_capacity", + register=0x104D, + register_type=REG_INPUT, + allowedtypes=AC, + icon="mdi:battery-sync", ), ] @dataclass class sofar_old_plugin(plugin_base): - """ def isAwake(self, datadict): return (datadict.get('run_mode', None) == 'Normal Mode') @@ -1053,44 +1068,60 @@ def wakeupButton(self): return 'battery_awaken' """ - def matchInverterWithMask (self, inverterspec, entitymask, serialnumber = 'not relevant', blacklist = None): + def matchInverterWithMask(self, inverterspec, entitymask, serialnumber="not relevant", blacklist=None): # returns true if the entity needs to be created for an inverter - genmatch = ((inverterspec & entitymask & ALL_GEN_GROUP) != 0) or (entitymask & ALL_GEN_GROUP == 0) - xmatch = ((inverterspec & entitymask & ALL_X_GROUP) != 0) or (entitymask & ALL_X_GROUP == 0) + genmatch = ((inverterspec & entitymask & ALL_GEN_GROUP) != 0) or (entitymask & ALL_GEN_GROUP == 0) + xmatch = ((inverterspec & entitymask & ALL_X_GROUP) != 0) or (entitymask & ALL_X_GROUP == 0) hybmatch = ((inverterspec & entitymask & ALL_TYPE_GROUP) != 0) or (entitymask & ALL_TYPE_GROUP == 0) - epsmatch = ((inverterspec & entitymask & ALL_EPS_GROUP) != 0) or (entitymask & ALL_EPS_GROUP == 0) - dcbmatch = ((inverterspec & entitymask & ALL_DCB_GROUP) != 0) or (entitymask & ALL_DCB_GROUP == 0) - pmmatch = ((inverterspec & entitymask & ALL_PM_GROUP) != 0) or (entitymask & ALL_PM_GROUP == 0) + epsmatch = ((inverterspec & entitymask & ALL_EPS_GROUP) != 0) or (entitymask & ALL_EPS_GROUP == 0) + dcbmatch = ((inverterspec & entitymask & ALL_DCB_GROUP) != 0) or (entitymask & ALL_DCB_GROUP == 0) + pmmatch = ((inverterspec & entitymask & ALL_PM_GROUP) != 0) or (entitymask & ALL_PM_GROUP == 0) blacklisted = False if blacklist: for start in blacklist: - if serialnumber.startswith(start) : blacklisted = True + if serialnumber.startswith(start): + blacklisted = True return (genmatch and xmatch and hybmatch and epsmatch and dcbmatch and pmmatch) and not blacklisted async def async_determineInverterType(self, hub, configdict): _LOGGER.info(f"{hub.name}: trying to determine inverter type") - seriesnumber = await async_read_serialnr(hub, 0x2002, swapbytes = False) + seriesnumber = await async_read_serialnr(hub, 0x2002, swapbytes=False) if not seriesnumber: _LOGGER.error(f"{hub.name}: cannot find serial number, even not for other Inverter") seriesnumber = "unknown" # derive invertertype from seriiesnumber - if seriesnumber.startswith('SA1'): invertertype = PV | X1 # Older Might be single - elif seriesnumber.startswith('SA3'): invertertype = PV | X1 # Older Might be single - elif seriesnumber.startswith('SB1'): invertertype = PV | X1 # Older Might be single - elif seriesnumber.startswith('ZA3'): invertertype = PV | X1 # Older Might be single - elif seriesnumber.startswith('SC1'): invertertype = PV | X3 # Older Probably 3phase - elif seriesnumber.startswith('SD1'): invertertype = PV | X3 # Older Probably 3phase - elif seriesnumber.startswith('SF4'): invertertype = PV | X3 # Older Probably 3phase - elif seriesnumber.startswith('SH1'): invertertype = PV | X3 # Older Probably 3phase - elif seriesnumber.startswith('SJ2'): invertertype = PV | X3 # Older Probably 3phase - elif seriesnumber.startswith('SL1'): invertertype = PV | X3 # Older Probably 3phase - elif seriesnumber.startswith('SM1'): invertertype = PV # Not sure if 1 or 3phase? - elif seriesnumber.startswith('SE1E'): invertertype = HYBRID | X1 # 3kW HYDxxxxES - elif seriesnumber.startswith('SM1E'): invertertype = HYBRID | X1 # 3kW HYDxxxxES - elif seriesnumber.startswith('ZE1E'): invertertype = HYBRID | X1 # 3kW HYDxxxxES - elif seriesnumber.startswith('ZM1E'): invertertype = HYBRID | X1 # 3.6kW HYDxxxxES - #elif seriesnumber.startswith('S??'): invertertype = AC | HYBRID # Storage Inverter 1 or 3phase? + if seriesnumber.startswith("SA1"): + invertertype = PV | X1 # Older Might be single + elif seriesnumber.startswith("SA3"): + invertertype = PV | X1 # Older Might be single + elif seriesnumber.startswith("SB1"): + invertertype = PV | X1 # Older Might be single + elif seriesnumber.startswith("ZA3"): + invertertype = PV | X1 # Older Might be single + elif seriesnumber.startswith("SC1"): + invertertype = PV | X3 # Older Probably 3phase + elif seriesnumber.startswith("SD1"): + invertertype = PV | X3 # Older Probably 3phase + elif seriesnumber.startswith("SF4"): + invertertype = PV | X3 # Older Probably 3phase + elif seriesnumber.startswith("SH1"): + invertertype = PV | X3 # Older Probably 3phase + elif seriesnumber.startswith("SJ2"): + invertertype = PV | X3 # Older Probably 3phase + elif seriesnumber.startswith("SL1"): + invertertype = PV | X3 # Older Probably 3phase + elif seriesnumber.startswith("SM1"): + invertertype = PV # Not sure if 1 or 3phase? + elif seriesnumber.startswith("SE1E"): + invertertype = HYBRID | X1 # 3kW HYDxxxxES + elif seriesnumber.startswith("SM1E"): + invertertype = HYBRID | X1 # 3kW HYDxxxxES + elif seriesnumber.startswith("ZE1E"): + invertertype = HYBRID | X1 # 3kW HYDxxxxES + elif seriesnumber.startswith("ZM1E"): + invertertype = HYBRID | X1 # 3.6kW HYDxxxxES + # elif seriesnumber.startswith('S??'): invertertype = AC | HYBRID # Storage Inverter 1 or 3phase? else: invertertype = 0 @@ -1100,23 +1131,26 @@ async def async_determineInverterType(self, hub, configdict): read_eps = configdict.get(CONF_READ_EPS, DEFAULT_READ_EPS) read_dcb = configdict.get(CONF_READ_DCB, DEFAULT_READ_DCB) read_pm = configdict.get(CONF_READ_PM, DEFAULT_READ_PM) - if read_eps: invertertype = invertertype | EPS - if read_dcb: invertertype = invertertype | DCB - if read_pm: invertertype = invertertype | PM + if read_eps: + invertertype = invertertype | EPS + if read_dcb: + invertertype = invertertype | DCB + if read_pm: + invertertype = invertertype | PM return invertertype - plugin_instance = sofar_old_plugin( - plugin_name = 'Sofar Old', - plugin_manufacturer = 'Sofar Solar', - SENSOR_TYPES = SENSOR_TYPES, - NUMBER_TYPES = NUMBER_TYPES, - BUTTON_TYPES = BUTTON_TYPES, - SELECT_TYPES = SELECT_TYPES, - block_size = 100, - order16 = Endian.BIG, - order32 = Endian.BIG, - auto_block_ignore_readerror = True - ) + plugin_name="Sofar Old", + plugin_manufacturer="Sofar Solar", + SENSOR_TYPES=SENSOR_TYPES, + NUMBER_TYPES=NUMBER_TYPES, + BUTTON_TYPES=BUTTON_TYPES, + SELECT_TYPES=SELECT_TYPES, + SWITCH_TYPES=[], + block_size=100, + order16=Endian.BIG, + order32=Endian.BIG, + auto_block_ignore_readerror=True, +) diff --git a/custom_components/solax_modbus/plugin_solax.py b/custom_components/solax_modbus/plugin_solax.py index 64d0c3ac..6665f564 100644 --- a/custom_components/solax_modbus/plugin_solax.py +++ b/custom_components/solax_modbus/plugin_solax.py @@ -20,41 +20,41 @@ An entity can be declared multiple times (with different bitmasks) if the parameters are different for each inverter type """ -GEN = 0x0001 # base generation for MIC, PV, AC -GEN2 = 0x0002 -GEN3 = 0x0004 -GEN4 = 0x0008 -GEN5 = 0x0010 -ALL_GEN_GROUP = GEN2 | GEN3 | GEN4 | GEN5 | GEN +GEN = 0x0001 # base generation for MIC, PV, AC +GEN2 = 0x0002 +GEN3 = 0x0004 +GEN4 = 0x0008 +GEN5 = 0x0010 +ALL_GEN_GROUP = GEN2 | GEN3 | GEN4 | GEN5 | GEN -X1 = 0x0100 -X3 = 0x0200 -ALL_X_GROUP = X1 | X3 +X1 = 0x0100 +X3 = 0x0200 +ALL_X_GROUP = X1 | X3 -PV = 0x0400 # Needs further work on PV Only Inverters -AC = 0x0800 -HYBRID = 0x1000 -MIC = 0x2000 -MAX = 0x4000 +PV = 0x0400 # Needs further work on PV Only Inverters +AC = 0x0800 +HYBRID = 0x1000 +MIC = 0x2000 +MAX = 0x4000 ALL_TYPE_GROUP = PV | AC | HYBRID | MIC | MAX -EPS = 0x8000 -ALL_EPS_GROUP = EPS +EPS = 0x8000 +ALL_EPS_GROUP = EPS -DCB = 0x10000 # dry contact box - gen4 -ALL_DCB_GROUP = DCB +DCB = 0x10000 # dry contact box - gen4 +ALL_DCB_GROUP = DCB -PM = 0x20000 +PM = 0x20000 ALL_PM_GROUP = PM -MPPT3 = 0x40000 -MPPT4 = 0x80000 -MPPT6 = 0x100000 -MPPT8 = 0x200000 -MPPT10 = 0x400000 +MPPT3 = 0x40000 +MPPT4 = 0x80000 +MPPT6 = 0x100000 +MPPT8 = 0x200000 +MPPT10 = 0x400000 ALL_MPPT_GROUP = MPPT3 | MPPT4 | MPPT6 | MPPT8 | MPPT10 -ALLDEFAULT = 0 # should be equivalent to AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5 | X1 | X3 +ALLDEFAULT = 0 # should be equivalent to AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5 | X1 | X3 # ======================= end of bitmask handling code ============================================= @@ -62,6 +62,7 @@ # ====================== find inverter type and details =========================================== + async def async_read_serialnr(hub, address): res = None inverter_data = None @@ -71,221 +72,289 @@ async def async_read_serialnr(hub, address): decoder = BinaryPayloadDecoder.fromRegisters(inverter_data.registers, byteorder=Endian.BIG) res = decoder.decode_string(14).decode("ascii") if address == 0x300: - if res and not res.startswith(("M", "X")): - ba = bytearray(res,"ascii") # convert to bytearray for swapping - ba[0::2], ba[1::2] = ba[1::2], ba[0::2] # swap bytes ourselves - due to bug in Endian.LITTLE ? - res = str(ba, "ascii") # convert back to string - hub.seriesnumber = res + if res and not res.startswith(("M", "X")): + ba = bytearray(res, "ascii") # convert to bytearray for swapping + ba[0::2], ba[1::2] = ba[1::2], ba[0::2] # swap bytes ourselves - due to bug in Endian.LITTLE ? + res = str(ba, "ascii") # convert back to string + hub.seriesnumber = res hub.seriesnumber = res - except Exception as ex: _LOGGER.warning(f"{hub.name}: attempt to read serialnumber failed at 0x{address:x} data: {inverter_data}", exc_info=True) - if not res: _LOGGER.warning(f"{hub.name}: reading serial number from address 0x{address:x} failed; other address may succeed") + except Exception as ex: + _LOGGER.warning( + f"{hub.name}: attempt to read serialnumber failed at 0x{address:x} data: {inverter_data}", exc_info=True + ) + if not res: + _LOGGER.warning( + f"{hub.name}: reading serial number from address 0x{address:x} failed; other address may succeed" + ) _LOGGER.info(f"Read {hub.name} 0x{address:x} serial number: {res}") return res + # ================================================================================================= + @dataclass class SolaxModbusButtonEntityDescription(BaseModbusButtonEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class SolaxModbusNumberEntityDescription(BaseModbusNumberEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class SolaxModbusSelectEntityDescription(BaseModbusSelectEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class SolaXModbusSensorEntityDescription(BaseModbusSensorEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice unit: int = REGISTER_U16 register_type: int = REG_HOLDING + # ====================================== Computed value functions ================================================= + def value_function_remotecontrol_recompute(initval, descr, datadict): - power_control = datadict.get('remotecontrol_power_control', "Disabled") - set_type = datadict.get('remotecontrol_set_type', "Set") # other options did not work - target = datadict.get('remotecontrol_active_power', 0) - reactive_power = datadict.get('remotecontrol_reactive_power', 0) - rc_duration = datadict.get('remotecontrol_duration', 20) - ap_up = datadict.get('active_power_upper', 0) - ap_lo = datadict.get('active_power_lower', 0) - reap_up = datadict.get('reactive_power_upper', 0) - reap_lo = datadict.get('reactive_power_lower', 0) - import_limit = datadict.get('remotecontrol_import_limit', 20000) - meas = datadict.get('measured_power', 0) - pv = datadict.get('pv_power_total', 0) - houseload_nett = datadict.get('inverter_power', 0) - meas - houseload_brut = pv - datadict.get('battery_power_charge', 0) - meas + power_control = datadict.get("remotecontrol_power_control", "Disabled") + set_type = datadict.get("remotecontrol_set_type", "Set") # other options did not work + target = datadict.get("remotecontrol_active_power", 0) + reactive_power = datadict.get("remotecontrol_reactive_power", 0) + rc_duration = datadict.get("remotecontrol_duration", 20) + ap_up = datadict.get("active_power_upper", 0) + ap_lo = datadict.get("active_power_lower", 0) + reap_up = datadict.get("reactive_power_upper", 0) + reap_lo = datadict.get("reactive_power_lower", 0) + import_limit = datadict.get("remotecontrol_import_limit", 20000) + meas = datadict.get("measured_power", 0) + pv = datadict.get("pv_power_total", 0) + houseload_nett = datadict.get("inverter_power", 0) - meas + houseload_brut = pv - datadict.get("battery_power_charge", 0) - meas # Current SoC for capacity related calculations like Battery Hold/No Discharge - battery_capacity = datadict.get('battery_capacity', 0) + battery_capacity = datadict.get("battery_capacity", 0) - if power_control == "Enabled Power Control": + if power_control == "Enabled Power Control": ap_target = target - elif power_control == "Enabled Grid Control": # alternative computation for Power Control - if target <0 : ap_target = target - houseload_nett # subtract house load - else: ap_target = target - houseload_brut + elif power_control == "Enabled Grid Control": # alternative computation for Power Control + if target < 0: + ap_target = target - houseload_nett # subtract house load + else: + ap_target = target - houseload_brut power_control = "Enabled Power Control" - elif power_control == "Enabled Self Use": # alternative computation for Power Control - ap_target = 0 - houseload_nett # subtract house load + elif power_control == "Enabled Self Use": # alternative computation for Power Control + ap_target = 0 - houseload_nett # subtract house load power_control = "Enabled Power Control" - elif power_control == "Enabled Battery Control": # alternative computation for Power Control - ap_target = target - pv # subtract house load and pv + elif power_control == "Enabled Battery Control": # alternative computation for Power Control + ap_target = target - pv # subtract house load and pv power_control = "Enabled Power Control" - elif power_control == "Enabled Feedin Priority": # alternative computation for Power Control - if pv > houseload_nett: ap_target = 0 - pv + (houseload_brut - houseload_nett)*1.20 # 0 - pv + (houseload_brut - houseload_nett) - else: ap_target = 0 - houseload_nett + elif power_control == "Enabled Feedin Priority": # alternative computation for Power Control + if pv > houseload_nett: + ap_target = 0 - pv + (houseload_brut - houseload_nett) * 1.20 # 0 - pv + (houseload_brut - houseload_nett) + else: + ap_target = 0 - houseload_nett power_control = "Enabled Power Control" - elif power_control == "Enabled No Discharge": # alternative computation for Power Control + elif power_control == "Enabled No Discharge": # alternative computation for Power Control # Only hold battery level at below 98% SoC to avoid PV from shutting down when full if battery_capacity < 98: - if pv <= houseload_nett: ap_target = 0 - pv + (houseload_brut - houseload_nett) # 0 - pv + (houseload_brut - houseload_nett) - else: ap_target = 0 - houseload_nett + if pv <= houseload_nett: + ap_target = 0 - pv + (houseload_brut - houseload_nett) # 0 - pv + (houseload_brut - houseload_nett) + else: + ap_target = 0 - houseload_nett power_control = "Enabled Power Control" else: ap_target = 0 power_control == "Disabled" elif power_control == "Disabled": ap_target = target - autorepeat_duration = 10 # or zero - stop autorepeat since it makes no sense when disabled + autorepeat_duration = 10 # or zero - stop autorepeat since it makes no sense when disabled old_ap_target = ap_target - ap_target = min(ap_target, import_limit - houseload_brut) - #_LOGGER.warning(f"peak shaving: old_ap_target:{old_ap_target} new ap_target:{ap_target} max: {import_limit-houseload} min:{-export_limit-houseload}") - if old_ap_target != ap_target: - _LOGGER.debug(f"peak shaving: old_ap_target:{old_ap_target} new ap_target:{ap_target} max: {import_limit-houseload_brut}") - res = [ ('remotecontrol_power_control', power_control, ), - ('remotecontrol_set_type', set_type, ), - ('remotecontrol_active_power', ap_target, ), # correct issues #488 , #492 used to be : max(min(ap_up, ap_target), ap_lo), ), - ('remotecontrol_reactive_power', max(min(reap_up, reactive_power), reap_lo), ), - ('remotecontrol_duration', rc_duration, ), - ] - if (power_control == "Disabled"): autorepeat_stop(datadict, descr.key) + ap_target = min(ap_target, import_limit - houseload_brut) + # _LOGGER.warning(f"peak shaving: old_ap_target:{old_ap_target} new ap_target:{ap_target} max: {import_limit-houseload} min:{-export_limit-houseload}") + if old_ap_target != ap_target: + _LOGGER.debug( + f"peak shaving: old_ap_target:{old_ap_target} new ap_target:{ap_target} max: {import_limit-houseload_brut}" + ) + res = [ + ( + "remotecontrol_power_control", + power_control, + ), + ( + "remotecontrol_set_type", + set_type, + ), + ( + "remotecontrol_active_power", + ap_target, + ), # correct issues #488 , #492 used to be : max(min(ap_up, ap_target), ap_lo), ), + ( + "remotecontrol_reactive_power", + max(min(reap_up, reactive_power), reap_lo), + ), + ( + "remotecontrol_duration", + rc_duration, + ), + ] + if power_control == "Disabled": + autorepeat_stop(datadict, descr.key) _LOGGER.debug(f"Evaluated remotecontrol_trigger: corrected/clamped values: {res}") return res + def value_function_byteswapserial(initval, descr, datadict): if initval and not initval.startswith(("M", "X")): preswap = initval swapped = "" for pos in range(0, len(preswap), 2): - swapped += preswap[pos+1] + preswap[pos] + swapped += preswap[pos + 1] + preswap[pos] return swapped return initval + def valuefunction_firmware_g3(initval, descr, datadict): return f"3.{initval}" + def valuefunction_firmware_g4(initval, descr, datadict): return f"1.{initval}" + def value_function_remotecontrol_autorepeat_remaining(initval, descr, datadict): - return autorepeat_remaining(datadict, 'remotecontrol_trigger', time()) + return autorepeat_remaining(datadict, "remotecontrol_trigger", time()) + def value_function_battery_power_charge(initval, descr, datadict): - return datadict.get('battery_1_power_charge', 0) + datadict.get('battery_2_power_charge',0) + return datadict.get("battery_1_power_charge", 0) + datadict.get("battery_2_power_charge", 0) + def value_function_hardware_version_g1(initval, descr, datadict): - return f"Gen1" + return f"Gen1" + def value_function_hardware_version_g2(initval, descr, datadict): - return f"Gen2" + return f"Gen2" + def value_function_hardware_version_g3(initval, descr, datadict): - return f"Gen3" + return f"Gen3" + def value_function_hardware_version_g4(initval, descr, datadict): - return f"Gen4" + return f"Gen4" + def value_function_hardware_version_g5(initval, descr, datadict): - return f"Gen5" + return f"Gen5" + def value_function_house_load(initval, descr, datadict): - return ( datadict.get('inverter_power', 0) - datadict.get('measured_power', 0) + datadict.get('meter_2_measured_power', 0) ) + return ( + datadict.get("inverter_power", 0) + - datadict.get("measured_power", 0) + + datadict.get("meter_2_measured_power", 0) + ) + def value_function_house_load_alt(initval, descr, datadict): - return ( datadict.get('pv_power_1', 0) + datadict.get('pv_power_2', 0) + datadict.get('pv_power_3', 0) - - datadict.get('battery_power_charge', 0) - - datadict.get('measured_power', 0) - + datadict.get('meter_2_measured_power', 0) ) + return ( + datadict.get("pv_power_1", 0) + + datadict.get("pv_power_2", 0) + + datadict.get("pv_power_3", 0) + - datadict.get("battery_power_charge", 0) + - datadict.get("measured_power", 0) + + datadict.get("meter_2_measured_power", 0) + ) + def value_function_software_version_g2(initval, descr, datadict): - return f"DSP v2.{datadict.get('firmware_dsp')} ARM v2.{datadict.get('firmware_arm')}" + return f"DSP v2.{datadict.get('firmware_dsp')} ARM v2.{datadict.get('firmware_arm')}" + def value_function_software_version_g3(initval, descr, datadict): - return f"DSP v3.{datadict.get('firmware_dsp')} ARM v3.{datadict.get('firmware_arm')}" + return f"DSP v3.{datadict.get('firmware_dsp')} ARM v3.{datadict.get('firmware_arm')}" + def value_function_software_version_g4(initval, descr, datadict): - return f"DSP v1.{datadict.get('firmware_dsp')} ARM v1.{datadict.get('firmware_arm')}" + return f"DSP v1.{datadict.get('firmware_dsp')} ARM v1.{datadict.get('firmware_arm')}" + def value_function_software_version_g5(initval, descr, datadict): - return f"DSP {datadict.get('firmware_dsp')} ARM {datadict.get('firmware_arm_major')}.{datadict.get('firmware_arm')}" + return ( + f"DSP {datadict.get('firmware_dsp')} ARM {datadict.get('firmware_arm_major')}.{datadict.get('firmware_arm')}" + ) + def value_function_software_version_air_g3(initval, descr, datadict): - return f"DSP v2.{datadict.get('firmware_dsp')} ARM v1.{datadict.get('firmware_arm')}" + return f"DSP v2.{datadict.get('firmware_dsp')} ARM v1.{datadict.get('firmware_arm')}" + def value_function_software_version_air_g4(initval, descr, datadict): - return f"DSP {datadict.get('firmware_dsp')} ARM {datadict.get('firmware_arm')}" + return f"DSP {datadict.get('firmware_dsp')} ARM {datadict.get('firmware_arm')}" + def value_function_battery_voltage_cell_difference(initval, descr, datadict): - return datadict.get('cell_voltage_high', 0) - datadict.get('cell_voltage_low',0) + return datadict.get("cell_voltage_high", 0) - datadict.get("cell_voltage_low", 0) + # ================================= Button Declarations ============================================================ BUTTON_TYPES = [ SolaxModbusButtonEntityDescription( - name = "Sync RTC", - key = "sync_rtc", - register = 0x00, - allowedtypes = AC | HYBRID, - write_method = WRITE_MULTI_MODBUS, - icon = "mdi:home-clock", - value_function = value_function_sync_rtc, + name="Sync RTC", + key="sync_rtc", + register=0x00, + allowedtypes=AC | HYBRID, + write_method=WRITE_MULTI_MODBUS, + icon="mdi:home-clock", + value_function=value_function_sync_rtc, ), SolaxModbusButtonEntityDescription( - name = "Remotecontrol Trigger", - key = "remotecontrol_trigger", - register = 0x7C, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - write_method = WRITE_MULTI_MODBUS, - icon = "mdi:battery-clock", - value_function = value_function_remotecontrol_recompute, - autorepeat= "remotecontrol_autorepeat_duration" + name="Remotecontrol Trigger", + key="remotecontrol_trigger", + register=0x7C, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + write_method=WRITE_MULTI_MODBUS, + icon="mdi:battery-clock", + value_function=value_function_remotecontrol_recompute, + autorepeat="remotecontrol_autorepeat_duration", ), SolaxModbusButtonEntityDescription( - name = "System On", - key = "system_on", - register = 0x1C, - command = 1, - allowedtypes = AC | HYBRID, - icon = "mdi:power-on", + name="System On", + key="system_on", + register=0x1C, + command=1, + allowedtypes=AC | HYBRID, + icon="mdi:power-on", ), SolaxModbusButtonEntityDescription( - name = "System Off", - key = "system_off", - register = 0x1C, - command = 0, - allowedtypes = AC | HYBRID, - icon = "mdi:power-off", + name="System Off", + key="system_off", + register=0x1C, + command=0, + allowedtypes=AC | HYBRID, + icon="mdi:power-off", ), SolaxModbusButtonEntityDescription( - name = "Battery Awaken", - key = "battery_awaken", - register = 0x56, - command = 1, - allowedtypes = AC | HYBRID, - entity_registry_enabled_default = False, - icon = "mdi:battery-alert-variant", + name="Battery Awaken", + key="battery_awaken", + register=0x56, + command=1, + allowedtypes=AC | HYBRID, + entity_registry_enabled_default=False, + icon="mdi:battery-alert-variant", ), SolaxModbusButtonEntityDescription( - name = "Grid Export", - key = "grid_export", - register = 0x51, - icon = "mdi:home-export-outline", - command = 1, - allowedtypes = AC | HYBRID | GEN3, - entity_category = EntityCategory.CONFIG, + name="Grid Export", + key="grid_export", + register=0x51, + icon="mdi:home-export-outline", + command=1, + allowedtypes=AC | HYBRID | GEN3, + entity_category=EntityCategory.CONFIG, ), ##### # @@ -293,281 +362,280 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict): # ##### SolaxModbusButtonEntityDescription( - name = "Sync RTC", - key = "sync_rtc", - register = 0x1015, - allowedtypes = MIC, - write_method = WRITE_MULTI_MODBUS, - icon = "mdi:home-clock", - value_function = value_function_sync_rtc, + name="Sync RTC", + key="sync_rtc", + register=0x1015, + allowedtypes=MIC, + write_method=WRITE_MULTI_MODBUS, + icon="mdi:home-clock", + value_function=value_function_sync_rtc, ), ] # ================================= Number Declarations ============================================================ MAX_CURRENTS = [ - ('L30E', 100 ), # Gen2 X1 SK-TL - ('U30', 50 ), # Gen2 X1 SK-SU - ('L37E', 100 ), # Gen2 X1 SK-TL - ('U37', 50 ), # Gen2 X1 SK-SU - ('L50E', 100 ), # Gen2 X1 SK-TL - ('U50', 50 ), # Gen2 X1 SK-SU - ('F3D', 35 ), # RetroFit X3 - ('F3E', 25 ), # RetroFit X3 - ('H3DE', 25 ), # Gen3 X3 might need changing? - ('H3E', 25 ), # Gen3 X3 - ('H3LE', 25 ), # Gen3 X3 - ('H3PE', 25 ), # Gen3 X3 might need changing? - ('H3UE', 25 ), # Gen3 X3 - ('H43', 30 ), # Gen4 X1 3 / 3.7kW - ('H450', 30 ), # Gen4 X1 5kW - ('H449', 30 ), # Gen4 X1 5kW - ('H460', 30 ), # Gen4 X1 6kW - ('H475', 30 ), # Gen4 X1 7.5kW - ('PRE', 30 ), # Gen4 X1 RetroFit - ('PRI', 30 ), # Gen4 X1 RetroFit - ('H55', 50 ), # Gen5 X1-IES - ('H56', 50 ), # Gen5 X1-IES - ('H58', 50 ), # Gen5 X1-IES - ('F34', 30 ), # Gen4 X3 RetroFit - ('H31', 30 ), # Gen4 X3 TIGO - ('H34A', 30 ), # Gen4 X3 A - ('H34B', 30 ), # Gen4 X3 B - ('H34C', 30 ), # Gen4 X3 C - ('H34T', 25 ), # Gen4 X3 T - ('H35A', 50 ), # Gen5 X3-IES A - ('H3BC', 60 ), # Gen5 X3 Ultra C - ('H3BD', 60 ), # Gen5 X3 Ultra D - ('H3BF', 60 ), # Gen5 X3 Ultra F + ("L30E", 100), # Gen2 X1 SK-TL + ("U30", 50), # Gen2 X1 SK-SU + ("L37E", 100), # Gen2 X1 SK-TL + ("U37", 50), # Gen2 X1 SK-SU + ("L50E", 100), # Gen2 X1 SK-TL + ("U50", 50), # Gen2 X1 SK-SU + ("F3D", 35), # RetroFit X3 + ("F3E", 25), # RetroFit X3 + ("H3DE", 25), # Gen3 X3 might need changing? + ("H3E", 25), # Gen3 X3 + ("H3LE", 25), # Gen3 X3 + ("H3PE", 25), # Gen3 X3 might need changing? + ("H3UE", 25), # Gen3 X3 + ("H43", 30), # Gen4 X1 3 / 3.7kW + ("H450", 30), # Gen4 X1 5kW + ("H449", 30), # Gen4 X1 5kW + ("H460", 30), # Gen4 X1 6kW + ("H475", 30), # Gen4 X1 7.5kW + ("PRE", 30), # Gen4 X1 RetroFit + ("PRI", 30), # Gen4 X1 RetroFit + ("H55", 50), # Gen5 X1-IES + ("H56", 50), # Gen5 X1-IES + ("H58", 50), # Gen5 X1-IES + ("F34", 30), # Gen4 X3 RetroFit + ("H31", 30), # Gen4 X3 TIGO + ("H34A", 30), # Gen4 X3 A + ("H34B", 30), # Gen4 X3 B + ("H34C", 30), # Gen4 X3 C + ("H34T", 25), # Gen4 X3 T + ("H35A", 50), # Gen5 X3-IES A + ("H3BC", 60), # Gen5 X3 Ultra C + ("H3BD", 60), # Gen5 X3 Ultra D + ("H3BF", 60), # Gen5 X3 Ultra F ### All known Inverters added ] MAX_EXPORT = [ - ('L30E', 3000 ), # Gen2 X1 SK-TL - ('U30', 3000 ), # Gen2 X1 SK-SU - ('L37E', 3700 ), # Gen2 X1 SK-TL - ('U37', 3700 ), # Gen2 X1 SK-SU - ('L50E', 4600 ), # Gen2 X1 SK-TL - ('U50', 4600 ), # Gen2 X1 SK-SU - ('H1E30', 5000 ), # Gen3 X1 - ('H1E37', 5000 ), # Gen3 X1 - ('H1E46', 6000 ), # Gen3 X1 - ('H1E5', 6000 ), # Gen3 X1 - ('H1I30', 5000 ), # Gen3 X1 - ('H1I37', 5000 ), # Gen3 X1 - ('H1I46', 6000 ), # Gen3 X1 - ('H1I5', 6000 ), # Gen3 X1 - ('HCC30', 5000 ), # Gen3 X1 - ('HCC37', 5000 ), # Gen3 X1 - ('HCC46', 6000 ), # Gen3 X1 - ('HCC5', 6000 ), # Gen3 X1 - ('HUE30', 5000 ), # Gen3 X1 - ('HUE37', 5000 ), # Gen3 X1 - ('HUE46', 6000 ), # Gen3 X1 - ('HUE5', 6000 ), # Gen3 X1 - ('XRE30', 5000 ), # Gen3 X1 - ('XRE37', 5000 ), # Gen3 X1 - ('XRE46', 6000 ), # Gen3 X1 - ('XRE5', 6000 ), # Gen3 X1 - ('F3D6', 9000 ), # RetroFit X3 - ('F3D8', 12000 ), # RetroFit X3 - ('F3D10', 15000 ), # RetroFit X3 - ('F3D15', 16500 ), # RetroFit X3 - ('F3E6', 9000 ), # RetroFit X3 - ('F3E8', 12000 ), # RetroFit X3 - ('F3E10', 15000 ), # RetroFit X3 - ('F3E15', 16500 ), # RetroFit X3 - ('H3DE05', 10000 ), # Gen3 X3 - ('H3DE06', 12000 ), # Gen3 X3 - ('H3DE08', 14000 ), # Gen3 X3 - ('H3DE10', 15000 ), # Gen3 X3 - ('H3E05', 10000 ), # Gen3 X3 - ('H3E06', 12000 ), # Gen3 X3 - ('H3E08', 14000 ), # Gen3 X3 - ('H3E10', 15000 ), # Gen3 X3 - ('H3LE05', 10000 ), # Gen3 X3 - ('H3LE06', 12000 ), # Gen3 X3 - ('H3LE08', 14000 ), # Gen3 X3 - ('H3LE10', 15000 ), # Gen3 X3 - ('H3PE05', 10000 ), # Gen3 X3 - ('H3PE06', 12000 ), # Gen3 X3 - ('H3PE08', 14000 ), # Gen3 X3 - ('H3PE10', 15000 ), # Gen3 X3 - ('H3UE05', 10000 ), # Gen3 X3 - ('H3UE06', 12000 ), # Gen3 X3 - ('H3UE08', 14000 ), # Gen3 X3 - ('H3UE10', 15000 ), # Gen3 X3 - ('H310', 15000 ), # Gen4 X3 TIGO - ('H312', 15000 ), # Gen4 X3 TIGO - ('H315', 16500 ), # Gen4 X3 TIGO - ('H430', 6300 ), # Gen4 X1 3kW? - ('H437', 7300 ), # Gen4 X1 3.7kW - ('H449', 9200 ), # Gen4 X1 5kW - ('H450', 9200 ), # Gen4 X1 5kW - ('H460', 9200 ), # Gen4 X1 6kW - ('H475', 9200 ), # Gen4 X1 7.5kW - ('PRE5', 9200 ), # Gen4 X1 RetroFit 5kW - ('PRI5', 9200 ), # Gen4 X1 RetroFit 5kW - ('F34', 10000 ), # Gen4 X3 RetroFit - ('H34A05', 7500 ), # Gen4 X3 A - ('H34A06', 6000 ), # Gen4 X3 A - ('H34A08', 12000 ), # Gen4 X3 A - ('H34A10', 15000 ), # Gen4 X3 A - ('H34A12', 15000 ), # Gen4 X3 A - ('H34A15', 16500 ), # Gen4 X3 A - ('H34B05', 7500 ), # Gen4 X3 B - ('H34B08', 12000 ), # Gen4 X3 B - ('H34B10', 15000 ), # Gen4 X3 B - ('H34B12', 15000 ), # Gen4 X3 B - ('H34B15', 16500 ), # Gen4 X3 B - ('H34C05', 7500 ), # Gen4 X3 C - ('H34C08', 12000 ), # Gen4 X3 C - ('H34C10', 15000 ), # Gen4 X3 C - ('H34C12', 15000 ), # Gen4 X3 C - ('H34C15', 16500 ), # Gen4 X3 C - ('H34T05', 7500 ), # Gen4 X3 T - ('H34T08', 12000 ), # Gen4 X3 T - ('H34T10', 15000 ), # Gen4 X3 T - ('H34T12', 15000 ), # Gen4 X3 T - ('H34T15', 16500 ), # Gen4 X3 T - ('H35A04', 4000 ), # Gen5 X3-IES A - ('H35A05', 5000 ), # Gen5 X3-IES A - ('H35A06', 6000 ), # Gen5 X3-IES A - ('H35A08', 8000 ), # Gen5 X3-IES A - ('H35A10', 10000 ), # Gen5 X3-IES A - ('H35A12', 12000 ), # Gen5 X3-IES A - ('H35A15', 15000 ), # Gen5 X3-IES A - ('H3BC15', 15000 ), # Gen5 X3 Ultra C - ('H3BC19', 19999 ), # Gen5 X3 Ultra C - ('H3BC20', 20000 ), # Gen5 X3 Ultra C - ('H3BC25', 25000 ), # Gen5 X3 Ultra C - ('H3BC30', 30000 ), # Gen5 X3 Ultra C - ('H3BD15', 15000 ), # Gen5 X3 Ultra D - ('H3BD19', 19999 ), # Gen5 X3 Ultra D - ('H3BD20', 20000 ), # Gen5 X3 Ultra D - ('H3BD25', 25000 ), # Gen5 X3 Ultra D - ('H3BD30', 30000 ), # Gen5 X3 Ultra D - ('H3BF15', 15000 ), # Gen5 X3 Ultra F - ('H3BF19', 19999 ), # Gen5 X3 Ultra F - ('H3BF20', 20000 ), # Gen5 X3 Ultra F - ('H3BF25', 25000 ), # Gen5 X3 Ultra F - ('H3BF30', 30000 ), # Gen5 X3 Ultra F + ("L30E", 3000), # Gen2 X1 SK-TL + ("U30", 3000), # Gen2 X1 SK-SU + ("L37E", 3700), # Gen2 X1 SK-TL + ("U37", 3700), # Gen2 X1 SK-SU + ("L50E", 4600), # Gen2 X1 SK-TL + ("U50", 4600), # Gen2 X1 SK-SU + ("H1E30", 5000), # Gen3 X1 + ("H1E37", 5000), # Gen3 X1 + ("H1E46", 6000), # Gen3 X1 + ("H1E5", 6000), # Gen3 X1 + ("H1I30", 5000), # Gen3 X1 + ("H1I37", 5000), # Gen3 X1 + ("H1I46", 6000), # Gen3 X1 + ("H1I5", 6000), # Gen3 X1 + ("HCC30", 5000), # Gen3 X1 + ("HCC37", 5000), # Gen3 X1 + ("HCC46", 6000), # Gen3 X1 + ("HCC5", 6000), # Gen3 X1 + ("HUE30", 5000), # Gen3 X1 + ("HUE37", 5000), # Gen3 X1 + ("HUE46", 6000), # Gen3 X1 + ("HUE5", 6000), # Gen3 X1 + ("XRE30", 5000), # Gen3 X1 + ("XRE37", 5000), # Gen3 X1 + ("XRE46", 6000), # Gen3 X1 + ("XRE5", 6000), # Gen3 X1 + ("F3D6", 9000), # RetroFit X3 + ("F3D8", 12000), # RetroFit X3 + ("F3D10", 15000), # RetroFit X3 + ("F3D15", 16500), # RetroFit X3 + ("F3E6", 9000), # RetroFit X3 + ("F3E8", 12000), # RetroFit X3 + ("F3E10", 15000), # RetroFit X3 + ("F3E15", 16500), # RetroFit X3 + ("H3DE05", 10000), # Gen3 X3 + ("H3DE06", 12000), # Gen3 X3 + ("H3DE08", 14000), # Gen3 X3 + ("H3DE10", 15000), # Gen3 X3 + ("H3E05", 10000), # Gen3 X3 + ("H3E06", 12000), # Gen3 X3 + ("H3E08", 14000), # Gen3 X3 + ("H3E10", 15000), # Gen3 X3 + ("H3LE05", 10000), # Gen3 X3 + ("H3LE06", 12000), # Gen3 X3 + ("H3LE08", 14000), # Gen3 X3 + ("H3LE10", 15000), # Gen3 X3 + ("H3PE05", 10000), # Gen3 X3 + ("H3PE06", 12000), # Gen3 X3 + ("H3PE08", 14000), # Gen3 X3 + ("H3PE10", 15000), # Gen3 X3 + ("H3UE05", 10000), # Gen3 X3 + ("H3UE06", 12000), # Gen3 X3 + ("H3UE08", 14000), # Gen3 X3 + ("H3UE10", 15000), # Gen3 X3 + ("H310", 15000), # Gen4 X3 TIGO + ("H312", 15000), # Gen4 X3 TIGO + ("H315", 16500), # Gen4 X3 TIGO + ("H430", 6300), # Gen4 X1 3kW? + ("H437", 7300), # Gen4 X1 3.7kW + ("H449", 9200), # Gen4 X1 5kW + ("H450", 9200), # Gen4 X1 5kW + ("H460", 9200), # Gen4 X1 6kW + ("H475", 9200), # Gen4 X1 7.5kW + ("PRE5", 9200), # Gen4 X1 RetroFit 5kW + ("PRI5", 9200), # Gen4 X1 RetroFit 5kW + ("F34", 10000), # Gen4 X3 RetroFit + ("H34A05", 7500), # Gen4 X3 A + ("H34A06", 6000), # Gen4 X3 A + ("H34A08", 12000), # Gen4 X3 A + ("H34A10", 15000), # Gen4 X3 A + ("H34A12", 15000), # Gen4 X3 A + ("H34A15", 16500), # Gen4 X3 A + ("H34B05", 7500), # Gen4 X3 B + ("H34B08", 12000), # Gen4 X3 B + ("H34B10", 15000), # Gen4 X3 B + ("H34B12", 15000), # Gen4 X3 B + ("H34B15", 16500), # Gen4 X3 B + ("H34C05", 7500), # Gen4 X3 C + ("H34C08", 12000), # Gen4 X3 C + ("H34C10", 15000), # Gen4 X3 C + ("H34C12", 15000), # Gen4 X3 C + ("H34C15", 16500), # Gen4 X3 C + ("H34T05", 7500), # Gen4 X3 T + ("H34T08", 12000), # Gen4 X3 T + ("H34T10", 15000), # Gen4 X3 T + ("H34T12", 15000), # Gen4 X3 T + ("H34T15", 16500), # Gen4 X3 T + ("H35A04", 4000), # Gen5 X3-IES A + ("H35A05", 5000), # Gen5 X3-IES A + ("H35A06", 6000), # Gen5 X3-IES A + ("H35A08", 8000), # Gen5 X3-IES A + ("H35A10", 10000), # Gen5 X3-IES A + ("H35A12", 12000), # Gen5 X3-IES A + ("H35A15", 15000), # Gen5 X3-IES A + ("H3BC15", 15000), # Gen5 X3 Ultra C + ("H3BC19", 19999), # Gen5 X3 Ultra C + ("H3BC20", 20000), # Gen5 X3 Ultra C + ("H3BC25", 25000), # Gen5 X3 Ultra C + ("H3BC30", 30000), # Gen5 X3 Ultra C + ("H3BD15", 15000), # Gen5 X3 Ultra D + ("H3BD19", 19999), # Gen5 X3 Ultra D + ("H3BD20", 20000), # Gen5 X3 Ultra D + ("H3BD25", 25000), # Gen5 X3 Ultra D + ("H3BD30", 30000), # Gen5 X3 Ultra D + ("H3BF15", 15000), # Gen5 X3 Ultra F + ("H3BF19", 19999), # Gen5 X3 Ultra F + ("H3BF20", 20000), # Gen5 X3 Ultra F + ("H3BF25", 25000), # Gen5 X3 Ultra F + ("H3BF30", 30000), # Gen5 X3 Ultra F ### All known Inverters added ] EXPORT_LIMIT_SCALE_EXCEPTIONS = [ - ('H4', 10 ), # assuming all Gen4s - ('H34', 10), # assuming all Gen4s - ('H3UE', 10), # Issue #339, 922 - ('H4372A', 1), # Issue #857 - ('H4502A', 1), # Issue #857 - ('H4502T', 1), # Issue #418 - ('H4602A', 1), # Issue #882 - ('H3BD', 10), # X3-Ultra - ('H4752A', 1), - ('H3BC',10), - ('H34B10H', 10) # need return @jansidlo , -# ('H1E', 10 ), # more specific entry comes last and wins + ("H4", 10), # assuming all Gen4s + ("H34", 10), # assuming all Gen4s + ("H3UE", 10), # Issue #339, 922 + ("H4372A", 1), # Issue #857 + ("H4502A", 1), # Issue #857 + ("H4502T", 1), # Issue #418 + ("H4602A", 1), # Issue #882 + ("H3BD", 10), # X3-Ultra + ("H4752A", 1), + ("H3BC", 10), + ("H34B10H", 10), # need return @jansidlo , + # ('H1E', 10 ), # more specific entry comes last and wins ] NUMBER_TYPES = [ - ### # # Data only number types # ### SolaxModbusNumberEntityDescription( - name = "Remotecontrol Active Power", - key = "remotecontrol_active_power", - allowedtypes = AC | HYBRID | GEN4 | GEN5, - native_min_value = -6000, - native_max_value = 30000, - native_step = 100, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = NumberDeviceClass.POWER, - initvalue = 0, - min_exceptions_minus = MAX_EXPORT, # negative - unit = REGISTER_S32, - write_method = WRITE_DATA_LOCAL, + name="Remotecontrol Active Power", + key="remotecontrol_active_power", + allowedtypes=AC | HYBRID | GEN4 | GEN5, + native_min_value=-6000, + native_max_value=30000, + native_step=100, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=NumberDeviceClass.POWER, + initvalue=0, + min_exceptions_minus=MAX_EXPORT, # negative + unit=REGISTER_S32, + write_method=WRITE_DATA_LOCAL, ), SolaxModbusNumberEntityDescription( - name = "Remotecontrol Reactive Power", - key = "remotecontrol_reactive_power", - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - native_min_value = -4000, - native_max_value = 4000, - native_step = 100, - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = NumberDeviceClass.REACTIVE_POWER, - initvalue = 0, - write_method = WRITE_DATA_LOCAL, + name="Remotecontrol Reactive Power", + key="remotecontrol_reactive_power", + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + native_min_value=-4000, + native_max_value=4000, + native_step=100, + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=NumberDeviceClass.REACTIVE_POWER, + initvalue=0, + write_method=WRITE_DATA_LOCAL, ), SolaxModbusNumberEntityDescription( - name = "Remotecontrol Duration", - key = "remotecontrol_duration", - unit = REGISTER_U16, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - icon = "mdi:home-clock", - initvalue = 20, # seconds - native_min_value = 10, - native_max_value = 360, - native_step = 1, - fmt = "i", - native_unit_of_measurement = UnitOfTime.SECONDS, - write_method = WRITE_DATA_LOCAL, + name="Remotecontrol Duration", + key="remotecontrol_duration", + unit=REGISTER_U16, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:home-clock", + initvalue=20, # seconds + native_min_value=10, + native_max_value=360, + native_step=1, + fmt="i", + native_unit_of_measurement=UnitOfTime.SECONDS, + write_method=WRITE_DATA_LOCAL, ), SolaxModbusNumberEntityDescription( - name = "Remotecontrol Autorepeat Duration", - key = "remotecontrol_autorepeat_duration", - unit = REGISTER_U16, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - icon = "mdi:home-clock", - initvalue = 0, # seconds - - native_min_value = 0, - native_max_value = 28800, - native_step = 600, - fmt = "i", - native_unit_of_measurement = UnitOfTime.SECONDS, - write_method = WRITE_DATA_LOCAL, + name="Remotecontrol Autorepeat Duration", + key="remotecontrol_autorepeat_duration", + unit=REGISTER_U16, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:home-clock", + initvalue=0, # seconds - + native_min_value=0, + native_max_value=28800, + native_step=600, + fmt="i", + native_unit_of_measurement=UnitOfTime.SECONDS, + write_method=WRITE_DATA_LOCAL, ), SolaxModbusNumberEntityDescription( - name = "Remotecontrol Import Limit", - key = "remotecontrol_import_limit", - allowedtypes = AC | HYBRID | GEN4 | GEN5, - native_min_value = 0, - native_max_value = 30000, # overwritten by MAX_EXPORT - native_step = 100, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = NumberDeviceClass.POWER, - initvalue = 20000, # will be reduced to MAX - unit = REGISTER_S32, - write_method = WRITE_DATA_LOCAL, + name="Remotecontrol Import Limit", + key="remotecontrol_import_limit", + allowedtypes=AC | HYBRID | GEN4 | GEN5, + native_min_value=0, + native_max_value=30000, # overwritten by MAX_EXPORT + native_step=100, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=NumberDeviceClass.POWER, + initvalue=20000, # will be reduced to MAX + unit=REGISTER_S32, + write_method=WRITE_DATA_LOCAL, ), SolaxModbusNumberEntityDescription( - name = "Config Export Control Limit Readscale", - key = "config_export_control_limit_readscale", - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, - native_min_value = 0.1, - native_max_value = 10.0, - native_step = 0.1, - entity_category = EntityCategory.DIAGNOSTIC, - initvalue = 1, - entity_registry_enabled_default = False, - write_method = WRITE_DATA_LOCAL, + name="Config Export Control Limit Readscale", + key="config_export_control_limit_readscale", + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + native_min_value=0.1, + native_max_value=10.0, + native_step=0.1, + entity_category=EntityCategory.DIAGNOSTIC, + initvalue=1, + entity_registry_enabled_default=False, + write_method=WRITE_DATA_LOCAL, ), SolaxModbusNumberEntityDescription( - name = "Config Max Export", - key = "config_max_export", - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, - native_min_value = 600, - native_max_value = 60000, - entity_category = EntityCategory.DIAGNOSTIC, - initvalue = 15000, - native_step = 200, - entity_registry_enabled_default = False, - write_method = WRITE_DATA_LOCAL, + name="Config Max Export", + key="config_max_export", + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + native_min_value=600, + native_max_value=60000, + entity_category=EntityCategory.DIAGNOSTIC, + initvalue=15000, + native_step=200, + entity_registry_enabled_default=False, + write_method=WRITE_DATA_LOCAL, ), ### # @@ -575,233 +643,233 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict): # ### SolaxModbusNumberEntityDescription( - name = "Backup Charge End Hours", - key = "backup_charge_end_h", - register = 0x97, - fmt = "i", - native_min_value = 0, - native_max_value = 23, - native_step = 1, - native_unit_of_measurement = UnitOfTime.HOURS, - allowedtypes = AC | HYBRID | GEN3, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", + name="Backup Charge End Hours", + key="backup_charge_end_h", + register=0x97, + fmt="i", + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=AC | HYBRID | GEN3, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", ), SolaxModbusNumberEntityDescription( - name = "Backup Charge End Minutes", - key = "backup_charge_end_m", - register = 0x98, - fmt = "i", - native_min_value = 0, - native_max_value = 59, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = AC | HYBRID | GEN3, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", + name="Backup Charge End Minutes", + key="backup_charge_end_m", + register=0x98, + fmt="i", + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=AC | HYBRID | GEN3, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", ), SolaxModbusNumberEntityDescription( - name = "Backup Charge Start Hours", - key = "backup_charge_start_h", - register = 0x95, - fmt = "i", - native_min_value = 0, - native_max_value = 23, - native_step = 1, - native_unit_of_measurement = UnitOfTime.HOURS, - allowedtypes = AC | HYBRID | GEN3, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", + name="Backup Charge Start Hours", + key="backup_charge_start_h", + register=0x95, + fmt="i", + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=AC | HYBRID | GEN3, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", ), SolaxModbusNumberEntityDescription( - name = "Backup Charge Start Minutes", - key = "backup_charge_start_m", - register = 0x96, - fmt = "i", - native_min_value = 0, - native_max_value = 59, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = AC | HYBRID | GEN3, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", + name="Backup Charge Start Minutes", + key="backup_charge_start_m", + register=0x96, + fmt="i", + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=AC | HYBRID | GEN3, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", ), SolaxModbusNumberEntityDescription( - name = "Backup Discharge Min SOC", - key = "backup_discharge_min_soc", - register = 0x67, - fmt = "i", - native_min_value = 15, - native_max_value = 100, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - icon = "mdi:battery-charging-low", + name="Backup Discharge Min SOC", + key="backup_discharge_min_soc", + register=0x67, + fmt="i", + native_min_value=15, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:battery-charging-low", ), SolaxModbusNumberEntityDescription( - name = "Backup Nightcharge Upper SOC", - key = "backup_nightcharge_upper_soc", - register = 0x66, - fmt = "i", - native_min_value = 30, - native_max_value = 100, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - icon = "mdi:battery-charging-high", + name="Backup Nightcharge Upper SOC", + key="backup_nightcharge_upper_soc", + register=0x66, + fmt="i", + native_min_value=30, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:battery-charging-high", ), SolaxModbusNumberEntityDescription( - name = "Battery Minimum Capacity", - key = "battery_minimum_capacity", - register = 0x20, - fmt = "i", - native_min_value = 10, - native_max_value = 99, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - state = "battery_minimum_capacity", - allowedtypes = AC | HYBRID | GEN2 | GEN3, - icon = "mdi:battery-sync", + name="Battery Minimum Capacity", + key="battery_minimum_capacity", + register=0x20, + fmt="i", + native_min_value=10, + native_max_value=99, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + state="battery_minimum_capacity", + allowedtypes=AC | HYBRID | GEN2 | GEN3, + icon="mdi:battery-sync", ), SolaxModbusNumberEntityDescription( - name = "Battery Minimum Capacity - Grid-tied", - key = "battery_minimum_capacity_gridtied", - register = 0xa7, - fmt = "i", - native_min_value = 10, - native_max_value = 99, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - state = "battery_minimum_capacity_gridtied", - allowedtypes = HYBRID | GEN3, - icon = "mdi:battery-sync", + name="Battery Minimum Capacity - Grid-tied", + key="battery_minimum_capacity_gridtied", + register=0xA7, + fmt="i", + native_min_value=10, + native_max_value=99, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + state="battery_minimum_capacity_gridtied", + allowedtypes=HYBRID | GEN3, + icon="mdi:battery-sync", ), SolaxModbusNumberEntityDescription( - name = "Battery Charge Max Current", # multiple versions depending on GEN - key = "battery_charge_max_current", - register = 0x24, - fmt = "f", - native_min_value = 0, - native_max_value = 20, # default (new default, was 50) - native_step = 0.1, - scale = 0.1, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = NumberDeviceClass.CURRENT, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - max_exceptions = MAX_CURRENTS, - icon = "mdi:current-dc", + name="Battery Charge Max Current", # multiple versions depending on GEN + key="battery_charge_max_current", + register=0x24, + fmt="f", + native_min_value=0, + native_max_value=20, # default (new default, was 50) + native_step=0.1, + scale=0.1, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=NumberDeviceClass.CURRENT, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + max_exceptions=MAX_CURRENTS, + icon="mdi:current-dc", ), SolaxModbusNumberEntityDescription( - name = "Battery Charge Max Current", # multiple versions depending on GEN - key = "battery_charge_max_current", - register = 0x24, - fmt = "f", - native_min_value = 0, - native_max_value = 20, # default (new default, was 50) - native_step = 0.1, - scale = 0.01, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = NumberDeviceClass.CURRENT, - allowedtypes = HYBRID | GEN2, - max_exceptions = MAX_CURRENTS, - icon = "mdi:current-dc", + name="Battery Charge Max Current", # multiple versions depending on GEN + key="battery_charge_max_current", + register=0x24, + fmt="f", + native_min_value=0, + native_max_value=20, # default (new default, was 50) + native_step=0.1, + scale=0.01, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=NumberDeviceClass.CURRENT, + allowedtypes=HYBRID | GEN2, + max_exceptions=MAX_CURRENTS, + icon="mdi:current-dc", ), SolaxModbusNumberEntityDescription( - name = "Battery Discharge Max Current", - key = "battery_discharge_max_current", - register = 0x25, - fmt = "f", - scale = 0.1, - native_min_value = 0, - native_max_value = 20, # universal default - native_step = 0.1, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = NumberDeviceClass.CURRENT, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - max_exceptions = MAX_CURRENTS, - icon = "mdi:current-dc", + name="Battery Discharge Max Current", + key="battery_discharge_max_current", + register=0x25, + fmt="f", + scale=0.1, + native_min_value=0, + native_max_value=20, # universal default + native_step=0.1, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=NumberDeviceClass.CURRENT, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + max_exceptions=MAX_CURRENTS, + icon="mdi:current-dc", ), SolaxModbusNumberEntityDescription( - name = "Battery Discharge Max Current", - key = "battery_discharge_max_current", - register = 0x25, - fmt = "f", - scale = 0.01, - native_min_value = 0, - native_max_value = 20, # universal default - native_step = 0.1, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = NumberDeviceClass.CURRENT, - allowedtypes = HYBRID | GEN2, - max_exceptions = MAX_CURRENTS, - icon = "mdi:current-dc", + name="Battery Discharge Max Current", + key="battery_discharge_max_current", + register=0x25, + fmt="f", + scale=0.01, + native_min_value=0, + native_max_value=20, # universal default + native_step=0.1, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=NumberDeviceClass.CURRENT, + allowedtypes=HYBRID | GEN2, + max_exceptions=MAX_CURRENTS, + icon="mdi:current-dc", ), SolaxModbusNumberEntityDescription( - name = "Consume Off Power", - key = "consume_off_power", - register = 0xB9, - fmt = "i", - native_min_value = 0, - native_max_value = 8000, - native_step = 100, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = NumberDeviceClass.POWER, - allowedtypes = AC | HYBRID | GEN4, + name="Consume Off Power", + key="consume_off_power", + register=0xB9, + fmt="i", + native_min_value=0, + native_max_value=8000, + native_step=100, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=NumberDeviceClass.POWER, + allowedtypes=AC | HYBRID | GEN4, ), SolaxModbusNumberEntityDescription( - name = "Export Control User Limit", - key = "export_control_user_limit", - register = 0x42, - fmt = "i", - native_min_value = 0, - native_max_value = 2500, - scale = 1, - native_step = 100, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = NumberDeviceClass.POWER, + name="Export Control User Limit", + key="export_control_user_limit", + register=0x42, + fmt="i", + native_min_value=0, + native_max_value=2500, + scale=1, + native_step=100, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=NumberDeviceClass.POWER, read_scale_exceptions=EXPORT_LIMIT_SCALE_EXCEPTIONS, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, - max_exceptions = MAX_EXPORT, - icon = "mdi:home-export-outline", + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + max_exceptions=MAX_EXPORT, + icon="mdi:home-export-outline", ), SolaxModbusNumberEntityDescription( - name = "Generator Max Charge", - key = "generator_max_charge", - register = 0xC8, - fmt = "i", - native_min_value = 0, - native_max_value = 2500, - scale = 1, - native_step = 100, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = NumberDeviceClass.POWER, + name="Generator Max Charge", + key="generator_max_charge", + register=0xC8, + fmt="i", + native_min_value=0, + native_max_value=2500, + scale=1, + native_step=100, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=NumberDeviceClass.POWER, read_scale_exceptions=EXPORT_LIMIT_SCALE_EXCEPTIONS, - allowedtypes = AC | HYBRID | GEN4 | GEN5 | DCB, - max_exceptions = MAX_EXPORT, + allowedtypes=AC | HYBRID | GEN4 | GEN5 | DCB, + max_exceptions=MAX_EXPORT, ), SolaxModbusNumberEntityDescription( - name = "Feedin Discharge Min SOC", - key = "feedin_discharge_min_soc", - register = 0x65, - fmt = "i", - native_min_value = 10, - native_max_value = 100, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - icon = "mdi:battery-charging-low", + name="Feedin Discharge Min SOC", + key="feedin_discharge_min_soc", + register=0x65, + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:battery-charging-low", ), SolaxModbusNumberEntityDescription( - name = "Feedin Nightcharge Upper SOC", - key = "feedin_nightcharge_upper_soc", - register = 0x64, - fmt = "i", - native_min_value = 10, - native_max_value = 100, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - icon = "mdi:battery-charging-high", + name="Feedin Nightcharge Upper SOC", + key="feedin_nightcharge_upper_soc", + register=0x64, + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:battery-charging-high", ), SolaxModbusNumberEntityDescription( name = "Main Breaker Current Limit", @@ -828,888 +896,888 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict): allowedtypes = AC | HYBRID | GEN4, ), SolaxModbusNumberEntityDescription( - name = "ForceTime Period 1 Max Capacity", - key = "forcetime_period_1_max_capacity", - register = 0xA4, - fmt = "i", - native_min_value = 5, - native_max_value = 100, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = AC | HYBRID | GEN3, - icon = "mdi:battery-sync", + name="ForceTime Period 1 Max Capacity", + key="forcetime_period_1_max_capacity", + register=0xA4, + fmt="i", + native_min_value=5, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=AC | HYBRID | GEN3, + icon="mdi:battery-sync", ), SolaxModbusNumberEntityDescription( - name = "ForceTime Period 2 Max Capacity", - key = "forcetime_period_2_max_capacity", - register = 0xA5, - fmt = "i", - native_min_value = 5, - native_max_value = 100, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = AC | HYBRID | GEN3, - icon = "mdi:battery-sync", + name="ForceTime Period 2 Max Capacity", + key="forcetime_period_2_max_capacity", + register=0xA5, + fmt="i", + native_min_value=5, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=AC | HYBRID | GEN3, + icon="mdi:battery-sync", ), SolaxModbusNumberEntityDescription( - name = "Grid Export Limit", - key = "grid_export_limit", - register = 0x52, - fmt = "i", - native_min_value = -6000, - native_max_value = 6000, - native_step = 100, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = NumberDeviceClass.POWER, - allowedtypes = AC | HYBRID | GEN3, - icon = "mdi:home-export-outline", + name="Grid Export Limit", + key="grid_export_limit", + register=0x52, + fmt="i", + native_min_value=-6000, + native_max_value=6000, + native_step=100, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=NumberDeviceClass.POWER, + allowedtypes=AC | HYBRID | GEN3, + icon="mdi:home-export-outline", ), SolaxModbusNumberEntityDescription( - name = "Grid Export Limit", - key = "grid_export_limit", - register = 0x51, - fmt = "i", - native_min_value = -5000, - native_max_value = 0, - native_step = 100, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = NumberDeviceClass.POWER, - allowedtypes = HYBRID | GEN2, - icon = "mdi:home-export-outline", + name="Grid Export Limit", + key="grid_export_limit", + register=0x51, + fmt="i", + native_min_value=-5000, + native_max_value=0, + native_step=100, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=NumberDeviceClass.POWER, + allowedtypes=HYBRID | GEN2, + icon="mdi:home-export-outline", ), SolaxModbusNumberEntityDescription( - name = "Maximum Per Day On", - key = "maximum_per_day_on", - register = 0xBC, - fmt = "i", - native_min_value = 5, - native_max_value = 1200, - native_step = 5, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = AC | HYBRID | GEN4 | DCB, + name="Maximum Per Day On", + key="maximum_per_day_on", + register=0xBC, + fmt="i", + native_min_value=5, + native_max_value=1200, + native_step=5, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=AC | HYBRID | GEN4 | DCB, ), SolaxModbusNumberEntityDescription( - name = "Minimum Per On Signal", - key = "minimum_per_on_signal", - register = 0xBB, - fmt = "i", - native_min_value = 5, - native_max_value = 100, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = AC | HYBRID | GEN4 | DCB, + name="Minimum Per On Signal", + key="minimum_per_on_signal", + register=0xBB, + fmt="i", + native_min_value=5, + native_max_value=100, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=AC | HYBRID | GEN4 | DCB, ), SolaxModbusNumberEntityDescription( - name = "Selfuse Backup SOC", - key = "selfuse_backup_soc", - register = 0xC5, - fmt = "i", - native_min_value = 10, - native_max_value = 100, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - icon = "mdi:battery-sync", + name="Selfuse Backup SOC", + key="selfuse_backup_soc", + register=0xC5, + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:battery-sync", ), SolaxModbusNumberEntityDescription( - name = "Selfuse Discharge Min SOC", - key = "selfuse_discharge_min_soc", - register = 0x61, - fmt = "i", - native_min_value = 10, - native_max_value = 100, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - icon = "mdi:battery-charging-low", + name="Selfuse Discharge Min SOC", + key="selfuse_discharge_min_soc", + register=0x61, + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:battery-charging-low", ), SolaxModbusNumberEntityDescription( - name = "Selfuse Nightcharge Upper SOC", - key = "selfuse_nightcharge_upper_soc", - register = 0x63, - fmt = "i", - native_min_value = 10, - native_max_value = 100, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - icon = "mdi:battery-charging-high", + name="Selfuse Nightcharge Upper SOC", + key="selfuse_nightcharge_upper_soc", + register=0x63, + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:battery-charging-high", ), SolaxModbusNumberEntityDescription( - name = "Switch Off SOC", - key = "switch_off_soc", - register = 0xBA, - fmt = "i", - native_min_value = 0, - native_max_value = 100, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = AC | HYBRID | GEN4 | DCB, + name="Switch Off SOC", + key="switch_off_soc", + register=0xBA, + fmt="i", + native_min_value=0, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=AC | HYBRID | GEN4 | DCB, ), SolaxModbusNumberEntityDescription( - name = "Switch On SOC", - key = "switch_on_soc", - register = 0xB8, - fmt = "i", - native_min_value = 0, - native_max_value = 100, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = AC | HYBRID | GEN4 | DCB, + name="Switch On SOC", + key="switch_on_soc", + register=0xB8, + fmt="i", + native_min_value=0, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=AC | HYBRID | GEN4 | DCB, ), SolaxModbusNumberEntityDescription( - name = "Battery Charge Upper SOC", - key = "battery_charge_upper_soc", - register = 0xE0, - fmt = "i", - native_min_value = 10, - native_max_value = 100, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - icon = "mdi:battery-charging-high", + name="Battery Charge Upper SOC", + key="battery_charge_upper_soc", + register=0xE0, + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:battery-charging-high", ), SolaxModbusNumberEntityDescription( - name = "Generator Switch On SOC", - key = "generator_switch_on_soc", - register = 0xE4, - fmt = "i", - native_min_value = 0, - native_max_value = 100, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = HYBRID | GEN4 | GEN5 | DCB, + name="Generator Switch On SOC", + key="generator_switch_on_soc", + register=0xE4, + fmt="i", + native_min_value=0, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=HYBRID | GEN4 | GEN5 | DCB, ), SolaxModbusNumberEntityDescription( - name = "Generator Switch Off SOC", - key = "generator_switch_off_soc", - register = 0xE5, - fmt = "i", - native_min_value = 0, - native_max_value = 100, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = HYBRID | GEN4 | GEN5 | DCB, + name="Generator Switch Off SOC", + key="generator_switch_off_soc", + register=0xE5, + fmt="i", + native_min_value=0, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=HYBRID | GEN4 | GEN5 | DCB, ), SolaxModbusNumberEntityDescription( - name = "PeakShaving Discharge Limit 1", - key = "peakshaving_discharge_limit_1", - register = 0xEE, - fmt = "i", - native_min_value = 0, - native_max_value = 15000, - native_step = 100, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = NumberDeviceClass.POWER, - allowedtypes = HYBRID | GEN4 | GEN5, + name="PeakShaving Discharge Limit 1", + key="peakshaving_discharge_limit_1", + register=0xEE, + fmt="i", + native_min_value=0, + native_max_value=15000, + native_step=100, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=NumberDeviceClass.POWER, + allowedtypes=HYBRID | GEN4 | GEN5, ), SolaxModbusNumberEntityDescription( - name = "PeakShaving Discharge Limit 2", - key = "peakshaving_discharge_limit_2", - register = 0xEF, - fmt = "i", - native_min_value = 0, - native_max_value = 15000, - native_step = 100, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = NumberDeviceClass.POWER, - allowedtypes = HYBRID | GEN4 | GEN5, + name="PeakShaving Discharge Limit 2", + key="peakshaving_discharge_limit_2", + register=0xEF, + fmt="i", + native_min_value=0, + native_max_value=15000, + native_step=100, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=NumberDeviceClass.POWER, + allowedtypes=HYBRID | GEN4 | GEN5, ), SolaxModbusNumberEntityDescription( - name = "PeakShaving Charge Limit", - key = "peakshaving_charge_limit", - register = 0xF1, - fmt = "i", - native_min_value = 0, - native_max_value = 7500, - native_step = 100, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = NumberDeviceClass.POWER, - allowedtypes = HYBRID | GEN4 | GEN5 | X1, + name="PeakShaving Charge Limit", + key="peakshaving_charge_limit", + register=0xF1, + fmt="i", + native_min_value=0, + native_max_value=7500, + native_step=100, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=NumberDeviceClass.POWER, + allowedtypes=HYBRID | GEN4 | GEN5 | X1, ), SolaxModbusNumberEntityDescription( - name = "PeakShaving Charge Limit", - key = "peakshaving_charge_limit", - register = 0xF1, - fmt = "i", - native_min_value = 0, - native_max_value = 15000, - native_step = 100, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = NumberDeviceClass.POWER, - allowedtypes = HYBRID | GEN4 | GEN5 | X3, + name="PeakShaving Charge Limit", + key="peakshaving_charge_limit", + register=0xF1, + fmt="i", + native_min_value=0, + native_max_value=15000, + native_step=100, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=NumberDeviceClass.POWER, + allowedtypes=HYBRID | GEN4 | GEN5 | X3, ), SolaxModbusNumberEntityDescription( - name = "PeakShaving Max SOC", - key = "peakshaving_max_soc", - register = 0xF2, - fmt = "i", - native_min_value = 0, - native_max_value = 100, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = HYBRID | GEN4 | GEN5, - icon = "mdi:battery-charging-high", + name="PeakShaving Max SOC", + key="peakshaving_max_soc", + register=0xF2, + fmt="i", + native_min_value=0, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=HYBRID | GEN4 | GEN5, + icon="mdi:battery-charging-high", ), SolaxModbusNumberEntityDescription( - name = "PeakShaving Reserved SOC", - key = "peakshaving_reserved_soc", - register = 0xF3, - fmt = "i", - native_min_value = 0, - native_max_value = 100, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = HYBRID | GEN4 | GEN5, + name="PeakShaving Reserved SOC", + key="peakshaving_reserved_soc", + register=0xF3, + fmt="i", + native_min_value=0, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=HYBRID | GEN4 | GEN5, ), SolaxModbusNumberEntityDescription( - name = "Generator Charge SOC", - key = "generator_charge_soc", - register = 0x10A, - fmt = "i", - native_min_value = 0, - native_max_value = 100, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = HYBRID | GEN4 | DCB, + name="Generator Charge SOC", + key="generator_charge_soc", + register=0x10A, + fmt="i", + native_min_value=0, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=HYBRID | GEN4 | DCB, ), SolaxModbusNumberEntityDescription( - name = "Generator Charge SOC", - key = "generator_charge_soc", - register = 0x10D, - fmt = "i", - native_min_value = 0, - native_max_value = 100, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = HYBRID | GEN5 | DCB, + name="Generator Charge SOC", + key="generator_charge_soc", + register=0x10D, + fmt="i", + native_min_value=0, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=HYBRID | GEN5 | DCB, ), -##### -# -# MIC -# -##### + ##### + # + # MIC + # + ##### SolaxModbusNumberEntityDescription( - name = "Active Power Limit", - key = "active_power_limit", - register = 0x638, - fmt = "i", - native_min_value = 0, - native_max_value = 30000, - native_step = 100, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = NumberDeviceClass.POWER, - allowedtypes = MIC | GEN2 | X3, + name="Active Power Limit", + key="active_power_limit", + register=0x638, + fmt="i", + native_min_value=0, + native_max_value=30000, + native_step=100, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=NumberDeviceClass.POWER, + allowedtypes=MIC | GEN2 | X3, ), SolaxModbusNumberEntityDescription( - name = "Export Power Limit", - key = "export_power_limit", - register = 0x65C, - fmt = "i", - native_min_value = 0, - native_max_value = 30000, - native_step = 100, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = NumberDeviceClass.POWER, - allowedtypes = MIC | GEN2 | X3, + name="Export Power Limit", + key="export_power_limit", + register=0x65C, + fmt="i", + native_min_value=0, + native_max_value=30000, + native_step=100, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=NumberDeviceClass.POWER, + allowedtypes=MIC | GEN2 | X3, ), SolaxModbusNumberEntityDescription( - name = "Active Power Limit", - key = "active_power_limit", - register = 0x669, - fmt = "i", - native_min_value = 0, - native_max_value = 30000, - native_step = 100, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = NumberDeviceClass.POWER, - allowedtypes = MIC | GEN4, + name="Active Power Limit", + key="active_power_limit", + register=0x669, + fmt="i", + native_min_value=0, + native_max_value=30000, + native_step=100, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=NumberDeviceClass.POWER, + allowedtypes=MIC | GEN4, ), ] # ================================= Select Declarations ============================================================ SELECT_TYPES = [ -### -# -# Data only select types -# -### + ### + # + # Data only select types + # + ### SolaxModbusSelectEntityDescription( - name = "Remotecontrol Power Control", - key = "remotecontrol_power_control", - unit = REGISTER_U16, - write_method = WRITE_DATA_LOCAL, - option_dict = { - 0: "Disabled", - 1: "Enabled Power Control", # battery charge level in absense of PV - 11: "Enabled Grid Control", # computed variation of Power Control, grid import level in absense of PV - 12: "Enabled Battery Control", # computed variation of Power Control, battery import without of PV - 110: "Enabled Self Use", # variation of Grid Control with fixed target 0 - 120: "Enabled Feedin Priority", # variation of Battery Control with fixed target 0 - 130: "Enabled No Discharge", # missing HL from grid - # 2: "Enabled Quantity Control", - # 3: "Enabled SOC Target Control", - }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - initvalue = "Disabled", - icon = "mdi:transmission-tower", + name="Remotecontrol Power Control", + key="remotecontrol_power_control", + unit=REGISTER_U16, + write_method=WRITE_DATA_LOCAL, + option_dict={ + 0: "Disabled", + 1: "Enabled Power Control", # battery charge level in absense of PV + 11: "Enabled Grid Control", # computed variation of Power Control, grid import level in absense of PV + 12: "Enabled Battery Control", # computed variation of Power Control, battery import without of PV + 110: "Enabled Self Use", # variation of Grid Control with fixed target 0 + 120: "Enabled Feedin Priority", # variation of Battery Control with fixed target 0 + 130: "Enabled No Discharge", # missing HL from grid + # 2: "Enabled Quantity Control", + # 3: "Enabled SOC Target Control", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + initvalue="Disabled", + icon="mdi:transmission-tower", ), SolaxModbusSelectEntityDescription( - name = "Remotecontrol Set Type", - key = "remotecontrol_set_type", - unit = REGISTER_U16, - write_method = WRITE_DATA_LOCAL, - option_dict = { - 1: "Set", - 2: "Update", - }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - initvalue = "Set", - icon = "mdi:transmission-tower", + name="Remotecontrol Set Type", + key="remotecontrol_set_type", + unit=REGISTER_U16, + write_method=WRITE_DATA_LOCAL, + option_dict={ + 1: "Set", + 2: "Update", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + initvalue="Set", + icon="mdi:transmission-tower", ), -### -# -# Normal select types -# -### + ### + # + # Normal select types + # + ### SolaxModbusSelectEntityDescription( - name = "Lock State", - key = "lock_state", - register = 0x0, - option_dict = { - 0: "Locked", - 2014: "Unlocked", - 6868: "Unlocked - Advanced", - }, - allowedtypes = AC | HYBRID, - icon = "mdi:lock-question", + name="Lock State", + key="lock_state", + register=0x0, + option_dict={ + 0: "Locked", + 2014: "Unlocked", + 6868: "Unlocked - Advanced", + }, + allowedtypes=AC | HYBRID, + icon="mdi:lock-question", ), SolaxModbusSelectEntityDescription( - name = "Allow Grid Charge", - key = "allow_grid_charge", - register = 0x40, - option_dict = { - 0: "Both Forbidden", - 1: "Period 1 Allowed", - 2: "Period 2 Allowed", - 3: "Both Allowed", - }, - allowedtypes = AC | HYBRID | GEN2 | GEN3, - icon = "mdi:transmission-tower", + name="Allow Grid Charge", + key="allow_grid_charge", + register=0x40, + option_dict={ + 0: "Both Forbidden", + 1: "Period 1 Allowed", + 2: "Period 2 Allowed", + 3: "Both Allowed", + }, + allowedtypes=AC | HYBRID | GEN2 | GEN3, + icon="mdi:transmission-tower", ), SolaxModbusSelectEntityDescription( - name = "Backup Grid Charge", - key = "backup_gridcharge", - register = 0x94, - option_dict = { - 0: "Disabled", - 1: "Enabled", - }, - allowedtypes = AC | HYBRID | GEN3, - icon = "mdi:transmission-tower", + name="Backup Grid Charge", + key="backup_gridcharge", + register=0x94, + option_dict={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN3, + icon="mdi:transmission-tower", ), SolaxModbusSelectEntityDescription( - name = "Charge and Discharge Period2 Enable", - key = "charge_and_discharge_period2_enable", - register = 0x6C, - option_dict = { - 0: "Disabled", - 1: "Enabled", - }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", + name="Charge and Discharge Period2 Enable", + key="charge_and_discharge_period2_enable", + register=0x6C, + option_dict={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", ), SolaxModbusSelectEntityDescription( - name = "Charger End Time 1", - key = "charger_end_time_1", - register = 0x27, - option_dict = TIME_OPTIONS, - allowedtypes = AC | HYBRID | GEN2 | GEN3, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-end", + name="Charger End Time 1", + key="charger_end_time_1", + register=0x27, + option_dict=TIME_OPTIONS, + allowedtypes=AC | HYBRID | GEN2 | GEN3, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-end", ), - SolaxModbusSelectEntityDescription( - name = "Charger End Time 1", - key = "charger_end_time_1", - register = 0x69, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-end", + SolaxModbusSelectEntityDescription( + name="Charger End Time 1", + key="charger_end_time_1", + register=0x69, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-end", ), SolaxModbusSelectEntityDescription( - name = "Charger End Time 2", - key = "charger_end_time_2", - register = 0x2B, - option_dict = TIME_OPTIONS, - allowedtypes = AC | HYBRID | GEN2 | GEN3, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-end", + name="Charger End Time 2", + key="charger_end_time_2", + register=0x2B, + option_dict=TIME_OPTIONS, + allowedtypes=AC | HYBRID | GEN2 | GEN3, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-end", ), SolaxModbusSelectEntityDescription( - name = "Charger End Time 2", - key = "charger_end_time_2", - register = 0x6E, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-end", + name="Charger End Time 2", + key="charger_end_time_2", + register=0x6E, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-end", ), SolaxModbusSelectEntityDescription( - name = "Charger Start Time 1", - key = "charger_start_time_1", - register = 0x26, - option_dict = TIME_OPTIONS, - allowedtypes = AC | HYBRID | GEN2 | GEN3, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-start", + name="Charger Start Time 1", + key="charger_start_time_1", + register=0x26, + option_dict=TIME_OPTIONS, + allowedtypes=AC | HYBRID | GEN2 | GEN3, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-start", ), SolaxModbusSelectEntityDescription( - name = "Charger Start Time 1", - key = "charger_start_time_1", - register = 0x68, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-start", + name="Charger Start Time 1", + key="charger_start_time_1", + register=0x68, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-start", ), SolaxModbusSelectEntityDescription( - name = "Charger Start Time 2", - key = "charger_start_time_2", - register = 0x2A, - option_dict = TIME_OPTIONS, - allowedtypes = AC | HYBRID | GEN2 | GEN3, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-start", + name="Charger Start Time 2", + key="charger_start_time_2", + register=0x2A, + option_dict=TIME_OPTIONS, + allowedtypes=AC | HYBRID | GEN2 | GEN3, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-start", ), SolaxModbusSelectEntityDescription( - name = "Charger Start Time 2", - key = "charger_start_time_2", - register = 0x6D, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-start", + name="Charger Start Time 2", + key="charger_start_time_2", + register=0x6D, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-start", ), SolaxModbusSelectEntityDescription( - name = "Charger Use Mode", - key = "charger_use_mode", - register = 0x1F, - option_dict = { + name="Charger Use Mode", + key="charger_use_mode", + register=0x1F, + option_dict={ 0: "Self Use Mode", 1: "Force Time Use", 2: "Back Up Mode", }, - allowedtypes = HYBRID | GEN2, - icon = "mdi:dip-switch", + allowedtypes=HYBRID | GEN2, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Charger Use Mode", - key = "charger_use_mode", - register = 0x1F, - option_dict = { + name="Charger Use Mode", + key="charger_use_mode", + register=0x1F, + option_dict={ 0: "Self Use Mode", 1: "Force Time Use", 2: "Back Up Mode", 3: "Feedin Priority", }, - allowedtypes = AC | HYBRID | GEN3, - icon = "mdi:dip-switch", + allowedtypes=AC | HYBRID | GEN3, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Charger Use Mode", - key = "charger_use_mode", - register = 0x1F, - option_dict = { - 0: "Self Use Mode", - 1: "Feedin Priority", - 2: "Back Up Mode", - 3: "Manual Mode", - 4: "PeakShaving", - 5: "Smart Schedule", - }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - icon = "mdi:dip-switch", + name="Charger Use Mode", + key="charger_use_mode", + register=0x1F, + option_dict={ + 0: "Self Use Mode", + 1: "Feedin Priority", + 2: "Back Up Mode", + 3: "Manual Mode", + 4: "PeakShaving", + 5: "Smart Schedule", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Cloud Control", - key = "cloud_control", - register = 0x99, - option_dict = { - 0: "Disabled", - 1: "Enabled", - }, - allowedtypes = AC | HYBRID | GEN3, - entity_category = EntityCategory.CONFIG, - entity_registry_enabled_default = False, - icon = "mdi:cloud", + name="Cloud Control", + key="cloud_control", + register=0x99, + option_dict={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN3, + entity_category=EntityCategory.CONFIG, + entity_registry_enabled_default=False, + icon="mdi:cloud", ), SolaxModbusSelectEntityDescription( - name = "Discharge Cut Off Point Different", - key = "discharge_cut_off_point_different", - register = 0xA6, - option_dict = { - 0: "Disabled", - 1: "Enabled", - }, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - icon = "mdi:dip-switch", + name="Discharge Cut Off Point Different", + key="discharge_cut_off_point_different", + register=0xA6, + option_dict={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Meter 1 Direction", - key = "meter_1_direction", - register = 0xAB, - option_dict = { - 0: "Positive", - 1: "Negative", - }, - allowedtypes = AC | HYBRID | GEN3, - entity_category = EntityCategory.CONFIG, - entity_registry_enabled_default = False, - icon = "mdi:meter-electric", + name="Meter 1 Direction", + key="meter_1_direction", + register=0xAB, + option_dict={ + 0: "Positive", + 1: "Negative", + }, + allowedtypes=AC | HYBRID | GEN3, + entity_category=EntityCategory.CONFIG, + entity_registry_enabled_default=False, + icon="mdi:meter-electric", ), SolaxModbusSelectEntityDescription( - name = "Meter 2 Direction", - key = "meter_2_direction", - register = 0xAC, - option_dict = { - 0: "Positive", - 1: "Negative", - }, - allowedtypes = AC | HYBRID | GEN3, - entity_category = EntityCategory.CONFIG, - entity_registry_enabled_default = False, - icon = "mdi:meter-electric", + name="Meter 2 Direction", + key="meter_2_direction", + register=0xAC, + option_dict={ + 0: "Positive", + 1: "Negative", + }, + allowedtypes=AC | HYBRID | GEN3, + entity_category=EntityCategory.CONFIG, + entity_registry_enabled_default=False, + icon="mdi:meter-electric", ), SolaxModbusSelectEntityDescription( - name = "Device Lock", - key = "device_lock", - register = 0xB5, - option_dict = { - 0: "Unlock", - 1: "Lock", - }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:lock", + name="Device Lock", + key="device_lock", + register=0xB5, + option_dict={ + 0: "Unlock", + 1: "Lock", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:lock", ), SolaxModbusSelectEntityDescription( - name = "Discharger End Time 1", - key = "discharger_end_time_1", - register = 0x29, - option_dict = TIME_OPTIONS, - allowedtypes = HYBRID | GEN2, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-end", + name="Discharger End Time 1", + key="discharger_end_time_1", + register=0x29, + option_dict=TIME_OPTIONS, + allowedtypes=HYBRID | GEN2, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-end", ), SolaxModbusSelectEntityDescription( - name = "Discharger End Time 1", - key = "discharger_end_time_1", - register = 0x6B, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-end", + name="Discharger End Time 1", + key="discharger_end_time_1", + register=0x6B, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-end", ), SolaxModbusSelectEntityDescription( - name = "Discharger End Time 2", - key = "discharger_end_time_2", - register = 0x2D, - option_dict = TIME_OPTIONS, - allowedtypes = HYBRID | GEN2, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-end", + name="Discharger End Time 2", + key="discharger_end_time_2", + register=0x2D, + option_dict=TIME_OPTIONS, + allowedtypes=HYBRID | GEN2, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-end", ), SolaxModbusSelectEntityDescription( - name = "Discharger End Time 2", - key = "discharger_end_time_2", - register = 0x70, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-end", + name="Discharger End Time 2", + key="discharger_end_time_2", + register=0x70, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-end", ), SolaxModbusSelectEntityDescription( - name = "Discharger Start Time 1", - key = "discharger_start_time_1", - register = 0x28, - option_dict = TIME_OPTIONS, - allowedtypes = HYBRID | GEN2, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-start", + name="Discharger Start Time 1", + key="discharger_start_time_1", + register=0x28, + option_dict=TIME_OPTIONS, + allowedtypes=HYBRID | GEN2, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-start", ), SolaxModbusSelectEntityDescription( - name = "Discharger Start Time 1", - key = "discharger_start_time_1", - register = 0x6A, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-start", + name="Discharger Start Time 1", + key="discharger_start_time_1", + register=0x6A, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-start", ), SolaxModbusSelectEntityDescription( - name = "Discharger Start Time 2", - key = "discharger_start_time_2", - register = 0x2C, - option_dict = TIME_OPTIONS, - allowedtypes = HYBRID | GEN2, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-start", + name="Discharger Start Time 2", + key="discharger_start_time_2", + register=0x2C, + option_dict=TIME_OPTIONS, + allowedtypes=HYBRID | GEN2, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-start", ), SolaxModbusSelectEntityDescription( - name = "Discharger Start Time 2", - key = "discharger_start_time_2", - register = 0x6F, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-start", + name="Discharger Start Time 2", + key="discharger_start_time_2", + register=0x6F, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-start", ), SolaxModbusSelectEntityDescription( - name = "HotStandBy", - key = "hotstandby", - register = 0x99, - option_dict = { - 0: "Enabled", - 1: "Disabled", - }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - icon = "mdi:dip-switch", + name="HotStandBy", + key="hotstandby", + register=0x99, + option_dict={ + 0: "Enabled", + 1: "Disabled", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Extend BMS Setting", - key = "extend_bms_setting", - register = 0x9A, - option_dict = { - 0: "Disabled", - 1: "Enabled", - }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - icon = "mdi:dip-switch", + name="Extend BMS Setting", + key="extend_bms_setting", + register=0x9A, + option_dict={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Export Duration", - key = "export_duration", - register = 0x9F, - option_dict = { - 4: "Default", - 900: "15 Minutes", - 1800: "30 Minutes", - 3600: "60 Minutes", - 5400: "90 Minutes", - 7200: "120 Minutes", - }, - allowedtypes = AC | HYBRID | GEN3, - entity_category = EntityCategory.CONFIG, - icon = "mdi:home-export-outline", + name="Export Duration", + key="export_duration", + register=0x9F, + option_dict={ + 4: "Default", + 900: "15 Minutes", + 1800: "30 Minutes", + 3600: "60 Minutes", + 5400: "90 Minutes", + 7200: "120 Minutes", + }, + allowedtypes=AC | HYBRID | GEN3, + entity_category=EntityCategory.CONFIG, + icon="mdi:home-export-outline", ), SolaxModbusSelectEntityDescription( - name = "Dry Contact Mode", - key = "dry_contact_mode", - register = 0xC3, - option_dict = { - 0: "Load Management", - 1: "Generator Control", - }, - allowedtypes = AC | HYBRID | GEN4 | DCB, - icon = "mdi:dip-switch", + name="Dry Contact Mode", + key="dry_contact_mode", + register=0xC3, + option_dict={ + 0: "Load Management", + 1: "Generator Control", + }, + allowedtypes=AC | HYBRID | GEN4 | DCB, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Generator Control", - key = "generator_control", - register = 0xC7, - option_dict = { - 0: "Disabled", - 1: "ATS Control", - 2: "Dry Contact", - }, - allowedtypes = AC | HYBRID | GEN4 | GEN5 | DCB, - icon = "mdi:dip-switch", + name="Generator Control", + key="generator_control", + register=0xC7, + option_dict={ + 0: "Disabled", + 1: "ATS Control", + 2: "Dry Contact", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5 | DCB, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Battery Heating", - key = "battery_heating", - register = 0xCF, - option_dict = { - 0: "Disabled", - 1: "Enabled", - }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - icon = "mdi:heating-coil", + name="Battery Heating", + key="battery_heating", + register=0xCF, + option_dict={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:heating-coil", ), SolaxModbusSelectEntityDescription( - name = "Battery Heating Start Time 1", - key = "battery_heating_start_time_1", - register = 0xD0, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-start", + name="Battery Heating Start Time 1", + key="battery_heating_start_time_1", + register=0xD0, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-start", ), SolaxModbusSelectEntityDescription( - name = "Battery Heating End Time 1", - key = "battery_heating_end_time_1", - register = 0xD1, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-end", + name="Battery Heating End Time 1", + key="battery_heating_end_time_1", + register=0xD1, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-end", ), SolaxModbusSelectEntityDescription( - name = "Battery Heating Start Time 2", - key = "battery_heating_start_time_2", - register = 0xD2, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-start", + name="Battery Heating Start Time 2", + key="battery_heating_start_time_2", + register=0xD2, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-start", ), SolaxModbusSelectEntityDescription( - name = "Battery Heating End Time 2", - key = "battery_heating_end_time_2", - register = 0xD3, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-end", + name="Battery Heating End Time 2", + key="battery_heating_end_time_2", + register=0xD3, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-end", ), SolaxModbusSelectEntityDescription( - name = "Battery to EV Charger", - key = "battery_to_ev_charger", - register = 0xE1, - option_dict = { - 0: "Disabled", - 1: "Enabled", - }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - entity_category = EntityCategory.CONFIG, - entity_registry_enabled_default = False, - icon = "mdi:dip-switch", + name="Battery to EV Charger", + key="battery_to_ev_charger", + register=0xE1, + option_dict={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + entity_category=EntityCategory.CONFIG, + entity_registry_enabled_default=False, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Generator Start Method", - key = "generator_start_method", - register = 0xE3, - option_dict = { - 0: "Reference SOC", - 1: "Immediately", - }, - allowedtypes = HYBRID | GEN4 | GEN5 | DCB, - icon = "mdi:dip-switch", + name="Generator Start Method", + key="generator_start_method", + register=0xE3, + option_dict={ + 0: "Reference SOC", + 1: "Immediately", + }, + allowedtypes=HYBRID | GEN4 | GEN5 | DCB, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Generator Start Time 1", - key = "generator_start_time_1", - register = 0xE8, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = HYBRID | GEN4 | GEN5 | DCB, - entity_category = EntityCategory.CONFIG, - icon = "mdi:generator-stationary", + name="Generator Start Time 1", + key="generator_start_time_1", + register=0xE8, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=HYBRID | GEN4 | GEN5 | DCB, + entity_category=EntityCategory.CONFIG, + icon="mdi:generator-stationary", ), SolaxModbusSelectEntityDescription( - name = "Generator Stop Time 1", - key = "generator_stop_time_1", - register = 0xE9, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = HYBRID | GEN4 | GEN5 | DCB, - entity_category = EntityCategory.CONFIG, - icon = "mdi:generator-stationary", + name="Generator Stop Time 1", + key="generator_stop_time_1", + register=0xE9, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=HYBRID | GEN4 | GEN5 | DCB, + entity_category=EntityCategory.CONFIG, + icon="mdi:generator-stationary", ), SolaxModbusSelectEntityDescription( - name = "PeakShaving Discharge Start Time 1", - key = "peakshaving_discharge_start_time_1", - register = 0xEA, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = HYBRID | GEN4 | GEN5, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-start", + name="PeakShaving Discharge Start Time 1", + key="peakshaving_discharge_start_time_1", + register=0xEA, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=HYBRID | GEN4 | GEN5, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-start", ), SolaxModbusSelectEntityDescription( - name = "PeakShaving Discharge Stop Time 1", - key = "peakshaving_discharge_stop_time_1", - register = 0xEB, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = HYBRID | GEN4 | GEN5, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-end", + name="PeakShaving Discharge Stop Time 1", + key="peakshaving_discharge_stop_time_1", + register=0xEB, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=HYBRID | GEN4 | GEN5, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-end", ), SolaxModbusSelectEntityDescription( - name = "PeakShaving Discharge Start Time 2", - key = "peakshaving_discharge_start_time_2", - register = 0xEC, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = HYBRID | GEN4 | GEN5, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-start", + name="PeakShaving Discharge Start Time 2", + key="peakshaving_discharge_start_time_2", + register=0xEC, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=HYBRID | GEN4 | GEN5, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-start", ), SolaxModbusSelectEntityDescription( - name = "MPPT", - key = "mppt", - register = 0x48, - option_dict = { - 0: "Disabled", - 1: "Enabled", - }, - allowedtypes = HYBRID | GEN4 | GEN5, - icon = "mdi:dip-switch", + name="MPPT", + key="mppt", + register=0x48, + option_dict={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=HYBRID | GEN4 | GEN5, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "PeakShaving Discharge Stop Time 2", - key = "peakshaving_discharge_stop_time_2", - register = 0xED, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = HYBRID | GEN4 | GEN5, - entity_category = EntityCategory.CONFIG, - icon = "mdi:clock-end", + name="PeakShaving Discharge Stop Time 2", + key="peakshaving_discharge_stop_time_2", + register=0xED, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=HYBRID | GEN4 | GEN5, + entity_category=EntityCategory.CONFIG, + icon="mdi:clock-end", ), SolaxModbusSelectEntityDescription( - name = "PeakShaving Charge from Grid", - key = "peakshaving_charge_from_grid", - register = 0xF0, - option_dict = { - 0: "Disabled", - 1: "Enabled", - }, - allowedtypes = HYBRID | GEN4 | GEN5, - icon = "mdi:dip-switch", + name="PeakShaving Charge from Grid", + key="peakshaving_charge_from_grid", + register=0xF0, + option_dict={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=HYBRID | GEN4 | GEN5, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Shadow Fix Function Level PV3 (GMPPT)", - key = "shadow_fix3_enable", - register = 0xFC, - option_dict = { - 0: "Off", - 1: "Low", - 2: "Middle", - 3: "High", - }, - allowedtypes = HYBRID | GEN5 | MPPT3, - icon = "mdi:dip-switch", + name="Shadow Fix Function Level PV3 (GMPPT)", + key="shadow_fix3_enable", + register=0xFC, + option_dict={ + 0: "Off", + 1: "Low", + 2: "Middle", + 3: "High", + }, + allowedtypes=HYBRID | GEN5 | MPPT3, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "CT Cycle Detection", - key = "ct_cycle_detection", - register = 0xFD, - option_dict = { - 0: "Disabled", - 1: "Enabled", - }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - icon = "mdi:dip-switch", + name="CT Cycle Detection", + key="ct_cycle_detection", + register=0xFD, + option_dict={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "EPS Mode without Battery", - key = "eps_mode_without_battery", - register = 0xFE, - option_dict = { - 0: "Disabled", - 1: "Enabled", - }, - allowedtypes = AC | HYBRID | GEN4 | GEN5 | EPS, - icon = "mdi:dip-switch", + name="EPS Mode without Battery", + key="eps_mode_without_battery", + register=0xFE, + option_dict={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5 | EPS, + icon="mdi:dip-switch", ), ##### # @@ -1717,98 +1785,98 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict): # ##### SolaxModbusSelectEntityDescription( - name = "Generator Charge Start Time 1", - key = "generator_charge_start_time_1", - register = 0x100, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = HYBRID | GEN4 | DCB, - entity_category = EntityCategory.CONFIG, - icon = "mdi:generator-stationary", + name="Generator Charge Start Time 1", + key="generator_charge_start_time_1", + register=0x100, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=HYBRID | GEN4 | DCB, + entity_category=EntityCategory.CONFIG, + icon="mdi:generator-stationary", ), SolaxModbusSelectEntityDescription( - name = "Generator Charge Stop Time 1", - key = "generator_charge_stop_time_1", - register = 0x101, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = HYBRID | GEN4 | DCB, - entity_category = EntityCategory.CONFIG, - icon = "mdi:generator-stationary", + name="Generator Charge Stop Time 1", + key="generator_charge_stop_time_1", + register=0x101, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=HYBRID | GEN4 | DCB, + entity_category=EntityCategory.CONFIG, + icon="mdi:generator-stationary", ), SolaxModbusSelectEntityDescription( - name = "Generator Discharge Start Time 1", - key = "generator_discharge_start_time_1", - register = 0x102, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = HYBRID | GEN4 | DCB, - entity_category = EntityCategory.CONFIG, - icon = "mdi:generator-stationary", + name="Generator Discharge Start Time 1", + key="generator_discharge_start_time_1", + register=0x102, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=HYBRID | GEN4 | DCB, + entity_category=EntityCategory.CONFIG, + icon="mdi:generator-stationary", ), SolaxModbusSelectEntityDescription( - name = "Generator Discharge Stop Time 1", - key = "generator_discharge_stop_time_1", - register = 0x103, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = HYBRID | GEN4 | DCB, - entity_category = EntityCategory.CONFIG, - icon = "mdi:generator-stationary", + name="Generator Discharge Stop Time 1", + key="generator_discharge_stop_time_1", + register=0x103, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=HYBRID | GEN4 | DCB, + entity_category=EntityCategory.CONFIG, + icon="mdi:generator-stationary", ), SolaxModbusSelectEntityDescription( - name = "Generator Time 2", - key = "generator_time_2", - register = 0x104, - option_dict = { - 0: "Disabled", - 1: "Enabled", - }, - allowedtypes = HYBRID | GEN4 | DCB, - icon = "mdi:dip-switch", + name="Generator Time 2", + key="generator_time_2", + register=0x104, + option_dict={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=HYBRID | GEN4 | DCB, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Generator Charge Start Time 2", - key = "generator_charge_start_time_2", - register = 0x105, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = HYBRID | GEN4 | DCB, - entity_category = EntityCategory.CONFIG, - icon = "mdi:generator-stationary", + name="Generator Charge Start Time 2", + key="generator_charge_start_time_2", + register=0x105, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=HYBRID | GEN4 | DCB, + entity_category=EntityCategory.CONFIG, + icon="mdi:generator-stationary", ), SolaxModbusSelectEntityDescription( - name = "Generator Charge Stop Time 2", - key = "generator_charge_stop_time_2", - register = 0x106, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = HYBRID | GEN4 | DCB, - entity_category = EntityCategory.CONFIG, - icon = "mdi:generator-stationary", + name="Generator Charge Stop Time 2", + key="generator_charge_stop_time_2", + register=0x106, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=HYBRID | GEN4 | DCB, + entity_category=EntityCategory.CONFIG, + icon="mdi:generator-stationary", ), SolaxModbusSelectEntityDescription( - name = "Generator Discharge Start Time 2", - key = "generator_discharge_start_time_2", - register = 0x107, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = HYBRID | GEN4 | DCB, - entity_category = EntityCategory.CONFIG, - icon = "mdi:generator-stationary", + name="Generator Discharge Start Time 2", + key="generator_discharge_start_time_2", + register=0x107, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=HYBRID | GEN4 | DCB, + entity_category=EntityCategory.CONFIG, + icon="mdi:generator-stationary", ), SolaxModbusSelectEntityDescription( - name = "Generator Discharge Stop Time 2", - key = "generator_discharge_stop_time_2", - register = 0x108, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = HYBRID | GEN4 | DCB, - entity_category = EntityCategory.CONFIG, - icon = "mdi:generator-stationary", + name="Generator Discharge Stop Time 2", + key="generator_discharge_stop_time_2", + register=0x108, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=HYBRID | GEN4 | DCB, + entity_category=EntityCategory.CONFIG, + icon="mdi:generator-stationary", ), SolaxModbusSelectEntityDescription( - name = "Generator Charge", - key = "generator_charge", - register = 0x109, - option_dict = { - 0: "Disabled", - 1: "Enabled", - }, - allowedtypes = HYBRID | GEN4 | DCB, - icon = "mdi:dip-switch", + name="Generator Charge", + key="generator_charge", + register=0x109, + option_dict={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=HYBRID | GEN4 | DCB, + icon="mdi:dip-switch", ), ##### # @@ -1816,308 +1884,308 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict): # ##### SolaxModbusSelectEntityDescription( - name = "Generator Charge Start Time 1", - key = "generator_charge_start_time_1", - register = 0x103, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = HYBRID | GEN5 | DCB, - entity_category = EntityCategory.CONFIG, - icon = "mdi:generator-stationary", + name="Generator Charge Start Time 1", + key="generator_charge_start_time_1", + register=0x103, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=HYBRID | GEN5 | DCB, + entity_category=EntityCategory.CONFIG, + icon="mdi:generator-stationary", ), SolaxModbusSelectEntityDescription( - name = "Generator Charge Stop Time 1", - key = "generator_charge_stop_time_1", - register = 0x104, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = HYBRID | GEN5 | DCB, - entity_category = EntityCategory.CONFIG, - icon = "mdi:generator-stationary", + name="Generator Charge Stop Time 1", + key="generator_charge_stop_time_1", + register=0x104, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=HYBRID | GEN5 | DCB, + entity_category=EntityCategory.CONFIG, + icon="mdi:generator-stationary", ), SolaxModbusSelectEntityDescription( - name = "Generator Discharge Start Time 1", - key = "generator_discharge_start_time_1", - register = 0x105, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = HYBRID | GEN5 | DCB, - entity_category = EntityCategory.CONFIG, - icon = "mdi:generator-stationary", + name="Generator Discharge Start Time 1", + key="generator_discharge_start_time_1", + register=0x105, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=HYBRID | GEN5 | DCB, + entity_category=EntityCategory.CONFIG, + icon="mdi:generator-stationary", ), SolaxModbusSelectEntityDescription( - name = "Generator Discharge Stop Time 1", - key = "generator_discharge_stop_time_1", - register = 0x106, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = HYBRID | GEN5 | DCB, - entity_category = EntityCategory.CONFIG, - icon = "mdi:generator-stationary", + name="Generator Discharge Stop Time 1", + key="generator_discharge_stop_time_1", + register=0x106, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=HYBRID | GEN5 | DCB, + entity_category=EntityCategory.CONFIG, + icon="mdi:generator-stationary", ), SolaxModbusSelectEntityDescription( - name = "Generator Time 2", - key = "generator_time_2", - register = 0x107, - option_dict = { - 0: "Disabled", - 1: "Enabled", - }, - allowedtypes = HYBRID | GEN5 | DCB, - icon = "mdi:dip-switch", + name="Generator Time 2", + key="generator_time_2", + register=0x107, + option_dict={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=HYBRID | GEN5 | DCB, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Generator Charge Start Time 2", - key = "generator_charge_start_time_2", - register = 0x108, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = HYBRID | GEN5 | DCB, - entity_category = EntityCategory.CONFIG, - icon = "mdi:generator-stationary", + name="Generator Charge Start Time 2", + key="generator_charge_start_time_2", + register=0x108, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=HYBRID | GEN5 | DCB, + entity_category=EntityCategory.CONFIG, + icon="mdi:generator-stationary", ), SolaxModbusSelectEntityDescription( - name = "Generator Charge Stop Time 2", - key = "generator_charge_stop_time_2", - register = 0x109, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = HYBRID | GEN5 | DCB, - entity_category = EntityCategory.CONFIG, - icon = "mdi:generator-stationary", + name="Generator Charge Stop Time 2", + key="generator_charge_stop_time_2", + register=0x109, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=HYBRID | GEN5 | DCB, + entity_category=EntityCategory.CONFIG, + icon="mdi:generator-stationary", ), SolaxModbusSelectEntityDescription( - name = "Generator Discharge Start Time 2", - key = "generator_discharge_start_time_2", - register = 0x10A, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = HYBRID | GEN5 | DCB, - entity_category = EntityCategory.CONFIG, - icon = "mdi:generator-stationary", + name="Generator Discharge Start Time 2", + key="generator_discharge_start_time_2", + register=0x10A, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=HYBRID | GEN5 | DCB, + entity_category=EntityCategory.CONFIG, + icon="mdi:generator-stationary", ), SolaxModbusSelectEntityDescription( - name = "Generator Discharge Stop Time 2", - key = "generator_discharge_stop_time_2", - register = 0x10B, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = HYBRID | GEN5 | DCB, - entity_category = EntityCategory.CONFIG, - icon = "mdi:generator-stationary", + name="Generator Discharge Stop Time 2", + key="generator_discharge_stop_time_2", + register=0x10B, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=HYBRID | GEN5 | DCB, + entity_category=EntityCategory.CONFIG, + icon="mdi:generator-stationary", ), SolaxModbusSelectEntityDescription( - name = "Generator Charge", - key = "generator_charge", - register = 0x10C, - option_dict = { - 0: "Disabled", - 1: "Enabled", - }, - allowedtypes = HYBRID | GEN5 | DCB, - icon = "mdi:dip-switch", + name="Generator Charge", + key="generator_charge", + register=0x10C, + option_dict={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=HYBRID | GEN5 | DCB, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Lease Mode", - key = "lease_mode", - register = 0xB4, - option_dict = { - 0: "Disabled", - 1: "Enabled", - }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - icon = "mdi:dip-switch", + name="Lease Mode", + key="lease_mode", + register=0xB4, + option_dict={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Manual Mode Select", - key = "manual_mode_select", - register = 0x20, - option_dict = { - 0: "Stop Charge and Discharge", - 1: "Force Charge", - 2: "Force Discharge", - }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - icon = "mdi:dip-switch", + name="Manual Mode Select", + key="manual_mode_select", + register=0x20, + option_dict={ + 0: "Stop Charge and Discharge", + 1: "Force Charge", + 2: "Force Discharge", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Manual Mode Control", - key = "manual_mode_control", - register = 0xB6, - option_dict = { - 0: "Off", - 1: "On", - }, - allowedtypes = AC | HYBRID | GEN4, - icon = "mdi:dip-switch", + name="Manual Mode Control", + key="manual_mode_control", + register=0xB6, + option_dict={ + 0: "Off", + 1: "On", + }, + allowedtypes=AC | HYBRID | GEN4, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Parallel Setting", - key = "parallel_setting", - register = 0xC6, - option_dict = { - 0: "Free", - 1: "Master", - 2: "Slave", - }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - entity_category = EntityCategory.CONFIG, - icon = "mdi:dip-switch", + name="Parallel Setting", + key="parallel_setting", + register=0xC6, + option_dict={ + 0: "Free", + 1: "Master", + 2: "Slave", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + entity_category=EntityCategory.CONFIG, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Pgrid Bias", - key = "pgrid_bias", - register = 0x8D, - option_dict = { - 0: "Disabled", - 1: "Grid", - 2: "Inverter", - }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - icon = "mdi:dip-switch", + name="Pgrid Bias", + key="pgrid_bias", + register=0x8D, + option_dict={ + 0: "Disabled", + 1: "Grid", + 2: "Inverter", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Shadow Fix Function Level PV2 (GMPPT)", - key = "shadow_fix_function_level_pv2_gmppt", - register = 0x98, - option_dict = { - 0: "Off", - 1: "Low", - 2: "Middle", - 3: "High", - }, - allowedtypes = HYBRID | GEN4 | GEN5, - icon = "mdi:dip-switch", + name="Shadow Fix Function Level PV2 (GMPPT)", + key="shadow_fix_function_level_pv2_gmppt", + register=0x98, + option_dict={ + 0: "Off", + 1: "Low", + 2: "Middle", + 3: "High", + }, + allowedtypes=HYBRID | GEN4 | GEN5, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Shadow Fix Function Level PV1 (GMPPT)", - key = "shadow_fix_function_level_pv1_gmppt", - register = 0x9C, - option_dict = { - 0: "Off", - 1: "Low", - 2: "Middle", - 3: "High", - }, - allowedtypes = HYBRID | GEN4 | GEN5, - icon = "mdi:dip-switch", + name="Shadow Fix Function Level PV1 (GMPPT)", + key="shadow_fix_function_level_pv1_gmppt", + register=0x9C, + option_dict={ + 0: "Off", + 1: "Low", + 2: "Middle", + 3: "High", + }, + allowedtypes=HYBRID | GEN4 | GEN5, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Phase Power Balance X3", - key = "phase_power_balance_x3", - register = 0x9E, - option_dict = { - 0: "Disabled", - 1: "Enabled", - }, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, - entity_category = EntityCategory.CONFIG, - icon = "mdi:dip-switch", + name="Phase Power Balance X3", + key="phase_power_balance_x3", + register=0x9E, + option_dict={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, + entity_category=EntityCategory.CONFIG, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Schedule", - key = "schedule", - register = 0xBD, - option_dict = { - 0: "Disabled", - 1: "Enabled", - }, - allowedtypes = AC | HYBRID | GEN4 | DCB, - icon = "mdi:dip-switch", + name="Schedule", + key="schedule", + register=0xBD, + option_dict={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN4 | DCB, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Selfuse Mode Backup", - key = "selfuse_mode_backup", - register = 0xC4, - option_dict = { - 0: "Disabled", - 1: "Enabled", - }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - icon = "mdi:dip-switch", + name="Selfuse Mode Backup", + key="selfuse_mode_backup", + register=0xC4, + option_dict={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Selfuse Night Charge Enable", - key = "selfuse_night_charge_enable", - register = 0x62, - option_dict = { - 0: "Disabled", - 1: "Enabled", - }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - icon = "mdi:dip-switch", + name="Selfuse Night Charge Enable", + key="selfuse_night_charge_enable", + register=0x62, + option_dict={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Work End Time 1", - key = "work_end_time_1", - register = 0xBF, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = AC | HYBRID | GEN4 | DCB, - entity_category = EntityCategory.CONFIG, - icon = "mdi:home-clock", + name="Work End Time 1", + key="work_end_time_1", + register=0xBF, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=AC | HYBRID | GEN4 | DCB, + entity_category=EntityCategory.CONFIG, + icon="mdi:home-clock", ), SolaxModbusSelectEntityDescription( - name = "Work End Time 2", - key = "work_end_time_2", - register = 0xC1, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = AC | HYBRID | GEN4 | DCB, - entity_category = EntityCategory.CONFIG, - icon = "mdi:home-clock", + name="Work End Time 2", + key="work_end_time_2", + register=0xC1, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=AC | HYBRID | GEN4 | DCB, + entity_category=EntityCategory.CONFIG, + icon="mdi:home-clock", ), SolaxModbusSelectEntityDescription( - name = "Work Mode", - key = "work_mode", - register = 0xC2, - option_dict = { - 0: "Disabled", - 1: "Manual", - 2: "Smart Save", - }, - allowedtypes = AC | HYBRID | GEN4 | DCB, - icon = "mdi:dip-switch", + name="Work Mode", + key="work_mode", + register=0xC2, + option_dict={ + 0: "Disabled", + 1: "Manual", + 2: "Smart Save", + }, + allowedtypes=AC | HYBRID | GEN4 | DCB, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Work Start Time 1", - key = "work_start_time_1", - register = 0xBE, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = AC | HYBRID | GEN4 | DCB, - entity_category = EntityCategory.CONFIG, - icon = "mdi:home-clock", + name="Work Start Time 1", + key="work_start_time_1", + register=0xBE, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=AC | HYBRID | GEN4 | DCB, + entity_category=EntityCategory.CONFIG, + icon="mdi:home-clock", ), SolaxModbusSelectEntityDescription( - name = "Work Start Time 2", - key = "work_start_time_2", - register = 0xC0, - option_dict = TIME_OPTIONS_GEN4, - allowedtypes = AC | HYBRID | GEN4 | DCB, - entity_category = EntityCategory.CONFIG, - icon = "mdi:home-clock", + name="Work Start Time 2", + key="work_start_time_2", + register=0xC0, + option_dict=TIME_OPTIONS_GEN4, + allowedtypes=AC | HYBRID | GEN4 | DCB, + entity_category=EntityCategory.CONFIG, + icon="mdi:home-clock", ), -##### -# -# MIC -# -##### + ##### + # + # MIC + # + ##### SolaxModbusSelectEntityDescription( - name = "Lock State", - key = "lock_state", - register = 0x600, - option_dict = { - 0: "Locked", - 2014: "Unlocked", - 6868: "Unlocked - Advanced", - }, - allowedtypes = MIC | GEN2 | GEN4, - icon = "mdi:lock-question", + name="Lock State", + key="lock_state", + register=0x600, + option_dict={ + 0: "Locked", + 2014: "Unlocked", + 6868: "Unlocked - Advanced", + }, + allowedtypes=MIC | GEN2 | GEN4, + icon="mdi:lock-question", ), SolaxModbusSelectEntityDescription( - name = "MPPT Scan Mode PV1", - key = "mppt_scan_mode_pv1", - register = 0x601, - option_dict = { - 0: "Off", - 1: "Low", - 2: "Middle", - 3: "High", - }, - allowedtypes = MIC | GEN4, - icon = "mdi:dip-switch", + name="MPPT Scan Mode PV1", + key="mppt_scan_mode_pv1", + register=0x601, + option_dict={ + 0: "Off", + 1: "Low", + 2: "Middle", + 3: "High", + }, + allowedtypes=MIC | GEN4, + icon="mdi:dip-switch", ), - #SolaxModbusSelectEntityDescription( + # SolaxModbusSelectEntityDescription( # name = "MPPT", # key = "mppt", # register = 0x602, @@ -2127,89 +2195,90 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict): # }, # allowedtypes = HYBRID | GEN4, # icon = "mdi:dip-switch", - #), + # ), SolaxModbusSelectEntityDescription( - name = "Q Curve", - key = "q-curve", - register = 0x62F, - option_dict = { - 0: "Off", - 1: "Over Excited", - 2: "Under Excited", - 3: "PF(p)", - 4: "Q(u)", - 5: "FixQPower", - }, - allowedtypes = MIC | GEN4, - icon = "mdi:dip-switch", + name="Q Curve", + key="q-curve", + register=0x62F, + option_dict={ + 0: "Off", + 1: "Over Excited", + 2: "Under Excited", + 3: "PF(p)", + 4: "Q(u)", + 5: "FixQPower", + }, + allowedtypes=MIC | GEN4, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "Q Curve", - key = "q-curve", - register = 0x640, - option_dict = { - 0: "Off", - 1: "Over Excited", - 2: "Under Excited", - 3: "PF(p)", - 4: "Q(u)", - 5: "FixQPower", - }, - allowedtypes = MIC | GEN2 | X3, - icon = "mdi:dip-switch", + name="Q Curve", + key="q-curve", + register=0x640, + option_dict={ + 0: "Off", + 1: "Over Excited", + 2: "Under Excited", + 3: "PF(p)", + 4: "Q(u)", + 5: "FixQPower", + }, + allowedtypes=MIC | GEN2 | X3, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "MPPT Scan Mode PV2", - key = "mppt_scan_mode_pv2", - register = 0x6A6, - option_dict = { - 0: "Off", - 1: "Low", - 2: "Middle", - 3: "High", - }, - allowedtypes = MIC | GEN4, - icon = "mdi:dip-switch", + name="MPPT Scan Mode PV2", + key="mppt_scan_mode_pv2", + register=0x6A6, + option_dict={ + 0: "Off", + 1: "Low", + 2: "Middle", + 3: "High", + }, + allowedtypes=MIC | GEN4, + icon="mdi:dip-switch", ), SolaxModbusSelectEntityDescription( - name = "MPPT Scan Mode PV3", - key = "mppt_scan_mode_pv3", - register = 0x6A7, - option_dict = { - 0: "Off", - 1: "Low", - 2: "Middle", - 3: "High", - }, - allowedtypes = MIC | GEN4 |MPPT3, - icon = "mdi:dip-switch", + name="MPPT Scan Mode PV3", + key="mppt_scan_mode_pv3", + register=0x6A7, + option_dict={ + 0: "Off", + 1: "Low", + 2: "Middle", + 3: "High", + }, + allowedtypes=MIC | GEN4 | MPPT3, + icon="mdi:dip-switch", ), ] # ================================= Sennsor Declarations ============================================================ SENSOR_TYPES_MAIN: list[SolaXModbusSensorEntityDescription] = [ -##### -# -# Holding -# -##### - SolaXModbusSensorEntityDescription( - name = "MateBox enabled", - key = "matebox_enabled", - register = 0x1E, - scale = { + ##### + # + # Holding + # + ##### + SolaXModbusSensorEntityDescription( + name="MateBox enabled", + key="matebox_enabled", + register=0x1E, + scale={ 0: "disabled", - 1: "enabled", }, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN4 | GEN5, - icon = "mdi:dip-switch", + 1: "enabled", + }, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN4 | GEN5, + icon="mdi:dip-switch", ), SolaXModbusSensorEntityDescription( - name = "Safety code", - key = "safety_code", - register = 0x1D, - scale = { + name="Safety code", + key="safety_code", + register=0x1D, + scale={ 0: "VDE0126", 1: "VDE4105", 2: "AS 4777_2020_A", @@ -2247,16 +2316,16 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict): 34: "AS 4777_2020_C", 35: "User Define", 36: "EN50549_Romania", - }, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN4 | GEN5 | X1, - icon = "mdi:dip-switch", + }, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN4 | GEN5 | X1, + icon="mdi:dip-switch", ), SolaXModbusSensorEntityDescription( - name = "Safety code", - key = "safety_code", - register = 0x1D, - scale = { + name="Safety code", + key="safety_code", + register=0x1D, + scale={ 0: "VDE0126", 1: "VDE4105", 2: "AS 4777_2020_A", @@ -2306,493 +2375,517 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict): 46: "CQC", 47: "LA_3P_380", 48: "LA_3P_220", - }, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN4 | GEN5 | X3, - icon = "mdi:dip-switch", + }, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN4 | GEN5 | X3, + icon="mdi:dip-switch", ), SolaXModbusSensorEntityDescription( - key = "firmware_dsp", - register = 0x7D, - allowedtypes = AC | HYBRID, - internal = True, + key="firmware_dsp", + register=0x7D, + allowedtypes=AC | HYBRID, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "Inverter DSP hardware version", - key = "firmware_DSP_hardware_version", - entity_registry_enabled_default = False, - register = 0x7E, - allowedtypes = AC | HYBRID | GEN5, - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:information", + name="Inverter DSP hardware version", + key="firmware_DSP_hardware_version", + entity_registry_enabled_default=False, + register=0x7E, + allowedtypes=AC | HYBRID | GEN5, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:information", ), SolaXModbusSensorEntityDescription( - name = "Inverter DSP firmware major version", - key = "firmware_DSP_major_version", - entity_registry_enabled_default = False, - register = 0x7F, - allowedtypes = AC | HYBRID | GEN5, - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:information", + name="Inverter DSP firmware major version", + key="firmware_DSP_major_version", + entity_registry_enabled_default=False, + register=0x7F, + allowedtypes=AC | HYBRID | GEN5, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:information", ), SolaXModbusSensorEntityDescription( - key = "firmware_arm_major", - register = 0x80, - allowedtypes = AC | HYBRID | GEN5, - internal = True, + key="firmware_arm_major", + register=0x80, + allowedtypes=AC | HYBRID | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "Firmware Version Modbus TCP Major", - key = "firmwareversion_modbustcp_major", - entity_registry_enabled_default = False, - register = 0x81, - allowedtypes = AC | HYBRID | GEN5, - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:information", + name="Firmware Version Modbus TCP Major", + key="firmwareversion_modbustcp_major", + entity_registry_enabled_default=False, + register=0x81, + allowedtypes=AC | HYBRID | GEN5, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:information", ), SolaXModbusSensorEntityDescription( - name = "Firmware Version Modbus TCP Minor", - key = "firmwareversion_modbustcp_minor", - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN5, - register = 0x82, - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:information", + name="Firmware Version Modbus TCP Minor", + key="firmwareversion_modbustcp_minor", + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN5, + register=0x82, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:information", ), SolaXModbusSensorEntityDescription( - key = "firmware_arm", - register = 0x83, - allowedtypes = AC | HYBRID, - internal = True, + key="firmware_arm", + register=0x83, + allowedtypes=AC | HYBRID, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "Bootloader Version", - key = "bootloader_version", - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN5, - register = 0x84, - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:information", + name="Bootloader Version", + key="bootloader_version", + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN5, + register=0x84, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:information", ), SolaXModbusSensorEntityDescription( - name = "RTC", - key = "rtc", - register = 0x85, - unit = REGISTER_WORDS, - wordcount = 6, - scale = value_function_rtc, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:clock", + name="RTC", + key="rtc", + register=0x85, + unit=REGISTER_WORDS, + wordcount=6, + scale=value_function_rtc, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:clock", ), SolaXModbusSensorEntityDescription( - key = "charger_use_mode", - register = 0x8B, - scale = { 0: "Self Use Mode", + key="charger_use_mode", + register=0x8B, + scale={ + 0: "Self Use Mode", 1: "Force Time Use", 2: "Back Up Mode", - 3: "Feedin Priority", }, - allowedtypes = AC | HYBRID | GEN2 | GEN3, - internal = True, + 3: "Feedin Priority", + }, + allowedtypes=AC | HYBRID | GEN2 | GEN3, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "charger_use_mode", - register = 0x8B, - scale = { 0: "Self Use Mode", + key="charger_use_mode", + register=0x8B, + scale={ + 0: "Self Use Mode", 1: "Feedin Priority", 2: "Back Up Mode", 3: "Manual Mode", 4: "PeakShaving", - 5: "Smart Schedule", }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, - ), - SolaXModbusSensorEntityDescription( - key = "battery_minimum_capacity", - register = 0x8C, - allowedtypes = AC | HYBRID | GEN2 | GEN3, - internal = True, - ), - SolaXModbusSensorEntityDescription( - key = "manual_mode_select", - register = 0x8C, - scale = { 0: "Stop Charge and Discharge", - 1: "Force Charge", - 2: "Force Discharge", }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, - ), - SolaXModbusSensorEntityDescription( - name = "Battery Type", - key = "battery_type", - register = 0x8D, - scale = { 0: "Lead Acid", - 1: "Lithium", }, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:battery-unknown", - ), - SolaXModbusSensorEntityDescription( - name = "Battery Charge Float Voltage", - key = "battery_charge_float_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x8E, - scale = 0.01, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Battery Charge Float Voltage", - key = "battery_charge_float_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x8E, - scale = 0.1, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Battery Discharge Cut Off Voltage", - key = "battery_discharge_cut_off_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x8F, - scale = 0.01, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Battery Discharge Cut Off Voltage", - key = "battery_discharge_cut_off_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x8F, - scale = 0.1, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - key = "battery_charge_max_current", - register = 0x90, - scale = 0.01, - allowedtypes = HYBRID | GEN2, - internal = True, - ), - SolaXModbusSensorEntityDescription( - key = "battery_charge_max_current", - register = 0x90, - scale = 0.1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - internal = True, - ), - SolaXModbusSensorEntityDescription( - key = "battery_discharge_max_current", - register = 0x91, - scale = 0.01, - allowedtypes = HYBRID | GEN2, - internal = True, - ), - SolaXModbusSensorEntityDescription( - key = "battery_discharge_max_current", - register = 0x91, - scale = 0.1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - internal = True, - ), - SolaXModbusSensorEntityDescription( - key = "charger_start_time_1", - register = 0x92, - unit = REGISTER_WORDS, - wordcount = 2, - scale = value_function_gen23time, - allowedtypes = AC | HYBRID | GEN2 | GEN3, - internal = True, - ), - SolaXModbusSensorEntityDescription( - key = "selfuse_discharge_min_soc", - register = 0x93, - unit = REGISTER_U8H, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, - ), - SolaXModbusSensorEntityDescription( - key = "selfuse_night_charge_enable", - register = 0x93, - unit = REGISTER_U8L, - scale = { 0: "Disabled", 1: "Enabled", }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, - ), - SolaXModbusSensorEntityDescription( - key = "charger_end_time_1", - register = 0x94, - unit = REGISTER_WORDS, - wordcount = 2, - scale = value_function_gen23time, - allowedtypes = AC | HYBRID | GEN2 | GEN3, - internal = True, - ), - SolaXModbusSensorEntityDescription( - key = "selfuse_nightcharge_upper_soc", - register = 0x94, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, - ), - SolaXModbusSensorEntityDescription( - key = "feedin_nightcharge_upper_soc", - register = 0x95, - unit = REGISTER_U8H, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + 5: "Smart Schedule", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "feedin_discharge_min_soc", - register = 0x95, - unit = REGISTER_U8L, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="battery_minimum_capacity", + register=0x8C, + allowedtypes=AC | HYBRID | GEN2 | GEN3, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "discharger_start_time_1", - register = 0x96, - unit = REGISTER_WORDS, - wordcount = 2, - scale = value_function_gen23time, - allowedtypes = HYBRID | GEN2, - internal = True, + key="manual_mode_select", + register=0x8C, + scale={ + 0: "Stop Charge and Discharge", + 1: "Force Charge", + 2: "Force Discharge", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "backup_nightcharge_upper_soc", - register = 0x96, - unit = REGISTER_U8H, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, - ), - SolaXModbusSensorEntityDescription( - key = "backup_discharge_min_soc", - register = 0x96, - unit = REGISTER_U8L, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + name="Battery Type", + key="battery_type", + register=0x8D, + scale={ + 0: "Lead Acid", + 1: "Lithium", + }, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:battery-unknown", + ), + SolaXModbusSensorEntityDescription( + name="Battery Charge Float Voltage", + key="battery_charge_float_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x8E, + scale=0.01, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Battery Charge Float Voltage", + key="battery_charge_float_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x8E, + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Battery Discharge Cut Off Voltage", + key="battery_discharge_cut_off_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x8F, + scale=0.01, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Battery Discharge Cut Off Voltage", + key="battery_discharge_cut_off_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x8F, + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + key="battery_charge_max_current", + register=0x90, + scale=0.01, + allowedtypes=HYBRID | GEN2, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="battery_charge_max_current", + register=0x90, + scale=0.1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="battery_discharge_max_current", + register=0x91, + scale=0.01, + allowedtypes=HYBRID | GEN2, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="battery_discharge_max_current", + register=0x91, + scale=0.1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="charger_start_time_1", + register=0x92, + unit=REGISTER_WORDS, + wordcount=2, + scale=value_function_gen23time, + allowedtypes=AC | HYBRID | GEN2 | GEN3, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="selfuse_discharge_min_soc", + register=0x93, + unit=REGISTER_U8H, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="selfuse_night_charge_enable", + register=0x93, + unit=REGISTER_U8L, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "charger_start_time_1", - register = 0x97, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="charger_end_time_1", + register=0x94, + unit=REGISTER_WORDS, + wordcount=2, + scale=value_function_gen23time, + allowedtypes=AC | HYBRID | GEN2 | GEN3, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "discharger_end_time_1", - register = 0x98, - unit = REGISTER_WORDS, - wordcount = 2, - scale = value_function_gen23time, - allowedtypes = HYBRID | GEN2, - internal = True, + key="selfuse_nightcharge_upper_soc", + register=0x94, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "charger_end_time_1", - register = 0x98, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="feedin_nightcharge_upper_soc", + register=0x95, + unit=REGISTER_U8H, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "discharger_start_time_1", - register = 0x99, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="feedin_discharge_min_soc", + register=0x95, + unit=REGISTER_U8L, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "charger_start_time_2", - register = 0x9A, - unit = REGISTER_WORDS, - wordcount = 2, - scale = value_function_gen23time, - allowedtypes = AC | HYBRID | GEN2 | GEN3, - internal = True, + key="discharger_start_time_1", + register=0x96, + unit=REGISTER_WORDS, + wordcount=2, + scale=value_function_gen23time, + allowedtypes=HYBRID | GEN2, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "discharger_end_time_1", - register = 0x9A, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="backup_nightcharge_upper_soc", + register=0x96, + unit=REGISTER_U8H, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "charge_and_discharge_period2_enable", - register = 0x9B, - scale = { 0: "Disabled", 1: "Enabled", }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="backup_discharge_min_soc", + register=0x96, + unit=REGISTER_U8L, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "charger_end_time_2", - register = 0x9C, - unit = REGISTER_WORDS, - wordcount = 2, - scale = value_function_gen23time, - allowedtypes = AC | HYBRID | GEN2 | GEN3, - internal = True, + key="charger_start_time_1", + register=0x97, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "charger_start_time_2", - register = 0x9C, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="discharger_end_time_1", + register=0x98, + unit=REGISTER_WORDS, + wordcount=2, + scale=value_function_gen23time, + allowedtypes=HYBRID | GEN2, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "charger_end_time_2", - register = 0x9D, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="charger_end_time_1", + register=0x98, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "discharger_start_time_2", - register = 0x9E, - unit = REGISTER_WORDS, - wordcount = 2, - scale = value_function_gen23time, - allowedtypes = HYBRID | GEN2, - internal = True, + key="discharger_start_time_1", + register=0x99, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "discharger_start_time_2", - register = 0x9E, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="charger_start_time_2", + register=0x9A, + unit=REGISTER_WORDS, + wordcount=2, + scale=value_function_gen23time, + allowedtypes=AC | HYBRID | GEN2 | GEN3, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "discharger_end_time_2", - register = 0x9F, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="discharger_end_time_1", + register=0x9A, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "discharger_end_time_2", - register = 0xA0, - unit = REGISTER_WORDS, - wordcount = 2, - scale = value_function_gen23time, - allowedtypes = HYBRID | GEN2, - internal = True, + key="charge_and_discharge_period2_enable", + register=0x9B, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "hotstandby", - register = 0xA1, - scale = { 0: "Enabled", - 1: "Disabled", }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="charger_end_time_2", + register=0x9C, + unit=REGISTER_WORDS, + wordcount=2, + scale=value_function_gen23time, + allowedtypes=AC | HYBRID | GEN2 | GEN3, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "extend_bms_setting", - register = 0xA2, - scale = { 0: "Disabled", - 1: "Enabled", }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="charger_start_time_2", + register=0x9C, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "battery_heating", - register = 0xA3, - scale = { 0: "Disabled", - 1: "Enabled", }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="charger_end_time_2", + register=0x9D, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "battery_heating_start_time_1", - register = 0xA4, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="discharger_start_time_2", + register=0x9E, + unit=REGISTER_WORDS, + wordcount=2, + scale=value_function_gen23time, + allowedtypes=HYBRID | GEN2, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "battery_heating_end_time_1", - register = 0xA5, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="discharger_start_time_2", + register=0x9E, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "battery_heating_start_time_2", - register = 0xA6, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="discharger_end_time_2", + register=0x9F, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "battery_heating_end_time_2", - register = 0xA7, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="discharger_end_time_2", + register=0xA0, + unit=REGISTER_WORDS, + wordcount=2, + scale=value_function_gen23time, + allowedtypes=HYBRID | GEN2, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "Registration Code Pocket", - key = "registration_code_pocket", - register = 0xAA, - unit = REGISTER_STR, - wordcount = 5, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:information", + key="hotstandby", + register=0xA1, + scale={ + 0: "Enabled", + 1: "Disabled", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "Registration Code Lan", - key = "registration_code_lan", - register = 0xAF, - unit = REGISTER_STR, - wordcount = 5, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN3, - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:information", + key="extend_bms_setting", + register=0xA2, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "pgrid_bias", - register = 0xB2, - scale = { 0: "Disabled", - 1: "Grid", - 2: "Inverter", }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="battery_heating", + register=0xA3, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="battery_heating_start_time_1", + register=0xA4, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="battery_heating_end_time_1", + register=0xA5, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="battery_heating_start_time_2", + register=0xA6, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="battery_heating_end_time_2", + register=0xA7, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, + ), + SolaXModbusSensorEntityDescription( + name="Registration Code Pocket", + key="registration_code_pocket", + register=0xAA, + unit=REGISTER_STR, + wordcount=5, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:information", + ), + SolaXModbusSensorEntityDescription( + name="Registration Code Lan", + key="registration_code_lan", + register=0xAF, + unit=REGISTER_STR, + wordcount=5, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN3, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:information", + ), + SolaXModbusSensorEntityDescription( + key="pgrid_bias", + register=0xB2, + scale={ + 0: "Disabled", + 1: "Grid", + 2: "Inverter", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "allow_grid_charge", - register = 0xB4, - scale = { 0: "Both Forbidden", - 1: "Period 1 Allowed", - 2: "Period 2 Allowed", - 3: "Both Allowed", }, - allowedtypes = AC | HYBRID | GEN2 | GEN3, - internal = True, + key="allow_grid_charge", + register=0xB4, + scale={ + 0: "Both Forbidden", + 1: "Period 1 Allowed", + 2: "Period 2 Allowed", + 3: "Both Allowed", + }, + allowedtypes=AC | HYBRID | GEN2 | GEN3, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "Export Control Factory Limit", - key = "export_control_factory_limit", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - register = 0xB5, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, - icon = "mdi:home-export-outline", + name="Export Control Factory Limit", + key="export_control_factory_limit", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + register=0xB5, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + icon="mdi:home-export-outline", ), SolaXModbusSensorEntityDescription( - key = "export_control_user_limit", - register = 0xB6, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + key="export_control_user_limit", + register=0xB6, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, read_scale_exceptions=EXPORT_LIMIT_SCALE_EXCEPTIONS, internal = True, ), @@ -3138,2637 +3231,3069 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict): internal = True, ), SolaXModbusSensorEntityDescription( - name = "CT Meter Setting", - key = "ct_meter_setting", - register = 0x115, - scale = { 0: "Meter", - 1: "CT", }, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN3 | GEN4 | GEN5, - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:meter-electric", + name="EPS Mute", + key="eps_mute", + register=0xB7, + scale={ + 0: "Off", + 1: "On", + }, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5 | EPS, + icon="mdi:volume-mute", ), SolaXModbusSensorEntityDescription( - key = "meter_1_direction", - register = 0x116, - scale = { 0: "Positive", - 1: "Negative", }, - allowedtypes = AC | HYBRID | GEN3, - internal = True, + name="EPS Set Frequency", + key="eps_set_frequency", + register=0xB8, + scale={ + 0: "50Hz", + 1: "60Hz", + }, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | EPS, + ), + SolaXModbusSensorEntityDescription( + name="EPS Min SOC", + key="eps_min_soc", + native_unit_of_measurement=PERCENTAGE, + register=0xB8, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="EPS frequency", + key="eps_frequency", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0xB9, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Language", + key="language", + register=0xBB, + scale={ + 0: "English", + 1: "Deutsche", + 2: "Francais", + 3: "Polskie", + 4: "Espanol", + 5: "Portugues", + 6: "Italiano", + 7: "Ukrainian", + }, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + icon="mdi:translate-variant", ), SolaXModbusSensorEntityDescription( - key = "meter_2_direction", - register = 0x117, - scale = { 0: "Positive", - 1: "Negative", }, - allowedtypes = AC | HYBRID | GEN3, - internal = True, + key="mppt", + register=0xBC, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=HYBRID | GEN4 | GEN5, + internal=True, + ), + SolaXModbusSensorEntityDescription( + name="Battery Install Capacity", + key="battery_install_capacity", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + entity_registry_enabled_default=False, + register=0xE8, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:battery-sync", + blacklist=("XRE",), + ), + SolaXModbusSensorEntityDescription( + name="Inverter Model Number", + key="inverter_model_number", + register=0xE9, + unit=REGISTER_STR, + wordcount=10, + allowedtypes=AC | HYBRID | GEN3, + entity_registry_enabled_default=False, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:information", + blacklist=("XRE",), + ), + SolaXModbusSensorEntityDescription( + name="Grid Service", + key="grid_service", + register=0xFC, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=HYBRID | GEN2, ), SolaXModbusSensorEntityDescription( - name = "FVRT Function", - key = "fvrt_function", - register = 0x116, - scale = { 0: "Disabled", - 1: "Enabled", }, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | GEN5, + key="backup_gridcharge", + register=0xFD, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN3, + internal=True, + ), + SolaXModbusSensorEntityDescription( + name="Backup Charge Start", + key="backup_charge_start", + register=0xFE, + unit=REGISTER_WORDS, + wordcount=2, + scale=value_function_gen23time, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN3, + icon="mdi:clock-start", + ), + SolaXModbusSensorEntityDescription( + name="Backup Charge End", + key="backup_charge_end", + register=0x100, + unit=REGISTER_WORDS, + wordcount=2, + scale=value_function_gen23time, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN3, + icon="mdi:clock-end", + ), + SolaXModbusSensorEntityDescription( + name="wAS4777 Power Manager", + key="was4777_power_manager", + register=0x102, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN3, + icon="mdi:information", ), SolaXModbusSensorEntityDescription( - name = "FVRT Vac Upper", - key = "fvrt_vac_upper", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x117, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | GEN5, + name="DRM Function Enable", + key="drm_function_enable", + register=0x102, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5, ), SolaXModbusSensorEntityDescription( - name = "FVRT Vac Lower", - key = "fvrt_vac_lower", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x118, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | GEN5, + key="cloud_control", + register=0x103, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN3, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "PV Connection Mode", - key = "pv_connection_mode", - register = 0x11B, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | GEN5, + name="CT Type", + key="ct_type", + register=0x103, + scale={ + 0: "100A", + 1: "200A", + }, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5, ), SolaXModbusSensorEntityDescription( - name = "Shut Down", - key = "shut_down", - register = 0x11C, - scale = { 0: "Disabled", - 1: "Enabled", }, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | GEN5, + name="Global MPPT Function", + key="global_mppt_function", + register=0x104, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN3, + icon="mdi:sun-compass", + ), + SolaXModbusSensorEntityDescription( + key="shadow_fix_function_level_pv1_gmppt", + register=0x104, + scale={ + 0: "Off", + 1: "Low", + 2: "Middle", + 3: "High", + }, + allowedtypes=HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "Micro Grid", - key = "micro_grid", - register = 0x11D, - scale = { 0: "Disabled", - 1: "Enabled", }, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | GEN5, + name="Grid Service X3", + key="grid_service_x3", + register=0x105, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN3 | X3, ), SolaXModbusSensorEntityDescription( - key = "selfuse_mode_backup", - register = 0x11E, - scale = { 0: "Disabled", - 1: "Enabled", }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="phase_power_balance_x3", + register=0x106, + scale={0: "Disabled", 1: "Enabled"}, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "selfuse_backup_soc", - native_unit_of_measurement = PERCENTAGE, - register = 0x11F, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + name="Meter Function", + key="meter_function", + register=0x108, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:meter-electric", + ), + SolaXModbusSensorEntityDescription( + name="Meter 1 id", + key="meter_1_id", + register=0x109, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:meter-electric", + ), + SolaXModbusSensorEntityDescription( + name="Meter 2 id", + key="meter_2_id", + register=0x10A, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:meter-electric", + ), + SolaXModbusSensorEntityDescription( + key="export_duration", + register=0x10B, + scale={ + 4: "Default", + 900: "15 Minutes", + 1800: "30 Minutes", + 3600: "60 Minutes", + 5400: "90 Minutes", + 7200: "120 Minutes", + }, + allowedtypes=AC | HYBRID | GEN3, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "lease_mode", - register = 0x120, - scale = { 0: "Disabled", - 1: "Enabled", }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="forcetime_period_1_max_capacity", + register=0x10C, + allowedtypes=AC | GEN3, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "device_lock", - register = 0x121, - scale = { 0: "Unlock", - 1: "Lock", }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + name="EPS Auto Restart", + key="eps_auto_restart", + register=0x10C, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=HYBRID | GEN3 | EPS, ), - #### - # - # Values need finding on Gen 5 - # - ### SolaXModbusSensorEntityDescription( - key = "manual_mode_control", - register = 0x122, - scale = { 0: "Off", - 1: "On", }, - allowedtypes = AC | HYBRID | GEN4, - internal = True, + key="forcetime_period_2_max_capacity", + register=0x10D, + allowedtypes=AC | GEN3, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "switch_on_soc", - register = 0x124, - allowedtypes = AC | HYBRID | GEN4, - internal = True, + name="CT Meter Setting", + key="ct_meter_setting", + register=0x10E, + scale={ + 0: "Meter", + 1: "CT", + }, + entity_registry_enabled_default=False, + allowedtypes=AC | GEN3, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:meter-electric", ), SolaXModbusSensorEntityDescription( - key = "consume_off_power", - register = 0x125, - allowedtypes = AC | HYBRID | GEN4, - internal = True, + key="battery_charge_upper_soc", + register=0x10E, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "switch_off_soc", - register = 0x126, - allowedtypes = AC | HYBRID | GEN4, - internal = True, + key="battery_to_ev_charger", + register=0x10F, + scale={ + 1: "Enabled", + 0: "Disabled", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "minimum_per_on_signal", - register = 0x127, - allowedtypes = AC | HYBRID | GEN4, - internal = True, + key="forcetime_period_1_max_capacity", + register=0x10F, + allowedtypes=HYBRID | GEN3, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "maximum_per_day_on", - register = 0x128, - allowedtypes = AC | HYBRID | GEN4, - internal = True, + key="forcetime_period_2_max_capacity", + register=0x110, + allowedtypes=HYBRID | GEN3, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "schedule", - register = 0x129, - scale = { 0: "Disabled", - 1: "Enabled", }, - allowedtypes = AC | HYBRID | GEN4, - internal = True, + key="discharge_cut_off_point_different", + register=0x111, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "work_start_time_1", - register = 0x12A, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | DCB, - internal = True, + key="battery_minimum_capacity_gridtied", + register=0x112, + allowedtypes=HYBRID | GEN3, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "Work Stop Time 1", - key = "work_stop_time_1", - register = 0x12B, - scale = value_function_gen4time, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | DCB, - icon = "mdi:home-clock", + name="Discharge Cut Off Voltage Grid Mode", + key="discharge_cut_off_voltage_grid_mode", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x113, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, ), SolaXModbusSensorEntityDescription( - key = "work_start_time_2", - register = 0x12C, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | DCB, - internal = True, + name="Earth Detect X3", + key="earth_detect_x3", + register=0x114, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN3 | X3, ), SolaXModbusSensorEntityDescription( - name = "Work Stop Time 2", - key = "work_stop_time_2", - register = 0x12D, - scale = value_function_gen4time, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | DCB, - icon = "mdi:home-clock", + key="shadow_fix_function_level_pv2_gmppt", + register=0x114, + scale={ + 0: "Off", + 1: "Low", + 2: "Middle", + 3: "High", + }, + allowedtypes=HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "work_mode", - register = 0x12E, - scale = { 0: "Disabled", - 1: "Manua;", - 2: "Smart Save" }, - allowedtypes = AC | HYBRID | GEN4 | DCB, - internal = True, + name="CT Meter Setting", + key="ct_meter_setting", + register=0x115, + scale={ + 0: "Meter", + 1: "CT", + }, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN3 | GEN4 | GEN5, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:meter-electric", ), SolaXModbusSensorEntityDescription( - key = "dry_contact_mode", - register = 0x12F, - scale = { 0: "Load Management", - 1: "Generator Control", }, - allowedtypes = AC | HYBRID | GEN4 | DCB, - internal = True, + key="meter_1_direction", + register=0x116, + scale={ + 0: "Positive", + 1: "Negative", + }, + allowedtypes=AC | HYBRID | GEN3, + internal=True, ), -##### -# -# End of block where Values need finding on Gen 5 -# -##### SolaXModbusSensorEntityDescription( - key = "parallel_setting", - register = 0x130, - scale = { 0: "Free", - 1: "Master", - 2: "Slave" }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="meter_2_direction", + register=0x117, + scale={ + 0: "Positive", + 1: "Negative", + }, + allowedtypes=AC | HYBRID | GEN3, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_control", - register = 0x131, - scale = { 0: "Disabled", - 1: "ATS Control", - 2: "Dry Contact", }, - allowedtypes = AC | HYBRID | GEN4 | GEN5 | DCB, - internal = True, + name="FVRT Function", + key="fvrt_function", + register=0x116, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="FVRT Vac Upper", + key="fvrt_vac_upper", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x117, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="FVRT Vac Lower", + key="fvrt_vac_lower", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x118, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="PV Connection Mode", + key="pv_connection_mode", + register=0x11B, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Shut Down", + key="shut_down", + register=0x11C, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5, ), SolaXModbusSensorEntityDescription( - key = "generator_max_charge", - register = 0x132, - allowedtypes = AC | HYBRID | GEN4 | GEN5 | DCB, - internal = True, + name="Micro Grid", + key="micro_grid", + register=0x11D, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5, ), SolaXModbusSensorEntityDescription( - key = "generator_start_method", - register = 0x140, - scale = { 0: "Reference SOC", - 1: "Immediately", }, - allowedtypes = AC | HYBRID | GEN4 | GEN5 | DCB, - internal = True, + key="selfuse_mode_backup", + register=0x11E, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_switch_on_soc", - register = 0x141, - allowedtypes = AC | HYBRID | GEN4 | GEN5 | DCB, - internal = True, + key="selfuse_backup_soc", + native_unit_of_measurement=PERCENTAGE, + register=0x11F, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_switch_off_soc", - register = 0x142, - allowedtypes = AC | HYBRID | GEN4 | GEN5 | DCB, - internal = True, + key="lease_mode", + register=0x120, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "Generator Max Run Time", - key = "generator_max_run_time", - native_unit_of_measurement = UnitOfTime.MINUTES, - register = 0x143, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | GEN5 | DCB, + key="device_lock", + register=0x121, + scale={ + 0: "Unlock", + 1: "Lock", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), + #### + # + # Values need finding on Gen 5 + # + ### SolaXModbusSensorEntityDescription( - name = "Generator Min Rest Time", - key = "generator_min_rest_time", - native_unit_of_measurement = UnitOfTime.MINUTES, - register = 0x145, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | GEN5 | DCB, + key="manual_mode_control", + register=0x122, + scale={ + 0: "Off", + 1: "On", + }, + allowedtypes=AC | HYBRID | GEN4, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_start_time_1", - register = 0x146, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | GEN5 | DCB, - internal = True, + key="switch_on_soc", + register=0x124, + allowedtypes=AC | HYBRID | GEN4, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_stop_time_1", - register = 0x147, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | GEN5 | DCB, - internal = True, + key="consume_off_power", + register=0x125, + allowedtypes=AC | HYBRID | GEN4, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "Generator Min Power", - key = "generator_min_power", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - register = 0x148, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | GEN5 | DCB, + key="switch_off_soc", + register=0x126, + allowedtypes=AC | HYBRID | GEN4, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "peakshaving_discharge_start_time_1", - register = 0x14F, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="minimum_per_on_signal", + register=0x127, + allowedtypes=AC | HYBRID | GEN4, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "peakshaving_discharge_stop_time_1", - register = 0x150, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="maximum_per_day_on", + register=0x128, + allowedtypes=AC | HYBRID | GEN4, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "peakshaving_discharge_start_time_2", - register = 0x151, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="schedule", + register=0x129, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN4, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "peakshaving_discharge_stop_time_2", - register = 0x152, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="work_start_time_1", + register=0x12A, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "peakshaving_discharge_limit_1", - register = 0x153, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + name="Work Stop Time 1", + key="work_stop_time_1", + register=0x12B, + scale=value_function_gen4time, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | DCB, + icon="mdi:home-clock", ), SolaXModbusSensorEntityDescription( - key = "peakshaving_discharge_limit_2", - register = 0x154, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="work_start_time_2", + register=0x12C, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "peakshaving_charge_from_grid", - register = 0x155, - scale = { 0: "Disabled", - 1: "Enabled", }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + name="Work Stop Time 2", + key="work_stop_time_2", + register=0x12D, + scale=value_function_gen4time, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | DCB, + icon="mdi:home-clock", ), SolaXModbusSensorEntityDescription( - key = "peakshaving_charge_limit", - register = 0x156, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="work_mode", + register=0x12E, + scale={0: "Disabled", 1: "Manua;", 2: "Smart Save"}, + allowedtypes=AC | HYBRID | GEN4 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "peakshaving_max_soc", - register = 0x157, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="dry_contact_mode", + register=0x12F, + scale={ + 0: "Load Management", + 1: "Generator Control", + }, + allowedtypes=AC | HYBRID | GEN4 | DCB, + internal=True, ), + ##### + # + # End of block where Values need finding on Gen 5 + # + ##### SolaXModbusSensorEntityDescription( - key = "peakshaving_reserved_soc", - register = 0x158, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="parallel_setting", + register=0x130, + scale={0: "Free", 1: "Master", 2: "Slave"}, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "shadow_fix3_enable", - register = 0x15F, - scale = { 0: "Off", - 1: "Low", - 2: "Middle", - 3: "High", }, - allowedtypes = HYBRID | GEN5 | MPPT3, - internal = True, + key="generator_control", + register=0x131, + scale={ + 0: "Disabled", + 1: "ATS Control", + 2: "Dry Contact", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "ct_cycle_detection", - register = 0x160, - scale = { 0: "Disabled", - 1: "Enabled", }, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, + key="generator_max_charge", + register=0x132, + allowedtypes=AC | HYBRID | GEN4 | GEN5 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "eps_mode_without_battery", - register = 0x161, - scale = { 0: "Disabled", - 1: "Enabled", }, - allowedtypes = AC | HYBRID | GEN4 | GEN5 | EPS, - internal = True, + key="generator_start_method", + register=0x140, + scale={ + 0: "Reference SOC", + 1: "Immediately", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_charge_start_time_1", - register = 0x162, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | DCB, - internal = True, + key="generator_switch_on_soc", + register=0x141, + allowedtypes=AC | HYBRID | GEN4 | GEN5 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_charge_stop_time_1", - register = 0x163, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | DCB, - internal = True, + key="generator_switch_off_soc", + register=0x142, + allowedtypes=AC | HYBRID | GEN4 | GEN5 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_discharge_start_time_1", - register = 0x164, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | DCB, - internal = True, + name="Generator Max Run Time", + key="generator_max_run_time", + native_unit_of_measurement=UnitOfTime.MINUTES, + register=0x143, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5 | DCB, ), SolaXModbusSensorEntityDescription( - key = "generator_discharge_stop_time_1", - register = 0x165, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | DCB, - internal = True, + name="Generator Min Rest Time", + key="generator_min_rest_time", + native_unit_of_measurement=UnitOfTime.MINUTES, + register=0x145, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5 | DCB, ), SolaXModbusSensorEntityDescription( - key = "generator_time_2", - register = 0x166, - scale = { 0: "Disabled", - 1: "Enabled", }, - allowedtypes = AC | HYBRID | GEN4 | DCB, - internal = True, + key="generator_start_time_1", + register=0x146, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | GEN5 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_charge_start_time_2", - register = 0x167, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | DCB, - internal = True, + key="generator_stop_time_1", + register=0x147, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | GEN5 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_charge_stop_time_2", - register = 0x168, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | DCB, - internal = True, + name="Generator Min Power", + key="generator_min_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + register=0x148, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5 | DCB, ), SolaXModbusSensorEntityDescription( - key = "generator_discharge_start_time_2", - register = 0x169, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | DCB, - internal = True, + key="peakshaving_discharge_start_time_1", + register=0x14F, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_discharge_stop_time_2", - register = 0x16A, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN4 | DCB, - internal = True, + key="peakshaving_discharge_stop_time_1", + register=0x150, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_charge", - register = 0x16B, - scale = { 0: "Disabled", - 1: "Enabled", }, - allowedtypes = AC | HYBRID | GEN4 | DCB, - internal = True, + key="peakshaving_discharge_start_time_2", + register=0x151, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_charge_soc", - register = 0x16C, - allowedtypes = AC | HYBRID | GEN4 | DCB, - internal = True, + key="peakshaving_discharge_stop_time_2", + register=0x152, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), -##### -# -# Gen5 Block -# -# Differs from Gen4 at 0x121 to 0x12F -# -##### SolaXModbusSensorEntityDescription( - key = "generator_charge_start_time_1", - register = 0x124, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN5 | DCB, - internal = True, + key="peakshaving_discharge_limit_1", + register=0x153, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_charge_stop_time_1", - register = 0x125, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN5 | DCB, - internal = True, + key="peakshaving_discharge_limit_2", + register=0x154, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_discharge_start_time_1", - register = 0x126, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN5 | DCB, - internal = True, + key="peakshaving_charge_from_grid", + register=0x155, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_discharge_stop_time_1", - register = 0x127, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN5 | DCB, - internal = True, + key="peakshaving_charge_limit", + register=0x156, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_time_2", - register = 0x128, - scale = { 0: "Disabled", - 1: "Enabled", }, - allowedtypes = AC | HYBRID | GEN5 | DCB, - internal = True, + key="peakshaving_max_soc", + register=0x157, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_charge_start_time_2", - register = 0x129, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN5 | DCB, - internal = True, + key="peakshaving_reserved_soc", + register=0x158, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_charge_stop_time_2", - register = 0x12A, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN5 | DCB, - internal = True, + key="shadow_fix3_enable", + register=0x15F, + scale={ + 0: "Off", + 1: "Low", + 2: "Middle", + 3: "High", + }, + allowedtypes=HYBRID | GEN5 | MPPT3, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_discharge_start_time_2", - register = 0x12B, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN5 | DCB, - internal = True, + key="ct_cycle_detection", + register=0x160, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_discharge_stop_time_2", - register = 0x12C, - scale = value_function_gen4time, - allowedtypes = AC | HYBRID | GEN5 | DCB, - internal = True, + key="eps_mode_without_battery", + register=0x161, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN4 | GEN5 | EPS, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_charge", - register = 0x12D, - scale = { 0: "Disabled", - 1: "Enabled", }, - allowedtypes = AC | HYBRID | GEN5 | DCB, - internal = True, + key="generator_charge_start_time_1", + register=0x162, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "generator_charge_soc", - register = 0x12E, - allowedtypes = AC | HYBRID | GEN5 | DCB, - internal = True, + key="generator_charge_stop_time_1", + register=0x163, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | DCB, + internal=True, ), - ##### - # - # Input - # - ##### SolaXModbusSensorEntityDescription( - name = "Inverter Voltage", - key = "inverter_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x0, - scale = 0.1, - register_type = REG_INPUT, - rounding = 1, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + key="generator_discharge_start_time_1", + register=0x164, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "Inverter Current", - key = "inverter_current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x1, - scale = 0.1, - register_type = REG_INPUT, - unit = REGISTER_S16, - rounding = 1, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + key="generator_discharge_stop_time_1", + register=0x165, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "Inverter Power", - key = "inverter_power", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x2, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + key="generator_time_2", + register=0x166, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN4 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "PV Voltage 1", - key = "pv_voltage_1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x3, - scale = 0.1, - register_type = REG_INPUT, - rounding = 1, - allowedtypes = HYBRID, + key="generator_charge_start_time_2", + register=0x167, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "PV Voltage 2", - key = "pv_voltage_2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x4, - scale = 0.1, - register_type = REG_INPUT, - rounding = 1, - allowedtypes = HYBRID, + key="generator_charge_stop_time_2", + register=0x168, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "PV Current 1", - key = "pv_current_1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x5, - scale = 0.1, - register_type = REG_INPUT, - allowedtypes = HYBRID, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "PV Current 2", - key = "pv_current_2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x6, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "Inverter Frequency", - key = "inverter_frequency", - native_unit_of_measurement = UnitOfFrequency.HERTZ, - state_class = SensorStateClass.MEASUREMENT, - register = 0x7, - scale = 0.01, - rounding = 2, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Inverter Temperature", - key = "inverter_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x8, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXModbusSensorEntityDescription( - name = "Inverter Temperature", - key = "inverter_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x8, - register_type = REG_INPUT, - scale = 0.1, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID | GEN5, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXModbusSensorEntityDescription( - name = "Run Mode", - key = "run_mode", - register = 0x9, - scale = { 0: "Waiting", - 1: "Checking", - 2: "Normal Mode", - 3: "Off Mode", - 4: "Permanent Fault Mode", - 5: "Update Mode", - 6: "EPS Check Mode", - 7: "EPS Mode", - 8: "Self Test", - 9: "Idle Mode", - 10: "Standby", }, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN2 | GEN3, - icon = "mdi:run", - ), - SolaXModbusSensorEntityDescription( - name = "Run Mode", - key = "run_mode", - register = 0x9, - scale = { 0: "Waiting", - 1: "Checking", - 2: "Normal Mode", - 3: "Fault", - 4: "Permanent Fault Mode", - 5: "Update Mode", - 6: "Off-Grid Waiting", - 7: "Off-Grid", - 8: "Self Test", - 9: "Idle Mode", - 10: "Standby", - 20: "Normal (R)", }, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - icon = "mdi:run", - ), - SolaXModbusSensorEntityDescription( - name = "PV Power 1", - key = "pv_power_1", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0xA, - register_type = REG_INPUT, - allowedtypes = HYBRID, - icon = "mdi:solar-power-variant", - ), - SolaXModbusSensorEntityDescription( - name = "PV Power 2", - key = "pv_power_2", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0xB, - register_type = REG_INPUT, - allowedtypes = HYBRID, - icon = "mdi:solar-power-variant", - ), - SolaXModbusSensorEntityDescription( - name = "Time Count Down", - key = "time_count_down", - entity_registry_enabled_default = False, - register = 0x13, - scale = 0.001, - rounding = 0, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, - icon = "mdi:timer", - ), - SolaXModbusSensorEntityDescription( - name = "Battery Voltage Charge", - key = "battery_voltage_charge", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x14, - scale = 0.01, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = HYBRID | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Battery Voltage Charge", - key = "battery_voltage_charge", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x14, - scale = 0.1, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID | GEN3 | GEN4, - ), - SolaXModbusSensorEntityDescription( - name = "Battery 1 Voltage Charge", - key = "battery_1_voltage_charge", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x14, - scale = 0.1, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Battery Current Charge", - key = "battery_current_charge", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x15, - scale = 0.01, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = HYBRID | GEN2, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "Battery Current Charge", - key = "battery_current_charge", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x15, - scale = 0.1, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID | GEN3 | GEN4, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "Battery 1 Current Charge", - key = "battery_1_current_charge", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x15, - scale = 0.1, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID | GEN5, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "Battery Power Charge", - key = "battery_power_charge", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x16, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4, - icon = "mdi:battery-charging", - ), - SolaXModbusSensorEntityDescription( - name = "Battery 1 Power Charge", - key = "battery_1_power_charge", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x16, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID | GEN5, - icon = "mdi:battery-charging", - ), - SolaXModbusSensorEntityDescription( - name = "Temperature Board Charge", - key = "temperature_board_charge", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x17, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = HYBRID | GEN2, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXModbusSensorEntityDescription( - name = "BMS Connect State", - key = "bms_connect_state", - entity_registry_enabled_default = False, - register = 0x17, - scale = { 0: "Disconnected", - 1: "Connected", }, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - icon = "mdi:state-machine", - ), - SolaXModbusSensorEntityDescription( - name = "Battery Temperature", - key = "battery_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x18, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXModbusSensorEntityDescription( - name = "Battery 1 Temperature", - key = "battery_1_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x18, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID | GEN5, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXModbusSensorEntityDescription( - name = "Temperature Boost Charge", - key = "temperature_boost_charge", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x19, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = HYBRID | GEN2, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXModbusSensorEntityDescription( - name = "Grid Status", - key = "grid_status", - entity_registry_enabled_default = False, - register = 0x1A, - scale = { 0: "OnGrid", - 1: "OffGrid", }, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - icon = "mdi:transmission-tower", - ), - SolaXModbusSensorEntityDescription( - name = "Battery Capacity", - key = "battery_capacity", - native_unit_of_measurement = PERCENTAGE, - device_class = SensorDeviceClass.BATTERY, - state_class = SensorStateClass.MEASUREMENT, - register = 0x1C, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4, - ), - SolaXModbusSensorEntityDescription( - name = "Battery 1 Capacity", - key = "battery_1_capacity_charge", - native_unit_of_measurement = PERCENTAGE, - device_class = SensorDeviceClass.BATTERY, - register = 0x1C, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Battery Output Energy Total", # Need revisit these - key = "battery_output_energy_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - icon = "mdi:battery-arrow-down", - register = 0x1D, - register_type = REG_INPUT, - scale = 0.1, - unit = REGISTER_U32,# REGISTER_ULSB16MSB16, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Battery Input Energy Total", - key = "battery_input_energy_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - icon = "mdi:battery-arrow-up", - register = 0x20, - register_type = REG_INPUT, - scale = 0.1, - unit = REGISTER_U32, # REGISTER_ULSB16MSB16, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Battery Output Energy Today", # Need revisit this - key = "battery_output_energy_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - icon = "mdi:battery-arrow-down", - register = 0x20, - register_type = REG_INPUT, - unit = REGISTER_U16, - scale = 0.1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Battery Input Energy Total", - key = "battery_input_energy_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - icon = "mdi:battery-arrow-up", - register = 0x21, - register_type = REG_INPUT, - scale = 0.1, - unit = REGISTER_U32, #REGISTER_ULSB16MSB16, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Battery Package Number", - key = "battery_package_number", - register = 0x22, - register_type = REG_INPUT, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Battery State of Health", - key = "battery_state_of_health", - icon = "mdi:battery-heart", - register = 0x23, - register_type = REG_INPUT, - native_unit_of_measurement = PERCENTAGE, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Battery Input Energy Today", # Need revisit this - key = "battery_input_energy_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - icon = "mdi:battery-arrow-up", - register = 0x23, - register_type = REG_INPUT, - scale = 0.1, - unit = REGISTER_U16, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "BMS Charge Max Current", - key = "bms_charge_max_current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - entity_registry_enabled_default = False, - register = 0x24, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "BMS Discharge Max Current", - key = "bms_discharge_max_current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - entity_registry_enabled_default = False, - register = 0x25, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "BMS Battery Capacity", - key = "bms_battery_capacity", - native_unit_of_measurement = UnitOfEnergy.WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - entity_registry_enabled_default = False, - register = 0x26, - register_type = REG_INPUT, - unit = REGISTER_U32, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Measured Power", - key = "measured_power", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x46, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Grid Export Total", - key = "grid_export_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - entity_registry_enabled_default = False, - register = 0x48, - register_type = REG_INPUT, - unit = REGISTER_S32, #Shouldn't this be UINT? - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, - icon = "mdi:home-export-outline", - ), - SolaXModbusSensorEntityDescription( - name = "Grid Import Total", - key = "grid_import_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - entity_registry_enabled_default = False, - register = 0x4A, - unit = REGISTER_U32, - register_type = REG_INPUT, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, - icon = "mdi:home-import-outline", - ), - SolaXModbusSensorEntityDescription( - name = "EPS Voltage", - key = "eps_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x4C, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5 | X1 | EPS, - ), - SolaXModbusSensorEntityDescription( - name = "EPS Current", - key = "eps_current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x4D, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5 | X1 | EPS, - ), - SolaXModbusSensorEntityDescription( - name = "EPS Power", - key = "eps_power", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - register = 0x4E, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5 | X1 | EPS, - ), - SolaXModbusSensorEntityDescription( - name = "EPS Frequency", - key = "eps_frequency", - native_unit_of_measurement = UnitOfFrequency.HERTZ, - state_class = SensorStateClass.MEASUREMENT, - register = 0x4F, - register_type = REG_INPUT, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5 | EPS, - ), - SolaXModbusSensorEntityDescription( - name = "Today's Solar Energy", - key = "today_s_solar_energy", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - icon = "mdi:solar-power", - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x50, - register_type = REG_INPUT, - unit = REGISTER_S32, - scale = 0.1, - rounding = 2, - allowedtypes = HYBRID | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Today's Yield", - key = "today_s_yield", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x50, - register_type = REG_INPUT, - scale = 0.1, - rounding = 2, # GEN4 | GEN5 might be 1 - allowedtypes = HYBRID | GEN3 | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Total Solar Energy", - key = "total_solar_energy", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - icon = "mdi:solar-power", - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - entity_registry_enabled_default = False, - register = 0x52, - scale = 0.001, - rounding = 2, - register_type = REG_INPUT, - unit = REGISTER_U32, - allowedtypes = HYBRID | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Total Yield", - key = "total_yield", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - icon = "mdi:solar-power", - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x52, - scale = 0.1, - rounding = 2, - register_type = REG_INPUT, - unit = REGISTER_U32, - allowedtypes = HYBRID | GEN3 | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - key = "lock_state", - register = 0x54, - scale = { 0: "Locked", - 1: "Unlocked", - 2: "Unlocked - Advanced", }, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, - internal = True, - ), - SolaXModbusSensorEntityDescription( - name = "Bus Volt", - key = "bus_volt", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - entity_registry_enabled_default = False, - register = 0x66, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "DC Fault Val", - key = "dc_fault_val", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - entity_registry_enabled_default = False, - register = 0x67, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Overload Fault Val", - key = "overload_fault_val", - register = 0x68, - register_type = REG_INPUT, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, - icon = "mdi:alert-circle", - ), - SolaXModbusSensorEntityDescription( - name = "Battery Volt Fault Val", - key = "battery_volt_fault_val", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x69, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Inverter Voltage L1", - key = "inverter_voltage_l1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x6A, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | GEN3 | GEN4 | GEN5 | X3, - ), - SolaXModbusSensorEntityDescription( - name = "Inverter Current L1", - key = "inverter_current_l1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x6B, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | GEN3 | GEN4 | GEN5 | X3, - ), - SolaXModbusSensorEntityDescription( - name = "Inverter Power L1", - key = "inverter_power_l1", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x6C, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, - ), - SolaXModbusSensorEntityDescription( - name = "Inverter Frequency L1", - key = "inverter_frequency_l1", - native_unit_of_measurement = UnitOfFrequency.HERTZ, - state_class = SensorStateClass.MEASUREMENT, - register = 0x6D, - register_type = REG_INPUT, - scale = 0.01, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, - ), - SolaXModbusSensorEntityDescription( - name = "Inverter Voltage L2", - key = "inverter_voltage_l2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x6E, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | GEN3 | GEN4 | GEN5 | X3, - ), - SolaXModbusSensorEntityDescription( - name = "Inverter Current L2", - key = "inverter_current_l2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x6F, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | GEN3 | GEN4 | GEN5 | X3, - ), - SolaXModbusSensorEntityDescription( - name = "Today's Yield", - key = "today_s_yield", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - icon = "mdi:solar-power", - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x70, - register_type = REG_INPUT, - unit = REGISTER_U32, - scale = 0.1, - rounding = 2, - allowedtypes = HYBRID | GEN2, - blacklist=('U50EC',) - ), - SolaXModbusSensorEntityDescription( - name = "Inverter Power L2", - key = "inverter_power_l2", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x70, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, - ), - SolaXModbusSensorEntityDescription( - name = "Inverter Frequency L2", - key = "inverter_frequency_l2", - native_unit_of_measurement = UnitOfFrequency.HERTZ, - state_class = SensorStateClass.MEASUREMENT, - register = 0x71, - register_type = REG_INPUT, - scale = 0.01, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, - ), - SolaXModbusSensorEntityDescription( - name = "Inverter Voltage L3", - key = "inverter_voltage_l3", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x72, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | GEN3 | GEN4 | GEN5 | X3, - ), - SolaXModbusSensorEntityDescription( - name = "Inverter Current L3", - key = "inverter_current_l3", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x73, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | GEN3 | GEN4 | GEN5 | X3, - ), - SolaXModbusSensorEntityDescription( - name = "Inverter Power L3", - key = "inverter_power_l3", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x74, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, - ), - SolaXModbusSensorEntityDescription( - name = "Inverter Frequency L3", - key = "inverter_frequency_l3", - native_unit_of_measurement = UnitOfFrequency.HERTZ, - state_class = SensorStateClass.MEASUREMENT, - register = 0x75, - register_type = REG_INPUT, - scale = 0.01, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, - ), - SolaXModbusSensorEntityDescription( - name = "EPS Voltage L1", - key = "eps_voltage_l1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x76, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, - ), - SolaXModbusSensorEntityDescription( - name = "EPS Current L1", - key = "eps_current_l1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x77, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, - ), - SolaXModbusSensorEntityDescription( - name = "EPS Power Active L1", - key = "eps_power_active_l1", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x78, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, - ), - SolaXModbusSensorEntityDescription( - name = "EPS Power L1", - key = "eps_power_l1", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - register = 0x79, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, - ), - SolaXModbusSensorEntityDescription( - name = "EPS Voltage L2", - key = "eps_voltage_l2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x7A, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, - ), - SolaXModbusSensorEntityDescription( - name = "EPS Current L2", - key = "eps_current_l2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x7B, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, - ), - SolaXModbusSensorEntityDescription( - name = "EPS Power Active L2", - key = "eps_power_active_l2", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x7C, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, - ), - SolaXModbusSensorEntityDescription( - name = "EPS Power L2", - key = "eps_power_l2", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - register = 0x7D, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, - ), - SolaXModbusSensorEntityDescription( - name = "EPS Voltage L3", - key = "eps_voltage_l3", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x7E, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, - ), - SolaXModbusSensorEntityDescription( - name = "EPS Current L3", - key = "eps_current_l3", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x7F, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, - ), - SolaXModbusSensorEntityDescription( - name = "EPS Power Active L3", - key = "eps_power_active_l3", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x80, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, - ), - SolaXModbusSensorEntityDescription( - name = "EPS Power L3", - key = "eps_power_l3", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - register = 0x81, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, - ), - SolaXModbusSensorEntityDescription( - name = "Measured Power L1", - key = "measured_power_l1", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x82, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = HYBRID | GEN3 | GEN4 | GEN5 | X3, - ), - SolaXModbusSensorEntityDescription( - name = "Measured Power L2", - key = "measured_power_l2", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x84, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = HYBRID | GEN3 | GEN4 | GEN5 | X3, - ), - SolaXModbusSensorEntityDescription( - name = "Measured Power L3", - key = "measured_power_l3", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x86, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = HYBRID | GEN3 | GEN4 | GEN5 | X3, - ), - SolaXModbusSensorEntityDescription( - name = "Grid Mode Runtime", - key = "grid_mode_runtime", - native_unit_of_measurement = UnitOfTime.HOURS, - register = 0x88, - register_type = REG_INPUT, - unit = REGISTER_S32, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, - icon = "mdi:timer", - ), - SolaXModbusSensorEntityDescription( - name = "EPS Mode Runtime", - key = "eps_mode_runtime", - native_unit_of_measurement = UnitOfTime.HOURS, - register = 0x8A, - register_type = REG_INPUT, - unit = REGISTER_S32, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, - icon = "mdi:timer", - ), - SolaXModbusSensorEntityDescription( - name = "Normal Runtime", - key = "normal_runtime", - native_unit_of_measurement = UnitOfTime.HOURS, - entity_registry_enabled_default = False, - register = 0x8C, - register_type = REG_INPUT, - unit = REGISTER_S32, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3, - icon = "mdi:timer", - ), - SolaXModbusSensorEntityDescription( - name = "EPS Yield Total", - key = "eps_yield_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x8E, - register_type = REG_INPUT, - unit = REGISTER_U32, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | GEN2 | GEN4 | EPS, - ), - SolaXModbusSensorEntityDescription( - name = "EPS Yield Total", - key = "eps_yield_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x8E, - register_type = REG_INPUT, - unit = REGISTER_U32, - allowedtypes = AC | HYBRID | GEN3 | GEN5 | EPS, - ), - SolaXModbusSensorEntityDescription( - name = "EPS Yield Today", - key = "eps_yield_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x90, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | EPS, - ), - SolaXModbusSensorEntityDescription( - name = "E Charge Today", - key = "e_charge_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - icon = "mdi:solar-power", - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - entity_registry_enabled_default = False, - register = 0x91, - register_type = REG_INPUT, - scale = 0.1, - rounding = 2, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "E Charge Total", - key = "e_charge_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - icon = "mdi:solar-power", - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - entity_registry_enabled_default = False, - register = 0x92, - register_type = REG_INPUT, - unit = REGISTER_U32, - scale = 0.1, - rounding = 2, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Total Solar Energy", - key = "total_solar_energy", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - icon = "mdi:solar-power", - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x94, - register_type = REG_INPUT, - unit = REGISTER_U32, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Today's Solar Energy", - key = "today_s_solar_energy", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - icon = "mdi:solar-power", - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x96, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Today's Export Energy", - key = "today_s_export_energy", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - register = 0x98, - register_type = REG_INPUT, - unit = REGISTER_U32, - scale = 0.01, - rounding = 2, - icon = "mdi:home-export-outline", - ), - SolaXModbusSensorEntityDescription( - name = "Today's Import Energy", - key = "today_s_import_energy", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x9A, - register_type = REG_INPUT, - unit = REGISTER_U32, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - icon = "mdi:home-import-outline", - ), - SolaXModbusSensorEntityDescription( - key = "grid_export_limit", - register = 0x9C, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN3, - internal = True, - ), - SolaXModbusSensorEntityDescription( - name = "Meter 2 Measured Power", - key = "meter_2_measured_power", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0xA8, - register_type = REG_INPUT, - unit = REGISTER_S32, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Meter 2 Export Total", - key = "meter_2_export_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0xAA, - register_type = REG_INPUT, - unit = REGISTER_U32, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - entity_registry_enabled_default = False, - icon = "mdi:home-export-outline", - ), - SolaXModbusSensorEntityDescription( - name = "Meter 2 Import Total", - key = "meter_2_import_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0xAC, - register_type = REG_INPUT, - unit = REGISTER_U32, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - entity_registry_enabled_default = False, - icon = "mdi:home-import-outline", - ), - SolaXModbusSensorEntityDescription( - name = "Meter 2 Export Today", - key = "meter_2_export_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0xAE, - register_type = REG_INPUT, - unit = REGISTER_U32, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - entity_registry_enabled_default = False, - icon = "mdi:home-export-outline", - ), - SolaXModbusSensorEntityDescription( - name = "Meter 2 Import Today", - key = "meter_2_import_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0xB0, - register_type = REG_INPUT, - unit = REGISTER_U32, - scale = 0.01, - rounding = 2, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - entity_registry_enabled_default = False, - icon = "mdi:home-import-outline", - ), - SolaXModbusSensorEntityDescription( - name = "Meter 2 Measured Power L1", - key = "meter_2_measured_power_l1", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0xB2, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, - entity_registry_enabled_default = False, - ), - SolaXModbusSensorEntityDescription( - name = "Meter 2 Measured Power L2", - key = "meter_2_measured_power_l2", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0xB4, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, - entity_registry_enabled_default = False, - ), - SolaXModbusSensorEntityDescription( - name = "Meter 2 Measured Power L3", - key = "meter_2_measured_power_l3", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0xB6, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, - entity_registry_enabled_default = False, - ), - SolaXModbusSensorEntityDescription( - name = "Meter 1 Communication State", - key = "meter_1_communication_state", - register = 0xB8, - register_type = REG_INPUT, - scale = { 0: "Communication Error", - 1: "Normal", }, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXModbusSensorEntityDescription( - name = "Meter 2 Communication State", - key = "meter_2_communication_state", - register = 0xB9, - register_type = REG_INPUT, - scale = { 0: "Communication Error", - 1: "Normal", }, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXModbusSensorEntityDescription( - name = "Battery Temp High", - key = "battery_temp_high", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - register = 0xBA, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Battery Temp Low", - key = "battery_temp_low", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - register = 0xBB, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Cell Voltage High", - key = "cell_voltage_high", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0xBC, - register_type = REG_INPUT, - scale = 0.001, - rounding = 3, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Cell Voltage Low", - key = "cell_voltage_low", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0xBD, - register_type = REG_INPUT, - scale = 0.001, - rounding = 3, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Battery Voltage Cell Difference", - key = "battery_voltage_cell_difference", - value_function= value_function_battery_voltage_cell_difference, - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - state_class = SensorStateClass.MEASUREMENT, - rounding = 3, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Battery State of Health", - key = "battery_soh", - icon = "mdi:battery-heart", - native_unit_of_measurement = PERCENTAGE, - state_class = SensorStateClass.MEASUREMENT, - register = 0xBF, - register_type = REG_INPUT, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Grid Frequency", - key = "grid_frequency", - native_unit_of_measurement = UnitOfFrequency.HERTZ, - state_class = SensorStateClass.MEASUREMENT, - register = 0xC8, - register_type = REG_INPUT, - scale = 0.01, - rounding = 2, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Grid Voltage", - key = "grid_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0xC9, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Grid Voltage L1", - key = "grid_voltage_l1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0xCA, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | GEN5 | X3, - ), - SolaXModbusSensorEntityDescription( - name = "Grid Voltage L2", - key = "grid_voltage_l2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0xCB, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | GEN5 | X3, - ), - SolaXModbusSensorEntityDescription( - name = "Grid Voltage L3", - key = "grid_voltage_l3", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0xCC, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - allowedtypes = AC | HYBRID | GEN4 | GEN5 | X3, - ), - SolaXModbusSensorEntityDescription( - name = "Modbus Power Control", - key = "modbus_power_control", - register = 0x100, - register_type = REG_INPUT, - scale = { - 0: "Disabled", - 1: "Enabled Power Control", - 2: "Enabled Quantity Control", - 3: "Enabled SOC Target Control", - }, - icon = "mdi:dip-switch", - allowedtypes = AC | HYBRID | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Target Finish Flag", - key = "target_finish_flag", - register = 0x101, - register_type = REG_INPUT, - scale = { 0: "Unfinished", - 1: "Finished", }, - icon = "mdi:bullseye-arrow", - allowedtypes = AC | HYBRID | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Active Power Target", - key = "active_power_target", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x102, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Reactive Power Target", - key = "reactive_power_target", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x104, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Active Power Real", - key = "active_power_real", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x106, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Reactive Power Real", - key = "reactive_power_real", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x108, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Active Power Upper", - key = "active_power_upper", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x10A, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Active Power Lower", - key = "active_power_lower", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x10C, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "EPS Min Esc Voltage", - key = "eps_min_esc_voltage", - register = 0x10D, - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - allowedtypes = HYBRID | GEN3 | EPS, - ), - SolaXModbusSensorEntityDescription( - name = "EPS Min Esc SOC", - key = "eps_min_esc_soc", - register = 0x10E, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = HYBRID | GEN3 | EPS, - ), - SolaXModbusSensorEntityDescription( - name = "Reactive Power Upper", - key = "reactive_power_upper", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x10E, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Reactive Power Lower", - key = "reactive_power_lower", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x110, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Charge Discharge Power", - key = "charge_discharge_power", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - entity_registry_enabled_default = False, - register = 0x114, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Chargeable Battery Capacity", - key = "chargeable_battery_capacity", - native_unit_of_measurement = UnitOfEnergy.WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - entity_registry_enabled_default = False, - register = 0x116, - register_type = REG_INPUT, - unit = REGISTER_U32, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Remaining Battery Capacity", - key = "remaining_battery_capacity", - native_unit_of_measurement = UnitOfEnergy.WATT_HOUR, - device_class = SensorDeviceClass.ENERGY_STORAGE, - state_class = SensorStateClass.MEASUREMENT, - entity_registry_enabled_default = False, - register = 0x118, - register_type = REG_INPUT, - unit = REGISTER_U32, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "PV Voltage 3", - key = "pv_voltage_3", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x122, - scale = 0.1, - register_type = REG_INPUT, - rounding = 1, - allowedtypes = HYBRID | GEN5 | MPPT3, - ), - SolaXModbusSensorEntityDescription( - name = "PV Current 3", - key = "pv_current_3", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x123, - scale = 0.1, - register_type = REG_INPUT, - allowedtypes = HYBRID | GEN5 | MPPT3, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "PV Power 3", - key = "pv_power_3", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x124, - register_type = REG_INPUT, - allowedtypes = HYBRID | GEN5 | MPPT3, - icon = "mdi:solar-power-variant", - ), - SolaXModbusSensorEntityDescription( - name = "Battery 2 Voltage Charge", - key = "battery_2_voltage_charge", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x127, - scale = 0.1, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = HYBRID | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Battery 2 Current Charge", - key = "battery_2_current_charge", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x128, - scale = 0.1, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = HYBRID | GEN5, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "Battery 2 Power Charge", - key = "battery_2_power_charge", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x129, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = HYBRID | GEN5, - icon = "mdi:battery-charging", - ), - SolaXModbusSensorEntityDescription( - name = "Battery 2 Capacity", - key = "battery_2_capacity_charge", - native_unit_of_measurement = PERCENTAGE, - device_class = SensorDeviceClass.BATTERY, - register = 0x12D, - register_type = REG_INPUT, - allowedtypes = HYBRID | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Battery Total Capacity", - key = "battery_total_capacity_charge", - native_unit_of_measurement = PERCENTAGE, - device_class = SensorDeviceClass.BATTERY, - register = 0x12E, - register_type = REG_INPUT, - allowedtypes = HYBRID | GEN5, - ), - SolaXModbusSensorEntityDescription( - name = "Battery 2 Temperature", - key = "battery_2_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x132, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID | GEN5, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXModbusSensorEntityDescription( - key = "feedin_on_power", - register = 0x123, - allowedtypes = AC | HYBRID | GEN4 | GEN5, - internal = True, - ), -##### -# -# Input - Parallel Mode -# -##### - SolaXModbusSensorEntityDescription( - name = "PM Inverter Count", - key = "pm_inverter_count", - register = 0x1DD, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - entity_registry_enabled_default = False, - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:information", - ), - SolaXModbusSensorEntityDescription( - name = "PM ActivePower L1", - key = "pm_activepower_l1", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - register = 0x1E0, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - ), - SolaXModbusSensorEntityDescription( - name = "PM ActivePower L2", - key = "pm_activepower_l2", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - register = 0x1E2, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - ), - SolaXModbusSensorEntityDescription( - name = "PM ActivePower L3", - key = "pm_activepower_l3", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - register = 0x1E4, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - ), - SolaXModbusSensorEntityDescription( - name = "PM Reactive or ApparentPower L1", - key = "pm_reactive_or_apparentpower_l1", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - register = 0x1E6, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - ), - SolaXModbusSensorEntityDescription( - name = "PM Reactive or ApparentPower L2", - key = "pm_reactive_or_apparentpower_l2", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - register = 0x1E8, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - ), - SolaXModbusSensorEntityDescription( - name = "PM Reactive or ApparentPower L3", - key = "pm_reactive_or_apparentpower_l3", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - register = 0x1EA, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - ), - SolaXModbusSensorEntityDescription( - name = "PM Inverter Current L1", - key = "pm__current_l1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x1EC, - register_type = REG_INPUT, - unit = REGISTER_S32, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - ), - SolaXModbusSensorEntityDescription( - name = "PM Inverter Current L2", - key = "pm__current_l2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x1EE, - register_type = REG_INPUT, - unit = REGISTER_S32, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - ), - SolaXModbusSensorEntityDescription( - name = "PM Inverter Current L3", - key = "pm__current_l3", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x1F0, - register_type = REG_INPUT, - unit = REGISTER_S32, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - ), - SolaXModbusSensorEntityDescription( - name = "PM PV Power 1", - key = "pm_pv_power_1", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x1F2, - register_type = REG_INPUT, - unit = REGISTER_U32, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - icon = "mdi:solar-power-variant", - ), - SolaXModbusSensorEntityDescription( - name = "PM PV Power 2", - key = "pm_pv_power_2", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x1F4, - register_type = REG_INPUT, - unit = REGISTER_U32, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - icon = "mdi:solar-power-variant", - ), - SolaXModbusSensorEntityDescription( - name = "PM PV Current 1", - key = "pm_pv_current_1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x1F6, - register_type = REG_INPUT, - unit = REGISTER_U32, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "PM PV Current 2", - key = "pm_pv_current_2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x1F8, - register_type = REG_INPUT, - unit = REGISTER_U32, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "PM Battery Power Charge", - key = "pm_battery_power_charge", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x1FA, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - icon = "mdi:battery-charging", - ), - SolaXModbusSensorEntityDescription( - name = "PM Battery Current Charge", - key = "pm_battery_current_charge", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - state_class = SensorStateClass.MEASUREMENT, - register = 0x1FC, - scale = 0.01, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - icon = "mdi:current-dc", - ), - # PM I2 Inverter - SolaXModbusSensorEntityDescription( - name = "PM I2 ActivePower L1", - key = "pm_i2_activepower_l1", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - register = 0x204, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - ), - SolaXModbusSensorEntityDescription( - name = "PM I2 ActivePower L2", - key = "pm_i2_activepower_l2", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - register = 0x205, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + key="generator_discharge_start_time_2", + register=0x169, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "PM I2 ActivePower L3", - key = "pm_i2_activepower_l3", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - register = 0x206, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + key="generator_discharge_stop_time_2", + register=0x16A, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN4 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "PM I2 Reactive or ApparentPower L1", - key = "pm_i2_reactive_or_apparentpower_l1", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - register = 0x207, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + key="generator_charge", + register=0x16B, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN4 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "PM I2 Reactive or ApparentPower L2", - key = "pm_i2_reactive_or_apparentpower_l2", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - register = 0x208, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + key="generator_charge_soc", + register=0x16C, + allowedtypes=AC | HYBRID | GEN4 | DCB, + internal=True, ), + ##### + # + # Gen5 Block + # + # Differs from Gen4 at 0x121 to 0x12F + # + ##### SolaXModbusSensorEntityDescription( - name = "PM I2 Reactive or ApparentPower L3", - key = "pm_i2_reactive_or_apparentpower_l3", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - register = 0x209, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + key="generator_charge_start_time_1", + register=0x124, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN5 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "PM I2 Inverter Current L1", - key = "pm_i2_current_l1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x20A, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + key="generator_charge_stop_time_1", + register=0x125, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN5 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "PM I2 Inverter Current L2", - key = "pm_i2_current_l2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x20B, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + key="generator_discharge_start_time_1", + register=0x126, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN5 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "PM I2 Inverter Current L3", - key = "pm_i2_current_l3", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x20C, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + key="generator_discharge_stop_time_1", + register=0x127, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN5 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "PM I2 PV Power 1", - key = "pm_i2_pv_power_1", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x20D, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - icon = "mdi:solar-power-variant", + key="generator_time_2", + register=0x128, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN5 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "PM I2 PV Power 2", - key = "pm_i2_pv_power_2", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x20E, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - icon = "mdi:solar-power-variant", + key="generator_charge_start_time_2", + register=0x129, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN5 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "PM I2 PV Voltage 1", - key = "pm_i2_pv_voltage_1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x20F, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - icon = "mdi:solar-power-variant", + key="generator_charge_stop_time_2", + register=0x12A, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN5 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "PM I2 PV Voltage 2", - key = "pm_i2_pv_voltage_2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x210, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - icon = "mdi:solar-power-variant", + key="generator_discharge_start_time_2", + register=0x12B, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN5 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "PM I2 PV Current 1", - key = "pm_i2_pv_current_1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x211, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - icon = "mdi:current-dc", + key="generator_discharge_stop_time_2", + register=0x12C, + scale=value_function_gen4time, + allowedtypes=AC | HYBRID | GEN5 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "PM I2 PV Current 2", - key = "pm_i2_pv_current_2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x212, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - icon = "mdi:current-dc", + key="generator_charge", + register=0x12D, + scale={ + 0: "Disabled", + 1: "Enabled", + }, + allowedtypes=AC | HYBRID | GEN5 | DCB, + internal=True, ), SolaXModbusSensorEntityDescription( - name = "PM I2 Battery Power Charge", - key = "pm_i2_battery_power_charge", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x213, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - icon = "mdi:battery-charging", + key="generator_charge_soc", + register=0x12E, + allowedtypes=AC | HYBRID | GEN5 | DCB, + internal=True, + ), + ##### + # + # Input + # + ##### + SolaXModbusSensorEntityDescription( + name="Inverter Voltage", + key="inverter_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x0, + scale=0.1, + register_type=REG_INPUT, + rounding=1, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Current", + key="inverter_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x1, + scale=0.1, + register_type=REG_INPUT, + unit=REGISTER_S16, + rounding=1, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Power", + key="inverter_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x2, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 1", + key="pv_voltage_1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x3, + scale=0.1, + register_type=REG_INPUT, + rounding=1, + allowedtypes=HYBRID, + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 2", + key="pv_voltage_2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x4, + scale=0.1, + register_type=REG_INPUT, + rounding=1, + allowedtypes=HYBRID, + ), + SolaXModbusSensorEntityDescription( + name="PV Current 1", + key="pv_current_1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x5, + scale=0.1, + register_type=REG_INPUT, + allowedtypes=HYBRID, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Current 2", + key="pv_current_2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x6, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="Inverter Frequency", + key="inverter_frequency", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0x7, + scale=0.01, + rounding=2, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Temperature", + key="inverter_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x8, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Temperature", + key="inverter_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x8, + register_type=REG_INPUT, + scale=0.1, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID | GEN5, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="Run Mode", + key="run_mode", + register=0x9, + scale={ + 0: "Waiting", + 1: "Checking", + 2: "Normal Mode", + 3: "Off Mode", + 4: "Permanent Fault Mode", + 5: "Update Mode", + 6: "EPS Check Mode", + 7: "EPS Mode", + 8: "Self Test", + 9: "Idle Mode", + 10: "Standby", + }, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN2 | GEN3, + icon="mdi:run", + ), + SolaXModbusSensorEntityDescription( + name="Run Mode", + key="run_mode", + register=0x9, + scale={ + 0: "Waiting", + 1: "Checking", + 2: "Normal Mode", + 3: "Fault", + 4: "Permanent Fault Mode", + 5: "Update Mode", + 6: "Off-Grid Waiting", + 7: "Off-Grid", + 8: "Self Test", + 9: "Idle Mode", + 10: "Standby", + 20: "Normal (R)", + }, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:run", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 1", + key="pv_power_1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0xA, + register_type=REG_INPUT, + allowedtypes=HYBRID, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 2", + key="pv_power_2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0xB, + register_type=REG_INPUT, + allowedtypes=HYBRID, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="Time Count Down", + key="time_count_down", + entity_registry_enabled_default=False, + register=0x13, + scale=0.001, + rounding=0, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + icon="mdi:timer", + ), + SolaXModbusSensorEntityDescription( + name="Battery Voltage Charge", + key="battery_voltage_charge", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x14, + scale=0.01, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=HYBRID | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Battery Voltage Charge", + key="battery_voltage_charge", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x14, + scale=0.1, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID | GEN3 | GEN4, + ), + SolaXModbusSensorEntityDescription( + name="Battery 1 Voltage Charge", + key="battery_1_voltage_charge", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x14, + scale=0.1, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Battery Current Charge", + key="battery_current_charge", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x15, + scale=0.01, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=HYBRID | GEN2, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="Battery Current Charge", + key="battery_current_charge", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x15, + scale=0.1, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID | GEN3 | GEN4, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="Battery 1 Current Charge", + key="battery_1_current_charge", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x15, + scale=0.1, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID | GEN5, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="Battery Power Charge", + key="battery_power_charge", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x16, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4, + icon="mdi:battery-charging", + ), + SolaXModbusSensorEntityDescription( + name="Battery 1 Power Charge", + key="battery_1_power_charge", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x16, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID | GEN5, + icon="mdi:battery-charging", + ), + SolaXModbusSensorEntityDescription( + name="Temperature Board Charge", + key="temperature_board_charge", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x17, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=HYBRID | GEN2, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="BMS Connect State", + key="bms_connect_state", + entity_registry_enabled_default=False, + register=0x17, + scale={ + 0: "Disconnected", + 1: "Connected", + }, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + icon="mdi:state-machine", + ), + SolaXModbusSensorEntityDescription( + name="Battery Temperature", + key="battery_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x18, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="Battery 1 Temperature", + key="battery_1_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x18, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID | GEN5, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="Temperature Boost Charge", + key="temperature_boost_charge", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x19, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=HYBRID | GEN2, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="Grid Status", + key="grid_status", + entity_registry_enabled_default=False, + register=0x1A, + scale={ + 0: "OnGrid", + 1: "OffGrid", + }, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:transmission-tower", + ), + SolaXModbusSensorEntityDescription( + name="Battery Capacity", + key="battery_capacity", + native_unit_of_measurement=PERCENTAGE, + device_class=SensorDeviceClass.BATTERY, + state_class=SensorStateClass.MEASUREMENT, + register=0x1C, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4, + ), + SolaXModbusSensorEntityDescription( + name="Battery 1 Capacity", + key="battery_1_capacity_charge", + native_unit_of_measurement=PERCENTAGE, + device_class=SensorDeviceClass.BATTERY, + register=0x1C, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Battery Output Energy Total", # Need revisit these + key="battery_output_energy_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + icon="mdi:battery-arrow-down", + register=0x1D, + register_type=REG_INPUT, + scale=0.1, + unit=REGISTER_U32, # REGISTER_ULSB16MSB16, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Battery Input Energy Total", + key="battery_input_energy_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + icon="mdi:battery-arrow-up", + register=0x20, + register_type=REG_INPUT, + scale=0.1, + unit=REGISTER_U32, # REGISTER_ULSB16MSB16, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Battery Output Energy Today", # Need revisit this + key="battery_output_energy_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + icon="mdi:battery-arrow-down", + register=0x20, + register_type=REG_INPUT, + unit=REGISTER_U16, + scale=0.1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Battery Input Energy Total", + key="battery_input_energy_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + icon="mdi:battery-arrow-up", + register=0x21, + register_type=REG_INPUT, + scale=0.1, + unit=REGISTER_U32, # REGISTER_ULSB16MSB16, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Battery Package Number", + key="battery_package_number", + register=0x22, + register_type=REG_INPUT, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Battery State of Health", + key="battery_state_of_health", + icon="mdi:battery-heart", + register=0x23, + register_type=REG_INPUT, + native_unit_of_measurement=PERCENTAGE, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Battery Input Energy Today", # Need revisit this + key="battery_input_energy_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + icon="mdi:battery-arrow-up", + register=0x23, + register_type=REG_INPUT, + scale=0.1, + unit=REGISTER_U16, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="BMS Charge Max Current", + key="bms_charge_max_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + entity_registry_enabled_default=False, + register=0x24, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="BMS Discharge Max Current", + key="bms_discharge_max_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + entity_registry_enabled_default=False, + register=0x25, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="BMS Battery Capacity", + key="bms_battery_capacity", + native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + entity_registry_enabled_default=False, + register=0x26, + register_type=REG_INPUT, + unit=REGISTER_U32, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Measured Power", + key="measured_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x46, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Grid Export Total", + key="grid_export_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + entity_registry_enabled_default=False, + register=0x48, + register_type=REG_INPUT, + unit=REGISTER_S32, # Shouldn't this be UINT? + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + icon="mdi:home-export-outline", + ), + SolaXModbusSensorEntityDescription( + name="Grid Import Total", + key="grid_import_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + entity_registry_enabled_default=False, + register=0x4A, + unit=REGISTER_U32, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + icon="mdi:home-import-outline", + ), + SolaXModbusSensorEntityDescription( + name="EPS Voltage", + key="eps_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x4C, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5 | X1 | EPS, + ), + SolaXModbusSensorEntityDescription( + name="EPS Current", + key="eps_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x4D, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5 | X1 | EPS, + ), + SolaXModbusSensorEntityDescription( + name="EPS Power", + key="eps_power", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + register=0x4E, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5 | X1 | EPS, + ), + SolaXModbusSensorEntityDescription( + name="EPS Frequency", + key="eps_frequency", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0x4F, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5 | EPS, + ), + SolaXModbusSensorEntityDescription( + name="Today's Solar Energy", + key="today_s_solar_energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x50, + register_type=REG_INPUT, + unit=REGISTER_S32, + scale=0.1, + rounding=2, + allowedtypes=HYBRID | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Today's Yield", + key="today_s_yield", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x50, + register_type=REG_INPUT, + scale=0.1, + rounding=2, # GEN4 | GEN5 might be 1 + allowedtypes=HYBRID | GEN3 | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Total Solar Energy", + key="total_solar_energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + entity_registry_enabled_default=False, + register=0x52, + scale=0.001, + rounding=2, + register_type=REG_INPUT, + unit=REGISTER_U32, + allowedtypes=HYBRID | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Total Yield", + key="total_yield", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x52, + scale=0.1, + rounding=2, + register_type=REG_INPUT, + unit=REGISTER_U32, + allowedtypes=HYBRID | GEN3 | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + key="lock_state", + register=0x54, + scale={ + 0: "Locked", + 1: "Unlocked", + 2: "Unlocked - Advanced", + }, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + internal=True, + ), + SolaXModbusSensorEntityDescription( + name="Bus Volt", + key="bus_volt", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + entity_registry_enabled_default=False, + register=0x66, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="DC Fault Val", + key="dc_fault_val", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + entity_registry_enabled_default=False, + register=0x67, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Overload Fault Val", + key="overload_fault_val", + register=0x68, + register_type=REG_INPUT, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + icon="mdi:alert-circle", + ), + SolaXModbusSensorEntityDescription( + name="Battery Volt Fault Val", + key="battery_volt_fault_val", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x69, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Voltage L1", + key="inverter_voltage_l1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x6A, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | GEN3 | GEN4 | GEN5 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Current L1", + key="inverter_current_l1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x6B, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | GEN3 | GEN4 | GEN5 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Power L1", + key="inverter_power_l1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x6C, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Frequency L1", + key="inverter_frequency_l1", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0x6D, + register_type=REG_INPUT, + scale=0.01, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Voltage L2", + key="inverter_voltage_l2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x6E, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | GEN3 | GEN4 | GEN5 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Current L2", + key="inverter_current_l2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x6F, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | GEN3 | GEN4 | GEN5 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Today's Yield", + key="today_s_yield", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x70, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.1, + rounding=2, + allowedtypes=HYBRID | GEN2, + blacklist=("U50EC",), + ), + SolaXModbusSensorEntityDescription( + name="Inverter Power L2", + key="inverter_power_l2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x70, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Frequency L2", + key="inverter_frequency_l2", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0x71, + register_type=REG_INPUT, + scale=0.01, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Voltage L3", + key="inverter_voltage_l3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x72, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | GEN3 | GEN4 | GEN5 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Current L3", + key="inverter_current_l3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x73, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | GEN3 | GEN4 | GEN5 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Power L3", + key="inverter_power_l3", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x74, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Frequency L3", + key="inverter_frequency_l3", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0x75, + register_type=REG_INPUT, + scale=0.01, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, + ), + SolaXModbusSensorEntityDescription( + name="EPS Voltage L1", + key="eps_voltage_l1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x76, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, + ), + SolaXModbusSensorEntityDescription( + name="EPS Current L1", + key="eps_current_l1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x77, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, + ), + SolaXModbusSensorEntityDescription( + name="EPS Power Active L1", + key="eps_power_active_l1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x78, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, + ), + SolaXModbusSensorEntityDescription( + name="EPS Power L1", + key="eps_power_l1", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + register=0x79, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, + ), + SolaXModbusSensorEntityDescription( + name="EPS Voltage L2", + key="eps_voltage_l2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x7A, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, + ), + SolaXModbusSensorEntityDescription( + name="EPS Current L2", + key="eps_current_l2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x7B, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, + ), + SolaXModbusSensorEntityDescription( + name="EPS Power Active L2", + key="eps_power_active_l2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x7C, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, + ), + SolaXModbusSensorEntityDescription( + name="EPS Power L2", + key="eps_power_l2", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + register=0x7D, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, + ), + SolaXModbusSensorEntityDescription( + name="EPS Voltage L3", + key="eps_voltage_l3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x7E, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, + ), + SolaXModbusSensorEntityDescription( + name="EPS Current L3", + key="eps_current_l3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x7F, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, + ), + SolaXModbusSensorEntityDescription( + name="EPS Power Active L3", + key="eps_power_active_l3", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x80, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, + ), + SolaXModbusSensorEntityDescription( + name="EPS Power L3", + key="eps_power_l3", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + register=0x81, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, + ), + SolaXModbusSensorEntityDescription( + name="Measured Power L1", + key="measured_power_l1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x82, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID | GEN3 | GEN4 | GEN5 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Measured Power L2", + key="measured_power_l2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x84, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID | GEN3 | GEN4 | GEN5 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Measured Power L3", + key="measured_power_l3", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x86, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID | GEN3 | GEN4 | GEN5 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Grid Mode Runtime", + key="grid_mode_runtime", + native_unit_of_measurement=UnitOfTime.HOURS, + register=0x88, + register_type=REG_INPUT, + unit=REGISTER_S32, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, + icon="mdi:timer", + ), + SolaXModbusSensorEntityDescription( + name="EPS Mode Runtime", + key="eps_mode_runtime", + native_unit_of_measurement=UnitOfTime.HOURS, + register=0x8A, + register_type=REG_INPUT, + unit=REGISTER_S32, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3 | EPS, + icon="mdi:timer", + ), + SolaXModbusSensorEntityDescription( + name="Normal Runtime", + key="normal_runtime", + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + register=0x8C, + register_type=REG_INPUT, + unit=REGISTER_S32, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3, + icon="mdi:timer", + ), + SolaXModbusSensorEntityDescription( + name="EPS Yield Total", + key="eps_yield_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x8E, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | GEN2 | GEN4 | EPS, + ), + SolaXModbusSensorEntityDescription( + name="EPS Yield Total", + key="eps_yield_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x8E, + register_type=REG_INPUT, + unit=REGISTER_U32, + allowedtypes=AC | HYBRID | GEN3 | GEN5 | EPS, + ), + SolaXModbusSensorEntityDescription( + name="EPS Yield Today", + key="eps_yield_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x90, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | EPS, + ), + SolaXModbusSensorEntityDescription( + name="E Charge Today", + key="e_charge_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + entity_registry_enabled_default=False, + register=0x91, + register_type=REG_INPUT, + scale=0.1, + rounding=2, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="E Charge Total", + key="e_charge_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + entity_registry_enabled_default=False, + register=0x92, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.1, + rounding=2, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Total Solar Energy", + key="total_solar_energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x94, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Today's Solar Energy", + key="today_s_solar_energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x96, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Today's Export Energy", + key="today_s_export_energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + register=0x98, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.01, + rounding=2, + icon="mdi:home-export-outline", + ), + SolaXModbusSensorEntityDescription( + name="Today's Import Energy", + key="today_s_import_energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x9A, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + icon="mdi:home-import-outline", + ), + SolaXModbusSensorEntityDescription( + key="grid_export_limit", + register=0x9C, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN3, + internal=True, + ), + SolaXModbusSensorEntityDescription( + name="Meter 2 Measured Power", + key="meter_2_measured_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0xA8, + register_type=REG_INPUT, + unit=REGISTER_S32, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Meter 2 Export Total", + key="meter_2_export_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0xAA, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + entity_registry_enabled_default=False, + icon="mdi:home-export-outline", + ), + SolaXModbusSensorEntityDescription( + name="Meter 2 Import Total", + key="meter_2_import_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0xAC, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + entity_registry_enabled_default=False, + icon="mdi:home-import-outline", + ), + SolaXModbusSensorEntityDescription( + name="Meter 2 Export Today", + key="meter_2_export_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0xAE, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + entity_registry_enabled_default=False, + icon="mdi:home-export-outline", + ), + SolaXModbusSensorEntityDescription( + name="Meter 2 Import Today", + key="meter_2_import_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0xB0, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.01, + rounding=2, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + entity_registry_enabled_default=False, + icon="mdi:home-import-outline", + ), + SolaXModbusSensorEntityDescription( + name="Meter 2 Measured Power L1", + key="meter_2_measured_power_l1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0xB2, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, + entity_registry_enabled_default=False, + ), + SolaXModbusSensorEntityDescription( + name="Meter 2 Measured Power L2", + key="meter_2_measured_power_l2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0xB4, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, + entity_registry_enabled_default=False, + ), + SolaXModbusSensorEntityDescription( + name="Meter 2 Measured Power L3", + key="meter_2_measured_power_l3", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0xB6, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | X3, + entity_registry_enabled_default=False, + ), + SolaXModbusSensorEntityDescription( + name="Meter 1 Communication State", + key="meter_1_communication_state", + register=0xB8, + register_type=REG_INPUT, + scale={ + 0: "Communication Error", + 1: "Normal", + }, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="Meter 2 Communication State", + key="meter_2_communication_state", + register=0xB9, + register_type=REG_INPUT, + scale={ + 0: "Communication Error", + 1: "Normal", + }, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="Battery Temp High", + key="battery_temp_high", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + register=0xBA, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Battery Temp Low", + key="battery_temp_low", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + register=0xBB, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Cell Voltage High", + key="cell_voltage_high", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0xBC, + register_type=REG_INPUT, + scale=0.001, + rounding=3, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Cell Voltage Low", + key="cell_voltage_low", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0xBD, + register_type=REG_INPUT, + scale=0.001, + rounding=3, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Battery Voltage Cell Difference", + key="battery_voltage_cell_difference", + value_function=value_function_battery_voltage_cell_difference, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, + rounding=3, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Battery State of Health", + key="battery_soh", + icon="mdi:battery-heart", + native_unit_of_measurement=PERCENTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=0xBF, + register_type=REG_INPUT, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Grid Frequency", + key="grid_frequency", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0xC8, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Grid Voltage", + key="grid_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0xC9, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Grid Voltage L1", + key="grid_voltage_l1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0xCA, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Grid Voltage L2", + key="grid_voltage_l2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0xCB, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Grid Voltage L3", + key="grid_voltage_l3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0xCC, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=AC | HYBRID | GEN4 | GEN5 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Modbus Power Control", + key="modbus_power_control", + register=0x100, + register_type=REG_INPUT, + scale={ + 0: "Disabled", + 1: "Enabled Power Control", + 2: "Enabled Quantity Control", + 3: "Enabled SOC Target Control", + }, + icon="mdi:dip-switch", + allowedtypes=AC | HYBRID | GEN4 | GEN5, ), SolaXModbusSensorEntityDescription( - name = "PM I2 Battery Voltage Charge", - key = "pm_i2_battery_voltage_charge", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x214, - scale = 0.1, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + name="Target Finish Flag", + key="target_finish_flag", + register=0x101, + register_type=REG_INPUT, + scale={ + 0: "Unfinished", + 1: "Finished", + }, + icon="mdi:bullseye-arrow", + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Active Power Target", + key="active_power_target", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x102, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Reactive Power Target", + key="reactive_power_target", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x104, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Active Power Real", + key="active_power_real", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x106, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Reactive Power Real", + key="reactive_power_real", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x108, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Active Power Upper", + key="active_power_upper", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x10A, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Active Power Lower", + key="active_power_lower", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x10C, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="EPS Min Esc Voltage", + key="eps_min_esc_voltage", + register=0x10D, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + allowedtypes=HYBRID | GEN3 | EPS, + ), + SolaXModbusSensorEntityDescription( + name="EPS Min Esc SOC", + key="eps_min_esc_soc", + register=0x10E, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=HYBRID | GEN3 | EPS, + ), + SolaXModbusSensorEntityDescription( + name="Reactive Power Upper", + key="reactive_power_upper", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x10E, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Reactive Power Lower", + key="reactive_power_lower", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x110, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Charge Discharge Power", + key="charge_discharge_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + entity_registry_enabled_default=False, + register=0x114, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Chargeable Battery Capacity", + key="chargeable_battery_capacity", + native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + entity_registry_enabled_default=False, + register=0x116, + register_type=REG_INPUT, + unit=REGISTER_U32, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Remaining Battery Capacity", + key="remaining_battery_capacity", + native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, + device_class=SensorDeviceClass.ENERGY_STORAGE, + state_class=SensorStateClass.MEASUREMENT, + entity_registry_enabled_default=False, + register=0x118, + register_type=REG_INPUT, + unit=REGISTER_U32, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 3", + key="pv_voltage_3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x122, + scale=0.1, + register_type=REG_INPUT, + rounding=1, + allowedtypes=HYBRID | GEN5 | MPPT3, + ), + SolaXModbusSensorEntityDescription( + name="PV Current 3", + key="pv_current_3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x123, + scale=0.1, + register_type=REG_INPUT, + allowedtypes=HYBRID | GEN5 | MPPT3, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 3", + key="pv_power_3", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x124, + register_type=REG_INPUT, + allowedtypes=HYBRID | GEN5 | MPPT3, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="Battery 2 Voltage Charge", + key="battery_2_voltage_charge", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x127, + scale=0.1, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=HYBRID | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Battery 2 Current Charge", + key="battery_2_current_charge", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x128, + scale=0.1, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=HYBRID | GEN5, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="Battery 2 Power Charge", + key="battery_2_power_charge", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x129, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=HYBRID | GEN5, + icon="mdi:battery-charging", + ), + SolaXModbusSensorEntityDescription( + name="Battery 2 Capacity", + key="battery_2_capacity_charge", + native_unit_of_measurement=PERCENTAGE, + device_class=SensorDeviceClass.BATTERY, + register=0x12D, + register_type=REG_INPUT, + allowedtypes=HYBRID | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Battery Total Capacity", + key="battery_total_capacity_charge", + native_unit_of_measurement=PERCENTAGE, + device_class=SensorDeviceClass.BATTERY, + register=0x12E, + register_type=REG_INPUT, + allowedtypes=HYBRID | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="Battery 2 Temperature", + key="battery_2_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x132, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID | GEN5, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + key="feedin_on_power", + register=0x123, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + internal=True, ), + ##### + # + # Input - Parallel Mode + # + ##### SolaXModbusSensorEntityDescription( - name = "PM I2 Battery Current Charge", - key = "pm_i2_battery_current_charge", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x215, - scale = 0.1, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, - icon = "mdi:current-dc", + name="PM Inverter Count", + key="pm_inverter_count", + register=0x1DD, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + entity_registry_enabled_default=False, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:information", + ), + SolaXModbusSensorEntityDescription( + name="PM ActivePower L1", + key="pm_activepower_l1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + register=0x1E0, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + ), + SolaXModbusSensorEntityDescription( + name="PM ActivePower L2", + key="pm_activepower_l2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + register=0x1E2, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + ), + SolaXModbusSensorEntityDescription( + name="PM ActivePower L3", + key="pm_activepower_l3", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + register=0x1E4, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + ), + SolaXModbusSensorEntityDescription( + name="PM Reactive or ApparentPower L1", + key="pm_reactive_or_apparentpower_l1", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=0x1E6, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + ), + SolaXModbusSensorEntityDescription( + name="PM Reactive or ApparentPower L2", + key="pm_reactive_or_apparentpower_l2", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=0x1E8, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + ), + SolaXModbusSensorEntityDescription( + name="PM Reactive or ApparentPower L3", + key="pm_reactive_or_apparentpower_l3", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=0x1EA, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + ), + SolaXModbusSensorEntityDescription( + name="PM Inverter Current L1", + key="pm__current_l1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x1EC, + register_type=REG_INPUT, + unit=REGISTER_S32, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + ), + SolaXModbusSensorEntityDescription( + name="PM Inverter Current L2", + key="pm__current_l2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x1EE, + register_type=REG_INPUT, + unit=REGISTER_S32, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + ), + SolaXModbusSensorEntityDescription( + name="PM Inverter Current L3", + key="pm__current_l3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x1F0, + register_type=REG_INPUT, + unit=REGISTER_S32, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + ), + SolaXModbusSensorEntityDescription( + name="PM PV Power 1", + key="pm_pv_power_1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x1F2, + register_type=REG_INPUT, + unit=REGISTER_U32, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="PM PV Power 2", + key="pm_pv_power_2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x1F4, + register_type=REG_INPUT, + unit=REGISTER_U32, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="PM PV Current 1", + key="pm_pv_current_1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x1F6, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PM PV Current 2", + key="pm_pv_current_2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x1F8, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PM Battery Power Charge", + key="pm_battery_power_charge", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x1FA, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + icon="mdi:battery-charging", + ), + SolaXModbusSensorEntityDescription( + name="PM Battery Current Charge", + key="pm_battery_current_charge", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=0x1FC, + scale=0.01, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + icon="mdi:current-dc", ), + # PM I2 Inverter SolaXModbusSensorEntityDescription( - name = "PM I2 Battery Capacity", - key = "pm_i2_battery_capacity_charge", - native_unit_of_measurement = PERCENTAGE, - device_class = SensorDeviceClass.BATTERY, - register = 0x219, - register_type = REG_INPUT, - allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + name="PM I2 ActivePower L1", + key="pm_i2_activepower_l1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + register=0x204, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + ), + SolaXModbusSensorEntityDescription( + name="PM I2 ActivePower L2", + key="pm_i2_activepower_l2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + register=0x205, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + ), + SolaXModbusSensorEntityDescription( + name="PM I2 ActivePower L3", + key="pm_i2_activepower_l3", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + register=0x206, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + ), + SolaXModbusSensorEntityDescription( + name="PM I2 Reactive or ApparentPower L1", + key="pm_i2_reactive_or_apparentpower_l1", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=0x207, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + ), + SolaXModbusSensorEntityDescription( + name="PM I2 Reactive or ApparentPower L2", + key="pm_i2_reactive_or_apparentpower_l2", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=0x208, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + ), + SolaXModbusSensorEntityDescription( + name="PM I2 Reactive or ApparentPower L3", + key="pm_i2_reactive_or_apparentpower_l3", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=0x209, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + ), + SolaXModbusSensorEntityDescription( + name="PM I2 Inverter Current L1", + key="pm_i2_current_l1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x20A, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + ), + SolaXModbusSensorEntityDescription( + name="PM I2 Inverter Current L2", + key="pm_i2_current_l2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x20B, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + ), + SolaXModbusSensorEntityDescription( + name="PM I2 Inverter Current L3", + key="pm_i2_current_l3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x20C, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + ), + SolaXModbusSensorEntityDescription( + name="PM I2 PV Power 1", + key="pm_i2_pv_power_1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x20D, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="PM I2 PV Power 2", + key="pm_i2_pv_power_2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x20E, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="PM I2 PV Voltage 1", + key="pm_i2_pv_voltage_1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=0x20F, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="PM I2 PV Voltage 2", + key="pm_i2_pv_voltage_2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=0x210, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="PM I2 PV Current 1", + key="pm_i2_pv_current_1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x211, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PM I2 PV Current 2", + key="pm_i2_pv_current_2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x212, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PM I2 Battery Power Charge", + key="pm_i2_battery_power_charge", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x213, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + icon="mdi:battery-charging", + ), + SolaXModbusSensorEntityDescription( + name="PM I2 Battery Voltage Charge", + key="pm_i2_battery_voltage_charge", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x214, + scale=0.1, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + ), + SolaXModbusSensorEntityDescription( + name="PM I2 Battery Current Charge", + key="pm_i2_battery_current_charge", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x215, + scale=0.1, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PM I2 Battery Capacity", + key="pm_i2_battery_capacity_charge", + native_unit_of_measurement=PERCENTAGE, + device_class=SensorDeviceClass.BATTERY, + register=0x219, + register_type=REG_INPUT, + allowedtypes=AC | HYBRID | GEN3 | GEN4 | GEN5 | PM, ), # PM I3 Inverter SolaXModbusSensorEntityDescription( @@ -7453,45 +7978,1507 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict): icon = "mdi:solar-power-variant", ), SolaXModbusSensorEntityDescription( - key = "software_version", - value_function = value_function_software_version_air_g3, - allowedtypes = MIC | GEN2 | X1, - internal = True, + key="hardware_version", + value_function=value_function_hardware_version_g4, + allowedtypes=AC | HYBRID | GEN4, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "software_version", - value_function = value_function_software_version_air_g4, - allowedtypes = MIC | GEN4 | X1, - internal = True, + key="hardware_version", + value_function=value_function_hardware_version_g5, + allowedtypes=AC | HYBRID | GEN5, + internal=True, ), SolaXModbusSensorEntityDescription( - key = "software_version", - value_function = value_function_software_version_g4, - allowedtypes = MIC | GEN | GEN2 | X3, - blacklist=('MU802T',), - internal = True, + name="House Load", + key="house_load", + value_function=value_function_house_load, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + icon="mdi:home-lightning-bolt", + ), + SolaXModbusSensorEntityDescription( + name="House Load Alt", + key="house_load_alt", + value_function=value_function_house_load_alt, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + allowedtypes=AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5, + entity_registry_enabled_default=False, + icon="mdi:home-lightning-bolt", + ), + SolaXModbusSensorEntityDescription( + name="PV Power Total", + key="pv_power_total", + value_function=value_function_pv_power_total, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + allowedtypes=HYBRID, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="Remotecontrol Autorepeat Remaining", + key="remotecontrol_autorepeat_remaining", + native_unit_of_measurement=UnitOfTime.SECONDS, + state_class=SensorStateClass.MEASUREMENT, + value_function=value_function_remotecontrol_autorepeat_remaining, + allowedtypes=AC | HYBRID | GEN4 | GEN5, + icon="mdi:home-clock", + ), + SolaXModbusSensorEntityDescription( + key="software_version", + value_function=value_function_software_version_g2, + allowedtypes=AC | HYBRID | GEN2, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="software_version", + value_function=value_function_software_version_g3, + allowedtypes=AC | HYBRID | GEN3, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="software_version", + value_function=value_function_software_version_g4, + allowedtypes=AC | HYBRID | GEN4, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="software_version", + value_function=value_function_software_version_g5, + allowedtypes=AC | HYBRID | GEN5, + internal=True, + ), + SolaXModbusSensorEntityDescription( + name="Total Battery Power Charge", + key="battery_power_charge", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + value_function=value_function_battery_power_charge, + allowedtypes=AC | HYBRID | GEN5, + icon="mdi:battery-charging", + ), + ##### + # + # X1 Air,Boost, Mini + # + # X3 Mic, Mic Pro + # + ##### + # + # Holding Registers + # + ##### + SolaXModbusSensorEntityDescription( + name="RTC", + key="rtc", + register=0x318, + unit=REGISTER_WORDS, + wordcount=6, + scale=value_function_rtc, + entity_registry_enabled_default=False, + allowedtypes=MIC, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:clock", + ), + SolaXModbusSensorEntityDescription( + key="firmware_dsp", + register=0x33D, + allowedtypes=MIC | GEN, + blacklist=( + "MC502T", + "MU802T", + ), + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="firmware_arm", + register=0x33E, + allowedtypes=MIC | GEN, + blacklist=( + "MC502T", + "MU802T", + ), + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="q-curve", + register=0x347, + scale={ + 0: "Off", + 1: "Over Excited", + 2: "Under Excited", + 3: "PF(p)", + 4: "Q(u)", + 5: "FixQPower", + }, + allowedtypes=MIC | GEN2 | X3, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="active_power_limit", + register=0x351, + allowedtypes=MIC | GEN2 | X3, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="firmware_dsp", + register=0x352, + allowedtypes=MIC | GEN2, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="firmware_arm", + register=0x353, + allowedtypes=MIC | GEN2, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="lock_state", + register=0x367, + scale={ + 0: "Locked", + 1: "Unlocked", + 2: "Unlocked - Advanced", + }, + allowedtypes=MIC | GEN2 | X3, + internal=True, + ), + SolaXModbusSensorEntityDescription( + name="Export Power Limit", + key="export_power_limit", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + register=0x371, + allowedtypes=MIC | GEN2 | X3, + ), + SolaXModbusSensorEntityDescription( + key="lock_state", + register=0x39A, + scale={ + 0: "Locked", + 1: "Unlocked", + 2: "Unlocked - Advanced", + }, + allowedtypes=MIC | GEN2 | GEN4 | X1, + internal=True, + ), + ##### + # + # Input Registers + # + ##### + SolaXModbusSensorEntityDescription( + name="PV Voltage 1", + key="pv_voltage_1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x400, + register_type=REG_INPUT, + ignore_readerror=True, + scale=0.1, + rounding=1, + allowedtypes=MIC | GEN | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 2", + key="pv_voltage_2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x401, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MIC | GEN | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="PV Current 1", + key="pv_current_1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x402, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MIC | GEN | GEN2, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Current 2", + key="pv_current_2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x403, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MIC | GEN | GEN2, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="Inverter Voltage", + key="inverter_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x404, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=MIC | GEN | GEN2 | X1, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Voltage L1", + key="inverter_voltage_l1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x404, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=MIC | GEN | GEN2 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Voltage L2", + key="inverter_voltage_l2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x405, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=MIC | GEN | GEN2 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Voltage L3", + key="inverter_voltage_l3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x406, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=MIC | GEN | GEN2 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Frequency", + key="inverter_frequency", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0x407, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=MIC | GEN | GEN2 | X1, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Frequency L1", + key="inverter_frequency_l1", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0x407, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=MIC | GEN | GEN2 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Frequency L2", + key="inverter_frequency_l2", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0x408, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=MIC | GEN | GEN2 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Frequency L3", + key="inverter_frequency_l3", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0x409, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=MIC | GEN | GEN2 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Current", + key="inverter_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x40A, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MIC | GEN | GEN2 | X1, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Current L1", + key="inverter_current_l1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x40A, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MIC | GEN | GEN2 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Current L2", + key="inverter_current_l2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x40B, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MIC | GEN | GEN2 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Current L3", + key="inverter_current_l3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x40C, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MIC | GEN | GEN2 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Temperature", + key="inverter_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x40D, + register_type=REG_INPUT, + allowedtypes=MIC | GEN | GEN2, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="Measured Power", + key="measured_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x40E, + # newblock = True, + register_type=REG_INPUT, + allowedtypes=MIC | GEN | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Run Mode", + key="run_mode", + register=0x40F, + scale={ + 0: "Waiting", + 1: "Checking", + 2: "Normal Mode", + 3: "Fault", + 4: "Permanent Fault Mode", + }, + register_type=REG_INPUT, + allowedtypes=MIC | GEN | GEN2, + icon="mdi:run", + ), + SolaXModbusSensorEntityDescription( + name="Measured Power L1", + key="measured_power_l1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x410, + register_type=REG_INPUT, + allowedtypes=MIC | GEN | X3, + ), + SolaXModbusSensorEntityDescription( + name="Measured Power L2", + key="measured_power_l2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x411, + register_type=REG_INPUT, + allowedtypes=MIC | GEN | X3, + ), + SolaXModbusSensorEntityDescription( + name="Measured Power L3", + key="measured_power_l3", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x412, + register_type=REG_INPUT, + allowedtypes=MIC | GEN | X3, + ), + SolaXModbusSensorEntityDescription( + name="PV Power 1", + key="pv_power_1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x414, + register_type=REG_INPUT, + allowedtypes=MIC | GEN | GEN2, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 2", + key="pv_power_2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x415, + register_type=REG_INPUT, + allowedtypes=MIC | GEN | GEN2, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="PV Power Total", + key="pv_power_total", + value_function=value_function_pv_power_total, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + allowedtypes=MIC | GEN | GEN2, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="PV Total Power", + key="pv_total_power", + value_function=value_function_pv_power_total, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + entity_registry_enabled_default=False, + allowedtypes=MIC | GEN | GEN2, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="Total Yield", + key="total_yield", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x423, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.001, + rounding=2, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=MIC | GEN, + ), + SolaXModbusSensorEntityDescription( + name="Today's Yield", + key="today_s_yield", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x425, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.001, + rounding=2, + allowedtypes=MIC | GEN, + ), + SolaXModbusSensorEntityDescription( + name="Total Yield", + key="total_yield", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x423, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.1, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=MIC | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Today's Yield", + key="today_s_yield", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x425, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.1, + rounding=1, + allowedtypes=MIC | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 3", + key="pv_voltage_3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x429, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MIC | MPPT3, + ), + SolaXModbusSensorEntityDescription( + name="PV Current 3", + key="pv_current_3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x42A, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MIC | MPPT3, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 3", + key="pv_power_3", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x42B, + register_type=REG_INPUT, + allowedtypes=MIC | MPPT3, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="Inverter Power", + key="inverter_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + ignore_readerror=True, + newblock=True, # Do not remove, required for FW <1.38 + register=0x435, + register_type=REG_INPUT, + unit=REGISTER_S32, + entity_registry_enabled_default=False, + allowedtypes=MIC | GEN, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="Total Grid Export", + key="total_grid_export", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x437, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=MIC | GEN, + icon="mdi:home-export-outline", + ), + SolaXModbusSensorEntityDescription( + name="Total Grid Import", + key="total_grid_import", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x439, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=MIC | GEN, + icon="mdi:home-import-outline", + ), + SolaXModbusSensorEntityDescription( + name="Today's Grid Export", + key="today_s_grid_export", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x43B, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=MIC | GEN, + icon="mdi:home-export-outline", + ), + SolaXModbusSensorEntityDescription( + name="Today's Grid Import", + key="today_s_grid_import", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x43C, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=MIC | GEN, + icon="mdi:home-import-outline", + ), + SolaXModbusSensorEntityDescription( + name="Inverter Power", + key="inverter_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + ignore_readerror=True, + newblock=True, # Do not remove, required for FW <1.38 + register=0x43B, + register_type=REG_INPUT, + unit=REGISTER_S32, + entity_registry_enabled_default=False, + allowedtypes=MIC | GEN2, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="Total Grid Export", + key="total_grid_export", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x43D, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=MIC | GEN2, + icon="mdi:home-export-outline", + ), + SolaXModbusSensorEntityDescription( + name="Total Grid Import", + key="total_grid_import", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x43F, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.01, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=MIC | GEN2, + icon="mdi:home-import-outline", + ), + SolaXModbusSensorEntityDescription( + name="Measured Power 2", + key="measured_power_2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x704, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=MIC | GEN2 | X1, + ), + SolaXModbusSensorEntityDescription( + name="Measured Power L1", + key="measured_power_l1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x704, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=MIC | GEN2 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Measured Power L2", + key="measured_power_l2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x706, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=MIC | GEN2 | X3, + ), + SolaXModbusSensorEntityDescription( + name="Measured Power L3", + key="measured_power_l3", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x708, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=MIC | GEN2 | X3, + ), + ##### + # + # X1 Boost Gen4 + # + # MIC Gen4? + # + ##### + # + # Holding Registers + # + ##### + SolaXModbusSensorEntityDescription( + key="mppt_scan_mode_pv1", + register=0x320, + scale={ + 0: "Off", + 1: "Low", + 2: "Middle", + 3: "High", + }, + allowedtypes=MIC | GEN4, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="q-curve", + register=0x35C, + scale={ + 0: "Off", + 1: "Over Excited", + 2: "Under Excited", + 3: "PF(p)", + 4: "Q(u)", + 5: "FixQPower", + }, + allowedtypes=MIC | GEN4, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="active_power_limit", + register=0x381, + allowedtypes=MIC | GEN4, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="firmware_arm", + register=0x390, + allowedtypes=MIC | GEN4, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="firmware_dsp", + register=0x394, + allowedtypes=MIC | GEN4, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="mppt_scan_mode_pv2", + register=0x3A6, + scale={ + 0: "Off", + 1: "Low", + 2: "Middle", + 3: "High", + }, + allowedtypes=MIC | GEN4, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="mppt_scan_mode_pv3", + register=0x3A7, + scale={ + 0: "Off", + 1: "Low", + 2: "Middle", + 3: "High", + }, + allowedtypes=MIC | GEN4 | MPPT3, + internal=True, + ), + ##### + # + # Input Registers + # + ##### + SolaXModbusSensorEntityDescription( + name="Inverter Voltage", + key="inverter_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x400, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=MIC | GEN4 | X1, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Current", + key="inverter_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x403, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MIC | GEN4 | X1, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Frequency", + key="inverter_frequency", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0x406, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=MIC | GEN4 | X1, + ), + SolaXModbusSensorEntityDescription( + name="CT Power", + key="ct_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x408, + register_type=REG_INPUT, + allowedtypes=MIC | GEN4, + ), + SolaXModbusSensorEntityDescription( + name="Measured Power", + key="measured_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x409, + register_type=REG_INPUT, + allowedtypes=MIC | GEN4 | GEN5, + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 1", + key="pv_voltage_1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x40A, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MIC | GEN4, + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 2", + key="pv_voltage_2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x40B, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MIC | GEN4, + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 3", + key="pv_voltage_3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x40C, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MIC | GEN4 | MPPT3, + ), + SolaXModbusSensorEntityDescription( + name="PV Current 1", + key="pv_current_1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x40D, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MIC | GEN4, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Current 2", + key="pv_current_2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x40E, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MIC | GEN4, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Current 3", + key="pv_current_3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x40F, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MIC | GEN4 | MPPT3, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 1", + key="pv_power_1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x410, + register_type=REG_INPUT, + allowedtypes=MIC | GEN4, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 2", + key="pv_power_2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x411, + register_type=REG_INPUT, + allowedtypes=MIC | GEN4, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 3", + key="pv_power_3", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x412, + register_type=REG_INPUT, + allowedtypes=MIC | GEN4, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="Inverter Temperature", + key="inverter_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x413, + register_type=REG_INPUT, + allowedtypes=MIC | GEN4, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="Control Board Temperature", + key="control_board_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x414, + register_type=REG_INPUT, + allowedtypes=MIC | GEN4, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="Run Mode", + key="run_mode", + register=0x415, + scale={ + 0: "Waiting", + 1: "Checking", + 2: "Normal Mode", + 3: "Fault", + 4: "Permanent Fault Mode", + 5: "Update Mode", + 6: "EPS Checking", + 7: "EPS Mode", + }, + register_type=REG_INPUT, + allowedtypes=MIC | GEN4, + icon="mdi:run", + ), + SolaXModbusSensorEntityDescription( + name="Total Yield", + key="total_yield", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x42B, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.1, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=MIC | GEN4, + ), + SolaXModbusSensorEntityDescription( + name="Total Grid Export", + key="total_grid_export", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x42F, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.1, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=MIC | GEN4, + icon="mdi:home-export-outline", + ), + SolaXModbusSensorEntityDescription( + name="Total Grid Import", + key="total_grid_import", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x431, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.1, + rounding=2, + entity_registry_enabled_default=False, + allowedtypes=MIC | GEN4, + icon="mdi:home-import-outline", + ), + SolaXModbusSensorEntityDescription( + name="Today's Yield", + key="today_s_yield", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x437, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MIC | GEN4, + ), + ##### + # + # X3 MAX MEGA G1 + # + # + ##### + # + # Holding Registers + # + ##### + SolaXModbusSensorEntityDescription( + name="Inverter Voltage L1", + key="inverter_voltage_l1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x1001, + scale=0.1, + rounding=1, + allowedtypes=MAX, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Current L1", + key="inverter_current_l1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x1002, + scale=0.01, + rounding=2, + allowedtypes=MAX, + ), + SolaXModbusSensorEntityDescription( + name="Measured Power L1", + key="measured_power_l1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x1003, + unit=REGISTER_U32, + scale=0.1, + rounding=1, + allowedtypes=MAX, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Frequency L1", + key="inverter_frequency_l1", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0x1005, + scale=0.01, + rounding=2, + allowedtypes=MAX, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Voltage L2", + key="inverter_voltage_l2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x1006, + scale=0.1, + rounding=1, + allowedtypes=MAX, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Current L2", + key="inverter_current_l2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x1007, + scale=0.01, + rounding=2, + allowedtypes=MAX, + ), + SolaXModbusSensorEntityDescription( + name="Measured Power L2", + key="measured_power_l2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x1008, + unit=REGISTER_U32, + scale=0.1, + rounding=1, + allowedtypes=MAX, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Frequency L2", + key="inverter_frequency_l2", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0x100A, + scale=0.01, + rounding=2, + allowedtypes=MAX, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Voltage L3", + key="inverter_voltage_l3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x100B, + scale=0.1, + rounding=1, + allowedtypes=MAX, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Current L3", + key="inverter_current_l3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x100C, + scale=0.01, + rounding=2, + allowedtypes=MAX, + ), + SolaXModbusSensorEntityDescription( + name="Measured Power L3", + key="measured_power_l3", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x100D, + unit=REGISTER_U32, + scale=0.1, + rounding=1, + allowedtypes=MAX, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Frequency L3", + key="inverter_frequency_l3", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0x100F, + scale=0.01, + rounding=2, + allowedtypes=MAX, + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 1", + key="pv_voltage_1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x1010, + scale=0.1, + rounding=1, + allowedtypes=MAX, + ), + SolaXModbusSensorEntityDescription( + name="PV Current 1", + key="pv_current_1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x1011, + scale=0.01, + rounding=2, + allowedtypes=MAX, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 1", + key="pv_power_1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x1012, + allowedtypes=MAX, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 2", + key="pv_voltage_2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x1014, + scale=0.1, + rounding=1, + allowedtypes=MAX, + ), + SolaXModbusSensorEntityDescription( + name="PV Current 2", + key="pv_current_2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x1015, + scale=0.01, + rounding=2, + allowedtypes=MAX, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 2", + key="pv_power_2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x1016, + allowedtypes=MAX, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 3", + key="pv_voltage_3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x1018, + scale=0.1, + rounding=1, + allowedtypes=MAX, + ), + SolaXModbusSensorEntityDescription( + name="PV Current 3", + key="pv_current_3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x1019, + scale=0.01, + rounding=2, + allowedtypes=MAX, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 3", + key="pv_power_3", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x101A, + allowedtypes=MAX, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="Inverter Temperature", + key="inverter_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x101C, + allowedtypes=MAX, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="Run Mode", + key="run_mode", + register=0x101D, + scale={ + 0: "Initial Mode", + 1: "Standby Mode", + 3: "Normal Mode", + 5: "Fault Mode", + 9: "Shutdown mode", + }, + allowedtypes=MAX, + icon="mdi:run", + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 4", + key="pv_voltage_4", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x103E, + scale=0.1, + rounding=1, + allowedtypes=MAX, + ), + SolaXModbusSensorEntityDescription( + name="PV Current 4", + key="pv_current_4", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x103F, + scale=0.01, + rounding=2, + allowedtypes=MAX, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 4", + key="pv_power_4", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x1040, + allowedtypes=MAX, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="Model Number", + key="model_number", + register=0x1A00, + unit=REGISTER_STR, + wordcount=8, + allowedtypes=MAX, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:information", + ), + SolaXModbusSensorEntityDescription( + name="Serial Number", + key="serial_number", + register=0x1A10, + unit=REGISTER_STR, + wordcount=8, + allowedtypes=MAX, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:information", + ), + SolaXModbusSensorEntityDescription( + name="Software Version", + key="software_version", + register=0x1A1C, + unit=REGISTER_STR, + wordcount=3, + allowedtypes=MAX, + icon="mdi:information", + ), + SolaXModbusSensorEntityDescription( + name="MPPT Qty", + key="mppt_qty", + register=0x1A3B, + allowedtypes=MAX, + icon="mdi:information", + ), + ##### + # + # Computed + # + ##### + SolaXModbusSensorEntityDescription( + name="Grid Export", + key="grid_export", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + value_function=value_function_grid_export, + allowedtypes=MIC, + icon="mdi:home-export-outline", + ), + SolaXModbusSensorEntityDescription( + name="Grid Import", + key="grid_import", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + value_function=value_function_grid_import, + allowedtypes=MIC, + icon="mdi:home-import-outline", + ), + SolaXModbusSensorEntityDescription( + key="hardware_version", + value_function=value_function_hardware_version_g3, + allowedtypes=MIC | GEN2 | X1, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="hardware_version", + value_function=value_function_hardware_version_g4, + allowedtypes=MIC | GEN4 | X1, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="hardware_version", + value_function=value_function_hardware_version_g1, + allowedtypes=MIC | GEN | X3, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="hardware_version", + value_function=value_function_hardware_version_g2, + allowedtypes=MIC | GEN2 | X3, + internal=True, + ), + SolaXModbusSensorEntityDescription( + name="PV Power Total", + key="pv_power_total", + value_function=value_function_pv_power_total, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + allowedtypes=MIC | GEN4, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + key="software_version", + value_function=value_function_software_version_air_g3, + allowedtypes=MIC | GEN2 | X1, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="software_version", + value_function=value_function_software_version_air_g4, + allowedtypes=MIC | GEN4 | X1, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="software_version", + value_function=value_function_software_version_g4, + allowedtypes=MIC | GEN | GEN2 | X3, + blacklist=("MU802T",), + internal=True, ), ] # ============================ plugin declaration ================================================= + @dataclass class solax_plugin(plugin_base): def isAwake(self, datadict): - """ determine if inverter is awake based on polled datadict""" - return (datadict.get('run_mode', None) == 'Normal Mode') + """determine if inverter is awake based on polled datadict""" + return datadict.get("run_mode", None) == "Normal Mode" def wakeupButton(self): - """ in order to wake up the inverter , press this button """ - return 'battery_awaken' + """in order to wake up the inverter , press this button""" + return "battery_awaken" async def async_determineInverterType(self, hub, configdict): - #global SENSOR_TYPES + # global SENSOR_TYPES _LOGGER.info(f"{hub.name}: trying to determine inverter type") - seriesnumber = await async_read_serialnr(hub, 0x0) + seriesnumber = await async_read_serialnr(hub, 0x0) if not seriesnumber: - seriesnumber = await async_read_serialnr(hub, 0x300) # bug in Endian.LITTLE decoding? + seriesnumber = await async_read_serialnr(hub, 0x300) # bug in Endian.LITTLE decoding? if not seriesnumber: seriesnumber = await async_read_serialnr(hub, 0x1A10) if not seriesnumber: @@ -7499,311 +9486,317 @@ async def async_determineInverterType(self, hub, configdict): seriesnumber = "unknown" # derive invertertupe from seriiesnumber - if seriesnumber.startswith('L30'): - invertertype = HYBRID | GEN2 | X1 # Gen2 X1 SK-TL 3kW + if seriesnumber.startswith("L30"): + invertertype = HYBRID | GEN2 | X1 # Gen2 X1 SK-TL 3kW self.inverter_model = f"X1-Hybrid-{seriesnumber[1:2]}.{seriesnumber[2:3]}kW SK-TL" - elif seriesnumber.startswith('U30'): - invertertype = HYBRID | GEN2 | X1 # Gen2 X1 SK-SU 3kW + elif seriesnumber.startswith("U30"): + invertertype = HYBRID | GEN2 | X1 # Gen2 X1 SK-SU 3kW self.inverter_model = f"X1-Hybrid-{seriesnumber[1:2]}.{seriesnumber[2:3]}kW SK-SU" - elif seriesnumber.startswith('L37'): - invertertype = HYBRID | GEN2 | X1 # Gen2 X1 SK-TL 3.7kW Untested + elif seriesnumber.startswith("L37"): + invertertype = HYBRID | GEN2 | X1 # Gen2 X1 SK-TL 3.7kW Untested self.inverter_model = f"X1-Hybrid-{seriesnumber[1:2]}.{seriesnumber[2:3]}kW SK-TL" - elif seriesnumber.startswith('U37'): - invertertype = HYBRID | GEN2 | X1 # Gen2 X1 SK-SU 3.7kW Untested + elif seriesnumber.startswith("U37"): + invertertype = HYBRID | GEN2 | X1 # Gen2 X1 SK-SU 3.7kW Untested self.inverter_model = f"X1-Hybrid-{seriesnumber[1:2]}.{seriesnumber[2:3]}kW SK-SU" - elif seriesnumber.startswith('L50'): - invertertype = HYBRID | GEN2 | X1 # Gen2 X1 SK-TL 5kW + elif seriesnumber.startswith("L50"): + invertertype = HYBRID | GEN2 | X1 # Gen2 X1 SK-TL 5kW self.inverter_model = f"X1-Hybrid-{seriesnumber[1:2]}.{seriesnumber[2:3]}kW SK-TL" - elif seriesnumber.startswith('U50'): - invertertype = HYBRID | GEN2 | X1 # Gen2 X1 SK-SU 5kW + elif seriesnumber.startswith("U50"): + invertertype = HYBRID | GEN2 | X1 # Gen2 X1 SK-SU 5kW self.inverter_model = f"X1-Hybrid-{seriesnumber[1:2]}.{seriesnumber[2:3]}kW SK-SU" - elif seriesnumber.startswith('H1E'): - invertertype = HYBRID | GEN3 | X1 # Gen3 X1 Early + elif seriesnumber.startswith("H1E"): + invertertype = HYBRID | GEN3 | X1 # Gen3 X1 Early self.inverter_model = f"X1-Hybrid-{seriesnumber[3:4]}.{seriesnumber[4:5]}kW" - elif seriesnumber.startswith('H1I'): - invertertype = HYBRID | GEN3 | X1 # Gen3 X1 Alternative + elif seriesnumber.startswith("H1I"): + invertertype = HYBRID | GEN3 | X1 # Gen3 X1 Alternative self.inverter_model = f"X1-Hybrid-{seriesnumber[3:4]}.{seriesnumber[4:5]}kW" - elif seriesnumber.startswith('HCC'): - invertertype = HYBRID | GEN3 | X1 # Gen3 X1 Alternative + elif seriesnumber.startswith("HCC"): + invertertype = HYBRID | GEN3 | X1 # Gen3 X1 Alternative self.inverter_model = f"X1-Hybrid-{seriesnumber[3:4]}.{seriesnumber[4:5]}kW" - elif seriesnumber.startswith('HUE'): - invertertype = HYBRID | GEN3 | X1 # Gen3 X1 Late + elif seriesnumber.startswith("HUE"): + invertertype = HYBRID | GEN3 | X1 # Gen3 X1 Late self.inverter_model = f"X1-Hybrid-{seriesnumber[3:4]}.{seriesnumber[4:5]}kW" - elif seriesnumber.startswith('XRE'): - invertertype = HYBRID | GEN3 | X1 # Gen3 X1 Alternative + elif seriesnumber.startswith("XRE"): + invertertype = HYBRID | GEN3 | X1 # Gen3 X1 Alternative self.inverter_model = f"X1-Hybrid-{seriesnumber[3:4]}.{seriesnumber[4:5]}kW" - elif seriesnumber.startswith('XAC'): - invertertype = AC | GEN3 | X1 # X1AC + elif seriesnumber.startswith("XAC"): + invertertype = AC | GEN3 | X1 # X1AC self.inverter_model = "X1-AC" - elif seriesnumber.startswith('PRI'): - invertertype = AC | GEN3 | X1 # RetroFit + elif seriesnumber.startswith("PRI"): + invertertype = AC | GEN3 | X1 # RetroFit self.inverter_model = "X1-RetroFit" - elif seriesnumber.startswith('H3DE'): - invertertype = HYBRID | GEN3 | X3 # Gen3 X3 + elif seriesnumber.startswith("H3DE"): + invertertype = HYBRID | GEN3 | X3 # Gen3 X3 self.inverter_model = f"X3-Hybrid-{seriesnumber[3:5]}kW" - elif seriesnumber.startswith('H3E'): - invertertype = HYBRID | GEN3 | X3 # Gen3 X3 + elif seriesnumber.startswith("H3E"): + invertertype = HYBRID | GEN3 | X3 # Gen3 X3 self.inverter_model = f"X3-Hybrid-{seriesnumber[4:6]}kW" - elif seriesnumber.startswith('H3LE'): - invertertype = HYBRID | GEN3 | X3 # Gen3 X3 + elif seriesnumber.startswith("H3LE"): + invertertype = HYBRID | GEN3 | X3 # Gen3 X3 self.inverter_model = f"X3-Hybrid-{seriesnumber[4:6]}kW" - elif seriesnumber.startswith('H3PE'): - invertertype = HYBRID | GEN3 | X3 # Gen3 X3 + elif seriesnumber.startswith("H3PE"): + invertertype = HYBRID | GEN3 | X3 # Gen3 X3 self.inverter_model = f"X3-Hybrid-{seriesnumber[4:6]}kW" - elif seriesnumber.startswith('H3UE'): - invertertype = HYBRID | GEN3 | X3 # Gen3 X3 + elif seriesnumber.startswith("H3UE"): + invertertype = HYBRID | GEN3 | X3 # Gen3 X3 self.inverter_model = f"X3-Hybrid-{seriesnumber[4:6]}kW" - elif seriesnumber.startswith('F3D'): - invertertype = AC | GEN3 | X3 # RetroFit + elif seriesnumber.startswith("F3D"): + invertertype = AC | GEN3 | X3 # RetroFit self.inverter_model = "X3-RetroFit" - elif seriesnumber.startswith('F3E'): - invertertype = AC | GEN3 | X3 # RetroFit + elif seriesnumber.startswith("F3E"): + invertertype = AC | GEN3 | X3 # RetroFit self.inverter_model = "X3-RetroFit" - elif seriesnumber.startswith('H43'): - invertertype = HYBRID | GEN4 | X1 # Gen4 X1 3kW / 3.7kW + elif seriesnumber.startswith("H43"): + invertertype = HYBRID | GEN4 | X1 # Gen4 X1 3kW / 3.7kW self.inverter_model = f"X1-Hybrid-{seriesnumber[2:3]}.{seriesnumber[3:4]}kW" - elif seriesnumber.startswith('H44'): - invertertype = HYBRID | GEN4 | X1 # Gen4 X1 alt 5kW + elif seriesnumber.startswith("H44"): + invertertype = HYBRID | GEN4 | X1 # Gen4 X1 alt 5kW self.inverter_model = f"X1-Hybrid-{seriesnumber[2:3]}.{seriesnumber[3:4]}kW" - elif seriesnumber.startswith('H450'): - invertertype = HYBRID | GEN4 | X1 # Gen4 X1 5.0kW + elif seriesnumber.startswith("H450"): + invertertype = HYBRID | GEN4 | X1 # Gen4 X1 5.0kW self.inverter_model = f"X1-Hybrid-{seriesnumber[2:3]}.{seriesnumber[3:4]}kW" - elif seriesnumber.startswith('H460'): - invertertype = HYBRID | GEN4 | X1 # Gen4 X1 6kW? + elif seriesnumber.startswith("H460"): + invertertype = HYBRID | GEN4 | X1 # Gen4 X1 6kW? self.inverter_model = f"X1-Hybrid-{seriesnumber[2:3]}.{seriesnumber[3:4]}kW" - elif seriesnumber.startswith('H475'): - invertertype = HYBRID | GEN4 | X1 # Gen4 X1 7.5kW + elif seriesnumber.startswith("H475"): + invertertype = HYBRID | GEN4 | X1 # Gen4 X1 7.5kW self.inverter_model = f"X1-Hybrid-{seriesnumber[2:3]}.{seriesnumber[3:4]}kW" - elif seriesnumber.startswith('F43'): - invertertype = AC | GEN4 | X1 # RetroFit X1 3kW / 3.7kW? + elif seriesnumber.startswith("F43"): + invertertype = AC | GEN4 | X1 # RetroFit X1 3kW / 3.7kW? self.inverter_model = f"X1-RetroFit-{seriesnumber[2:3]}.{seriesnumber[3:4]}kW" - elif seriesnumber.startswith('F450'): - invertertype = AC | GEN4 | X1 # RetroFit 5kW + elif seriesnumber.startswith("F450"): + invertertype = AC | GEN4 | X1 # RetroFit 5kW self.inverter_model = f"X1-RetroFit-{seriesnumber[2:3]}.{seriesnumber[3:4]}kW" - elif seriesnumber.startswith('F460'): - invertertype = AC | GEN4 | X1 # RetroFit X1 6kW? + elif seriesnumber.startswith("F460"): + invertertype = AC | GEN4 | X1 # RetroFit X1 6kW? self.inverter_model = f"X1-RetroFit-{seriesnumber[2:3]}.{seriesnumber[3:4]}kW" - elif seriesnumber.startswith('F475'): - invertertype = AC | GEN4 | X1 # RetroFit X1 7.5kW? + elif seriesnumber.startswith("F475"): + invertertype = AC | GEN4 | X1 # RetroFit X1 7.5kW? self.inverter_model = f"X1-RetroFit-{seriesnumber[2:3]}.{seriesnumber[3:4]}kW" - elif seriesnumber.startswith('PRE'): - invertertype = AC | GEN4 | X1 # RetroFit + elif seriesnumber.startswith("PRE"): + invertertype = AC | GEN4 | X1 # RetroFit self.inverter_model = "X1-RetroFit" - elif seriesnumber.startswith('H55'): - invertertype = HYBRID | GEN5 | X1 | MPPT3 # X1-IES 5kW? + elif seriesnumber.startswith("H55"): + invertertype = HYBRID | GEN5 | X1 | MPPT3 # X1-IES 5kW? self.inverter_model = f"X1-IES-{seriesnumber[2:3]}.{seriesnumber[3:4]}kW" - elif seriesnumber.startswith('H56'): - invertertype = HYBRID | GEN5 | X1 | MPPT3 # X1-IES 6kW? + elif seriesnumber.startswith("H56"): + invertertype = HYBRID | GEN5 | X1 | MPPT3 # X1-IES 6kW? self.inverter_model = f"X1-IES-{seriesnumber[2:3]}.{seriesnumber[3:4]}kW" - elif seriesnumber.startswith('H58'): - invertertype = HYBRID | GEN5 | X1 | MPPT3 # X1-IES 8kW + elif seriesnumber.startswith("H58"): + invertertype = HYBRID | GEN5 | X1 | MPPT3 # X1-IES 8kW self.inverter_model = f"X1-IES-{seriesnumber[2:3]}.{seriesnumber[3:4]}kW" - elif seriesnumber.startswith('H31'): - invertertype = HYBRID | GEN4 | X3 # TIGO TSI X3 + elif seriesnumber.startswith("H31"): + invertertype = HYBRID | GEN4 | X3 # TIGO TSI X3 self.inverter_model = "X3-TIGO TSI" - elif seriesnumber.startswith('H34'): - invertertype = HYBRID | GEN4 | X3 # Gen4 X3 + elif seriesnumber.startswith("H34"): + invertertype = HYBRID | GEN4 | X3 # Gen4 X3 self.inverter_model = "X3-Hybrid" - elif seriesnumber.startswith('F34'): - invertertype = AC | GEN4 | X3 # Gen4 X3 FIT + elif seriesnumber.startswith("F34"): + invertertype = AC | GEN4 | X3 # Gen4 X3 FIT self.inverter_model = "X3-RetroFit" - elif seriesnumber.startswith('H35A0'): - invertertype = HYBRID | GEN5 | X3 # X3-IES 4-8kW + elif seriesnumber.startswith("H35A0"): + invertertype = HYBRID | GEN5 | X3 # X3-IES 4-8kW self.inverter_model = f"X3-IES-{seriesnumber[5:6]}kW" - elif seriesnumber.startswith('H35A1'): - invertertype = HYBRID | GEN5 | X3 # X3-IES 10-15kW + elif seriesnumber.startswith("H35A1"): + invertertype = HYBRID | GEN5 | X3 # X3-IES 10-15kW self.inverter_model = f"X3-IES-{seriesnumber[4:6]}kW" - elif seriesnumber.startswith('H3BC15'): - invertertype = HYBRID | GEN5 | X3 # X3 Ultra C + elif seriesnumber.startswith("H3BC15"): + invertertype = HYBRID | GEN5 | X3 # X3 Ultra C self.inverter_model = "X3-Ultra-15kW" - elif seriesnumber.startswith('H3BC19'): - invertertype = HYBRID | GEN5 | X3 # X3 Ultra C + elif seriesnumber.startswith("H3BC19"): + invertertype = HYBRID | GEN5 | X3 # X3 Ultra C self.inverter_model = "X3-Ultra-19.9kW" - elif seriesnumber.startswith('H3BC20'): - invertertype = HYBRID | GEN5 | X3 # X3 Ultra C + elif seriesnumber.startswith("H3BC20"): + invertertype = HYBRID | GEN5 | X3 # X3 Ultra C self.inverter_model = "X3-Ultra-20kW" - elif seriesnumber.startswith('H3BC25'): - invertertype = HYBRID | GEN5 | MPPT3 | X3 # X3 Ultra C + elif seriesnumber.startswith("H3BC25"): + invertertype = HYBRID | GEN5 | MPPT3 | X3 # X3 Ultra C self.inverter_model = "X3-Ultra-25kW" - elif seriesnumber.startswith('H3BC30'): - invertertype = HYBRID | GEN5 | MPPT3 | X3 # X3 Ultra C + elif seriesnumber.startswith("H3BC30"): + invertertype = HYBRID | GEN5 | MPPT3 | X3 # X3 Ultra C self.inverter_model = "X3-Ultra-30kW" - elif seriesnumber.startswith('H3BD15'): - invertertype = HYBRID | GEN5 | X3 # X3 Ultra D + elif seriesnumber.startswith("H3BD15"): + invertertype = HYBRID | GEN5 | X3 # X3 Ultra D self.inverter_model = "X3-Ultra-15kW" - elif seriesnumber.startswith('H3BD19'): - invertertype = HYBRID | GEN5 | X3 # X3 Ultra D + elif seriesnumber.startswith("H3BD19"): + invertertype = HYBRID | GEN5 | X3 # X3 Ultra D self.inverter_model = "X3-Ultra-19.9kW" - elif seriesnumber.startswith('H3BD20'): - invertertype = HYBRID | GEN5 | X3 # X3 Ultra D + elif seriesnumber.startswith("H3BD20"): + invertertype = HYBRID | GEN5 | X3 # X3 Ultra D self.inverter_model = "X3-Ultra-20kW" - elif seriesnumber.startswith('H3BD25'): - invertertype = HYBRID | GEN5 | MPPT3 | X3 # X3 Ultra D + elif seriesnumber.startswith("H3BD25"): + invertertype = HYBRID | GEN5 | MPPT3 | X3 # X3 Ultra D self.inverter_model = "X3-Ultra-20kW" - elif seriesnumber.startswith('H3BD30'): - invertertype = HYBRID | GEN5 | MPPT3 | X3 # X3 Ultra D + elif seriesnumber.startswith("H3BD30"): + invertertype = HYBRID | GEN5 | MPPT3 | X3 # X3 Ultra D self.inverter_model = "X3-Ultra-30kW" - elif seriesnumber.startswith('H3BF15'): - invertertype = HYBRID | GEN5 | X3 # X3 Ultra F + elif seriesnumber.startswith("H3BF15"): + invertertype = HYBRID | GEN5 | X3 # X3 Ultra F self.inverter_model = "X3-Ultra-15kW" - elif seriesnumber.startswith('H3BF19'): - invertertype = HYBRID | GEN5 | X3 # X3 Ultra F + elif seriesnumber.startswith("H3BF19"): + invertertype = HYBRID | GEN5 | X3 # X3 Ultra F self.inverter_model = "X3-Ultra-19.9kW" - elif seriesnumber.startswith('H3BF20'): - invertertype = HYBRID | GEN5 | X3 # X3 Ultra F + elif seriesnumber.startswith("H3BF20"): + invertertype = HYBRID | GEN5 | X3 # X3 Ultra F self.inverter_model = "X3-Ultra-20kW" - elif seriesnumber.startswith('H3BF25'): - invertertype = HYBRID | GEN5 | MPPT3 | X3 # X3 Ultra F + elif seriesnumber.startswith("H3BF25"): + invertertype = HYBRID | GEN5 | MPPT3 | X3 # X3 Ultra F self.inverter_model = "X3-Ultra-20kW" - elif seriesnumber.startswith('H3BF30'): - invertertype = HYBRID | GEN5 | MPPT3 | X3 # X3 Ultra F + elif seriesnumber.startswith("H3BF30"): + invertertype = HYBRID | GEN5 | MPPT3 | X3 # X3 Ultra F self.inverter_model = "X3-Ultra-30kW" - elif seriesnumber.startswith('XAU'): - invertertype = MIC | GEN2 | X1 # X1-Boost + elif seriesnumber.startswith("XAU"): + invertertype = MIC | GEN2 | X1 # X1-Boost self.inverter_model = "X1-Boost" - elif seriesnumber.startswith('XB3'): - invertertype = MIC | GEN2 | X1 # X1-Boost + elif seriesnumber.startswith("XB3"): + invertertype = MIC | GEN2 | X1 # X1-Boost self.inverter_model = "X1-Boost" - elif seriesnumber.startswith('XM3'): - invertertype = MIC | GEN2 | X1 # X1-Mini G3 + elif seriesnumber.startswith("XM3"): + invertertype = MIC | GEN2 | X1 # X1-Mini G3 self.inverter_model = "X1-Mini" - elif seriesnumber.startswith('XB4'): - invertertype = MIC | GEN4 | X1 # X1-Boost G4 + elif seriesnumber.startswith("XB4"): + invertertype = MIC | GEN4 | X1 # X1-Boost G4 self.inverter_model = "X1-Boost" - elif seriesnumber.startswith('XM4'): - invertertype = MIC | GEN4 | X1 # X1-Mini G4 + elif seriesnumber.startswith("XM4"): + invertertype = MIC | GEN4 | X1 # X1-Mini G4 self.inverter_model = "X1-Mini" - elif seriesnumber.startswith('XMA'): - invertertype = MIC | GEN2 | X1 # X1-Mini G3 + elif seriesnumber.startswith("XMA"): + invertertype = MIC | GEN2 | X1 # X1-Mini G3 self.inverter_model = "X1-Mini" - elif seriesnumber.startswith('ZA4'): - invertertype = MIC | GEN4 | X1 # X1-Boost G4 + elif seriesnumber.startswith("ZA4"): + invertertype = MIC | GEN4 | X1 # X1-Boost G4 self.inverter_model = "X1-Boost" - elif seriesnumber.startswith('XST'): - invertertype = MIC | GEN4 | X1 | MPPT3 # X1-SMART-G2 + elif seriesnumber.startswith("XST"): + invertertype = MIC | GEN4 | X1 | MPPT3 # X1-SMART-G2 self.inverter_model = "X1-SMART-G2" - elif seriesnumber.startswith('MC103T'): - invertertype = MIC | GEN | X3 # MIC X3 + elif seriesnumber.startswith("MC103T"): + invertertype = MIC | GEN | X3 # MIC X3 self.inverter_model = "X3-MIC" - elif seriesnumber.startswith('MP153T'): - invertertype = MIC | GEN | X3 # MIC X3 + elif seriesnumber.startswith("MP153T"): + invertertype = MIC | GEN | X3 # MIC X3 self.inverter_model = "X3-MIC" - elif seriesnumber.startswith('MC203T'): - invertertype = MIC | GEN | X3 # MIC X3 + elif seriesnumber.startswith("MC203T"): + invertertype = MIC | GEN | X3 # MIC X3 self.inverter_model = "X3-MIC" - elif seriesnumber.startswith('MC502T'): - invertertype = MIC | GEN | X3 # MIC X3 + elif seriesnumber.startswith("MC502T"): + invertertype = MIC | GEN | X3 # MIC X3 self.inverter_model = "X3-MIC" - elif seriesnumber.startswith('MU502T'): - invertertype = MIC | GEN | X3 # MIC X3 + elif seriesnumber.startswith("MU502T"): + invertertype = MIC | GEN | X3 # MIC X3 self.inverter_model = "X3-MIC" - elif seriesnumber.startswith('MC602T'): - invertertype = MIC | GEN | X3 # MIC X3 6kW + elif seriesnumber.startswith("MC602T"): + invertertype = MIC | GEN | X3 # MIC X3 6kW self.inverter_model = "X3-MIC" - elif seriesnumber.startswith('MU602T'): - invertertype = MIC | GEN | X3 # MIC X3 6kW + elif seriesnumber.startswith("MU602T"): + invertertype = MIC | GEN | X3 # MIC X3 6kW self.inverter_model = "X3-MIC" - elif seriesnumber.startswith('MC702T'): - invertertype = MIC | GEN | X3 # MIC X3 + elif seriesnumber.startswith("MC702T"): + invertertype = MIC | GEN | X3 # MIC X3 self.inverter_model = "X3-MIC" - elif seriesnumber.startswith('MU702T'): - invertertype = MIC | GEN | X3 # MIC X3 + elif seriesnumber.startswith("MU702T"): + invertertype = MIC | GEN | X3 # MIC X3 self.inverter_model = "X3-MIC" - elif seriesnumber.startswith('MC802T'): - invertertype = MIC | GEN | X3 # MIC X3 8kW - elif seriesnumber.startswith('MCU08T'): - invertertype = MIC | GEN | X3 # MIC X3 8kW - elif seriesnumber.startswith('MU802T'): - invertertype = MIC | GEN | X3 # MIC X3 - elif seriesnumber.startswith('MC803T'): - invertertype = MIC | GEN | X3 # MIC X3 + elif seriesnumber.startswith("MC802T"): + invertertype = MIC | GEN | X3 # MIC X3 8kW + elif seriesnumber.startswith("MCU08T"): + invertertype = MIC | GEN | X3 # MIC X3 8kW + elif seriesnumber.startswith("MU802T"): + invertertype = MIC | GEN | X3 # MIC X3 + elif seriesnumber.startswith("MC803T"): + invertertype = MIC | GEN | X3 # MIC X3 self.inverter_model = "X3-MIC" - elif seriesnumber.startswith('MU803T'): - invertertype = MIC | GEN | X3 # MIC X3 + elif seriesnumber.startswith("MU803T"): + invertertype = MIC | GEN | X3 # MIC X3 self.inverter_model = "X3-MIC" - elif seriesnumber.startswith('MU902T'): - invertertype = MIC | GEN | X3 # MIC X3 + elif seriesnumber.startswith("MU902T"): + invertertype = MIC | GEN | X3 # MIC X3 self.inverter_model = "X3-MIC" - elif seriesnumber.startswith('MC806T'): - invertertype = MIC | GEN2 | X3 # MIC X3 + elif seriesnumber.startswith("MC806T"): + invertertype = MIC | GEN2 | X3 # MIC X3 self.inverter_model = "X3-MIC" - elif seriesnumber.startswith('MU806T'): - invertertype = MIC | GEN2 | X3 # MIC X3 + elif seriesnumber.startswith("MU806T"): + invertertype = MIC | GEN2 | X3 # MIC X3 self.inverter_model = "X3-MIC" - elif seriesnumber.startswith('MC106T'): - invertertype = MIC | GEN2 | X3 # MIC X3 + elif seriesnumber.startswith("MC106T"): + invertertype = MIC | GEN2 | X3 # MIC X3 self.inverter_model = "X3-MIC" - elif seriesnumber.startswith('MC204T'): - invertertype = MIC | GEN2 | X3 # MIC X3 + elif seriesnumber.startswith("MC204T"): + invertertype = MIC | GEN2 | X3 # MIC X3 self.inverter_model = "X3-MIC" - elif seriesnumber.startswith('MC205T'): - invertertype = MIC | GEN2 | X3 # MIC X3 + elif seriesnumber.startswith("MC205T"): + invertertype = MIC | GEN2 | X3 # MIC X3 self.inverter_model = "X3-MIC" - elif seriesnumber.startswith('MC206T'): - invertertype = MIC | GEN2 | X3 # MIC X3 + elif seriesnumber.startswith("MC206T"): + invertertype = MIC | GEN2 | X3 # MIC X3 self.inverter_model = "X3-MIC" - elif seriesnumber.startswith('MC208T'): - invertertype = MIC | GEN2 | X3 # MIC X3 + elif seriesnumber.startswith("MC208T"): + invertertype = MIC | GEN2 | X3 # MIC X3 self.inverter_model = "X3-MIC" self.software_version = "Unknown" - elif seriesnumber.startswith('MC210T'): - invertertype = MIC | GEN2 | X3 # MIC X3 + elif seriesnumber.startswith("MC210T"): + invertertype = MIC | GEN2 | X3 # MIC X3 self.inverter_model = "X3-MIC" - elif seriesnumber.startswith('MC212T'): - invertertype = MIC | GEN2 | X3 # MIC X3 + elif seriesnumber.startswith("MC212T"): + invertertype = MIC | GEN2 | X3 # MIC X3 self.inverter_model = "X3-MIC" - elif seriesnumber.startswith('MC215T'): - invertertype = MIC | GEN2 | X3 # MIC X3 + elif seriesnumber.startswith("MC215T"): + invertertype = MIC | GEN2 | X3 # MIC X3 self.inverter_model = "X3-MIC" - elif seriesnumber.startswith('MP156T'): - invertertype = MIC | GEN2 | X3 # MIC X3 + elif seriesnumber.startswith("MP156T"): + invertertype = MIC | GEN2 | X3 # MIC X3 self.inverter_model = "X3-MIC" - elif seriesnumber.startswith('MPT08'): - invertertype = MIC | GEN2 | X3 # MIC PRO X3 + elif seriesnumber.startswith("MPT08"): + invertertype = MIC | GEN2 | X3 # MIC PRO X3 self.inverter_model = "X3-MIC PRO-8kW" - elif seriesnumber.startswith('MPT1'): - invertertype = MIC | GEN2 | X3 # MIC PRO X3 10-17kW + elif seriesnumber.startswith("MPT1"): + invertertype = MIC | GEN2 | X3 # MIC PRO X3 10-17kW self.inverter_model = f"X3-MIC PRO-{seriesnumber[3:5]}kW" - elif seriesnumber.startswith('MPT20'): - invertertype = MIC | GEN2 | X3 # MIC PRO X3 + elif seriesnumber.startswith("MPT20"): + invertertype = MIC | GEN2 | X3 # MIC PRO X3 self.inverter_model = "X3-MIC PRO-20kW" - elif seriesnumber.startswith('MPT25'): - invertertype = MIC | GEN2 | X3 | MPPT3 # MIC PRO X3 + elif seriesnumber.startswith("MPT25"): + invertertype = MIC | GEN2 | X3 | MPPT3 # MIC PRO X3 self.inverter_model = "X3-MIC PRO-25kW" - elif seriesnumber.startswith('MPT30'): - invertertype = MIC | GEN2 | X3 | MPPT3 # MIC PRO X3 + elif seriesnumber.startswith("MPT30"): + invertertype = MIC | GEN2 | X3 | MPPT3 # MIC PRO X3 self.inverter_model = "X3-MIC PRO-30kW" - elif seriesnumber.startswith('MAX'): - invertertype = MAX # MAX G1 + elif seriesnumber.startswith("MAX"): + invertertype = MAX # MAX G1 self.inverter_model = "X3-MAX" else: invertertype = 0 _LOGGER.error(f"unrecognized inverter type - serial number : {seriesnumber}") - + if invertertype > 0: read_eps = configdict.get(CONF_READ_EPS, DEFAULT_READ_EPS) read_dcb = configdict.get(CONF_READ_DCB, DEFAULT_READ_DCB) read_pm = configdict.get(CONF_READ_PM, DEFAULT_READ_PM) - if read_eps: invertertype = invertertype | EPS - if read_dcb: invertertype = invertertype | DCB - if read_pm: invertertype = invertertype | PM + if read_eps: + invertertype = invertertype | EPS + if read_dcb: + invertertype = invertertype | DCB + if read_pm: + invertertype = invertertype | PM return invertertype - def matchInverterWithMask (self, inverterspec, entitymask, serialnumber = 'not relevant', blacklist = None): + def matchInverterWithMask(self, inverterspec, entitymask, serialnumber="not relevant", blacklist=None): # returns true if the entity needs to be created for an inverter - genmatch = ((inverterspec & entitymask & ALL_GEN_GROUP) != 0) or (entitymask & ALL_GEN_GROUP == 0) - xmatch = ((inverterspec & entitymask & ALL_X_GROUP) != 0) or (entitymask & ALL_X_GROUP == 0) + genmatch = ((inverterspec & entitymask & ALL_GEN_GROUP) != 0) or (entitymask & ALL_GEN_GROUP == 0) + xmatch = ((inverterspec & entitymask & ALL_X_GROUP) != 0) or (entitymask & ALL_X_GROUP == 0) hybmatch = ((inverterspec & entitymask & ALL_TYPE_GROUP) != 0) or (entitymask & ALL_TYPE_GROUP == 0) - epsmatch = ((inverterspec & entitymask & ALL_EPS_GROUP) != 0) or (entitymask & ALL_EPS_GROUP == 0) - dcbmatch = ((inverterspec & entitymask & ALL_DCB_GROUP) != 0) or (entitymask & ALL_DCB_GROUP == 0) - mpptmatch = ((inverterspec & entitymask & ALL_MPPT_GROUP) != 0) or (entitymask & ALL_MPPT_GROUP == 0) - pmmatch = ((inverterspec & entitymask & ALL_PM_GROUP) != 0) or (entitymask & ALL_PM_GROUP == 0) + epsmatch = ((inverterspec & entitymask & ALL_EPS_GROUP) != 0) or (entitymask & ALL_EPS_GROUP == 0) + dcbmatch = ((inverterspec & entitymask & ALL_DCB_GROUP) != 0) or (entitymask & ALL_DCB_GROUP == 0) + mpptmatch = ((inverterspec & entitymask & ALL_MPPT_GROUP) != 0) or (entitymask & ALL_MPPT_GROUP == 0) + pmmatch = ((inverterspec & entitymask & ALL_PM_GROUP) != 0) or (entitymask & ALL_PM_GROUP == 0) blacklisted = False if blacklist: for start in blacklist: - if serialnumber.startswith(start) : blacklisted = True - return (genmatch and xmatch and hybmatch and epsmatch and dcbmatch and mpptmatch and pmmatch) and not blacklisted + if serialnumber.startswith(start): + blacklisted = True + return ( + genmatch and xmatch and hybmatch and epsmatch and dcbmatch and mpptmatch and pmmatch + ) and not blacklisted def getSoftwareVersion(self, new_data): return new_data.get("software_version", None) @@ -7820,33 +9813,53 @@ def localDataCallback(self, hub): if config_scale_entity and config_scale_entity.enabled: new_read_scale = hub.data.get("config_export_control_limit_readscale") if new_read_scale != None: - _LOGGER.info(f"local data update callback for read_scale: {new_read_scale} enabled: {config_scale_entity.enabled}") + _LOGGER.info( + f"local data update callback for read_scale: {new_read_scale} enabled: {config_scale_entity.enabled}" + ) number_entity = hub.numberEntities.get("export_control_user_limit") sensor_entity = hub.sensorEntities.get("export_control_user_limit") - if number_entity: number_entity.entity_description = replace(number_entity.entity_description, read_scale = new_read_scale, ) - if sensor_entity: sensor_entity.entity_description = replace(sensor_entity.entity_description, read_scale = new_read_scale, ) + if number_entity: + number_entity.entity_description = replace( + number_entity.entity_description, + read_scale=new_read_scale, + ) + if sensor_entity: + sensor_entity.entity_description = replace( + sensor_entity.entity_description, + read_scale=new_read_scale, + ) config_maxexport_entity = hub.numberEntities.get("config_max_export") if config_maxexport_entity and config_maxexport_entity.enabled: new_max_export = hub.data.get("config_max_export") if new_max_export != None: - for key in ["remotecontrol_active_power", "remotecontrol_import_limit", "export_control_user_limit", "generator_max_charge"]: + for key in [ + "remotecontrol_active_power", + "remotecontrol_import_limit", + "export_control_user_limit", + "generator_max_charge", + ]: number_entity = hub.numberEntities.get(key) if number_entity: number_entity._attr_native_max_value = new_max_export # update description also, not sure whether needed or not - number_entity.entity_description = replace(number_entity.entity_description, native_max_value = new_max_export, ) + number_entity.entity_description = replace( + number_entity.entity_description, + native_max_value=new_max_export, + ) _LOGGER.info(f"local data update callback for entity: {key} new limit: {new_max_export}") + plugin_instance = solax_plugin( - plugin_name = 'SolaX', - plugin_manufacturer = 'SolaX Power', - SENSOR_TYPES = SENSOR_TYPES_MAIN, - NUMBER_TYPES = NUMBER_TYPES, - BUTTON_TYPES = BUTTON_TYPES, - SELECT_TYPES = SELECT_TYPES, - block_size = 100, - order16 = Endian.BIG, - order32 = Endian.LITTLE, - auto_block_ignore_readerror = True - ) + plugin_name="SolaX", + plugin_manufacturer="SolaX Power", + SENSOR_TYPES=SENSOR_TYPES_MAIN, + NUMBER_TYPES=NUMBER_TYPES, + BUTTON_TYPES=BUTTON_TYPES, + SELECT_TYPES=SELECT_TYPES, + SWITCH_TYPES=[], + block_size=100, + order16=Endian.BIG, + order32=Endian.LITTLE, + auto_block_ignore_readerror=True, +) diff --git a/custom_components/solax_modbus/plugin_solax_a1j1.py b/custom_components/solax_modbus/plugin_solax_a1j1.py index 26e0556d..0e5b9161 100644 --- a/custom_components/solax_modbus/plugin_solax_a1j1.py +++ b/custom_components/solax_modbus/plugin_solax_a1j1.py @@ -20,32 +20,32 @@ An entity can be declared multiple times (with different bitmasks) if the parameters are different for each inverter type """ -A1 = 0x0001 # base generation for MIC, PV, AC -J1 = 0x0002 -GEN3 = 0x0004 -GEN4 = 0x0008 -ALL_GEN_GROUP = A1 | J1 | GEN3 | GEN4 +A1 = 0x0001 # base generation for MIC, PV, AC +J1 = 0x0002 +GEN3 = 0x0004 +GEN4 = 0x0008 +ALL_GEN_GROUP = A1 | J1 | GEN3 | GEN4 -X1 = 0x0100 -X3 = 0x0200 -ALL_X_GROUP = X1 | X3 +X1 = 0x0100 +X3 = 0x0200 +ALL_X_GROUP = X1 | X3 -PV = 0x0400 # Needs further work on PV Only Inverters -AC = 0x0800 -HYBRID = 0x1000 -MIC = 0x2000 +PV = 0x0400 # Needs further work on PV Only Inverters +AC = 0x0800 +HYBRID = 0x1000 +MIC = 0x2000 ALL_TYPE_GROUP = PV | AC | HYBRID | MIC -EPS = 0x8000 -ALL_EPS_GROUP = EPS +EPS = 0x8000 +ALL_EPS_GROUP = EPS -DCB = 0x10000 # dry contact box - gen4 -ALL_DCB_GROUP = DCB +DCB = 0x10000 # dry contact box - gen4 +ALL_DCB_GROUP = DCB -PM = 0x20000 +PM = 0x20000 ALL_PM_GROUP = PM -ALLDEFAULT = 0 # should be equivalent to HYBRID | AC | GEN2 | GEN3 | GEN4 | X1 | X3 +ALLDEFAULT = 0 # should be equivalent to HYBRID | AC | GEN2 | GEN3 | GEN4 | X1 | X3 # ======================= end of bitmask handling code ============================================= @@ -53,6 +53,7 @@ # ====================== find inverter type and details =========================================== + async def async_read_serialnr(hub, address): res = None try: @@ -61,114 +62,146 @@ async def async_read_serialnr(hub, address): decoder = BinaryPayloadDecoder.fromRegisters(inverter_data.registers, byteorder=Endian.BIG) res = decoder.decode_string(14).decode("ascii") hub.seriesnumber = res - except Exception as ex: _LOGGER.warning(f"{hub.name}: attempt to read serialnumber failed at 0x{address:x}", exc_info=True) - if not res: _LOGGER.warning(f"{hub.name}: reading serial number from address 0x{address:x} failed; other address may succeed") + except Exception as ex: + _LOGGER.warning(f"{hub.name}: attempt to read serialnumber failed at 0x{address:x}", exc_info=True) + if not res: + _LOGGER.warning( + f"{hub.name}: reading serial number from address 0x{address:x} failed; other address may succeed" + ) _LOGGER.info(f"Read {hub.name} 0x{address:x} serial number before potential swap: {res}") return res + # ================================================================================================= + @dataclass class SolaxA1J1ModbusButtonEntityDescription(BaseModbusButtonEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class SolaxA1J1ModbusNumberEntityDescription(BaseModbusNumberEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class SolaxA1J1ModbusSelectEntityDescription(BaseModbusSelectEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class SolaXA1J1ModbusSensorEntityDescription(BaseModbusSensorEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice - #order16: int = Endian.BIG - #order32: int = Endian.LITTLE + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + # order16: int = Endian.BIG + # order32: int = Endian.LITTLE unit: int = REGISTER_U16 register_type: int = REG_HOLDING + # ====================================== Computed value functions ================================================= + def value_function_remotecontrol_recompute(initval, descr, datadict): - power_control = datadict.get('remotecontrol_power_control', "Disabled") - set_type = datadict.get('remotecontrol_set_type', "Set") # other options did not work - target = datadict.get('remotecontrol_active_power', 0) - reactive_power = datadict.get('remotecontrol_reactive_power', 0) - rc_duration = datadict.get('remotecontrol_duration', 20) - ap_up = datadict.get('active_power_upper', 0) - ap_lo = datadict.get('active_power_lower', 0) - reap_up = datadict.get('reactive_power_upper', 0) - reap_lo = datadict.get('reactive_power_lower', 0) - import_limit = datadict.get('remotecontrol_import_limit', 20000) - meas = datadict.get('measured_power', 0) - pv = datadict.get('pv_power_total', 0) - houseload_nett = datadict.get('inverter_power', 0) - meas - houseload_brut = pv - datadict.get('battery_power_charge', 0) - meas - if power_control == "Enabled Power Control": + power_control = datadict.get("remotecontrol_power_control", "Disabled") + set_type = datadict.get("remotecontrol_set_type", "Set") # other options did not work + target = datadict.get("remotecontrol_active_power", 0) + reactive_power = datadict.get("remotecontrol_reactive_power", 0) + rc_duration = datadict.get("remotecontrol_duration", 20) + ap_up = datadict.get("active_power_upper", 0) + ap_lo = datadict.get("active_power_lower", 0) + reap_up = datadict.get("reactive_power_upper", 0) + reap_lo = datadict.get("reactive_power_lower", 0) + import_limit = datadict.get("remotecontrol_import_limit", 20000) + meas = datadict.get("measured_power", 0) + pv = datadict.get("pv_power_total", 0) + houseload_nett = datadict.get("inverter_power", 0) - meas + houseload_brut = pv - datadict.get("battery_power_charge", 0) - meas + if power_control == "Enabled Power Control": ap_target = target - elif power_control == "Enabled Grid Control": # alternative computation for Power Control - if target <0 : ap_target = target - houseload_nett # subtract house load - else: ap_target = target - houseload_brut + elif power_control == "Enabled Grid Control": # alternative computation for Power Control + if target < 0: + ap_target = target - houseload_nett # subtract house load + else: + ap_target = target - houseload_brut power_control = "Enabled Power Control" - elif power_control == "Enabled Self Use": # alternative computation for Power Control - ap_target = 0 - houseload_nett # subtract house load + elif power_control == "Enabled Self Use": # alternative computation for Power Control + ap_target = 0 - houseload_nett # subtract house load power_control = "Enabled Power Control" - elif power_control == "Enabled Battery Control": # alternative computation for Power Control - ap_target = target - pv # subtract house load and pv + elif power_control == "Enabled Battery Control": # alternative computation for Power Control + ap_target = target - pv # subtract house load and pv power_control = "Enabled Power Control" - elif power_control == "Enabled Feedin Priority": # alternative computation for Power Control - if pv > houseload_nett: ap_target = 0 - pv + (houseload_brut - houseload_nett)*1.20 # 0 - pv + (houseload_brut - houseload_nett) - else: ap_target = 0 - houseload_nett + elif power_control == "Enabled Feedin Priority": # alternative computation for Power Control + if pv > houseload_nett: + ap_target = 0 - pv + (houseload_brut - houseload_nett) * 1.20 # 0 - pv + (houseload_brut - houseload_nett) + else: + ap_target = 0 - houseload_nett power_control = "Enabled Power Control" - elif power_control == "Enabled No Discharge": # alternative computation for Power Control - if pv <= houseload_nett: ap_target = 0 - pv + (houseload_brut - houseload_nett) # 0 - pv + (houseload_brut - houseload_nett) - else: ap_target = 0 - houseload_nett + elif power_control == "Enabled No Discharge": # alternative computation for Power Control + if pv <= houseload_nett: + ap_target = 0 - pv + (houseload_brut - houseload_nett) # 0 - pv + (houseload_brut - houseload_nett) + else: + ap_target = 0 - houseload_nett power_control = "Enabled Power Control" elif power_control == "Disabled": ap_target = target - autorepeat_duration = 10 # or zero - stop autorepeat since it makes no sense when disabled + autorepeat_duration = 10 # or zero - stop autorepeat since it makes no sense when disabled old_ap_target = ap_target - ap_target = min(ap_target, import_limit - houseload_brut) - #_LOGGER.warning(f"peak shaving: old_ap_target:{old_ap_target} new ap_target:{ap_target} max: {import_limit-houseload} min:{-export_limit-houseload}") - if old_ap_target != ap_target: - _LOGGER.debug(f"peak shaving: old_ap_target:{old_ap_target} new ap_target:{ap_target} max: {import_limit-houseload_brut}") - res = [ ('remotecontrol_power_control', power_control, ), - ('remotecontrol_set_type', set_type, ), - ('remotecontrol_active_power', max(min(ap_up, ap_target), ap_lo), ), - ('remotecontrol_reactive_power', max(min(reap_up, reactive_power), reap_lo), ), - ('remotecontrol_duration', rc_duration, ), - ] - if (power_control == "Disabled"): autorepeat_stop(datadict, descr.key) + ap_target = min(ap_target, import_limit - houseload_brut) + # _LOGGER.warning(f"peak shaving: old_ap_target:{old_ap_target} new ap_target:{ap_target} max: {import_limit-houseload} min:{-export_limit-houseload}") + if old_ap_target != ap_target: + _LOGGER.debug( + f"peak shaving: old_ap_target:{old_ap_target} new ap_target:{ap_target} max: {import_limit-houseload_brut}" + ) + res = [ + ( + "remotecontrol_power_control", + power_control, + ), + ( + "remotecontrol_set_type", + set_type, + ), + ( + "remotecontrol_active_power", + max(min(ap_up, ap_target), ap_lo), + ), + ( + "remotecontrol_reactive_power", + max(min(reap_up, reactive_power), reap_lo), + ), + ( + "remotecontrol_duration", + rc_duration, + ), + ] + if power_control == "Disabled": + autorepeat_stop(datadict, descr.key) _LOGGER.debug(f"Evaluated remotecontrol_trigger: corrected/clamped values: {res}") return res + def value_function_remotecontrol_autorepeat_remaining(initval, descr, datadict): - return autorepeat_remaining(datadict, 'remotecontrol_trigger', time()) + return autorepeat_remaining(datadict, "remotecontrol_trigger", time()) + # for testing prevent_update only -#def value_function_test_prevent(initval, descr, datadict): +# def value_function_test_prevent(initval, descr, datadict): # _LOGGER.warning(f"succeeded test prevent_update - datadict: {datadict['dummy_timed_charge_start_h']}") # return None # ================================= Button Declarations ============================================================ -BUTTON_TYPES = [ - -] +BUTTON_TYPES = [] # ================================= Number Declarations ============================================================ -NUMBER_TYPES = [ - -] +NUMBER_TYPES = [] # ================================= Select Declarations ============================================================ -SELECT_TYPES = [ - -] +SELECT_TYPES = [] # ================================= Sennsor Declarations ============================================================ @@ -179,214 +212,221 @@ def value_function_remotecontrol_autorepeat_remaining(initval, descr, datadict): # ### SolaXA1J1ModbusSensorEntityDescription( - name = "Series Number", - key = "seriesnumber", - register = 0x00, - unit = REGISTER_STR, + name="Series Number", + key="seriesnumber", + register=0x00, + unit=REGISTER_STR, wordcount=7, - allowedtypes = ALL_GEN_GROUP, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - icon = "mdi:information", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Firmware Version Inverter Master", - key = "firmware_version_inverter_master", - entity_registry_enabled_default = False, - register = 0x23, - allowedtypes = J1, - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:information", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Firmware Version Manager", - key = "firmware_version_manager", - register = 0x24, - allowedtypes = J1, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - icon = "mdi:information", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Firmware Version Manager Bootloader", - key = "firmware_version_manager_bootloader", - register = 0x25, - allowedtypes = J1, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - icon = "mdi:information", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Firmware Version Modbus", - key = "firmware_version_modbustcp", - register = 0x26, - allowedtypes = J1, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - icon = "mdi:information", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "RTC", - key = "rtc", - register = 0x27, - unit = REGISTER_WORDS, - wordcount = 6, - scale = value_function_rtc, - allowedtypes = J1, - entity_category = EntityCategory.DIAGNOSTIC, - entity_registry_enabled_default = False, - icon = "mdi:clock", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Charger Use Mode", - key = "charger_use_mode", - register = 0x2D, - scale = { 0: "Economic Mode", + allowedtypes=ALL_GEN_GROUP, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + icon="mdi:information", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Firmware Version Inverter Master", + key="firmware_version_inverter_master", + entity_registry_enabled_default=False, + register=0x23, + allowedtypes=J1, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:information", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Firmware Version Manager", + key="firmware_version_manager", + register=0x24, + allowedtypes=J1, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + icon="mdi:information", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Firmware Version Manager Bootloader", + key="firmware_version_manager_bootloader", + register=0x25, + allowedtypes=J1, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + icon="mdi:information", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Firmware Version Modbus", + key="firmware_version_modbustcp", + register=0x26, + allowedtypes=J1, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + icon="mdi:information", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="RTC", + key="rtc", + register=0x27, + unit=REGISTER_WORDS, + wordcount=6, + scale=value_function_rtc, + allowedtypes=J1, + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + icon="mdi:clock", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Charger Use Mode", + key="charger_use_mode", + register=0x2D, + scale={ + 0: "Economic Mode", 1: "Green Mode", 2: "Ease Use Mode", - 3: "Manual Mode", }, - allowedtypes = J1, - entity_registry_enabled_default = False, - icon = "mdi:dip-switch", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Charger Start Time 1", - key = "charger_start_time_1", - register = 0x2E, - allowedtypes = J1, - entity_registry_enabled_default = False, - icon = "mdi:battery-clock", - scale = value_function_gen4time, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Charger Stop Time 1", - key = "charger_stop_time_1", - register = 0x2F, - allowedtypes = J1, - entity_registry_enabled_default = False, - icon = "mdi:battery-clock", - scale = value_function_gen4time, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Charger Start Time 2", - key = "charger_start_time_2", - register = 0x30, - allowedtypes = J1, - entity_registry_enabled_default = False, - icon = "mdi:battery-clock", - scale = value_function_gen4time, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Charger Stop Time 2", - key = "charger_stop_time_2", - register = 0x31, - allowedtypes = J1, - entity_registry_enabled_default = False, - icon = "mdi:battery-clock", - scale = value_function_gen4time, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "ForceCharge SOC - Economic", - key = "forcharge_soc_economic", - native_unit_of_measurement = PERCENTAGE, - register = 0x33, - allowedtypes = J1, - entity_registry_enabled_default = False, - icon = "mdi:battery-sync", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Discharger Start Time 1", - key = "discharger_start_time_1", - register = 0x34, - allowedtypes = J1, - entity_registry_enabled_default = False, - icon = "mdi:battery-clock", - scale = value_function_gen4time, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Discharger Stop Time 1", - key = "discharger_stop_time_1", - register = 0x35, - allowedtypes = J1, - entity_registry_enabled_default = False, - icon = "mdi:battery-clock", - scale = value_function_gen4time, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Discharger Start Time 2", - key = "discharger_start_time_2", - register = 0x36, - allowedtypes = J1, - entity_registry_enabled_default = False, - icon = "mdi:battery-clock", - scale = value_function_gen4time, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Discharger Stop Time 2", - key = "discharger_stop_time_2", - register = 0x37, - allowedtypes = J1, - entity_registry_enabled_default = False, - icon = "mdi:battery-clock", - scale = value_function_gen4time, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "ForceCharge SOC - Green", - key = "forcharge_soc_green", - native_unit_of_measurement = PERCENTAGE, - register = 0x33, - allowedtypes = J1, - entity_registry_enabled_default = False, - icon = "mdi:battery-sync", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "EPS Mute", - key = "eps_mute", - register = 0x52, - scale = { 0: "Off", - 1: "On", }, - allowedtypes = J1 | EPS, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Language", - key = "language", - register = 0x53, - scale = { 0: "Nihongo", - 1: "Chūgokugo", }, - allowedtypes = J1 | EPS, - entity_registry_enabled_default = False, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Manual Mode", - key = "manual_mode", - register = 0x5A, - scale = { 0: "Stop Charge and Discharge", - 1: "Force Charge", - 2: "Force Discharge", }, - allowedtypes = J1, - entity_registry_enabled_default = False, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Power Factor Mode", - key = "power_factor_mode", - register = 0x5B, - scale = { 0: "Off", - 1: "Over Excited", - 2: "Under Excited", - 3: "Fix Q" }, - allowedtypes = J1, - entity_registry_enabled_default = False, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "EPS Set Frequency", - key = "eps_set_frequency", - native_unit_of_measurement = UnitOfFrequency.HERTZ, - state_class = SensorStateClass.MEASUREMENT, - register = 0x67, - scale = { 0: "50", - 1: "60", }, - allowedtypes = J1, - entity_registry_enabled_default = False, + 3: "Manual Mode", + }, + allowedtypes=J1, + entity_registry_enabled_default=False, + icon="mdi:dip-switch", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Charger Start Time 1", + key="charger_start_time_1", + register=0x2E, + allowedtypes=J1, + entity_registry_enabled_default=False, + icon="mdi:battery-clock", + scale=value_function_gen4time, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Charger Stop Time 1", + key="charger_stop_time_1", + register=0x2F, + allowedtypes=J1, + entity_registry_enabled_default=False, + icon="mdi:battery-clock", + scale=value_function_gen4time, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Charger Start Time 2", + key="charger_start_time_2", + register=0x30, + allowedtypes=J1, + entity_registry_enabled_default=False, + icon="mdi:battery-clock", + scale=value_function_gen4time, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Charger Stop Time 2", + key="charger_stop_time_2", + register=0x31, + allowedtypes=J1, + entity_registry_enabled_default=False, + icon="mdi:battery-clock", + scale=value_function_gen4time, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="ForceCharge SOC - Economic", + key="forcharge_soc_economic", + native_unit_of_measurement=PERCENTAGE, + register=0x33, + allowedtypes=J1, + entity_registry_enabled_default=False, + icon="mdi:battery-sync", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Discharger Start Time 1", + key="discharger_start_time_1", + register=0x34, + allowedtypes=J1, + entity_registry_enabled_default=False, + icon="mdi:battery-clock", + scale=value_function_gen4time, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Discharger Stop Time 1", + key="discharger_stop_time_1", + register=0x35, + allowedtypes=J1, + entity_registry_enabled_default=False, + icon="mdi:battery-clock", + scale=value_function_gen4time, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Discharger Start Time 2", + key="discharger_start_time_2", + register=0x36, + allowedtypes=J1, + entity_registry_enabled_default=False, + icon="mdi:battery-clock", + scale=value_function_gen4time, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Discharger Stop Time 2", + key="discharger_stop_time_2", + register=0x37, + allowedtypes=J1, + entity_registry_enabled_default=False, + icon="mdi:battery-clock", + scale=value_function_gen4time, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="ForceCharge SOC - Green", + key="forcharge_soc_green", + native_unit_of_measurement=PERCENTAGE, + register=0x33, + allowedtypes=J1, + entity_registry_enabled_default=False, + icon="mdi:battery-sync", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="EPS Mute", + key="eps_mute", + register=0x52, + scale={ + 0: "Off", + 1: "On", + }, + allowedtypes=J1 | EPS, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Language", + key="language", + register=0x53, + scale={ + 0: "Nihongo", + 1: "Chūgokugo", + }, + allowedtypes=J1 | EPS, + entity_registry_enabled_default=False, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Manual Mode", + key="manual_mode", + register=0x5A, + scale={ + 0: "Stop Charge and Discharge", + 1: "Force Charge", + 2: "Force Discharge", + }, + allowedtypes=J1, + entity_registry_enabled_default=False, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Power Factor Mode", + key="power_factor_mode", + register=0x5B, + scale={0: "Off", 1: "Over Excited", 2: "Under Excited", 3: "Fix Q"}, + allowedtypes=J1, + entity_registry_enabled_default=False, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="EPS Set Frequency", + key="eps_set_frequency", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0x67, + scale={ + 0: "50", + 1: "60", + }, + allowedtypes=J1, + entity_registry_enabled_default=False, ), ### # @@ -394,647 +434,650 @@ def value_function_remotecontrol_autorepeat_remaining(initval, descr, datadict): # ### SolaXA1J1ModbusSensorEntityDescription( - name = "Inverter Voltage L1", - key = "inverter_voltage_l1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x0, - register_type = REG_INPUT, - rounding = 1, - scale = 0.1, - allowedtypes = J1, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Inverter Current L1", - key = "inverter_current_l1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x1, - register_type = REG_INPUT, - rounding = 1, - scale = 0.1, - unit = REGISTER_S16, - allowedtypes = J1, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Inverter Power L1", - key = "inverter_power_l1", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x2, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = J1, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Inverter Voltage L2", - key = "inverter_voltage_l2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x3, - scale = 0.1, - register_type = REG_INPUT, - rounding = 1, - allowedtypes = J1, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Inverter Current L2", - key = "inverter_current_l2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x4, - register_type = REG_INPUT, - rounding = 1, - scale = 0.1, - unit = REGISTER_S16, - allowedtypes = J1, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Inverter Power L2", - key = "inverter_power_l2", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x5, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = J1, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Inverter Frequency L1", - key = "inverter_frequency_l1", - native_unit_of_measurement = UnitOfFrequency.HERTZ, - state_class = SensorStateClass.MEASUREMENT, - register = 0x6, - register_type = REG_INPUT, - rounding = 2, - scale = 0.01, - allowedtypes = J1, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Measured Power L1", - key = "measured_power_l1", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x7, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = J1, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Measured Power L2", - key = "measured_power_l2", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x8, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = J1, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "PV Voltage 1", - key = "pv_voltage_1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x9, - register_type = REG_INPUT, - rounding = 1, - scale = 0.1, - allowedtypes = J1, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "PV Current 1", - key = "pv_current_1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0xA, - register_type = REG_INPUT, - scale = 0.1, - allowedtypes = J1, - icon = "mdi:current-dc", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "PV Power 1", - key = "pv_power_1", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0xB, - register_type = REG_INPUT, - allowedtypes = J1, - icon = "mdi:solar-power-variant", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "PV Voltage 2", - key = "pv_voltage_2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0xC, - register_type = REG_INPUT, - rounding = 1, - scale = 0.1, - allowedtypes = J1, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "PV Current 2", - key = "pv_current_2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0xD, - register_type = REG_INPUT, - scale = 0.1, - allowedtypes = J1, - icon = "mdi:current-dc", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "PV Power 2", - key = "pv_power_2", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0xE, - register_type = REG_INPUT, - allowedtypes = J1, - icon = "mdi:solar-power-variant", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "PV Voltage 3", - key = "pv_voltage_3", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0xF, - register_type = REG_INPUT, - rounding = 1, - scale = 0.1, - allowedtypes = J1, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "PV Current 3", - key = "pv_current_3", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x10, - register_type = REG_INPUT, - scale = 0.1, - allowedtypes = J1, - icon = "mdi:current-dc", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "PV Power 3", - key = "pv_power_3", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x11, - register_type = REG_INPUT, - allowedtypes = J1, - icon = "mdi:solar-power-variant", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Battery Voltage", - key = "battery_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x12, - register_type = REG_INPUT, - scale = 0.1, - allowedtypes = J1, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Battery Current", - key = "battery_current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x13, - register_type = REG_INPUT, - scale = 0.1, - unit = REGISTER_S16, - allowedtypes = J1, - icon = "mdi:current-dc", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Battery Power", - key = "battery_power", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x14, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = J1, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Battery Temperature", - key = "battery_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x16, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = J1, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Battery Capacity", - key = "battery_capacity_charge", - native_unit_of_measurement = PERCENTAGE, - device_class = SensorDeviceClass.BATTERY, - register = 0x17, - register_type = REG_INPUT, - allowedtypes = J1, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Inverter Temperature", - key = "inverter_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x1A, - register_type = REG_INPUT, - allowedtypes = J1, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "EPS Voltage L1", - key = "eps_voltage_l1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x1D, - register_type = REG_INPUT, - scale = 0.1, - allowedtypes = J1 | EPS, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "EPS Current L1", - key = "eps_current_l1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x1E, - register_type = REG_INPUT, - scale = 0.1, - unit = REGISTER_S16, - allowedtypes = J1 | EPS, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "EPS Power Active L1", - key = "eps_power_active_l1", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x1F, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = J1 | EPS, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "EPS Power L1", - key = "eps_power_l1", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - register = 0x20, - register_type = REG_INPUT, - allowedtypes = J1 | EPS, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "EPS Voltage L2", - key = "eps_voltage_l2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x21, - register_type = REG_INPUT, - scale = 0.1, - allowedtypes = J1 | EPS, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "EPS Current L2", - key = "eps_current_l2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x22, - register_type = REG_INPUT, - scale = 0.1, - unit = REGISTER_S16, - allowedtypes = J1 | EPS, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "EPS Power Active L2", - key = "eps_power_active_l2", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x23, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = J1 | EPS, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "EPS Power L2", - key = "eps_power_l2", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - register = 0x24, - register_type = REG_INPUT, - allowedtypes = J1 | EPS, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "EPS Frequency L1", - key = "eps_frequency_l1", - native_unit_of_measurement = UnitOfFrequency.HERTZ, - state_class = SensorStateClass.MEASUREMENT, - register = 0x25, - register_type = REG_INPUT, - rounding = 2, - scale = 0.01, - allowedtypes = J1 | EPS, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Today's Yield", - key = "today_yield", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x2B, - register_type = REG_INPUT, - scale = 0.1, - allowedtypes = J1, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Total Yield", - key = "total_yield", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x2C, - register_type = REG_INPUT, - scale = 0.1, - unit = REGISTER_U32, - allowedtypes = J1, - entity_registry_enabled_default = False, - icon = "mdi:solar-power", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Total E Charge", - key = "total_e_charge", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x2E, - register_type = REG_INPUT, - scale = 0.1, - unit = REGISTER_U32, - allowedtypes = J1, - entity_registry_enabled_default = False, - icon = "mdi:solar-power", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Today's E Charge", - key = "today_e_charge", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x30, - register_type = REG_INPUT, - scale = 0.1, - allowedtypes = J1, - entity_registry_enabled_default = False, - icon = "mdi:solar-power", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Today's Battery Output Energy", - key = "today_battery_output_energy", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x31, - register_type = REG_INPUT, - scale = 0.1, - allowedtypes = J1, - icon = "mdi:battery-arrow-down", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Total Battery Output Energy", - key = "total_battery_output_energy", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x32, - register_type = REG_INPUT, - scale = 0.1, - unit = REGISTER_U32, - allowedtypes = J1, - icon = "mdi:battery-arrow-down", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Total Battery Input Energy", - key = "total_battery_input_energy", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x34, - register_type = REG_INPUT, - scale = 0.1, - unit = REGISTER_U32, - allowedtypes = J1, - icon = "mdi:battery-arrow-ip", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Today's Battery Input Energy", - key = "today_battery_inpput_energy", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x36, - register_type = REG_INPUT, - scale = 0.1, - allowedtypes = J1, - icon = "mdi:battery-arrow-up", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Today's EPS Yield", - key = "today_eps_yield", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x37, - register_type = REG_INPUT, - scale = 0.1, - allowedtypes = J1 | EPS, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Total EPS Yield", - key = "total_eps_yield", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x38, - register_type = REG_INPUT, - scale = 0.1, - unit = REGISTER_U32, - allowedtypes = J1 | EPS, - entity_registry_enabled_default = False, - icon = "mdi:solar-power", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Total Solar Energy", - key = "total_solar_energy", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x3A, - register_type = REG_INPUT, - scale = 0.1, - unit = REGISTER_U32, - allowedtypes = J1, - entity_registry_enabled_default = False, - icon = "mdi:solar-power", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Today's Solar Energy", - key = "today_solar_energy", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x3C, - register_type = REG_INPUT, - scale = 0.1, - allowedtypes = J1, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Today's Grid Export", - key = "today_grid_export", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x3E, - register_type = REG_INPUT, - scale = 0.1, - unit = REGISTER_U32, - allowedtypes = J1, - icon = "mdi:home-export-outline", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Total Grid Export", - key = "total_grid_export", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x40, - register_type = REG_INPUT, - scale = 0.1, - unit = REGISTER_U32, - allowedtypes = J1, - entity_registry_enabled_default = False, - icon = "mdi:home-export-outline", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Today's Grid Import", - key = "today_grid_import", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x42, - register_type = REG_INPUT, - scale = 0.1, - unit = REGISTER_U32, - allowedtypes = J1, - icon = "mdi:home-import-outline", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Total Grid Import", - key = "total_grid_import", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x44, - register_type = REG_INPUT, - scale = 0.1, - unit = REGISTER_U32, - allowedtypes = J1, - entity_registry_enabled_default = False, - icon = "mdi:home-import-outline", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Grid Mode Runtime", - key = "grid_mode_runtime", - native_unit_of_measurement = UnitOfTime.HOURS, - register = 0x46, - register_type = REG_INPUT, - unit = REGISTER_U32, - scale = 0.1, - allowedtypes = J1, - icon = "mdi:timer", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "EPS Mode Runtime", - key = "eps_mode_runtime", - native_unit_of_measurement = UnitOfTime.HOURS, - register = 0x48, - register_type = REG_INPUT, - unit = REGISTER_U32, - scale = 0.1, - rounding = 1, - allowedtypes = J1, - icon = "mdi:timer", - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "Inverter Frequency L2", - key = "inverter_frequency_l2", - native_unit_of_measurement = UnitOfFrequency.HERTZ, - state_class = SensorStateClass.MEASUREMENT, - register = 0x7E, - register_type = REG_INPUT, - rounding = 2, - scale = 0.01, - allowedtypes = J1, - ), - SolaXA1J1ModbusSensorEntityDescription( - name = "EPS Frequency L2", - key = "eps_frequency_l2", - native_unit_of_measurement = UnitOfFrequency.HERTZ, - state_class = SensorStateClass.MEASUREMENT, - register = 0x7F, - register_type = REG_INPUT, - rounding = 2, - scale = 0.01, - allowedtypes = J1 | EPS, + name="Inverter Voltage L1", + key="inverter_voltage_l1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x0, + register_type=REG_INPUT, + rounding=1, + scale=0.1, + allowedtypes=J1, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Inverter Current L1", + key="inverter_current_l1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x1, + register_type=REG_INPUT, + rounding=1, + scale=0.1, + unit=REGISTER_S16, + allowedtypes=J1, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Inverter Power L1", + key="inverter_power_l1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x2, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=J1, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Inverter Voltage L2", + key="inverter_voltage_l2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x3, + scale=0.1, + register_type=REG_INPUT, + rounding=1, + allowedtypes=J1, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Inverter Current L2", + key="inverter_current_l2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x4, + register_type=REG_INPUT, + rounding=1, + scale=0.1, + unit=REGISTER_S16, + allowedtypes=J1, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Inverter Power L2", + key="inverter_power_l2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x5, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=J1, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Inverter Frequency L1", + key="inverter_frequency_l1", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0x6, + register_type=REG_INPUT, + rounding=2, + scale=0.01, + allowedtypes=J1, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Measured Power L1", + key="measured_power_l1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x7, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=J1, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Measured Power L2", + key="measured_power_l2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x8, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=J1, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="PV Voltage 1", + key="pv_voltage_1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x9, + register_type=REG_INPUT, + rounding=1, + scale=0.1, + allowedtypes=J1, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="PV Current 1", + key="pv_current_1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0xA, + register_type=REG_INPUT, + scale=0.1, + allowedtypes=J1, + icon="mdi:current-dc", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="PV Power 1", + key="pv_power_1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0xB, + register_type=REG_INPUT, + allowedtypes=J1, + icon="mdi:solar-power-variant", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="PV Voltage 2", + key="pv_voltage_2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0xC, + register_type=REG_INPUT, + rounding=1, + scale=0.1, + allowedtypes=J1, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="PV Current 2", + key="pv_current_2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0xD, + register_type=REG_INPUT, + scale=0.1, + allowedtypes=J1, + icon="mdi:current-dc", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="PV Power 2", + key="pv_power_2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0xE, + register_type=REG_INPUT, + allowedtypes=J1, + icon="mdi:solar-power-variant", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="PV Voltage 3", + key="pv_voltage_3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0xF, + register_type=REG_INPUT, + rounding=1, + scale=0.1, + allowedtypes=J1, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="PV Current 3", + key="pv_current_3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x10, + register_type=REG_INPUT, + scale=0.1, + allowedtypes=J1, + icon="mdi:current-dc", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="PV Power 3", + key="pv_power_3", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x11, + register_type=REG_INPUT, + allowedtypes=J1, + icon="mdi:solar-power-variant", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Battery Voltage", + key="battery_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x12, + register_type=REG_INPUT, + scale=0.1, + allowedtypes=J1, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Battery Current", + key="battery_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x13, + register_type=REG_INPUT, + scale=0.1, + unit=REGISTER_S16, + allowedtypes=J1, + icon="mdi:current-dc", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Battery Power", + key="battery_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x14, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=J1, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Battery Temperature", + key="battery_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x16, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=J1, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Battery Capacity", + key="battery_capacity_charge", + native_unit_of_measurement=PERCENTAGE, + device_class=SensorDeviceClass.BATTERY, + register=0x17, + register_type=REG_INPUT, + allowedtypes=J1, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Inverter Temperature", + key="inverter_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x1A, + register_type=REG_INPUT, + allowedtypes=J1, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="EPS Voltage L1", + key="eps_voltage_l1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x1D, + register_type=REG_INPUT, + scale=0.1, + allowedtypes=J1 | EPS, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="EPS Current L1", + key="eps_current_l1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x1E, + register_type=REG_INPUT, + scale=0.1, + unit=REGISTER_S16, + allowedtypes=J1 | EPS, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="EPS Power Active L1", + key="eps_power_active_l1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x1F, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=J1 | EPS, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="EPS Power L1", + key="eps_power_l1", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=0x20, + register_type=REG_INPUT, + allowedtypes=J1 | EPS, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="EPS Voltage L2", + key="eps_voltage_l2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x21, + register_type=REG_INPUT, + scale=0.1, + allowedtypes=J1 | EPS, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="EPS Current L2", + key="eps_current_l2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x22, + register_type=REG_INPUT, + scale=0.1, + unit=REGISTER_S16, + allowedtypes=J1 | EPS, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="EPS Power Active L2", + key="eps_power_active_l2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x23, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=J1 | EPS, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="EPS Power L2", + key="eps_power_l2", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=0x24, + register_type=REG_INPUT, + allowedtypes=J1 | EPS, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="EPS Frequency L1", + key="eps_frequency_l1", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0x25, + register_type=REG_INPUT, + rounding=2, + scale=0.01, + allowedtypes=J1 | EPS, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Today's Yield", + key="today_yield", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x2B, + register_type=REG_INPUT, + scale=0.1, + allowedtypes=J1, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Total Yield", + key="total_yield", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x2C, + register_type=REG_INPUT, + scale=0.1, + unit=REGISTER_U32, + allowedtypes=J1, + entity_registry_enabled_default=False, + icon="mdi:solar-power", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Total E Charge", + key="total_e_charge", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x2E, + register_type=REG_INPUT, + scale=0.1, + unit=REGISTER_U32, + allowedtypes=J1, + entity_registry_enabled_default=False, + icon="mdi:solar-power", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Today's E Charge", + key="today_e_charge", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x30, + register_type=REG_INPUT, + scale=0.1, + allowedtypes=J1, + entity_registry_enabled_default=False, + icon="mdi:solar-power", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Today's Battery Output Energy", + key="today_battery_output_energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x31, + register_type=REG_INPUT, + scale=0.1, + allowedtypes=J1, + icon="mdi:battery-arrow-down", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Total Battery Output Energy", + key="total_battery_output_energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x32, + register_type=REG_INPUT, + scale=0.1, + unit=REGISTER_U32, + allowedtypes=J1, + icon="mdi:battery-arrow-down", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Total Battery Input Energy", + key="total_battery_input_energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x34, + register_type=REG_INPUT, + scale=0.1, + unit=REGISTER_U32, + allowedtypes=J1, + icon="mdi:battery-arrow-ip", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Today's Battery Input Energy", + key="today_battery_inpput_energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x36, + register_type=REG_INPUT, + scale=0.1, + allowedtypes=J1, + icon="mdi:battery-arrow-up", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Today's EPS Yield", + key="today_eps_yield", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x37, + register_type=REG_INPUT, + scale=0.1, + allowedtypes=J1 | EPS, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Total EPS Yield", + key="total_eps_yield", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x38, + register_type=REG_INPUT, + scale=0.1, + unit=REGISTER_U32, + allowedtypes=J1 | EPS, + entity_registry_enabled_default=False, + icon="mdi:solar-power", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Total Solar Energy", + key="total_solar_energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x3A, + register_type=REG_INPUT, + scale=0.1, + unit=REGISTER_U32, + allowedtypes=J1, + entity_registry_enabled_default=False, + icon="mdi:solar-power", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Today's Solar Energy", + key="today_solar_energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x3C, + register_type=REG_INPUT, + scale=0.1, + allowedtypes=J1, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Today's Grid Export", + key="today_grid_export", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x3E, + register_type=REG_INPUT, + scale=0.1, + unit=REGISTER_U32, + allowedtypes=J1, + icon="mdi:home-export-outline", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Total Grid Export", + key="total_grid_export", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x40, + register_type=REG_INPUT, + scale=0.1, + unit=REGISTER_U32, + allowedtypes=J1, + entity_registry_enabled_default=False, + icon="mdi:home-export-outline", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Today's Grid Import", + key="today_grid_import", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x42, + register_type=REG_INPUT, + scale=0.1, + unit=REGISTER_U32, + allowedtypes=J1, + icon="mdi:home-import-outline", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Total Grid Import", + key="total_grid_import", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x44, + register_type=REG_INPUT, + scale=0.1, + unit=REGISTER_U32, + allowedtypes=J1, + entity_registry_enabled_default=False, + icon="mdi:home-import-outline", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Grid Mode Runtime", + key="grid_mode_runtime", + native_unit_of_measurement=UnitOfTime.HOURS, + register=0x46, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.1, + allowedtypes=J1, + icon="mdi:timer", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="EPS Mode Runtime", + key="eps_mode_runtime", + native_unit_of_measurement=UnitOfTime.HOURS, + register=0x48, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.1, + rounding=1, + allowedtypes=J1, + icon="mdi:timer", + ), + SolaXA1J1ModbusSensorEntityDescription( + name="Inverter Frequency L2", + key="inverter_frequency_l2", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0x7E, + register_type=REG_INPUT, + rounding=2, + scale=0.01, + allowedtypes=J1, + ), + SolaXA1J1ModbusSensorEntityDescription( + name="EPS Frequency L2", + key="eps_frequency_l2", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0x7F, + register_type=REG_INPUT, + rounding=2, + scale=0.01, + allowedtypes=J1 | EPS, ), ] # ============================ plugin declaration ================================================= + @dataclass class solax_a1j1_plugin(plugin_base): def isAwake(self, datadict): - """ determine if inverter is awake based on polled datadict""" - return (datadict.get('run_mode', None) == 'Normal Mode') + """determine if inverter is awake based on polled datadict""" + return datadict.get("run_mode", None) == "Normal Mode" def wakeupButton(self): - """ in order to wake up the inverter , press this button """ - return 'battery_awaken' + """in order to wake up the inverter , press this button""" + return "battery_awaken" async def async_determineInverterType(self, hub, configdict): - #global SENSOR_TYPES + # global SENSOR_TYPES _LOGGER.info(f"{hub.name}: trying to determine inverter type") - seriesnumber = await async_read_serialnr(hub, 0x0) + seriesnumber = await async_read_serialnr(hub, 0x0) if not seriesnumber: - seriesnumber = await async_read_serialnr(hub, 0x300) # bug in Endian.LITTLE decoding? + seriesnumber = await async_read_serialnr(hub, 0x300) # bug in Endian.LITTLE decoding? if seriesnumber and not seriesnumber.startswith(("M", "X")): - ba = bytearray(seriesnumber,"ascii") # convert to bytearray for swapping - ba[0::2], ba[1::2] = ba[1::2], ba[0::2] # swap bytes ourselves - due to bug in Endian.LITTLE ? - res = str(ba, "ascii") # convert back to string + ba = bytearray(seriesnumber, "ascii") # convert to bytearray for swapping + ba[0::2], ba[1::2] = ba[1::2], ba[0::2] # swap bytes ourselves - due to bug in Endian.LITTLE ? + res = str(ba, "ascii") # convert back to string seriesnumber = res if not seriesnumber: _LOGGER.error(f"{hub.name}: cannot find serial number, even not for MIC") seriesnumber = "unknown" # derive invertertupe from seriiesnumber - if seriesnumber.startswith('J1'): invertertype = HYBRID | J1 # J1 Hybrid - Unknown Serial - elif seriesnumber.startswith('A1'): invertertype = HYBRID | A1 # A1 Hybrid - Unknown Serial + if seriesnumber.startswith("J1"): + invertertype = HYBRID | J1 # J1 Hybrid - Unknown Serial + elif seriesnumber.startswith("A1"): + invertertype = HYBRID | A1 # A1 Hybrid - Unknown Serial # add cases here else: invertertype = 0 @@ -1044,27 +1087,32 @@ async def async_determineInverterType(self, hub, configdict): read_eps = configdict.get(CONF_READ_EPS, DEFAULT_READ_EPS) read_dcb = configdict.get(CONF_READ_DCB, DEFAULT_READ_DCB) read_pm = configdict.get(CONF_READ_PM, DEFAULT_READ_PM) - if read_eps: invertertype = invertertype | EPS - if read_dcb: invertertype = invertertype | DCB - if read_pm: invertertype = invertertype | PM + if read_eps: + invertertype = invertertype | EPS + if read_dcb: + invertertype = invertertype | DCB + if read_pm: + invertertype = invertertype | PM - if invertertype & MIC: self.SENSOR_TYPES = SENSOR_TYPES_MIC - #else: self.SENSOR_TYPES = SENSOR_TYPES_MAIN + if invertertype & MIC: + self.SENSOR_TYPES = SENSOR_TYPES_MIC + # else: self.SENSOR_TYPES = SENSOR_TYPES_MAIN return invertertype - def matchInverterWithMask (self, inverterspec, entitymask, serialnumber = 'not relevant', blacklist = None): + def matchInverterWithMask(self, inverterspec, entitymask, serialnumber="not relevant", blacklist=None): # returns true if the entity needs to be created for an inverter - genmatch = ((inverterspec & entitymask & ALL_GEN_GROUP) != 0) or (entitymask & ALL_GEN_GROUP == 0) - xmatch = ((inverterspec & entitymask & ALL_X_GROUP) != 0) or (entitymask & ALL_X_GROUP == 0) + genmatch = ((inverterspec & entitymask & ALL_GEN_GROUP) != 0) or (entitymask & ALL_GEN_GROUP == 0) + xmatch = ((inverterspec & entitymask & ALL_X_GROUP) != 0) or (entitymask & ALL_X_GROUP == 0) hybmatch = ((inverterspec & entitymask & ALL_TYPE_GROUP) != 0) or (entitymask & ALL_TYPE_GROUP == 0) - epsmatch = ((inverterspec & entitymask & ALL_EPS_GROUP) != 0) or (entitymask & ALL_EPS_GROUP == 0) - dcbmatch = ((inverterspec & entitymask & ALL_DCB_GROUP) != 0) or (entitymask & ALL_DCB_GROUP == 0) - pmmatch = ((inverterspec & entitymask & ALL_PM_GROUP) != 0) or (entitymask & ALL_PM_GROUP == 0) + epsmatch = ((inverterspec & entitymask & ALL_EPS_GROUP) != 0) or (entitymask & ALL_EPS_GROUP == 0) + dcbmatch = ((inverterspec & entitymask & ALL_DCB_GROUP) != 0) or (entitymask & ALL_DCB_GROUP == 0) + pmmatch = ((inverterspec & entitymask & ALL_PM_GROUP) != 0) or (entitymask & ALL_PM_GROUP == 0) blacklisted = False if blacklist: for start in blacklist: - if serialnumber.startswith(start) : blacklisted = True + if serialnumber.startswith(start): + blacklisted = True return (genmatch and xmatch and hybmatch and epsmatch and dcbmatch and pmmatch) and not blacklisted def localDataCallback(self, hub): @@ -1076,33 +1124,53 @@ def localDataCallback(self, hub): if config_scale_entity and config_scale_entity.enabled: new_read_scale = hub.data.get("config_export_control_limit_readscale") if new_read_scale != None: - _LOGGER.info(f"local data update callback for read_scale: {new_read_scale} enabled: {config_scale_entity.enabled}") + _LOGGER.info( + f"local data update callback for read_scale: {new_read_scale} enabled: {config_scale_entity.enabled}" + ) number_entity = hub.numberEntities.get("export_control_user_limit") sensor_entity = hub.sensorEntities.get("export_control_user_limit") - if number_entity: number_entity.entity_description = replace(number_entity.entity_description, read_scale = new_read_scale, ) - if sensor_entity: sensor_entity.entity_description = replace(sensor_entity.entity_description, read_scale = new_read_scale, ) + if number_entity: + number_entity.entity_description = replace( + number_entity.entity_description, + read_scale=new_read_scale, + ) + if sensor_entity: + sensor_entity.entity_description = replace( + sensor_entity.entity_description, + read_scale=new_read_scale, + ) config_maxexport_entity = hub.numberEntities.get("config_max_export") if config_maxexport_entity and config_maxexport_entity.enabled: new_max_export = hub.data.get("config_max_export") if new_max_export != None: - for key in ["remotecontrol_active_power", "remotecontrol_import_limit", "export_control_user_limit", "external_generation_max_charge"]: + for key in [ + "remotecontrol_active_power", + "remotecontrol_import_limit", + "export_control_user_limit", + "external_generation_max_charge", + ]: number_entity = hub.numberEntities.get(key) if number_entity: number_entity._attr_native_max_value = new_max_export # update description also, not sure whether needed or not - number_entity.entity_description = replace(number_entity.entity_description, native_max_value = new_max_export, ) + number_entity.entity_description = replace( + number_entity.entity_description, + native_max_value=new_max_export, + ) _LOGGER.info(f"local data update callback for entity: {key} new limit: {new_max_export}") + plugin_instance = solax_a1j1_plugin( - plugin_name = 'SolaX A1-J1', - plugin_manufacturer = 'SolaX Power', - SENSOR_TYPES = SENSOR_TYPES_MAIN, - NUMBER_TYPES = NUMBER_TYPES, - BUTTON_TYPES = BUTTON_TYPES, - SELECT_TYPES = SELECT_TYPES, - block_size = 100, - order16 = Endian.BIG, - order32 = Endian.LITTLE, - auto_block_ignore_readerror = True - ) \ No newline at end of file + plugin_name="SolaX A1-J1", + plugin_manufacturer="SolaX Power", + SENSOR_TYPES=SENSOR_TYPES_MAIN, + NUMBER_TYPES=NUMBER_TYPES, + BUTTON_TYPES=BUTTON_TYPES, + SELECT_TYPES=SELECT_TYPES, + SWITCH_TYPES=[], + block_size=100, + order16=Endian.BIG, + order32=Endian.LITTLE, + auto_block_ignore_readerror=True, +) diff --git a/custom_components/solax_modbus/plugin_solax_ev_charger.py b/custom_components/solax_modbus/plugin_solax_ev_charger.py index 6f7ac390..92fad4ae 100644 --- a/custom_components/solax_modbus/plugin_solax_ev_charger.py +++ b/custom_components/solax_modbus/plugin_solax_ev_charger.py @@ -20,22 +20,22 @@ An entity can be declared multiple times (with different bitmasks) if the parameters are different for each inverter type """ -GEN = 0x0001 # base generation for MIC, PV, AC -GEN2 = 0x0002 -GEN3 = 0x0004 -GEN4 = 0x0008 -ALL_GEN_GROUP = GEN2 | GEN3 | GEN4 | GEN +GEN = 0x0001 # base generation for MIC, PV, AC +GEN2 = 0x0002 +GEN3 = 0x0004 +GEN4 = 0x0008 +ALL_GEN_GROUP = GEN2 | GEN3 | GEN4 | GEN -X1 = 0x0100 -X3 = 0x0200 -ALL_X_GROUP = X1 | X3 +X1 = 0x0100 +X3 = 0x0200 +ALL_X_GROUP = X1 | X3 -POW7 = 0x0001 -POW11 = 0x0002 -POW22 = 0x0004 -ALL_POW_GROUP = POW7 | POW11 | POW22 +POW7 = 0x0001 +POW11 = 0x0002 +POW22 = 0x0004 +ALL_POW_GROUP = POW7 | POW11 | POW22 -ALLDEFAULT = 0 # should be equivalent to HYBRID | AC | GEN2 | GEN3 | GEN4 | X1 | X3 +ALLDEFAULT = 0 # should be equivalent to HYBRID | AC | GEN2 | GEN3 | GEN4 | X1 | X3 # ======================= end of bitmask handling code ============================================= @@ -43,6 +43,7 @@ # ====================== find inverter type and details =========================================== + async def async_read_serialnr(hub, address): res = None try: @@ -51,45 +52,55 @@ async def async_read_serialnr(hub, address): decoder = BinaryPayloadDecoder.fromRegisters(inverter_data.registers, byteorder=Endian.BIG) res = decoder.decode_string(14).decode("ascii") hub.seriesnumber = res - except Exception as ex: _LOGGER.warning(f"{hub.name}: attempt to read serialnumber failed at 0x{address:x}", exc_info=True) - if not res: _LOGGER.warning(f"{hub.name}: reading serial number from address 0x{address:x} failed; other address may succeed") + except Exception as ex: + _LOGGER.warning(f"{hub.name}: attempt to read serialnumber failed at 0x{address:x}", exc_info=True) + if not res: + _LOGGER.warning( + f"{hub.name}: reading serial number from address 0x{address:x} failed; other address may succeed" + ) _LOGGER.info(f"Read {hub.name} 0x{address:x} serial number before potential swap: {res}") return res + # ================================================================================================= + @dataclass class SolaXEVChargerModbusButtonEntityDescription(BaseModbusButtonEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class SolaXEVChargerModbusNumberEntityDescription(BaseModbusNumberEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class SolaXEVChargerModbusSelectEntityDescription(BaseModbusSelectEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class SolaXEVChargerModbusSensorEntityDescription(BaseModbusSensorEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice - #order16: int = Endian.BIG - #order32: int = Endian.LITTLE + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + # order16: int = Endian.BIG + # order32: int = Endian.LITTLE unit: int = REGISTER_U16 register_type: int = REG_HOLDING + # ====================================== Computed value functions ================================================= # ================================= Button Declarations ============================================================ BUTTON_TYPES = [ SolaXEVChargerModbusButtonEntityDescription( - name = "Sync RTC", - key = "sync_rtc", - register = 0x61E, - write_method = WRITE_MULTI_MODBUS, - icon = "mdi:home-clock", - value_function = value_function_sync_rtc, + name="Sync RTC", + key="sync_rtc", + register=0x61E, + write_method=WRITE_MULTI_MODBUS, + icon="mdi:home-clock", + value_function=value_function_sync_rtc, ), ] @@ -101,35 +112,34 @@ class SolaXEVChargerModbusSensorEntityDescription(BaseModbusSensorEntityDescript # Data only number types # ### - ### # # Normal number types # ### SolaXEVChargerModbusNumberEntityDescription( - name = "Datahub Charge Current", - key = "datahub_charge_current", - register = 0x624, - fmt = "f", - native_min_value = 6, - native_max_value = 32, - native_step = 0.1, - scale = 0.01, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = NumberDeviceClass.CURRENT, + name="Datahub Charge Current", + key="datahub_charge_current", + register=0x624, + fmt="f", + native_min_value=6, + native_max_value=32, + native_step=0.1, + scale=0.01, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=NumberDeviceClass.CURRENT, ), SolaXEVChargerModbusNumberEntityDescription( - name = "Charge Current", - key = "charge_current", - register = 0x628, - fmt = "f", - native_min_value = 6, - native_max_value = 32, - native_step = 0.1, - scale = 0.01, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = NumberDeviceClass.CURRENT, + name="Charge Current", + key="charge_current", + register=0x628, + fmt="f", + native_min_value=6, + native_max_value=32, + native_step=0.1, + scale=0.01, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=NumberDeviceClass.CURRENT, ), ] @@ -141,116 +151,125 @@ class SolaXEVChargerModbusSensorEntityDescription(BaseModbusSensorEntityDescript # Data only select types # ### - ### # # Normal select types # ### SolaXEVChargerModbusSelectEntityDescription( - name = "Meter Setting", - key = "meter_setting", - register = 0x60C, - option_dict = { + name="Meter Setting", + key="meter_setting", + register=0x60C, + option_dict={ 0: "External CT", 1: "External Meter", - 2: "Inverter", }, - entity_registry_enabled_default = False, - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:meter-electric", + 2: "Inverter", + }, + entity_registry_enabled_default=False, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:meter-electric", ), SolaXEVChargerModbusSelectEntityDescription( - name = "Charger Use Mode", - key = "charger_use_mode", - register = 0x60D, - option_dict = { + name="Charger Use Mode", + key="charger_use_mode", + register=0x60D, + option_dict={ 0: "Stop", 1: "Fast", 2: "ECO", - 3: "Green", }, - icon = "mdi:dip-switch", + 3: "Green", + }, + icon="mdi:dip-switch", ), SolaXEVChargerModbusSelectEntityDescription( - name = "ECO Gear", - key = "eco_gear", - register = 0x60E, - option_dict = { + name="ECO Gear", + key="eco_gear", + register=0x60E, + option_dict={ 1: "6A", 2: "10A", 3: "16A", 4: "20A", - 5: "25A", }, - icon = "mdi:dip-switch", + 5: "25A", + }, + icon="mdi:dip-switch", ), SolaXEVChargerModbusSelectEntityDescription( - name = "Green Gear", - key = "green_gear", - register = 0x60F, - option_dict = { + name="Green Gear", + key="green_gear", + register=0x60F, + option_dict={ 1: "3A", - 2: "6A", }, - icon = "mdi:dip-switch", + 2: "6A", + }, + icon="mdi:dip-switch", ), SolaXEVChargerModbusSelectEntityDescription( - name = "Start Charge Mode", - key = "start_charge_mode", - register = 0x610, - option_dict = { + name="Start Charge Mode", + key="start_charge_mode", + register=0x610, + option_dict={ 0: "Plug & Charge", - 1: "RFID to Charge", }, - icon = "mdi:lock", + 1: "RFID to Charge", + }, + icon="mdi:lock", ), SolaXEVChargerModbusSelectEntityDescription( - name = "Boost Mode", - key = "boost_mode", - register = 0x613, - option_dict = { + name="Boost Mode", + key="boost_mode", + register=0x613, + option_dict={ 0: "Normal", 1: "Timer Boost", - 2: "Smart Boost", }, - icon = "mdi:dip-switch", + 2: "Smart Boost", + }, + icon="mdi:dip-switch", ), SolaXEVChargerModbusSelectEntityDescription( - name = "Device Lock", - key = "device_lock", - register = 0x615, - option_dict = { + name="Device Lock", + key="device_lock", + register=0x615, + option_dict={ 0: "Unlock", - 1: "Lock", }, - icon = "mdi:lock", + 1: "Lock", + }, + icon="mdi:lock", ), SolaXEVChargerModbusSelectEntityDescription( - name = "RFID Program", - key = "rfid_program", - register = 0x616, - option_dict = { + name="RFID Program", + key="rfid_program", + register=0x616, + option_dict={ 1: "Program New", - 0: "Program Off", }, - icon = "mdi:dip-switch", + 0: "Program Off", + }, + icon="mdi:dip-switch", ), SolaXEVChargerModbusSelectEntityDescription( - name = "Charge Phase", - key = "charge_phase", - register = 0x625, - option_dict = { + name="Charge Phase", + key="charge_phase", + register=0x625, + option_dict={ 0: "Three Phase", 1: "L1 Phase", 2: "L2 Phase", - 3: "L3 Phase", }, - icon = "mdi:dip-switch", + 3: "L3 Phase", + }, + icon="mdi:dip-switch", ), SolaXEVChargerModbusSelectEntityDescription( - name = "Control Command", - key = "control_command", - register = 0x627, - option_dict = { + name="Control Command", + key="control_command", + register=0x627, + option_dict={ 1: "Available", 2: "Unavailable", 3: "Stop charging", 4: "Start Charging", 5: "Reserve", - 6: "Cancel the Reservation", }, - icon = "mdi:dip-switch", + 6: "Cancel the Reservation", + }, + icon="mdi:dip-switch", ), ] @@ -263,150 +282,160 @@ class SolaXEVChargerModbusSensorEntityDescription(BaseModbusSensorEntityDescript # ### SolaXEVChargerModbusSensorEntityDescription( - name = "Meter Setting", - key = "meter_setting", - register = 0x60C, - scale = { + name="Meter Setting", + key="meter_setting", + register=0x60C, + scale={ 0: "External CT", 1: "External Meter", - 2: "Inverter", }, - entity_registry_enabled_default = False, - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:meter-electric", + 2: "Inverter", + }, + entity_registry_enabled_default=False, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:meter-electric", ), SolaXEVChargerModbusSensorEntityDescription( - name = "Charger Use Mode", - key = "charger_use_mode", - register = 0x60D, - scale = { + name="Charger Use Mode", + key="charger_use_mode", + register=0x60D, + scale={ 0: "Stop", 1: "Fast", 2: "ECO", - 3: "Green", }, - entity_registry_enabled_default = False, - icon = "mdi:dip-switch", + 3: "Green", + }, + entity_registry_enabled_default=False, + icon="mdi:dip-switch", ), SolaXEVChargerModbusSensorEntityDescription( - name = "ECO Gear", - key = "eco_gear", - register = 0x60E, - scale = { + name="ECO Gear", + key="eco_gear", + register=0x60E, + scale={ 1: "6A", 2: "10A", 3: "16A", 4: "20A", - 5: "25A", }, - entity_registry_enabled_default = False, - icon = "mdi:dip-switch", + 5: "25A", + }, + entity_registry_enabled_default=False, + icon="mdi:dip-switch", ), SolaXEVChargerModbusSensorEntityDescription( - name = "Green Gear", - key = "green_gear", - register = 0x60F, - scale = { + name="Green Gear", + key="green_gear", + register=0x60F, + scale={ 1: "3A", - 2: "6A", }, - entity_registry_enabled_default = False, - icon = "mdi:dip-switch", + 2: "6A", + }, + entity_registry_enabled_default=False, + icon="mdi:dip-switch", ), SolaXEVChargerModbusSensorEntityDescription( - name = "Start Charge Mode", - key = "start_charge_mode", - register = 0x610, - scale = { + name="Start Charge Mode", + key="start_charge_mode", + register=0x610, + scale={ 0: "Plug & Charge", - 1: "RFID to Charge", }, - entity_registry_enabled_default = False, - icon = "mdi:lock", + 1: "RFID to Charge", + }, + entity_registry_enabled_default=False, + icon="mdi:lock", ), SolaXEVChargerModbusSensorEntityDescription( - name = "Boost Mode", - key = "boost_mode", - register = 0x613, - scale = { + name="Boost Mode", + key="boost_mode", + register=0x613, + scale={ 0: "Normal", 1: "Timer Boost", - 2: "Smart Boost", }, - entity_registry_enabled_default = False, - icon = "mdi:dip-switch", + 2: "Smart Boost", + }, + entity_registry_enabled_default=False, + icon="mdi:dip-switch", ), SolaXEVChargerModbusSensorEntityDescription( - name = "Device Lock", - key = "device_lock", - register = 0x615, - scale = { + name="Device Lock", + key="device_lock", + register=0x615, + scale={ 0: "Unlock", - 1: "Lock", }, - entity_registry_enabled_default = False, - icon = "mdi:lock", + 1: "Lock", + }, + entity_registry_enabled_default=False, + icon="mdi:lock", ), SolaXEVChargerModbusSensorEntityDescription( - name = "RFID Program", - key = "rfid_program", - register = 0x616, - scale = { + name="RFID Program", + key="rfid_program", + register=0x616, + scale={ 1: "Program New", - 0: "Program Off", }, - entity_registry_enabled_default = False, - icon = "mdi:dip-switch", - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "RTC", - key = "rtc", - register = 0x61E, - unit = REGISTER_WORDS, - wordcount = 6, - scale = value_function_rtc, - entity_registry_enabled_default = False, - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:clock", - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Datahub Charge Current", - key = "datahub_charge_current", - register = 0x624, - scale = 0.01, - rounding = 1, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charge Phase", - key = "charge_phase", - register = 0x625, - scale = { + 0: "Program Off", + }, + entity_registry_enabled_default=False, + icon="mdi:dip-switch", + ), + SolaXEVChargerModbusSensorEntityDescription( + name="RTC", + key="rtc", + register=0x61E, + unit=REGISTER_WORDS, + wordcount=6, + scale=value_function_rtc, + entity_registry_enabled_default=False, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:clock", + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Datahub Charge Current", + key="datahub_charge_current", + register=0x624, + scale=0.01, + rounding=1, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charge Phase", + key="charge_phase", + register=0x625, + scale={ 0: "Three Phase", 1: "L1 Phase", 2: "L2 Phase", - 3: "L3 Phase", }, - allowedtypes = X3, - entity_registry_enabled_default = False, - icon = "mdi:dip-switch", - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charge Current", - key = "charge_current", - register = 0x628, - scale = 0.01, - rounding = 1, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Control Command", - key = "control_command", - register = 0x627, - scale = { + 3: "L3 Phase", + }, + allowedtypes=X3, + entity_registry_enabled_default=False, + icon="mdi:dip-switch", + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charge Current", + key="charge_current", + register=0x628, + scale=0.01, + rounding=1, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Control Command", + key="control_command", + register=0x627, + scale={ 1: "Available", 2: "Unavailable", 3: "Stop charging", 4: "Start Charging", 5: "Reserve", - 6: "Cancel the Reservation", }, - entity_registry_enabled_default = False, - icon = "mdi:dip-switch", + 6: "Cancel the Reservation", + }, + entity_registry_enabled_default=False, + icon="mdi:dip-switch", ), ### # @@ -414,363 +443,366 @@ class SolaXEVChargerModbusSensorEntityDescription(BaseModbusSensorEntityDescript # ### SolaXEVChargerModbusSensorEntityDescription( - name = "Charge Voltage", - key = "charge_voltage", - register = 0x0, - register_type = REG_INPUT, - scale = 0.01, - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - allowedtypes = X1, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charge Voltage L1", - key = "charge_voltage_l1", - register = 0x0, - register_type = REG_INPUT, - scale = 0.01, - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - allowedtypes = X3, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charge Voltage L2", - key = "charge_voltage_l2", - register = 0x1, - register_type = REG_INPUT, - scale = 0.01, - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - allowedtypes = X3, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charge Voltage L3", - key = "charge_voltage_l3", - register = 0x2, - register_type = REG_INPUT, - scale = 0.01, - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - allowedtypes = X3, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charge PE Voltage", - key = "charge_pe_voltage", - register = 0x3, - register_type = REG_INPUT, - scale = 0.01, - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charge Current", - key = "charge_current", - register = 0x4, - register_type = REG_INPUT, - scale = 0.01, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - allowedtypes = X1, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charge Current L1", - key = "charge_current_l1", - register = 0x4, - register_type = REG_INPUT, - scale = 0.01, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - allowedtypes = X3, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charge Current L2", - key = "charge_current_l2", - register = 0x5, - register_type = REG_INPUT, - scale = 0.01, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - allowedtypes = X3, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charge Current L3", - key = "charge_current_l3", - register = 0x6, - register_type = REG_INPUT, - scale = 0.01, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - allowedtypes = X3, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charge PE Current", - key = "charge_pe_current", - register = 0x7, - register_type = REG_INPUT, - native_unit_of_measurement = UnitOfElectricCurrent.MILLIAMPERE, - device_class = SensorDeviceClass.CURRENT, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charge Power", - key = "charge_power", - register = 0x8, - register_type = REG_INPUT, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - allowedtypes = X1, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charge Power L1", - key = "charge_power_l1", - register = 0x8, - register_type = REG_INPUT, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - allowedtypes = X3, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charge Power L2", - key = "charge_power_l2", - register = 0x9, - register_type = REG_INPUT, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - allowedtypes = X3, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charge Power L3", - key = "charge_power_l3", - register = 0xA, - register_type = REG_INPUT, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - allowedtypes = X3, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charge Power Total", - key = "charge_power_total", - register = 0xB, - register_type = REG_INPUT, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charge Frequency", - key = "charge_frequency", - register = 0xC, - register_type = REG_INPUT, - scale = 0.01, - native_unit_of_measurement = UnitOfFrequency.HERTZ, - allowedtypes = X1, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charge Frequency L1", - key = "charge_frequency_l1", - register = 0xC, - register_type = REG_INPUT, - scale = 0.01, - native_unit_of_measurement = UnitOfFrequency.HERTZ, - allowedtypes = X3, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charge Frequency L2", - key = "charge_frequency_l2", - register = 0xD, - register_type = REG_INPUT, - scale = 0.01, - native_unit_of_measurement = UnitOfFrequency.HERTZ, - allowedtypes = X3, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charge Frequency L3", - key = "charge_frequency_l3", - register = 0xE, - register_type = REG_INPUT, - scale = 0.01, - native_unit_of_measurement = UnitOfFrequency.HERTZ, - allowedtypes = X3, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charge Added", - key = "charge_added", - register = 0xF, - register_type = REG_INPUT, - scale = 0.1, - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charge Added Total", - key = "charge_added_total", + name="Charge Voltage", + key="charge_voltage", + register=0x0, + register_type=REG_INPUT, + scale=0.01, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + allowedtypes=X1, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charge Voltage L1", + key="charge_voltage_l1", + register=0x0, + register_type=REG_INPUT, + scale=0.01, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + allowedtypes=X3, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charge Voltage L2", + key="charge_voltage_l2", + register=0x1, + register_type=REG_INPUT, + scale=0.01, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + allowedtypes=X3, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charge Voltage L3", + key="charge_voltage_l3", + register=0x2, + register_type=REG_INPUT, + scale=0.01, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + allowedtypes=X3, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charge PE Voltage", + key="charge_pe_voltage", + register=0x3, + register_type=REG_INPUT, + scale=0.01, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charge Current", + key="charge_current", + register=0x4, + register_type=REG_INPUT, + scale=0.01, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + allowedtypes=X1, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charge Current L1", + key="charge_current_l1", + register=0x4, + register_type=REG_INPUT, + scale=0.01, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + allowedtypes=X3, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charge Current L2", + key="charge_current_l2", + register=0x5, + register_type=REG_INPUT, + scale=0.01, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + allowedtypes=X3, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charge Current L3", + key="charge_current_l3", + register=0x6, + register_type=REG_INPUT, + scale=0.01, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + allowedtypes=X3, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charge PE Current", + key="charge_pe_current", + register=0x7, + register_type=REG_INPUT, + native_unit_of_measurement=UnitOfElectricCurrent.MILLIAMPERE, + device_class=SensorDeviceClass.CURRENT, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charge Power", + key="charge_power", + register=0x8, + register_type=REG_INPUT, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + allowedtypes=X1, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charge Power L1", + key="charge_power_l1", + register=0x8, + register_type=REG_INPUT, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + allowedtypes=X3, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charge Power L2", + key="charge_power_l2", + register=0x9, + register_type=REG_INPUT, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + allowedtypes=X3, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charge Power L3", + key="charge_power_l3", + register=0xA, + register_type=REG_INPUT, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + allowedtypes=X3, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charge Power Total", + key="charge_power_total", + register=0xB, + register_type=REG_INPUT, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charge Frequency", + key="charge_frequency", + register=0xC, + register_type=REG_INPUT, + scale=0.01, + native_unit_of_measurement=UnitOfFrequency.HERTZ, + allowedtypes=X1, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charge Frequency L1", + key="charge_frequency_l1", + register=0xC, + register_type=REG_INPUT, + scale=0.01, + native_unit_of_measurement=UnitOfFrequency.HERTZ, + allowedtypes=X3, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charge Frequency L2", + key="charge_frequency_l2", + register=0xD, + register_type=REG_INPUT, + scale=0.01, + native_unit_of_measurement=UnitOfFrequency.HERTZ, + allowedtypes=X3, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charge Frequency L3", + key="charge_frequency_l3", + register=0xE, + register_type=REG_INPUT, + scale=0.01, + native_unit_of_measurement=UnitOfFrequency.HERTZ, + allowedtypes=X3, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charge Added", + key="charge_added", + register=0xF, + register_type=REG_INPUT, + scale=0.1, + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charge Added Total", + key="charge_added_total", register=0x619, register_type=REG_HOLDING, - unit = REGISTER_U32, - scale = 0.1, - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Grid Current", - key = "grid_current", - register = 0x12, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.01, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - allowedtypes = X1, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Grid Current L1", - key = "grid_current_l1", - register = 0x12, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.01, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - allowedtypes = X3, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Grid Current L2", - key = "grid_current_l2", - register = 0x13, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.01, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - allowedtypes = X3, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Grid Current L3", - key = "grid_current_l3", - register = 0x14, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.01, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - allowedtypes = X3, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Grid Power", - key = "grid_power", - register = 0x15, - register_type = REG_INPUT, - unit = REGISTER_S16, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - allowedtypes = X1, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Grid Power L1", - key = "grid_power_l1", - register = 0x15, - register_type = REG_INPUT, - unit = REGISTER_S16, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - allowedtypes = X3, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Grid Power L2", - key = "grid_power_l2", - register = 0x16, - register_type = REG_INPUT, - unit = REGISTER_S16, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - allowedtypes = X3, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Grid Power L3", - key = "grid_power_l3", - register = 0x17, - register_type = REG_INPUT, - unit = REGISTER_S16, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - allowedtypes = X3, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Grid Power Total", - key = "grid_power_total", - register = 0x18, - register_type = REG_INPUT, - unit = REGISTER_S16, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - entity_registry_enabled_default = False, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Charger Temperature", - key = "charger_temperature", - register = 0x1C, - register_type = REG_INPUT, - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXEVChargerModbusSensorEntityDescription( - name = "Run Mode", - key = "run_mode", - register = 0x1D, - scale = { 0: "Available", - 1: "Preparing", - 2: "Charging", - 3: "Finishing", - 4: "Fault Mode", - 5: "Unavailable", - 6: "Reserved", - 7: "Suspended EV", - 8: "Suspended EVSE", - 9: "Update", - 10: "RFID Activation", }, - register_type = REG_INPUT, - icon = "mdi:run", + unit=REGISTER_U32, + scale=0.1, + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Grid Current", + key="grid_current", + register=0x12, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.01, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + allowedtypes=X1, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Grid Current L1", + key="grid_current_l1", + register=0x12, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.01, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + allowedtypes=X3, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Grid Current L2", + key="grid_current_l2", + register=0x13, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.01, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + allowedtypes=X3, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Grid Current L3", + key="grid_current_l3", + register=0x14, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.01, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + allowedtypes=X3, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Grid Power", + key="grid_power", + register=0x15, + register_type=REG_INPUT, + unit=REGISTER_S16, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + allowedtypes=X1, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Grid Power L1", + key="grid_power_l1", + register=0x15, + register_type=REG_INPUT, + unit=REGISTER_S16, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + allowedtypes=X3, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Grid Power L2", + key="grid_power_l2", + register=0x16, + register_type=REG_INPUT, + unit=REGISTER_S16, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + allowedtypes=X3, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Grid Power L3", + key="grid_power_l3", + register=0x17, + register_type=REG_INPUT, + unit=REGISTER_S16, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + allowedtypes=X3, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Grid Power Total", + key="grid_power_total", + register=0x18, + register_type=REG_INPUT, + unit=REGISTER_S16, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + entity_registry_enabled_default=False, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Charger Temperature", + key="charger_temperature", + register=0x1C, + register_type=REG_INPUT, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXEVChargerModbusSensorEntityDescription( + name="Run Mode", + key="run_mode", + register=0x1D, + scale={ + 0: "Available", + 1: "Preparing", + 2: "Charging", + 3: "Finishing", + 4: "Fault Mode", + 5: "Unavailable", + 6: "Reserved", + 7: "Suspended EV", + 8: "Suspended EVSE", + 9: "Update", + 10: "RFID Activation", + }, + register_type=REG_INPUT, + icon="mdi:run", ), ] # ============================ plugin declaration ================================================= + @dataclass class solax_ev_charger_plugin(plugin_base): ''' @@ -785,39 +817,45 @@ def wakeupButton(self): async def async_determineInverterType(self, hub, configdict): _LOGGER.info(f"{hub.name}: trying to determine inverter type") - seriesnumber = await async_read_serialnr(hub, 0x600) + seriesnumber = await async_read_serialnr(hub, 0x600) if not seriesnumber: _LOGGER.error(f"{hub.name}: cannot find serial number for EV Charger") seriesnumber = "unknown" # derive invertertupe from seriiesnumber - if seriesnumber.startswith('C107'): invertertype = X1 | POW7 # 7kW EV Single Phase - elif seriesnumber.startswith('C311'): invertertype = X3 | POW11 # 11kW EV Three Phase - elif seriesnumber.startswith('C322'): invertertype = X3 | POW22 # 22kW EV Three Phase + if seriesnumber.startswith("C107"): + invertertype = X1 | POW7 # 7kW EV Single Phase + elif seriesnumber.startswith("C311"): + invertertype = X3 | POW11 # 11kW EV Three Phase + elif seriesnumber.startswith("C322"): + invertertype = X3 | POW22 # 22kW EV Three Phase # add cases here else: invertertype = 0 _LOGGER.error(f"unrecognized inverter type - serial number : {seriesnumber}") return invertertype - def matchInverterWithMask (self, inverterspec, entitymask, serialnumber = 'not relevant', blacklist = None): + def matchInverterWithMask(self, inverterspec, entitymask, serialnumber="not relevant", blacklist=None): # returns true if the entity needs to be created for an inverter - powmatch = ((inverterspec & entitymask & ALL_POW_GROUP) != 0) or (entitymask & ALL_POW_GROUP == 0) - xmatch = ((inverterspec & entitymask & ALL_X_GROUP) != 0) or (entitymask & ALL_X_GROUP == 0) + powmatch = ((inverterspec & entitymask & ALL_POW_GROUP) != 0) or (entitymask & ALL_POW_GROUP == 0) + xmatch = ((inverterspec & entitymask & ALL_X_GROUP) != 0) or (entitymask & ALL_X_GROUP == 0) blacklisted = False if blacklist: for start in blacklist: - if serialnumber.startswith(start) : blacklisted = True + if serialnumber.startswith(start): + blacklisted = True return (xmatch and powmatch) and not blacklisted + plugin_instance = solax_ev_charger_plugin( - plugin_name = 'SolaX EV Charger', - plugin_manufacturer = 'SolaX Power', - SENSOR_TYPES = SENSOR_TYPES_MAIN, - NUMBER_TYPES = NUMBER_TYPES, - BUTTON_TYPES = BUTTON_TYPES, - SELECT_TYPES = SELECT_TYPES, - block_size = 100, - order16 = Endian.BIG, - order32 = Endian.LITTLE, - ) + plugin_name="SolaX EV Charger", + plugin_manufacturer="SolaX Power", + SENSOR_TYPES=SENSOR_TYPES_MAIN, + NUMBER_TYPES=NUMBER_TYPES, + BUTTON_TYPES=BUTTON_TYPES, + SELECT_TYPES=SELECT_TYPES, + SWITCH_TYPES=[], + block_size=100, + order16=Endian.BIG, + order32=Endian.LITTLE, +) diff --git a/custom_components/solax_modbus/plugin_solax_mega_forth.py b/custom_components/solax_modbus/plugin_solax_mega_forth.py index eacce7c2..3b037ea9 100644 --- a/custom_components/solax_modbus/plugin_solax_mega_forth.py +++ b/custom_components/solax_modbus/plugin_solax_mega_forth.py @@ -20,41 +20,41 @@ An entity can be declared multiple times (with different bitmasks) if the parameters are different for each inverter type """ -GEN = 0x0001 # base generation for MIC, PV, AC -GEN2 = 0x0002 -GEN3 = 0x0004 -GEN4 = 0x0008 -GEN5 = 0x0010 -ALL_GEN_GROUP = GEN2 | GEN3 | GEN4 | GEN5 | GEN +GEN = 0x0001 # base generation for MIC, PV, AC +GEN2 = 0x0002 +GEN3 = 0x0004 +GEN4 = 0x0008 +GEN5 = 0x0010 +ALL_GEN_GROUP = GEN2 | GEN3 | GEN4 | GEN5 | GEN -X1 = 0x0100 -X3 = 0x0200 -ALL_X_GROUP = X1 | X3 +X1 = 0x0100 +X3 = 0x0200 +ALL_X_GROUP = X1 | X3 -PV = 0x0400 # Needs further work on PV Only Inverters -AC = 0x0800 -HYBRID = 0x1000 -MIC = 0x2000 -MAX = 0x4000 +PV = 0x0400 # Needs further work on PV Only Inverters +AC = 0x0800 +HYBRID = 0x1000 +MIC = 0x2000 +MAX = 0x4000 ALL_TYPE_GROUP = PV | AC | HYBRID | MIC | MAX -EPS = 0x8000 -ALL_EPS_GROUP = EPS +EPS = 0x8000 +ALL_EPS_GROUP = EPS -DCB = 0x10000 # dry contact box - gen4 -ALL_DCB_GROUP = DCB +DCB = 0x10000 # dry contact box - gen4 +ALL_DCB_GROUP = DCB -PM = 0x20000 +PM = 0x20000 ALL_PM_GROUP = PM -MPPT5 = 0x40000 -MPPT6 = 0x80000 -MPPT9 = 0x100000 -MPPT12 = 0x200000 -MPPT14 = 0x400000 +MPPT5 = 0x40000 +MPPT6 = 0x80000 +MPPT9 = 0x100000 +MPPT12 = 0x200000 +MPPT14 = 0x400000 ALL_MPPT_GROUP = MPPT5 | MPPT6 | MPPT9 | MPPT12 | MPPT14 -ALLDEFAULT = 0 # should be equivalent to AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5 | X1 | X3 +ALLDEFAULT = 0 # should be equivalent to AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5 | X1 | X3 # ======================= end of bitmask handling code ============================================= @@ -62,6 +62,7 @@ # ====================== find inverter type and details =========================================== + async def async_read_serialnr(hub, address): res = None inverter_data = None @@ -71,31 +72,43 @@ async def async_read_serialnr(hub, address): decoder = BinaryPayloadDecoder.fromRegisters(inverter_data.registers, byteorder=Endian.BIG) res = decoder.decode_string(16).decode("ascii") hub.seriesnumber = res - except Exception as ex: _LOGGER.warning(f"{hub.name}: attempt to read serialnumber failed at 0x{address:x} data: {inverter_data}", exc_info=True) - if not res: _LOGGER.warning(f"{hub.name}: reading serial number from address 0x{address:x} failed; other address may succeed") + except Exception as ex: + _LOGGER.warning( + f"{hub.name}: attempt to read serialnumber failed at 0x{address:x} data: {inverter_data}", exc_info=True + ) + if not res: + _LOGGER.warning( + f"{hub.name}: reading serial number from address 0x{address:x} failed; other address may succeed" + ) _LOGGER.info(f"Read {hub.name} 0x{address:x} serial number: {res}") return res + # ================================================================================================= + @dataclass class SolaxModbusButtonEntityDescription(BaseModbusButtonEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class SolaxModbusNumberEntityDescription(BaseModbusNumberEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class SolaxModbusSelectEntityDescription(BaseModbusSelectEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class SolaXModbusSensorEntityDescription(BaseModbusSensorEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice unit: int = REGISTER_U16 register_type: int = REG_HOLDING + # ====================================== Computed value functions ================================================= # ================================= Button Declarations ============================================================ @@ -111,32 +124,30 @@ class SolaXModbusSensorEntityDescription(BaseModbusSensorEntityDescription): EXPORT_LIMIT_SCALE_EXCEPTIONS = [] NUMBER_TYPES = [ - SolaxModbusNumberEntityDescription( - name = "Active Power", - key = "active_power_control", - register = 0x2304, - fmt = "i", - native_min_value = 1, - native_max_value = 100, - native_step = 1, - scale = 0.1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = MAX | GEN2, + name="Active Power", + key="active_power_control", + register=0x2304, + fmt="i", + native_min_value=1, + native_max_value=100, + native_step=1, + scale=0.1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=MAX | GEN2, ), SolaxModbusNumberEntityDescription( - name = "Reactive Power", - key = "reactive_power_control", - register = 0x2305, - fmt = "i", - native_min_value = 1, - native_max_value = 100, - native_step = 1, - scale = 0.1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = MAX | GEN2, - ), - + name="Reactive Power", + key="reactive_power_control", + register=0x2305, + fmt="i", + native_min_value=1, + native_max_value=100, + native_step=1, + scale=0.1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=MAX | GEN2, + ), ] # ================================= Select Declarations ============================================================ @@ -146,915 +157,922 @@ class SolaXModbusSensorEntityDescription(BaseModbusSensorEntityDescription): # ================================= Sennsor Declarations ============================================================ SENSOR_TYPES_MAIN: list[SolaXModbusSensorEntityDescription] = [ -##### -# -# X3 MEGA G2 -# -# -##### -# -# Input Registers -# -##### - SolaXModbusSensorEntityDescription( - name = "Model Type", - key = "model_type", - register = 0x12, - register_type = REG_INPUT, - unit = REGISTER_STR, - wordcount = 8, - allowedtypes = MAX | GEN2, - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:information", - ), - SolaXModbusSensorEntityDescription( - name = "Software Version", - key = "software_version", - register = 0x22, - register_type = REG_INPUT, - unit = REGISTER_STR, - wordcount = 8, - allowedtypes = MAX | GEN2, - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:information", - ), - SolaXModbusSensorEntityDescription( - name = "Grid Voltage L1", - key = "grid_voltage_l1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x100, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Grid Voltage L2", - key = "grid_voltage_l2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x101, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Grid Voltage L3", - key = "grid_voltage_l3", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x102, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Inverter Voltage L1", - key = "inverter_voltage_l1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x103, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Inverter Voltage L2", - key = "inverter_voltage_l2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x104, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Inverter Voltage L3", - key = "inverter_voltage_l3", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x105, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Grid Frequency", - key = "grid_frequency", - native_unit_of_measurement = UnitOfFrequency.HERTZ, - state_class = SensorStateClass.MEASUREMENT, - register = 0x106, - register_type = REG_INPUT, - scale = 0.01, - rounding = 2, - allowedtypes = MAX | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Inverter Current L1", - key = "inverter_current_l1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x180, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Inverter Current L2", - key = "inverter_current_l2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x181, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Inverter Current L3", - key = "inverter_current_l3", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x182, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Active Power Energy", - key = "active_power_energy", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x183, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = MAX | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Reactive Power", - key = "reactive_power", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x185, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = MAX | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Apparent Power", - key = "apparent_power", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - register = 0x187, - register_type = REG_INPUT, - unit = REGISTER_U32, - allowedtypes = MAX | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Today's Energy", - key = "today_s_energy", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x189, - register_type = REG_INPUT, - scale = 0.1, - allowedtypes = MAX | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Total Energy", - key = "total_energy", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 0x18A, - register_type = REG_INPUT, - unit = REGISTER_U32, - scale = 0.1, - allowedtypes = MAX | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Power Factor", - key = "power_factor", - native_unit_of_measurement = None, - device_class = SensorDeviceClass.POWER_FACTOR, - state_class = SensorStateClass.MEASUREMENT, - register = 0x18F, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.001, - allowedtypes = MAX | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "Inverter Temperature", - key = "inverter_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x202, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - allowedtypes = MAX | GEN2, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXModbusSensorEntityDescription( - name = "PV Voltage 1", - key = "pv_voltage_1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x28B, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "PV Current 1", - key = "pv_current_1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x28C, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "PV Power 1", - key = "pv_power_1", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x28D, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = MAX | GEN2, - icon = "mdi:solar-power-variant", - ), - SolaXModbusSensorEntityDescription( - name = "MPPT 1 Temperature", - key = "mppt_1_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x28F, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = MAX | GEN2, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXModbusSensorEntityDescription( - name = "PV Voltage 2", - key = "pv_voltage_2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x292, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "PV Current 2", - key = "pv_current_2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x293, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "PV Power 2", - key = "pv_power_2", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x294, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = MAX | GEN2, - icon = "mdi:solar-power-variant", - ), - SolaXModbusSensorEntityDescription( - name = "MPPT 2 Temperature", - key = "mppt_2_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x296, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = MAX | GEN2, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXModbusSensorEntityDescription( - name = "PV Voltage 3", - key = "pv_voltage_3", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x299, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "PV Current 3", - key = "pv_current_3", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x29A, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "PV Power 3", - key = "pv_power_3", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x29B, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = MAX | GEN2, - icon = "mdi:solar-power-variant", - ), - SolaXModbusSensorEntityDescription( - name = "MPPT 3 Temperature", - key = "mppt_3_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x29D, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = MAX | GEN2, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXModbusSensorEntityDescription( - name = "PV Voltage 4", - key = "pv_voltage_4", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x2A0, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2, - ), - SolaXModbusSensorEntityDescription( - name = "PV Current 4", - key = "pv_current_4", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x2A1, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "PV Power 4", - key = "pv_power_4", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x2A2, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = MAX | GEN2, - icon = "mdi:solar-power-variant", - ), - SolaXModbusSensorEntityDescription( - name = "MPPT 4 Temperature", - key = "mppt_4_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x2A4, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = MAX | GEN2, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXModbusSensorEntityDescription( - name = "PV Voltage 5", - key = "pv_voltage_5", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x2A7, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2 | MPPT12 | MPPT9 | MPPT6 | MPPT5, - ), - SolaXModbusSensorEntityDescription( - name = "PV Current 5", - key = "pv_current_5", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x2A8, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2 | MPPT12 | MPPT9 | MPPT6 | MPPT5, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "PV Power 5", - key = "pv_power_5", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x2A9, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = MAX | GEN2 | MPPT12 | MPPT9 | MPPT6 | MPPT5, - icon = "mdi:solar-power-variant", - ), - SolaXModbusSensorEntityDescription( - name = "MPPT 5 Temperature", - key = "mppt_5_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x2AB, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = MAX | GEN2 | MPPT12 | MPPT9 | MPPT6 | MPPT5, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXModbusSensorEntityDescription( - name = "PV Voltage 6", - key = "pv_voltage_6", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x2AE, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2 | MPPT12 | MPPT9 | MPPT6, - ), - SolaXModbusSensorEntityDescription( - name = "PV Current 6", - key = "pv_current_6", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x2AF, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2 | MPPT12 | MPPT9 | MPPT6, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "PV Power 6", - key = "pv_power_6", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x2B0, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = MAX | GEN2 | MPPT12 | MPPT9 | MPPT6, - icon = "mdi:solar-power-variant", - ), - SolaXModbusSensorEntityDescription( - name = "MPPT 6 Temperature", - key = "mppt_6_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x2B2, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = MAX | GEN2 | MPPT12 | MPPT9 | MPPT6, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXModbusSensorEntityDescription( - name = "PV Voltage 7", - key = "pv_voltage_7", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x2B5, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2 | MPPT12 | MPPT9, - ), - SolaXModbusSensorEntityDescription( - name = "PV Current 7", - key = "pv_current_7", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x2B6, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2 | MPPT12 | MPPT9, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "PV Power 7", - key = "pv_power_7", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x2B7, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = MAX | GEN2 | MPPT12 | MPPT9, - icon = "mdi:solar-power-variant", - ), - SolaXModbusSensorEntityDescription( - name = "MPPT 7 Temperature", - key = "mppt_7_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x2B9, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = MAX | GEN2 | MPPT12 | MPPT9, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXModbusSensorEntityDescription( - name = "PV Voltage 8", - key = "pv_voltage_8", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x2BC, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2 | MPPT12 | MPPT9, - ), - SolaXModbusSensorEntityDescription( - name = "PV Current 8", - key = "pv_current_8", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x2BD, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2 | MPPT12 | MPPT9, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "PV Power 8", - key = "pv_power_8", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x2BE, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = MAX | GEN2 | MPPT12 | MPPT9, - icon = "mdi:solar-power-variant", - ), - SolaXModbusSensorEntityDescription( - name = "MPPT 8 Temperature", - key = "mppt_8_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x2C0, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = MAX | GEN2 | MPPT12 | MPPT9, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXModbusSensorEntityDescription( - name = "PV Voltage 9", - key = "pv_voltage_9", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x2C3, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2 | MPPT12 | MPPT9, - ), - SolaXModbusSensorEntityDescription( - name = "PV Current 9", - key = "pv_current_9", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x2C4, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2 | MPPT12 | MPPT9, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "PV Power 9", - key = "pv_power_9", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x2C5, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = MAX | GEN2 | MPPT12 | MPPT9, - icon = "mdi:solar-power-variant", - ), - SolaXModbusSensorEntityDescription( - name = "MPPT 9 Temperature", - key = "mppt_9_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x2C7, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = MAX | GEN2 | MPPT12 | MPPT9, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXModbusSensorEntityDescription( - name = "PV Voltage 10", - key = "pv_voltage_10", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x2CA, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2 | MPPT12, - ), - SolaXModbusSensorEntityDescription( - name = "PV Current 10", - key = "pv_current_10", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x2CB, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2 | MPPT12, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "PV Power 10", - key = "pv_power_10", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x2CC, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = MAX | GEN2 | MPPT12, - icon = "mdi:solar-power-variant", - ), - SolaXModbusSensorEntityDescription( - name = "MPPT 10 Temperature", - key = "mppt_10_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x2CE, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = MAX | GEN2 | MPPT12, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXModbusSensorEntityDescription( - name = "PV Voltage 11", - key = "pv_voltage_11", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x2D1, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2 | MPPT12, - ), - SolaXModbusSensorEntityDescription( - name = "PV Current 11", - key = "pv_current_11", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x2D2, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2 | MPPT12, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "PV Power 11", - key = "pv_power_11", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x2D3, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = MAX | GEN2 | MPPT12, - icon = "mdi:solar-power-variant", - ), - SolaXModbusSensorEntityDescription( - name = "MPPT 11 Temperature", - key = "mppt_11_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x2D5, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = MAX | GEN2 | MPPT12, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolaXModbusSensorEntityDescription( - name = "PV Voltage 12", - key = "pv_voltage_12", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 0x2D8, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2 | MPPT12, - ), - SolaXModbusSensorEntityDescription( - name = "PV Current 12", - key = "pv_current_12", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 0x2D9, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = MAX | GEN2 | MPPT12, - icon = "mdi:current-dc", - ), - SolaXModbusSensorEntityDescription( - name = "PV Power 12", - key = "pv_power_12", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x2DA, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = MAX | GEN2 | MPPT12, - icon = "mdi:solar-power-variant", - ), - SolaXModbusSensorEntityDescription( - name = "MPPT 12 Temperature", - key = "mppt_12_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 0x2DC, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = MAX | GEN2 | MPPT12, - entity_category = EntityCategory.DIAGNOSTIC, - ), -##### -# -# Holding Registers -# -##### - SolaXModbusSensorEntityDescription( - key = "active_power_control", - register = 0x2304, - scale = 0.1, - allowedtypes = MAX | GEN2, - internal = True, - ), - SolaXModbusSensorEntityDescription( - key = "reactive_power_control", - register = 0x2305, - scale = 0.1, - allowedtypes = MAX | GEN2, - internal = True, + ##### + # + # X3 MEGA G2 + # + # + ##### + # + # Input Registers + # + ##### + SolaXModbusSensorEntityDescription( + name="Model Type", + key="model_type", + register=0x12, + register_type=REG_INPUT, + unit=REGISTER_STR, + wordcount=8, + allowedtypes=MAX | GEN2, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:information", + ), + SolaXModbusSensorEntityDescription( + name="Software Version", + key="software_version", + register=0x22, + register_type=REG_INPUT, + unit=REGISTER_STR, + wordcount=8, + allowedtypes=MAX | GEN2, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:information", + ), + SolaXModbusSensorEntityDescription( + name="Grid Voltage L1", + key="grid_voltage_l1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x100, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Grid Voltage L2", + key="grid_voltage_l2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x101, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Grid Voltage L3", + key="grid_voltage_l3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x102, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Voltage L1", + key="inverter_voltage_l1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x103, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Voltage L2", + key="inverter_voltage_l2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x104, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Voltage L3", + key="inverter_voltage_l3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x105, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Grid Frequency", + key="grid_frequency", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + state_class=SensorStateClass.MEASUREMENT, + register=0x106, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + allowedtypes=MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Current L1", + key="inverter_current_l1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x180, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Current L2", + key="inverter_current_l2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x181, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Current L3", + key="inverter_current_l3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x182, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Active Power Energy", + key="active_power_energy", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x183, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Reactive Power", + key="reactive_power", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x185, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Apparent Power", + key="apparent_power", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=0x187, + register_type=REG_INPUT, + unit=REGISTER_U32, + allowedtypes=MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Today's Energy", + key="today_s_energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x189, + register_type=REG_INPUT, + scale=0.1, + allowedtypes=MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Total Energy", + key="total_energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=0x18A, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.1, + allowedtypes=MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Power Factor", + key="power_factor", + native_unit_of_measurement=None, + device_class=SensorDeviceClass.POWER_FACTOR, + state_class=SensorStateClass.MEASUREMENT, + register=0x18F, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.001, + allowedtypes=MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="Inverter Temperature", + key="inverter_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x202, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + allowedtypes=MAX | GEN2, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 1", + key="pv_voltage_1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x28B, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="PV Current 1", + key="pv_current_1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x28C, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 1", + key="pv_power_1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x28D, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=MAX | GEN2, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="MPPT 1 Temperature", + key="mppt_1_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x28F, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=MAX | GEN2, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 2", + key="pv_voltage_2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x292, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="PV Current 2", + key="pv_current_2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x293, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 2", + key="pv_power_2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x294, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=MAX | GEN2, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="MPPT 2 Temperature", + key="mppt_2_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x296, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=MAX | GEN2, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 3", + key="pv_voltage_3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x299, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="PV Current 3", + key="pv_current_3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x29A, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 3", + key="pv_power_3", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x29B, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=MAX | GEN2, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="MPPT 3 Temperature", + key="mppt_3_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x29D, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=MAX | GEN2, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 4", + key="pv_voltage_4", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x2A0, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name="PV Current 4", + key="pv_current_4", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x2A1, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 4", + key="pv_power_4", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x2A2, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=MAX | GEN2, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="MPPT 4 Temperature", + key="mppt_4_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x2A4, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=MAX | GEN2, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 5", + key="pv_voltage_5", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x2A7, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2 | MPPT12 | MPPT9 | MPPT6 | MPPT5, + ), + SolaXModbusSensorEntityDescription( + name="PV Current 5", + key="pv_current_5", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x2A8, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2 | MPPT12 | MPPT9 | MPPT6 | MPPT5, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 5", + key="pv_power_5", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x2A9, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=MAX | GEN2 | MPPT12 | MPPT9 | MPPT6 | MPPT5, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="MPPT 5 Temperature", + key="mppt_5_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x2AB, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=MAX | GEN2 | MPPT12 | MPPT9 | MPPT6 | MPPT5, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 6", + key="pv_voltage_6", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x2AE, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2 | MPPT12 | MPPT9 | MPPT6, + ), + SolaXModbusSensorEntityDescription( + name="PV Current 6", + key="pv_current_6", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x2AF, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2 | MPPT12 | MPPT9 | MPPT6, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 6", + key="pv_power_6", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x2B0, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=MAX | GEN2 | MPPT12 | MPPT9 | MPPT6, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="MPPT 6 Temperature", + key="mppt_6_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x2B2, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=MAX | GEN2 | MPPT12 | MPPT9 | MPPT6, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 7", + key="pv_voltage_7", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x2B5, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2 | MPPT12 | MPPT9, + ), + SolaXModbusSensorEntityDescription( + name="PV Current 7", + key="pv_current_7", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x2B6, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2 | MPPT12 | MPPT9, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 7", + key="pv_power_7", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x2B7, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=MAX | GEN2 | MPPT12 | MPPT9, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="MPPT 7 Temperature", + key="mppt_7_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x2B9, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=MAX | GEN2 | MPPT12 | MPPT9, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 8", + key="pv_voltage_8", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x2BC, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2 | MPPT12 | MPPT9, + ), + SolaXModbusSensorEntityDescription( + name="PV Current 8", + key="pv_current_8", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x2BD, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2 | MPPT12 | MPPT9, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 8", + key="pv_power_8", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x2BE, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=MAX | GEN2 | MPPT12 | MPPT9, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="MPPT 8 Temperature", + key="mppt_8_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x2C0, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=MAX | GEN2 | MPPT12 | MPPT9, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 9", + key="pv_voltage_9", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x2C3, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2 | MPPT12 | MPPT9, + ), + SolaXModbusSensorEntityDescription( + name="PV Current 9", + key="pv_current_9", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x2C4, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2 | MPPT12 | MPPT9, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 9", + key="pv_power_9", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x2C5, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=MAX | GEN2 | MPPT12 | MPPT9, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="MPPT 9 Temperature", + key="mppt_9_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x2C7, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=MAX | GEN2 | MPPT12 | MPPT9, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 10", + key="pv_voltage_10", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x2CA, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2 | MPPT12, + ), + SolaXModbusSensorEntityDescription( + name="PV Current 10", + key="pv_current_10", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x2CB, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2 | MPPT12, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 10", + key="pv_power_10", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x2CC, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=MAX | GEN2 | MPPT12, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="MPPT 10 Temperature", + key="mppt_10_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x2CE, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=MAX | GEN2 | MPPT12, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 11", + key="pv_voltage_11", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x2D1, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2 | MPPT12, + ), + SolaXModbusSensorEntityDescription( + name="PV Current 11", + key="pv_current_11", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x2D2, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2 | MPPT12, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 11", + key="pv_power_11", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x2D3, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=MAX | GEN2 | MPPT12, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="MPPT 11 Temperature", + key="mppt_11_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x2D5, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=MAX | GEN2 | MPPT12, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolaXModbusSensorEntityDescription( + name="PV Voltage 12", + key="pv_voltage_12", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=0x2D8, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2 | MPPT12, + ), + SolaXModbusSensorEntityDescription( + name="PV Current 12", + key="pv_current_12", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=0x2D9, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=MAX | GEN2 | MPPT12, + icon="mdi:current-dc", + ), + SolaXModbusSensorEntityDescription( + name="PV Power 12", + key="pv_power_12", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=0x2DA, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=MAX | GEN2 | MPPT12, + icon="mdi:solar-power-variant", + ), + SolaXModbusSensorEntityDescription( + name="MPPT 12 Temperature", + key="mppt_12_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=0x2DC, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=MAX | GEN2 | MPPT12, + entity_category=EntityCategory.DIAGNOSTIC, + ), + ##### + # + # Holding Registers + # + ##### + SolaXModbusSensorEntityDescription( + key="active_power_control", + register=0x2304, + scale=0.1, + allowedtypes=MAX | GEN2, + internal=True, + ), + SolaXModbusSensorEntityDescription( + key="reactive_power_control", + register=0x2305, + scale=0.1, + allowedtypes=MAX | GEN2, + internal=True, ), ] # ============================ plugin declaration ================================================= + @dataclass class solax_mega_forth_plugin(plugin_base): async def async_determineInverterType(self, hub, configdict): - #global SENSOR_TYPES + # global SENSOR_TYPES _LOGGER.info(f"{hub.name}: trying to determine inverter type") - seriesnumber = await async_read_serialnr(hub, 0x32) + seriesnumber = await async_read_serialnr(hub, 0x32) if not seriesnumber: _LOGGER.error(f"{hub.name}: cannot find any serial number(s)") seriesnumber = "unknown" # derive invertertupe from seriiesnumber - if seriesnumber.startswith('X3G04'): - invertertype = MAX | GEN2 # MAX G2 + if seriesnumber.startswith("X3G04"): + invertertype = MAX | GEN2 # MAX G2 self.inverter_model = "X3 - MEGA 40kW - G2" - elif seriesnumber.startswith('X3G05'): - invertertype = MAX | GEN2 | MPPT5 # MAX MEGA G2 + elif seriesnumber.startswith("X3G05"): + invertertype = MAX | GEN2 | MPPT5 # MAX MEGA G2 self.inverter_model = "X3- MEGA 50kW - G2" - elif seriesnumber.startswith('X3G06'): - invertertype = MAX | GEN2 | MPPT6 # MAX MEGA G2 + elif seriesnumber.startswith("X3G06"): + invertertype = MAX | GEN2 | MPPT6 # MAX MEGA G2 self.inverter_model = "X3- MEGA 60kW - G2" - elif seriesnumber.startswith('X3G075'): - invertertype = MAX | GEN2 | MPPT9 # MAX FORTH G2 + elif seriesnumber.startswith("X3G075"): + invertertype = MAX | GEN2 | MPPT9 # MAX FORTH G2 self.inverter_model = "X3- FORTH 75kW - G2" - elif seriesnumber.startswith('X3G08'): - invertertype = MAX | GEN2 | MPPT9 # MAX FORTH G2 + elif seriesnumber.startswith("X3G08"): + invertertype = MAX | GEN2 | MPPT9 # MAX FORTH G2 self.inverter_model = "X3- FORTH 80kW - G2" - elif seriesnumber.startswith('X3G01'): - invertertype = MAX | GEN2 | MPPT9 # MAX FORTH G2 + elif seriesnumber.startswith("X3G01"): + invertertype = MAX | GEN2 | MPPT9 # MAX FORTH G2 self.inverter_model = "X3- FORTH 100kW - G2" - elif seriesnumber.startswith('X3G011'): - invertertype = MAX | GEN2 | MPPT9 # MAX FORTH G2 + elif seriesnumber.startswith("X3G011"): + invertertype = MAX | GEN2 | MPPT9 # MAX FORTH G2 self.inverter_model = "X3- FORTH 110kW - G2" - elif seriesnumber.startswith('X3G012'): - invertertype = MAX | GEN2 | MPPT12 # MAX FORTH G2 + elif seriesnumber.startswith("X3G012"): + invertertype = MAX | GEN2 | MPPT12 # MAX FORTH G2 self.inverter_model = "X3- FORTH 120kW - G2" - elif seriesnumber.startswith('X3G0125'): - invertertype = MAX | GEN2 | MPPT12 # MAX FORTH G2 + elif seriesnumber.startswith("X3G0125"): + invertertype = MAX | GEN2 | MPPT12 # MAX FORTH G2 self.inverter_model = "X3- FORTH 125kW - G2" - elif seriesnumber.startswith('X3G013'): - invertertype = MAX | GEN2 | MPPT12 # MAX FORTH G2 + elif seriesnumber.startswith("X3G013"): + invertertype = MAX | GEN2 | MPPT12 # MAX FORTH G2 self.inverter_model = "X3- FORTH 136kW - G2" - elif seriesnumber.startswith('X3G015'): - invertertype = MAX | GEN2 | MPPT12 # MAX FORTH G2 + elif seriesnumber.startswith("X3G015"): + invertertype = MAX | GEN2 | MPPT12 # MAX FORTH G2 self.inverter_model = "X3- FORTH 150kW - G2" - elif seriesnumber.startswith('MAXMEG_G2'): - invertertype = MAX | GEN2 # MAX MEGA G2 + elif seriesnumber.startswith("MAXMEG_G2"): + invertertype = MAX | GEN2 # MAX MEGA G2 self.inverter_model = "X3-MAX MEGA - G2" else: invertertype = 0 _LOGGER.error(f"unrecognized inverter type - serial number : {seriesnumber}") - + if invertertype > 0: read_eps = configdict.get(CONF_READ_EPS, DEFAULT_READ_EPS) read_dcb = configdict.get(CONF_READ_DCB, DEFAULT_READ_DCB) read_pm = configdict.get(CONF_READ_PM, DEFAULT_READ_PM) - if read_eps: invertertype = invertertype | EPS - if read_dcb: invertertype = invertertype | DCB - if read_pm: invertertype = invertertype | PM + if read_eps: + invertertype = invertertype | EPS + if read_dcb: + invertertype = invertertype | DCB + if read_pm: + invertertype = invertertype | PM return invertertype - def matchInverterWithMask (self, inverterspec, entitymask, serialnumber = 'not relevant', blacklist = None): + def matchInverterWithMask(self, inverterspec, entitymask, serialnumber="not relevant", blacklist=None): # returns true if the entity needs to be created for an inverter - genmatch = ((inverterspec & entitymask & ALL_GEN_GROUP) != 0) or (entitymask & ALL_GEN_GROUP == 0) - xmatch = ((inverterspec & entitymask & ALL_X_GROUP) != 0) or (entitymask & ALL_X_GROUP == 0) + genmatch = ((inverterspec & entitymask & ALL_GEN_GROUP) != 0) or (entitymask & ALL_GEN_GROUP == 0) + xmatch = ((inverterspec & entitymask & ALL_X_GROUP) != 0) or (entitymask & ALL_X_GROUP == 0) hybmatch = ((inverterspec & entitymask & ALL_TYPE_GROUP) != 0) or (entitymask & ALL_TYPE_GROUP == 0) - epsmatch = ((inverterspec & entitymask & ALL_EPS_GROUP) != 0) or (entitymask & ALL_EPS_GROUP == 0) - dcbmatch = ((inverterspec & entitymask & ALL_DCB_GROUP) != 0) or (entitymask & ALL_DCB_GROUP == 0) - mpptmatch = ((inverterspec & entitymask & ALL_MPPT_GROUP) != 0) or (entitymask & ALL_MPPT_GROUP == 0) - pmmatch = ((inverterspec & entitymask & ALL_PM_GROUP) != 0) or (entitymask & ALL_PM_GROUP == 0) + epsmatch = ((inverterspec & entitymask & ALL_EPS_GROUP) != 0) or (entitymask & ALL_EPS_GROUP == 0) + dcbmatch = ((inverterspec & entitymask & ALL_DCB_GROUP) != 0) or (entitymask & ALL_DCB_GROUP == 0) + mpptmatch = ((inverterspec & entitymask & ALL_MPPT_GROUP) != 0) or (entitymask & ALL_MPPT_GROUP == 0) + pmmatch = ((inverterspec & entitymask & ALL_PM_GROUP) != 0) or (entitymask & ALL_PM_GROUP == 0) blacklisted = False if blacklist: for start in blacklist: - if serialnumber.startswith(start) : blacklisted = True - return (genmatch and xmatch and hybmatch and epsmatch and dcbmatch and mpptmatch and pmmatch) and not blacklisted + if serialnumber.startswith(start): + blacklisted = True + return ( + genmatch and xmatch and hybmatch and epsmatch and dcbmatch and mpptmatch and pmmatch + ) and not blacklisted def getSoftwareVersion(self, new_data): return new_data.get("software_version", None) @@ -1071,33 +1089,53 @@ def localDataCallback(self, hub): if config_scale_entity and config_scale_entity.enabled: new_read_scale = hub.data.get("config_export_control_limit_readscale") if new_read_scale != None: - _LOGGER.info(f"local data update callback for read_scale: {new_read_scale} enabled: {config_scale_entity.enabled}") + _LOGGER.info( + f"local data update callback for read_scale: {new_read_scale} enabled: {config_scale_entity.enabled}" + ) number_entity = hub.numberEntities.get("export_control_user_limit") sensor_entity = hub.sensorEntities.get("export_control_user_limit") - if number_entity: number_entity.entity_description = replace(number_entity.entity_description, read_scale = new_read_scale, ) - if sensor_entity: sensor_entity.entity_description = replace(sensor_entity.entity_description, read_scale = new_read_scale, ) + if number_entity: + number_entity.entity_description = replace( + number_entity.entity_description, + read_scale=new_read_scale, + ) + if sensor_entity: + sensor_entity.entity_description = replace( + sensor_entity.entity_description, + read_scale=new_read_scale, + ) config_maxexport_entity = hub.numberEntities.get("config_max_export") if config_maxexport_entity and config_maxexport_entity.enabled: new_max_export = hub.data.get("config_max_export") if new_max_export != None: - for key in ["remotecontrol_active_power", "remotecontrol_import_limit", "export_control_user_limit", "generator_max_charge"]: + for key in [ + "remotecontrol_active_power", + "remotecontrol_import_limit", + "export_control_user_limit", + "generator_max_charge", + ]: number_entity = hub.numberEntities.get(key) if number_entity: number_entity._attr_native_max_value = new_max_export # update description also, not sure whether needed or not - number_entity.entity_description = replace(number_entity.entity_description, native_max_value = new_max_export, ) + number_entity.entity_description = replace( + number_entity.entity_description, + native_max_value=new_max_export, + ) _LOGGER.info(f"local data update callback for entity: {key} new limit: {new_max_export}") + plugin_instance = solax_mega_forth_plugin( - plugin_name = 'SolaX', - plugin_manufacturer = 'SolaX Power', - SENSOR_TYPES = SENSOR_TYPES_MAIN, - NUMBER_TYPES = NUMBER_TYPES, - BUTTON_TYPES = BUTTON_TYPES, - SELECT_TYPES = SELECT_TYPES, - block_size = 100, - order16 = Endian.BIG, - order32 = Endian.BIG, - auto_block_ignore_readerror = True - ) \ No newline at end of file + plugin_name="SolaX", + plugin_manufacturer="SolaX Power", + SENSOR_TYPES=SENSOR_TYPES_MAIN, + NUMBER_TYPES=NUMBER_TYPES, + BUTTON_TYPES=BUTTON_TYPES, + SELECT_TYPES=SELECT_TYPES, + SWITCH_TYPES=[], + block_size=100, + order16=Endian.BIG, + order32=Endian.BIG, + auto_block_ignore_readerror=True, +) diff --git a/custom_components/solax_modbus/plugin_solinteg.py b/custom_components/solax_modbus/plugin_solinteg.py index e6a9a213..7fb613f7 100644 --- a/custom_components/solax_modbus/plugin_solinteg.py +++ b/custom_components/solax_modbus/plugin_solinteg.py @@ -26,34 +26,34 @@ An entity can be declared multiple times (with different bitmasks) if the parameters are different for each inverter type """ -GEN = 0x0001 # base generation for MIC, PV, AC -GEN2 = 0x0002 -ALL_GEN_GROUP = GEN2 - -X1 = 0x0100 #not needed -X3 = 0x0200 -ALL_X_GROUP = X1 | X3 - -PV = 0x0400 # Needs further work on PV Only Inverters -AC = 0x0800 -HYBRID = 0x1000 -MIC = 0x2000 +GEN = 0x0001 # base generation for MIC, PV, AC +GEN2 = 0x0002 +ALL_GEN_GROUP = GEN2 + +X1 = 0x0100 # not needed +X3 = 0x0200 +ALL_X_GROUP = X1 | X3 + +PV = 0x0400 # Needs further work on PV Only Inverters +AC = 0x0800 +HYBRID = 0x1000 +MIC = 0x2000 ALL_TYPE_GROUP = PV | AC | HYBRID | MIC -EPS = 0x8000 -ALL_EPS_GROUP = EPS +EPS = 0x8000 +ALL_EPS_GROUP = EPS -DCB = 0x10000 # dry contact box - gen4 -ALL_DCB_GROUP = DCB +DCB = 0x10000 # dry contact box - gen4 +ALL_DCB_GROUP = DCB -#1 is minimum -MPPT2 = 0x20000 -MPPT4 = 0x40000 -MPPT_MIN2 = MPPT2 | MPPT4 +# 1 is minimum +MPPT2 = 0x20000 +MPPT4 = 0x40000 +MPPT_MIN2 = MPPT2 | MPPT4 ALL_MPPT = MPPT2 | MPPT4 -#ALLDEFAULT = 0 # should be equivalent to HYBRID | AC | GEN2 | GEN3 | GEN4 | X1 | X3 -ALLDEFAULT = 0 #HYBRID | AC | ALL_X_GROUP +# ALLDEFAULT = 0 # should be equivalent to HYBRID | AC | GEN2 | GEN3 | GEN4 | X1 | X3 +ALLDEFAULT = 0 # HYBRID | AC | ALL_X_GROUP SCAN_GROUP_MPPT = SCAN_GROUP_MEDIUM @@ -63,23 +63,29 @@ # ====================== find inverter type and details =========================================== + async def _read_serialnr(hub, address=10000, count=8, swapbytes=False): res = None try: data = await hub.async_read_holding_registers(unit=hub._modbus_addr, address=address, count=count) if not data.isError(): decoder = BinaryPayloadDecoder.fromRegisters(data.registers, byteorder=Endian.BIG) - res = decoder.decode_string(count*2).decode("ascii") + res = decoder.decode_string(count * 2).decode("ascii") if swapbytes: - ba = bytearray(res,"ascii") # convert to bytearray for swapping - ba[0::2], ba[1::2] = ba[1::2], ba[0::2] # swap bytes ourselves - due to bug in Endian.Little ? - res = str(ba, "ascii") # convert back to string + ba = bytearray(res, "ascii") # convert to bytearray for swapping + ba[0::2], ba[1::2] = ba[1::2], ba[0::2] # swap bytes ourselves - due to bug in Endian.Little ? + res = str(ba, "ascii") # convert back to string hub.seriesnumber = res - except Exception as ex: _LOGGER.warning(f"{hub.name}: attempt to read serialnumber failed at 0x{address:x}", exc_info=True) - if not res: _LOGGER.warning(f"{hub.name}: reading serial number from address 0x{address:x} failed; other address may succeed") + except Exception as ex: + _LOGGER.warning(f"{hub.name}: attempt to read serialnumber failed at 0x{address:x}", exc_info=True) + if not res: + _LOGGER.warning( + f"{hub.name}: reading serial number from address 0x{address:x} failed; other address may succeed" + ) _LOGGER.info(f"Read {hub.name} 0x{address:x} serial number: {res}, swapped: {swapbytes}") return res + async def _read_model(hub, address=10008): res = None try: @@ -88,17 +94,21 @@ async def _read_model(hub, address=10008): decoder = BinaryPayloadDecoder.fromRegisters(data.registers, byteorder=Endian.BIG) res = decoder.decode_16bit_uint() hub._invertertype = res - except Exception as ex: _LOGGER.warning(f"{hub.name}: attempt to read model failed at 0x{address:x}", exc_info=True) + except Exception as ex: + _LOGGER.warning(f"{hub.name}: attempt to read model failed at 0x{address:x}", exc_info=True) _LOGGER.info(f"Read {hub.name} 0x{address:x} model: {res}") return res + # ====================================== Computed value functions ================================================= + def _bytes_str(b_array): - return '.'.join(str(x) for x in b_array) + return ".".join(str(x) for x in b_array) + def _model_str(val): - #there are models 40,41,42, docu not found + # there are models 40,41,42, docu not found d = { 30: [ "MHT-4K-25", @@ -111,8 +121,7 @@ def _model_str(val): "MHT-12K-40", "MHT-15K-40", "MHT-20K-40", - ], - + ], 31: [ "MHS-3K-30D", "MHS-3.6K-30D", @@ -124,14 +133,14 @@ def _model_str(val): "MHS-8K-30D", "MHS-3K-30S", "MHS-3.6K-30S", - ], + ], 32: [ "MHT-25K-100", "MHT-30K-100", "MHT-36K-100", "MHT-40K-100", "MHT-50K-100", - ] + ], } try: bh, bl = val // 256, val % 256 @@ -139,15 +148,18 @@ def _model_str(val): except: return "unknown" + def _flag_list(v, flags, empty=""): - #v int, flags array of bit/string, empty string - v = format(v, 'b')#[::-1] #optimized, don't reverse each time + # v int, flags array of bit/string, empty string + v = format(v, "b") # [::-1] #optimized, don't reverse each time n = len(v) ret = [] for i in range(0, min(n, len(flags))): - if v[n-i-1] == '1': ret.append(flags[i]) + if v[n - i - 1] == "1": + ret.append(flags[i]) + + return empty if not ret else ",".join(ret) - return empty if not ret else ','.join(ret) _op_flags = [ "WorkMode Abn.", @@ -158,7 +170,14 @@ def _flag_list(v, flags, empty=""): "Batt. Abn.", "Cmd Stop", "Soc Lowerand No PV", - "","","","","","","","", #8x unused + "", + "", + "", + "", + "", + "", + "", + "", # 8x unused "Cmd PowerLimit", "OverFreq PowerLimit", "OverTemp PowerLimit", @@ -168,107 +187,120 @@ def _flag_list(v, flags, empty=""): "Slow Loading", "OverVolt PowerLimit", "System PowerLim", - ] +] + def _fw_str(wa, *a): ba = [b for w in wa for b in w.to_bytes(2)] return f"V{_bytes_str(ba[0:4])}-{_bytes_str(ba[4:8])}" -_mppt_dd = {0: "off", 0x7fff: "on"} #dict uses 16 bit signed!?, 0xffff not possible -_mppt_mask = 0xff #max 8 mppts + +_mppt_dd = {0: "off", 0x7FFF: "on"} # dict uses 16 bit signed!?, 0xffff not possible +_mppt_mask = 0xFF # max 8 mppts _mppt_list = ["mppt1", "mppt2", "mppt3", "mppt4", "mppt5", "mppt6", "mppt7", "mppt8"] + def _fn_mppt_mask(v, descr, dd): return "off" if v == 0 else "on" if v & _mppt_mask == _mppt_mask else _flag_list(v, _mppt_list, "unknown") -_nan = float('NaN') + +_nan = float("NaN") + + def value_function_house_load(initval, descr, datadict): - v = datadict.get('inverter_load', _nan) - datadict.get('measured_power', _nan) - return None if v != v else v #test nan + v = datadict.get("inverter_load", _nan) - datadict.get("measured_power", _nan) + return None if v != v else v # test nan + # ================================================================================================= -#gc: set defaults; not all classes have all fields... + +# gc: set defaults; not all classes have all fields... @dataclass class SolintegModbusButtonEntityDescription(BaseModbusButtonEntityDescription): def __init__(self, **kwargs): - kwargs.setdefault("allowedtypes",ALLDEFAULT) - #kwargs.setdefault("register_type",REG_HOLDING) - #kwargs.setdefault("write_method",WRITE_SINGLE_MODBUS) - super().__init__( **kwargs) + kwargs.setdefault("allowedtypes", ALLDEFAULT) + # kwargs.setdefault("register_type",REG_HOLDING) + # kwargs.setdefault("write_method",WRITE_SINGLE_MODBUS) + super().__init__(**kwargs) + @dataclass class SolintegModbusNumberEntityDescription(BaseModbusNumberEntityDescription): def __init__(self, **kwargs): - kwargs.setdefault("allowedtypes",ALLDEFAULT) - #kwargs.setdefault("sleepmode",SLEEPMODE_LASTAWAKE) - #kwargs.setdefault("register_type",REG_HOLDING) - kwargs.setdefault("unit",REGISTER_U16) - super().__init__( **kwargs) + kwargs.setdefault("allowedtypes", ALLDEFAULT) + # kwargs.setdefault("sleepmode",SLEEPMODE_LASTAWAKE) + # kwargs.setdefault("register_type",REG_HOLDING) + kwargs.setdefault("unit", REGISTER_U16) + super().__init__(**kwargs) + @dataclass class SolintegModbusSelectEntityDescription(BaseModbusSelectEntityDescription): def __init__(self, **kwargs): - kwargs.setdefault("allowedtypes",ALLDEFAULT) - #kwargs.setdefault("sleepmode",SLEEPMODE_LASTAWAKE) - #kwargs.setdefault("register_type",REG_HOLDING) - #kwargs.setdefault("write_method",WRITE_SINGLE_MODBUS) - kwargs.setdefault("unit",REGISTER_U16) - super().__init__( **kwargs) + kwargs.setdefault("allowedtypes", ALLDEFAULT) + # kwargs.setdefault("sleepmode",SLEEPMODE_LASTAWAKE) + # kwargs.setdefault("register_type",REG_HOLDING) + # kwargs.setdefault("write_method",WRITE_SINGLE_MODBUS) + kwargs.setdefault("unit", REGISTER_U16) + super().__init__(**kwargs) @property def should_poll(self) -> bool: return True + @dataclass class SolintegModbusSensorEntityDescription(BaseModbusSensorEntityDescription): """A class that describes Solinteg Modbus sensor entities.""" + def __init__(self, **kwargs): - #_LOGGER.warning("sensor init") - kwargs.setdefault("allowedtypes",ALLDEFAULT) - kwargs.setdefault("sleepmode",SLEEPMODE_LASTAWAKE) - kwargs.setdefault("register_type",REG_HOLDING) - kwargs.setdefault("unit",REGISTER_U16) - super().__init__( **kwargs) + # _LOGGER.warning("sensor init") + kwargs.setdefault("allowedtypes", ALLDEFAULT) + kwargs.setdefault("sleepmode", SLEEPMODE_LASTAWAKE) + kwargs.setdefault("register_type", REG_HOLDING) + kwargs.setdefault("unit", REGISTER_U16) + super().__init__(**kwargs) + # ================================= Button Declarations ============================================================ BUTTON_TYPES = [ - #on off commands, reg 25008 - SolintegModbusButtonEntityDescription( - name = "Stop Soft(Backup on)", - key = "control_cmd_stop", - register = 25008, - icon = "mdi:stop", - command = 0x100, - ), - SolintegModbusButtonEntityDescription( - name = "Stop Full", - key = "control_cmd_stop_full", - register = 25008, - icon = "mdi:alert-box", - command = 0x404, - ), - SolintegModbusButtonEntityDescription( - name = "Start", - key = "control_cmd_start", - register = 25008, - icon = "mdi:play", - command = 0x101, - ), - SolintegModbusButtonEntityDescription( - name = "Restart", - key = "control_cmd_restart", - register = 25009, - icon = "mdi:restart", - command = 1, + # on off commands, reg 25008 + SolintegModbusButtonEntityDescription( + name="Stop Soft(Backup on)", + key="control_cmd_stop", + register=25008, + icon="mdi:stop", + command=0x100, + ), + SolintegModbusButtonEntityDescription( + name="Stop Full", + key="control_cmd_stop_full", + register=25008, + icon="mdi:alert-box", + command=0x404, + ), + SolintegModbusButtonEntityDescription( + name="Start", + key="control_cmd_start", + register=25008, + icon="mdi:play", + command=0x101, + ), + SolintegModbusButtonEntityDescription( + name="Restart", + key="control_cmd_restart", + register=25009, + icon="mdi:restart", + command=1, ), ] # ================================= Number Declarations ============================================================ MAX_CURRENTS = [ - ('110C', 25 ), # 10kW HV + ("110C", 25), # 10kW HV ] NUMBER_TYPES = [ @@ -277,193 +309,186 @@ def __init__(self, **kwargs): # Data only number types # ### - ### # # Normal number types # ### SolintegModbusNumberEntityDescription( - name = "Battery SOC Min On Grid", - key = "battery_soc_min_ongrid", - register = 52503, - fmt = "i", - native_min_value = 5, - native_max_value = 100, - native_step = 1, + name="Battery SOC Min On Grid", + key="battery_soc_min_ongrid", + register=52503, + fmt="i", + native_min_value=5, + native_max_value=100, + native_step=1, mode="box", - scale = 0.1, - native_unit_of_measurement = PERCENTAGE, - entity_category = EntityCategory.CONFIG, - allowedtypes = HYBRID, - icon = "mdi:battery-charging-low", + scale=0.1, + native_unit_of_measurement=PERCENTAGE, + entity_category=EntityCategory.CONFIG, + allowedtypes=HYBRID, + icon="mdi:battery-charging-low", ), SolintegModbusNumberEntityDescription( - name = "Battery SOC Min Off Grid", - key = "battery_soc_min_offgrid", - register = 52505, - fmt = "i", - native_min_value = 5, - native_max_value = 100, - native_step = 1, + name="Battery SOC Min Off Grid", + key="battery_soc_min_offgrid", + register=52505, + fmt="i", + native_min_value=5, + native_max_value=100, + native_step=1, mode="box", - scale = 0.1, - native_unit_of_measurement = PERCENTAGE, - entity_category = EntityCategory.CONFIG, - allowedtypes = HYBRID, - icon = "mdi:battery-charging-low", + scale=0.1, + native_unit_of_measurement=PERCENTAGE, + entity_category=EntityCategory.CONFIG, + allowedtypes=HYBRID, + icon="mdi:battery-charging-low", ), SolintegModbusNumberEntityDescription( - name = "Battery Charge Current Limit", - key = "battery_charge_current_limit", - register = 52601, - fmt = "i", - native_min_value = 0, - native_max_value = 200, - native_step = 1, + name="Battery Charge Current Limit", + key="battery_charge_current_limit", + register=52601, + fmt="i", + native_min_value=0, + native_max_value=200, + native_step=1, mode="box", - scale = 0.1, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - entity_category = EntityCategory.CONFIG, - allowedtypes = HYBRID, - icon = "mdi:battery-charging-low", + scale=0.1, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + entity_category=EntityCategory.CONFIG, + allowedtypes=HYBRID, + icon="mdi:battery-charging-low", ), SolintegModbusNumberEntityDescription( - name = "Battery Discharge Current Limit", - key = "battery_discharge_current_limit", - register = 52603, - fmt = "i", - native_min_value = 0, - native_max_value = 200, - native_step = 1, + name="Battery Discharge Current Limit", + key="battery_discharge_current_limit", + register=52603, + fmt="i", + native_min_value=0, + native_max_value=200, + native_step=1, mode="box", - scale = 0.1, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - entity_category = EntityCategory.CONFIG, - allowedtypes = HYBRID, - icon = "mdi:battery-charging-low", + scale=0.1, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + entity_category=EntityCategory.CONFIG, + allowedtypes=HYBRID, + icon="mdi:battery-charging-low", ), SolintegModbusNumberEntityDescription( - name = "Export Limit", - key = "export_limit_value", - register = 25103, - fmt = "i", - native_min_value = -100, - native_max_value = 100, - native_step = 1, - unit = REGISTER_S16, + name="Export Limit", + key="export_limit_value", + register=25103, + fmt="i", + native_min_value=-100, + native_max_value=100, + native_step=1, + unit=REGISTER_S16, mode="box", - scale = 0.1, - native_unit_of_measurement = PERCENTAGE, - entity_category = EntityCategory.CONFIG, - allowedtypes = HYBRID, - icon = "mdi:export", + scale=0.1, + native_unit_of_measurement=PERCENTAGE, + entity_category=EntityCategory.CONFIG, + allowedtypes=HYBRID, + icon="mdi:export", ), ] # ================================= Select Declarations ============================================================ - + SELECT_TYPES = [ SolintegModbusSelectEntityDescription( - name = "Working Mode", - key = "working_mode", - register = 50000, - option_dict = { - 257: "General", - 258: "Economic", - 259: "UPS", - 512: "Off-Grid Mode" - }, - entity_category = EntityCategory.CONFIG, - allowedtypes = HYBRID, - icon = "mdi:dip-switch", + name="Working Mode", + key="working_mode", + register=50000, + option_dict={257: "General", 258: "Economic", 259: "UPS", 512: "Off-Grid Mode"}, + entity_category=EntityCategory.CONFIG, + allowedtypes=HYBRID, + icon="mdi:dip-switch", ), SolintegModbusSelectEntityDescription( - name = "UPS Function", - key = "ups_function", - register = 50001, - option_dict = _simple_switch, - entity_category = EntityCategory.CONFIG, - allowedtypes = HYBRID, - icon = "mdi:power-plug-battery-outline", + name="UPS Function", + key="ups_function", + register=50001, + option_dict=_simple_switch, + entity_category=EntityCategory.CONFIG, + allowedtypes=HYBRID, + icon="mdi:power-plug-battery-outline", ), SolintegModbusSelectEntityDescription( - name = "Grid Unbalanced Output", - key = "grid_unbalanced_output", - register = 50006, - option_dict = _simple_switch, - entity_category = EntityCategory.CONFIG, - allowedtypes = HYBRID, - icon = "mdi:scale-unbalanced", + name="Grid Unbalanced Output", + key="grid_unbalanced_output", + register=50006, + option_dict=_simple_switch, + entity_category=EntityCategory.CONFIG, + allowedtypes=HYBRID, + icon="mdi:scale-unbalanced", ), SolintegModbusSelectEntityDescription( - name = "Export Limit Switch", - key = "export_limit_switch", - register = 25100, - option_dict = _simple_switch, - entity_category = EntityCategory.CONFIG, - icon = "mdi:export", + name="Export Limit Switch", + key="export_limit_switch", + register=25100, + option_dict=_simple_switch, + entity_category=EntityCategory.CONFIG, + icon="mdi:export", ), SolintegModbusSelectEntityDescription( - name = "Battery SOC Protection On Grid", - key = "battery_soc_prot_ongrid", - register = 52502, - option_dict = _simple_switch, - entity_category = EntityCategory.CONFIG, - allowedtypes = HYBRID, - icon = "mdi:dip-switch", + name="Battery SOC Protection On Grid", + key="battery_soc_prot_ongrid", + register=52502, + option_dict=_simple_switch, + entity_category=EntityCategory.CONFIG, + allowedtypes=HYBRID, + icon="mdi:dip-switch", ), SolintegModbusSelectEntityDescription( - name = "Battery SOC Protection Off Grid", - key = "battery_soc_prot_offgrid", - register = 52504, - option_dict = _simple_switch, - entity_category = EntityCategory.CONFIG, - allowedtypes = HYBRID, - icon = "mdi:dip-switch", + name="Battery SOC Protection Off Grid", + key="battery_soc_prot_offgrid", + register=52504, + option_dict=_simple_switch, + entity_category=EntityCategory.CONFIG, + allowedtypes=HYBRID, + icon="mdi:dip-switch", ), SolintegModbusSelectEntityDescription( - name = "Shadow Scan", - key = "shadow_scan", - register = 25020, - option_dict = _mppt_dd, - entity_category = EntityCategory.CONFIG, - icon = "mdi:box-shadow", + name="Shadow Scan", + key="shadow_scan", + register=25020, + option_dict=_mppt_dd, + entity_category=EntityCategory.CONFIG, + icon="mdi:box-shadow", ), SolintegModbusSelectEntityDescription( - name = "Battery Protection Relax", - key = "battery_soc_prot_relax", - register = 50012, - option_dict = _simple_switch, - entity_category = EntityCategory.CONFIG, - allowedtypes = HYBRID, - icon = "mdi:dip-switch", + name="Battery Protection Relax", + key="battery_soc_prot_relax", + register=50012, + option_dict=_simple_switch, + entity_category=EntityCategory.CONFIG, + allowedtypes=HYBRID, + icon="mdi:dip-switch", ), ] # ================================= Sensor Declarations ============================================================ -SENSOR_TYPES: list[SolintegModbusSensorEntityDescription] = [ +SENSOR_TYPES: list[SolintegModbusSensorEntityDescription] = [ SolintegModbusSensorEntityDescription( - name = "Firmware", - key = "software_version", - register = 10011, - #both values - #unit = REGISTER_U32, - unit = REGISTER_WORDS, - wordcount = 4, - scale = _fw_str, #v is array of words - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:information", - ), - - SolintegModbusSensorEntityDescription( - name = "Inverter Status", - key = "inverter_status", - entity_category = EntityCategory.DIAGNOSTIC, - register = 10105, - scan_group = SCAN_GROUP_MEDIUM, - scale = { + name="Firmware", + key="software_version", + register=10011, + # both values + # unit = REGISTER_U32, + unit=REGISTER_WORDS, + wordcount=4, + scale=_fw_str, # v is array of words + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:information", + ), + SolintegModbusSensorEntityDescription( + name="Inverter Status", + key="inverter_status", + entity_category=EntityCategory.DIAGNOSTIC, + register=10105, + scan_group=SCAN_GROUP_MEDIUM, + scale={ 0: "Waiting", 1: "Self checking", 2: "On Grid generating", @@ -734,17 +759,16 @@ def __init__(self, **kwargs): rounding = 2, ), # SolintegModbusSensorEntityDescription( - # name = "Meter Total Energy", - # key = "meter_total_activepower", - # native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - # device_class = SensorDeviceClass.ENERGY, - # register = 33126, - # unit = REGISTER_U32, - # scale = 0.01, - # rounding = 2, - # allowedtypes = HYBRID, + # name = "Meter Total Energy", + # key = "meter_total_activepower", + # native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, + # device_class = SensorDeviceClass.ENERGY, + # register = 33126, + # unit = REGISTER_U32, + # scale = 0.01, + # rounding = 2, + # allowedtypes = HYBRID, # ), - SolintegModbusSensorEntityDescription( name = "Battery Voltage", key = "battery_voltage", @@ -1129,121 +1153,125 @@ def __init__(self, **kwargs): #allowedtypes = HYBRID, ), SolintegModbusSensorEntityDescription( - key = "grid_unbalanced_output", - register = 50006, - scale = _simple_switch, - internal = True, + key="grid_unbalanced_output", + register=50006, + scale=_simple_switch, + internal=True, ), SolintegModbusSensorEntityDescription( - name = "Shadow Scan", - key = "shadow_scan", - register = 25020, - scale = _fn_mppt_mask, - entity_registry_enabled_default = False, - #internal = True, #leave visible for debugging - entity_category = EntityCategory.DIAGNOSTIC, + name="Shadow Scan", + key="shadow_scan", + register=25020, + scale=_fn_mppt_mask, + entity_registry_enabled_default=False, + # internal = True, #leave visible for debugging + entity_category=EntityCategory.DIAGNOSTIC, ), SolintegModbusSensorEntityDescription( - key = "export_limit_switch", - register = 25100, - scale = _simple_switch, - internal = True, + key="export_limit_switch", + register=25100, + scale=_simple_switch, + internal=True, ), SolintegModbusSensorEntityDescription( - key = "export_limit_value", - register = 25103, - unit = REGISTER_S16, - scale = 0.1, - internal = True, + key="export_limit_value", + register=25103, + unit=REGISTER_S16, + scale=0.1, + internal=True, ), - SolintegModbusSensorEntityDescription( - key = "ups_function", - register = 50001, - scale = _simple_switch, - allowedtypes = HYBRID, - internal = True, + key="ups_function", + register=50001, + scale=_simple_switch, + allowedtypes=HYBRID, + internal=True, ), SolintegModbusSensorEntityDescription( - key = "battery_soc_min_ongrid", - register = 52503, - scale = 0.1, - internal = True, - allowedtypes = HYBRID, + key="battery_soc_min_ongrid", + register=52503, + scale=0.1, + internal=True, + allowedtypes=HYBRID, ), SolintegModbusSensorEntityDescription( - key = "battery_soc_min_offgrid", - register = 52505, - scale = 0.1, - internal = True, - allowedtypes = HYBRID, + key="battery_soc_min_offgrid", + register=52505, + scale=0.1, + internal=True, + allowedtypes=HYBRID, ), SolintegModbusSensorEntityDescription( - key = "battery_charge_current_limit", - register = 52601, - scale = 0.1, - internal = True, - allowedtypes = HYBRID, + key="battery_charge_current_limit", + register=52601, + scale=0.1, + internal=True, + allowedtypes=HYBRID, ), SolintegModbusSensorEntityDescription( - key = "battery_discharge_current_limit", - register = 52603, - scale = 0.1, - internal = True, - allowedtypes = HYBRID, + key="battery_discharge_current_limit", + register=52603, + scale=0.1, + internal=True, + allowedtypes=HYBRID, ), SolintegModbusSensorEntityDescription( - key = "battery_soc_prot_ongrid", - register = 52502, - scale = _simple_switch, - internal = True, + key="battery_soc_prot_ongrid", + register=52502, + scale=_simple_switch, + internal=True, ), SolintegModbusSensorEntityDescription( - key = "battery_soc_prot_offgrid", - register = 52504, - scale = _simple_switch, - internal = True, - allowedtypes = HYBRID, + key="battery_soc_prot_offgrid", + register=52504, + scale=_simple_switch, + internal=True, + allowedtypes=HYBRID, ), SolintegModbusSensorEntityDescription( - key = "battery_soc_prot_relax", - register = 50012, - scale = _simple_switch, - internal = True, - allowedtypes = HYBRID, + key="battery_soc_prot_relax", + register=50012, + scale=_simple_switch, + internal=True, + allowedtypes=HYBRID, + ), + SolintegModbusSensorEntityDescription( + key="battery_soc_prot_relax", + register=50012, + scale=_simple_switch, + internal=True, + allowedtypes=HYBRID, ), ] - # ============================ plugin declaration ================================================= + @dataclass class solinteg_plugin(plugin_base): - """ def isAwake(self, datadict): return (datadict.get('run_mode', None) == 'Normal Mode') """ - async def async_determineInverterType(self, hub, configdict): _LOGGER.info(f"{hub.name}: trying to determine inverter type") - seriesnumber = await _read_serialnr(hub) + seriesnumber = await _read_serialnr(hub) if not seriesnumber: _LOGGER.error(f"{hub.name}: cannot find serial number, even not for other Inverter") seriesnumber = "unknown" model = await _read_model(hub) - self.inverter_model = _model_str(model) #as string + self.inverter_model = _model_str(model) # as string bh, bl = model // 256, model % 256 invertertype = 0 - if bh in [30,31,32]: + if bh in [30, 31, 32]: invertertype = invertertype | HYBRID - if bh in [30,32, 40,42]: + if bh in [30, 32, 40, 42]: invertertype = invertertype | X3 if bh == 30 and bl in [0, 1]: @@ -1251,19 +1279,19 @@ async def async_determineInverterType(self, hub, configdict): elif bh == 32: mppt = 4 invertertype = invertertype | MPPT4 - else : #bh == 31, other 30... + else: # bh == 31, other 30... mppt = 2 invertertype = invertertype | MPPT2 - + if invertertype > 0: data = hub.data - #prepare mppt list + # prepare mppt list data["mppt_count"] = mppt - data["mppt_mask"] = 2**mppt - 1 #mask - sel_dd = _mppt_dd.copy() #copy + data["mppt_mask"] = 2**mppt - 1 # mask + sel_dd = _mppt_dd.copy() # copy for i in range(mppt): sel_dd[2**i] = f"mppt{i+1}" - #set the options + # set the options for sel in self.SELECT_TYPES: if sel.key == "shadow_scan": sel.option_dict = sel_dd @@ -1271,27 +1299,35 @@ async def async_determineInverterType(self, hub, configdict): read_eps = configdict.get(CONF_READ_EPS, DEFAULT_READ_EPS) read_dcb = configdict.get(CONF_READ_DCB, DEFAULT_READ_DCB) - if read_eps: invertertype = invertertype | EPS - if read_dcb: invertertype = invertertype | DCB + if read_eps: + invertertype = invertertype | EPS + if read_dcb: + invertertype = invertertype | DCB _LOGGER.info(f"{hub.name}: inverter type: x{invertertype:x}, mppt count={mppt}") - + return invertertype - def matchInverterWithMask (self, inverterspec, entitymask, serialnumber = 'not relevant', blacklist = None): + def matchInverterWithMask(self, inverterspec, entitymask, serialnumber="not relevant", blacklist=None): # returns true if the entity needs to be created for an inverter - genmatch = ((inverterspec & entitymask & ALL_GEN_GROUP) != 0) or (entitymask & ALL_GEN_GROUP == 0) - xmatch = ((inverterspec & entitymask & ALL_X_GROUP) != 0) or (entitymask & ALL_X_GROUP == 0) + genmatch = ((inverterspec & entitymask & ALL_GEN_GROUP) != 0) or (entitymask & ALL_GEN_GROUP == 0) + xmatch = ((inverterspec & entitymask & ALL_X_GROUP) != 0) or (entitymask & ALL_X_GROUP == 0) hybmatch = ((inverterspec & entitymask & ALL_TYPE_GROUP) != 0) or (entitymask & ALL_TYPE_GROUP == 0) - epsmatch = ((inverterspec & entitymask & ALL_EPS_GROUP) != 0) or (entitymask & ALL_EPS_GROUP == 0) - dcbmatch = ((inverterspec & entitymask & ALL_DCB_GROUP) != 0) or (entitymask & ALL_DCB_GROUP == 0) - mpptmatch= ((inverterspec & entitymask & ALL_MPPT) != 0) or (entitymask & ALL_MPPT == 0) + epsmatch = ((inverterspec & entitymask & ALL_EPS_GROUP) != 0) or (entitymask & ALL_EPS_GROUP == 0) + dcbmatch = ((inverterspec & entitymask & ALL_DCB_GROUP) != 0) or (entitymask & ALL_DCB_GROUP == 0) + mpptmatch = ((inverterspec & entitymask & ALL_MPPT) != 0) or (entitymask & ALL_MPPT == 0) blacklisted = False if blacklist: - for start in blacklist: - if serialnumber.startswith(start) : return False - return (genmatch and xmatch and hybmatch and epsmatch and dcbmatch and mpptmatch) + for start in blacklist: + if serialnumber.startswith(start): + return False + return genmatch and xmatch and hybmatch and epsmatch and dcbmatch and mpptmatch + def getSoftwareVersion(self, new_data): + return new_data.get("software_version", None) + + def getHardwareVersion(self, new_data): + return new_data.get("hardware_version", None) def getSoftwareVersion(self, new_data): return new_data.get("software_version", None) @@ -1299,15 +1335,17 @@ def getSoftwareVersion(self, new_data): def getHardwareVersion(self, new_data): return new_data.get("hardware_version", None) + plugin_instance = solinteg_plugin( - plugin_name = 'solinteg', - plugin_manufacturer = 'Gabriel C.', - SENSOR_TYPES = SENSOR_TYPES, - NUMBER_TYPES = NUMBER_TYPES, - BUTTON_TYPES = BUTTON_TYPES, - SELECT_TYPES = SELECT_TYPES, - block_size = 120, - order16 = Endian.BIG, - order32 = Endian.BIG, - #auto_block_ignore_readerror = True - ) + plugin_name="solinteg", + plugin_manufacturer="Gabriel C.", + SENSOR_TYPES=SENSOR_TYPES, + NUMBER_TYPES=NUMBER_TYPES, + BUTTON_TYPES=BUTTON_TYPES, + SELECT_TYPES=SELECT_TYPES, + SWITCH_TYPES=[], + block_size=120, + order16=Endian.BIG, + order32=Endian.BIG, + # auto_block_ignore_readerror = True +) diff --git a/custom_components/solax_modbus/plugin_solis.py b/custom_components/solax_modbus/plugin_solis.py index 8fc66aa3..6e3d5a6c 100644 --- a/custom_components/solax_modbus/plugin_solis.py +++ b/custom_components/solax_modbus/plugin_solis.py @@ -19,41 +19,42 @@ An entity can be declared multiple times (with different bitmasks) if the parameters are different for each inverter type """ -GEN = 0x0001 # base generation for MIC, PV, AC -GEN2 = 0x0002 -GEN3 = 0x0004 -GEN4 = 0x0008 -ALL_GEN_GROUP = GEN2 | GEN3 | GEN4 | GEN +GEN = 0x0001 # base generation for MIC, PV, AC +GEN2 = 0x0002 +GEN3 = 0x0004 +GEN4 = 0x0008 +ALL_GEN_GROUP = GEN2 | GEN3 | GEN4 | GEN -X1 = 0x0100 -X3 = 0x0200 -ALL_X_GROUP = X1 | X3 +X1 = 0x0100 +X3 = 0x0200 +ALL_X_GROUP = X1 | X3 -PV = 0x0400 # Needs further work on PV Only Inverters -AC = 0x0800 -HYBRID = 0x1000 -MIC = 0x2000 +PV = 0x0400 # Needs further work on PV Only Inverters +AC = 0x0800 +HYBRID = 0x1000 +MIC = 0x2000 ALL_TYPE_GROUP = PV | AC | HYBRID | MIC -EPS = 0x8000 -ALL_EPS_GROUP = EPS +EPS = 0x8000 +ALL_EPS_GROUP = EPS -DCB = 0x10000 # dry contact box - gen4 -ALL_DCB_GROUP = DCB +DCB = 0x10000 # dry contact box - gen4 +ALL_DCB_GROUP = DCB -MPPT3 = 0x40000 -MPPT4 = 0x80000 -MPPT6 = 0x100000 -MPPT8 = 0x200000 -MPPT10 = 0x400000 +MPPT3 = 0x40000 +MPPT4 = 0x80000 +MPPT6 = 0x100000 +MPPT8 = 0x200000 +MPPT10 = 0x400000 ALL_MPPT_GROUP = MPPT3 | MPPT4 | MPPT6 | MPPT8 | MPPT10 -ALLDEFAULT = 0 # should be equivalent to HYBRID | AC | GEN2 | GEN3 | GEN4 | X1 | X3 +ALLDEFAULT = 0 # should be equivalent to HYBRID | AC | GEN2 | GEN3 | GEN4 | X1 | X3 # ======================= end of bitmask handling code ============================================= # ====================== find inverter type and details =========================================== + async def async_read_serialnr(hub, address, swapbytes): res = None try: @@ -62,140 +63,233 @@ async def async_read_serialnr(hub, address, swapbytes): decoder = BinaryPayloadDecoder.fromRegisters(inverter_data.registers, byteorder=Endian.BIG) res = decoder.decode_string(14).decode("ascii") if swapbytes: - ba = bytearray(res,"ascii") # convert to bytearray for swapping - ba[0::2], ba[1::2] = ba[1::2], ba[0::2] # swap bytes ourselves - due to bug in Endian.LITTLE ? - res = str(ba, "ascii") # convert back to string + ba = bytearray(res, "ascii") # convert to bytearray for swapping + ba[0::2], ba[1::2] = ba[1::2], ba[0::2] # swap bytes ourselves - due to bug in Endian.LITTLE ? + res = str(ba, "ascii") # convert back to string hub.seriesnumber = res - except Exception as ex: _LOGGER.warning(f"{hub.name}: attempt to read serialnumber failed at 0x{address:x}", exc_info=True) - if not res: _LOGGER.warning(f"{hub.name}: reading serial number from address 0x{address:x} failed; other address may succeed") + except Exception as ex: + _LOGGER.warning(f"{hub.name}: attempt to read serialnumber failed at 0x{address:x}", exc_info=True) + if not res: + _LOGGER.warning( + f"{hub.name}: reading serial number from address 0x{address:x} failed; other address may succeed" + ) _LOGGER.info(f"Read {hub.name} 0x{address:x} serial number: {res}, swapped: {swapbytes}") return res + # ================================================================================================= + @dataclass class SolisModbusButtonEntityDescription(BaseModbusButtonEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class SolisModbusNumberEntityDescription(BaseModbusNumberEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class SolisModbusSelectEntityDescription(BaseModbusSelectEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class SolisModbusSensorEntityDescription(BaseModbusSensorEntityDescription): """A class that describes Solis Modbus sensor entities.""" - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice order16: int = Endian.BIG order32: int = Endian.BIG unit: int = REGISTER_U16 - register_type: int= REG_HOLDING + register_type: int = REG_HOLDING + # ====================================== Computed value functions ================================================= + def value_function_timingmode(initval, descr, datadict): - return [ ('timed_charge_start_hours', datadict.get('timed_charge_start_hours', 0), ), - ('timed_charge_start_minutes', datadict.get('timed_charge_start_minutes', 0), ), - ('timed_charge_end_hours', datadict.get('timed_charge_end_hours', 0), ), - ('timed_charge_end_minutes', datadict.get('timed_charge_end_minutes', 0), ), - ('timed_discharge_start_hours', datadict.get('timed_discharge_start_hours', 0), ), - ('timed_discharge_start_minutes', datadict.get('timed_discharge_start_minutes', 0), ), - ('timed_discharge_end_hours', datadict.get('timed_discharge_end_hours', 0), ), - ('timed_discharge_end_minutes', datadict.get('timed_discharge_end_minutes', 0), ), - ] + return [ + ( + "timed_charge_start_hours", + datadict.get("timed_charge_start_hours", 0), + ), + ( + "timed_charge_start_minutes", + datadict.get("timed_charge_start_minutes", 0), + ), + ( + "timed_charge_end_hours", + datadict.get("timed_charge_end_hours", 0), + ), + ( + "timed_charge_end_minutes", + datadict.get("timed_charge_end_minutes", 0), + ), + ( + "timed_discharge_start_hours", + datadict.get("timed_discharge_start_hours", 0), + ), + ( + "timed_discharge_start_minutes", + datadict.get("timed_discharge_start_minutes", 0), + ), + ( + "timed_discharge_end_hours", + datadict.get("timed_discharge_end_hours", 0), + ), + ( + "timed_discharge_end_minutes", + datadict.get("timed_discharge_end_minutes", 0), + ), + ] + + def value_function_timingmode2(initval, descr, datadict): - return [ - ('timed_charge_start_hours_2', datadict.get('timed_charge_start_hours_2', 0), ), - ('timed_charge_start_minutes_2', datadict.get('timed_charge_start_minutes_2', 0), ), - ('timed_charge_end_hours_2', datadict.get('timed_charge_end_hours_2', 0), ), - ('timed_charge_end_minutes_2', datadict.get('timed_charge_end_minutes_2', 0), ), - ('timed_discharge_start_hours_2', datadict.get('timed_discharge_start_hours_2', 0), ), - ('timed_discharge_start_minutes_2', datadict.get('timed_discharge_start_minutes_2', 0), ), - ('timed_discharge_end_hours_2', datadict.get('timed_discharge_end_hours_2', 0), ), - ('timed_discharge_end_minutes_2', datadict.get('timed_discharge_end_minutes_2', 0), ), - ] + return [ + ( + "timed_charge_start_hours_2", + datadict.get("timed_charge_start_hours_2", 0), + ), + ( + "timed_charge_start_minutes_2", + datadict.get("timed_charge_start_minutes_2", 0), + ), + ( + "timed_charge_end_hours_2", + datadict.get("timed_charge_end_hours_2", 0), + ), + ( + "timed_charge_end_minutes_2", + datadict.get("timed_charge_end_minutes_2", 0), + ), + ( + "timed_discharge_start_hours_2", + datadict.get("timed_discharge_start_hours_2", 0), + ), + ( + "timed_discharge_start_minutes_2", + datadict.get("timed_discharge_start_minutes_2", 0), + ), + ( + "timed_discharge_end_hours_2", + datadict.get("timed_discharge_end_hours_2", 0), + ), + ( + "timed_discharge_end_minutes_2", + datadict.get("timed_discharge_end_minutes_2", 0), + ), + ] + def value_function_timingmode3(initval, descr, datadict): - return [ - ('timed_charge_start_hours_3', datadict.get('timed_charge_start_hours_3', 0), ), - ('timed_charge_start_minutes_3', datadict.get('timed_charge_start_minutes_3', 0), ), - ('timed_charge_end_hours_3', datadict.get('timed_charge_end_hours_3', 0), ), - ('timed_charge_end_minutes_3', datadict.get('timed_charge_end_minutes_3', 0), ), - ('timed_discharge_start_hours_3', datadict.get('timed_discharge_start_hours_3', 0), ), - ('timed_discharge_start_minutes_3', datadict.get('timed_discharge_start_minutes_3', 0), ), - ('timed_discharge_end_hours_3', datadict.get('timed_discharge_end_hours_3', 0), ), - ('timed_discharge_end_minutes_3', datadict.get('timed_discharge_end_minutes_3', 0), ), - ] + return [ + ( + "timed_charge_start_hours_3", + datadict.get("timed_charge_start_hours_3", 0), + ), + ( + "timed_charge_start_minutes_3", + datadict.get("timed_charge_start_minutes_3", 0), + ), + ( + "timed_charge_end_hours_3", + datadict.get("timed_charge_end_hours_3", 0), + ), + ( + "timed_charge_end_minutes_3", + datadict.get("timed_charge_end_minutes_3", 0), + ), + ( + "timed_discharge_start_hours_3", + datadict.get("timed_discharge_start_hours_3", 0), + ), + ( + "timed_discharge_start_minutes_3", + datadict.get("timed_discharge_start_minutes_3", 0), + ), + ( + "timed_discharge_end_hours_3", + datadict.get("timed_discharge_end_hours_3", 0), + ), + ( + "timed_discharge_end_minutes_3", + datadict.get("timed_discharge_end_minutes_3", 0), + ), + ] + def value_function_pv1_power(initval, descr, datadict): - return datadict.get('pv_voltage_1', 0) * datadict.get('pv_current_1',0) + return datadict.get("pv_voltage_1", 0) * datadict.get("pv_current_1", 0) + def value_function_pv2_power(initval, descr, datadict): - return datadict.get('pv_voltage_2', 0) * datadict.get('pv_current_2',0) + return datadict.get("pv_voltage_2", 0) * datadict.get("pv_current_2", 0) + def value_function_pv3_power(initval, descr, datadict): - return datadict.get('pv_voltage_3', 0) * datadict.get('pv_current_3',0) + return datadict.get("pv_voltage_3", 0) * datadict.get("pv_current_3", 0) + def value_function_pv4_power(initval, descr, datadict): - return datadict.get('pv_voltage_4', 0) * datadict.get('pv_current_4',0) + return datadict.get("pv_voltage_4", 0) * datadict.get("pv_current_4", 0) + # ================================= Button Declarations ============================================================ BUTTON_TYPES = [ SolisModbusButtonEntityDescription( - name = "Sync RTC", - key = "sync_rtc", - register = 43000, - allowedtypes = HYBRID, - write_method = WRITE_MULTI_MODBUS, - icon = "mdi:home-clock", - value_function = value_function_sync_rtc_ymd, + name="Sync RTC", + key="sync_rtc", + register=43000, + allowedtypes=HYBRID, + write_method=WRITE_MULTI_MODBUS, + icon="mdi:home-clock", + value_function=value_function_sync_rtc_ymd, ), SolisModbusButtonEntityDescription( - name = "Update Charge/Discharge Times", - key = "update_charge_discharge_times", - register = 43143, - allowedtypes = HYBRID, - write_method = WRITE_MULTI_MODBUS, - icon = "mdi:battery-clock", - value_function = value_function_timingmode, + name="Update Charge/Discharge Times", + key="update_charge_discharge_times", + register=43143, + allowedtypes=HYBRID, + write_method=WRITE_MULTI_MODBUS, + icon="mdi:battery-clock", + value_function=value_function_timingmode, ), SolisModbusButtonEntityDescription( - name = "Update Charge/Discharge Times 2", - key = "update_charge_discharge_times_2", - register = 43153, - allowedtypes = HYBRID, - write_method = WRITE_MULTI_MODBUS, - icon = "mdi:battery-clock", - value_function = value_function_timingmode2, + name="Update Charge/Discharge Times 2", + key="update_charge_discharge_times_2", + register=43153, + allowedtypes=HYBRID, + write_method=WRITE_MULTI_MODBUS, + icon="mdi:battery-clock", + value_function=value_function_timingmode2, ), SolisModbusButtonEntityDescription( - name = "Update Charge/Discharge Times 3", - key = "update_charge_discharge_times_3", - register = 43163, - allowedtypes = HYBRID, - write_method = WRITE_MULTI_MODBUS, - icon = "mdi:battery-clock", - value_function = value_function_timingmode3, + name="Update Charge/Discharge Times 3", + key="update_charge_discharge_times_3", + register=43163, + allowedtypes=HYBRID, + write_method=WRITE_MULTI_MODBUS, + icon="mdi:battery-clock", + value_function=value_function_timingmode3, ), ] # ================================= Number Declarations ============================================================ MAX_CURRENTS = [ - ('0602', 62.5 ), # 3kW 48v - ('0102', 62.5 ), # 3kW 48v AC Only? - ('110F', 62.5 ), # 3.6kW 48v - ('160F3', 100 ), # 5kW 48v - ('160F4', 60 ), # 3.6kW 48v - ('160F5', 62.5 ), # 3.6kW 48v - ('1031', 100 ), # 5kW 48v - ('134F', 100 ), # 5kW 48v - ('6031', 100 ), # 6kW 48v - ('110C', 25 ), # 10kW HV + ("0602", 62.5), # 3kW 48v + ("0102", 62.5), # 3kW 48v AC Only? + ("110F", 62.5), # 3.6kW 48v + ("160F3", 100), # 5kW 48v + ("160F4", 60), # 3.6kW 48v + ("160F5", 62.5), # 3.6kW 48v + ("1031", 100), # 5kW 48v + ("134F", 100), # 5kW 48v + ("6031", 100), # 6kW 48v + ("110C", 25), # 10kW HV ] NUMBER_TYPES = [ @@ -205,406 +299,406 @@ def value_function_pv4_power(initval, descr, datadict): # ### SolisModbusNumberEntityDescription( - name = "Sync RTC Offset", - key = "sync_rtc_offset", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = -3600, - native_max_value = 3600, - native_step = 1, - native_unit_of_measurement = UnitOfTime.SECONDS, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:home-clock", - prevent_update = True, + name="Sync RTC Offset", + key="sync_rtc_offset", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=-3600, + native_max_value=3600, + native_step=1, + native_unit_of_measurement=UnitOfTime.SECONDS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:home-clock", + prevent_update=True, ), SolisModbusNumberEntityDescription( - name = "Timed Charge Start Hours", - key = "timed_charge_start_hours", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 23, - native_step = 1, - native_unit_of_measurement = UnitOfTime.HOURS, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Charge Start Hours", + key="timed_charge_start_hours", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), SolisModbusNumberEntityDescription( - name = "Timed Charge Start Minutes", - key = "timed_charge_start_minutes", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 59, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Charge Start Minutes", + key="timed_charge_start_minutes", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), SolisModbusNumberEntityDescription( - name = "Timed Charge End Hours", - key = "timed_charge_end_hours", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 23, - native_step = 1, - native_unit_of_measurement = UnitOfTime.HOURS, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Charge End Hours", + key="timed_charge_end_hours", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), SolisModbusNumberEntityDescription( - name = "Timed Charge End Minutes", - key = "timed_charge_end_minutes", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 59, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Charge End Minutes", + key="timed_charge_end_minutes", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), SolisModbusNumberEntityDescription( - name = "Timed Discharge Start Hours", - key = "timed_discharge_start_hours", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 23, - native_step = 1, - native_unit_of_measurement = UnitOfTime.HOURS, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Discharge Start Hours", + key="timed_discharge_start_hours", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), SolisModbusNumberEntityDescription( - name = "Timed Discharge Start Minutes", - key = "timed_discharge_start_minutes", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 59, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Discharge Start Minutes", + key="timed_discharge_start_minutes", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), SolisModbusNumberEntityDescription( - name = "Timed Discharge End Hours", - key = "timed_discharge_end_hours", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 23, - native_step = 1, - native_unit_of_measurement = UnitOfTime.HOURS, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Discharge End Hours", + key="timed_discharge_end_hours", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), SolisModbusNumberEntityDescription( - name = "Timed Discharge End Minutes", - key = "timed_discharge_end_minutes", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 59, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Discharge End Minutes", + key="timed_discharge_end_minutes", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), ### TimeSlot2 SolisModbusNumberEntityDescription( - name = "Timed Charge Start Hours 2", - key = "timed_charge_start_hours_2", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 23, - native_step = 1, - native_unit_of_measurement = UnitOfTime.HOURS, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Charge Start Hours 2", + key="timed_charge_start_hours_2", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), SolisModbusNumberEntityDescription( - name = "Timed Charge Start Minutes 2", - key = "timed_charge_start_minutes_2", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 59, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Charge Start Minutes 2", + key="timed_charge_start_minutes_2", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), SolisModbusNumberEntityDescription( - name = "Timed Charge End Hours 2", - key = "timed_charge_end_hours_2", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 23, - native_step = 1, - native_unit_of_measurement = UnitOfTime.HOURS, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Charge End Hours 2", + key="timed_charge_end_hours_2", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), SolisModbusNumberEntityDescription( - name = "Timed Charge End Minutes 2", - key = "timed_charge_end_minutes_2", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 59, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Charge End Minutes 2", + key="timed_charge_end_minutes_2", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), SolisModbusNumberEntityDescription( - name = "Timed Discharge Start Hours 2", - key = "timed_discharge_start_hours_2", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 23, - native_step = 1, - native_unit_of_measurement = UnitOfTime.HOURS, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Discharge Start Hours 2", + key="timed_discharge_start_hours_2", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), SolisModbusNumberEntityDescription( - name = "Timed Discharge Start Minutes 2", - key = "timed_discharge_start_minutes_2", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 59, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Discharge Start Minutes 2", + key="timed_discharge_start_minutes_2", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), SolisModbusNumberEntityDescription( - name = "Timed Discharge End Hours 2", - key = "timed_discharge_end_hours_2", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 23, - native_step = 1, - native_unit_of_measurement = UnitOfTime.HOURS, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Discharge End Hours 2", + key="timed_discharge_end_hours_2", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), SolisModbusNumberEntityDescription( - name = "Timed Discharge End Minutes 2", - key = "timed_discharge_end_minutes_2", - fmt = "i", - unit = REGISTER_U16, - initvalue = 0, - native_min_value = 0, - native_max_value = 59, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Discharge End Minutes 2", + key="timed_discharge_end_minutes_2", + fmt="i", + unit=REGISTER_U16, + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), ###TimeSlot3 SolisModbusNumberEntityDescription( - name = "Timed Charge Start Hours 3", - key = "timed_charge_start_hours_3", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 23, - native_step = 1, - native_unit_of_measurement = UnitOfTime.HOURS, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Charge Start Hours 3", + key="timed_charge_start_hours_3", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), SolisModbusNumberEntityDescription( - name = "Timed Charge Start Minutes 3", - key = "timed_charge_start_minutes_3", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 59, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Charge Start Minutes 3", + key="timed_charge_start_minutes_3", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), SolisModbusNumberEntityDescription( - name = "Timed Charge End Hours 3", - key = "timed_charge_end_hours_3", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 23, - native_step = 1, - native_unit_of_measurement = UnitOfTime.HOURS, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Charge End Hours 3", + key="timed_charge_end_hours_3", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), SolisModbusNumberEntityDescription( - name = "Timed Charge End Minutes 3", - key = "timed_charge_end_minutes_3", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 59, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Charge End Minutes 3", + key="timed_charge_end_minutes_3", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), SolisModbusNumberEntityDescription( - name = "Timed Discharge Start Hours 3", - key = "timed_discharge_start_hours_3", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 23, - native_step = 1, - native_unit_of_measurement = UnitOfTime.HOURS, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Discharge Start Hours 3", + key="timed_discharge_start_hours_3", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), SolisModbusNumberEntityDescription( - name = "Timed Discharge Start Minutes 3", - key = "timed_discharge_start_minutes_3", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 59, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Discharge Start Minutes 3", + key="timed_discharge_start_minutes_3", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), SolisModbusNumberEntityDescription( - name = "Timed Discharge End Hours 3", - key = "timed_discharge_end_hours_3", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 23, - native_step = 1, - native_unit_of_measurement = UnitOfTime.HOURS, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Discharge End Hours 3", + key="timed_discharge_end_hours_3", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), SolisModbusNumberEntityDescription( - name = "Timed Discharge End Minutes 3", - key = "timed_discharge_end_minutes_3", - unit = REGISTER_U16, - fmt = "i", - initvalue = 0, - native_min_value = 0, - native_max_value = 59, - native_step = 1, - native_unit_of_measurement = UnitOfTime.MINUTES, - allowedtypes = HYBRID, - write_method = WRITE_DATA_LOCAL, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - prevent_update = True, + name="Timed Discharge End Minutes 3", + key="timed_discharge_end_minutes_3", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, ), ### # @@ -612,129 +706,129 @@ def value_function_pv4_power(initval, descr, datadict): # ### SolisModbusNumberEntityDescription( - name = "Battery Minimum SOC", - key = "battery_minimum_soc", - register = 43011, - fmt = "i", - native_min_value = 10, - native_max_value = 100, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = HYBRID, - icon = "mdi:battery-sync", + name="Battery Minimum SOC", + key="battery_minimum_soc", + register=43011, + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=HYBRID, + icon="mdi:battery-sync", ), SolisModbusNumberEntityDescription( - name = "Force Charge SOC", - key = "force_charge_soc", - register = 43018, - fmt = "i", - native_min_value = 10, - native_max_value = 100, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = HYBRID, - icon = "mdi:battery-sync", + name="Force Charge SOC", + key="force_charge_soc", + register=43018, + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=HYBRID, + icon="mdi:battery-sync", ), SolisModbusNumberEntityDescription( - name = "Backup Mode SOC", - key = "backup_mode_soc", - register = 43024, - fmt = "i", - native_min_value = 10, - native_max_value = 100, - native_step = 1, - native_unit_of_measurement = PERCENTAGE, - allowedtypes = HYBRID, - icon = "mdi:battery-sync", + name="Backup Mode SOC", + key="backup_mode_soc", + register=43024, + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=HYBRID, + icon="mdi:battery-sync", ), SolisModbusNumberEntityDescription( - name = "Backflow Power", - key = "backflow_power", - register = 43074, - fmt = "i", - native_min_value = 0, - native_max_value = 9900, - native_step = 100, - scale = 100, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = NumberDeviceClass.POWER, - allowedtypes = HYBRID, - entity_category = EntityCategory.CONFIG, + name="Backflow Power", + key="backflow_power", + register=43074, + fmt="i", + native_min_value=0, + native_max_value=9900, + native_step=100, + scale=100, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=NumberDeviceClass.POWER, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, ), SolisModbusNumberEntityDescription( - name = "Battery ChargeDischarge Current", - key = "battery_chargedischarge_current", - register = 43116, - fmt = "f", - native_min_value = 0, - native_max_value = 20, - native_step = 1, - scale = 0.1, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = NumberDeviceClass.CURRENT, - allowedtypes = HYBRID, - max_exceptions = MAX_CURRENTS, - entity_category = EntityCategory.CONFIG, + name="Battery ChargeDischarge Current", + key="battery_chargedischarge_current", + register=43116, + fmt="f", + native_min_value=0, + native_max_value=20, + native_step=1, + scale=0.1, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=NumberDeviceClass.CURRENT, + allowedtypes=HYBRID, + max_exceptions=MAX_CURRENTS, + entity_category=EntityCategory.CONFIG, ), SolisModbusNumberEntityDescription( - name = "Battery Charge Current", - key = "battery_charge_current", - register = 43117, - fmt = "f", - native_min_value = 0, - native_max_value = 20, - native_step = 1, - scale = 0.1, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = NumberDeviceClass.CURRENT, - allowedtypes = HYBRID, - max_exceptions = MAX_CURRENTS, - entity_category = EntityCategory.CONFIG, + name="Battery Charge Current", + key="battery_charge_current", + register=43117, + fmt="f", + native_min_value=0, + native_max_value=20, + native_step=1, + scale=0.1, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=NumberDeviceClass.CURRENT, + allowedtypes=HYBRID, + max_exceptions=MAX_CURRENTS, + entity_category=EntityCategory.CONFIG, ), SolisModbusNumberEntityDescription( - name = "Battery Discharge Current", - key = "battery_discharge_current", - register = 43118, - fmt = "f", - native_min_value = 0, - native_max_value = 20, - native_step = 1, - scale = 0.1, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = NumberDeviceClass.CURRENT, - allowedtypes = HYBRID, - max_exceptions = MAX_CURRENTS, - entity_category = EntityCategory.CONFIG, + name="Battery Discharge Current", + key="battery_discharge_current", + register=43118, + fmt="f", + native_min_value=0, + native_max_value=20, + native_step=1, + scale=0.1, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=NumberDeviceClass.CURRENT, + allowedtypes=HYBRID, + max_exceptions=MAX_CURRENTS, + entity_category=EntityCategory.CONFIG, ), SolisModbusNumberEntityDescription( - name = "Timed Charge Current", - key = "timed_charge_current", - register = 43141, - fmt = "f", - native_min_value = 0, - native_max_value = 20, - native_step = 1, - scale = 0.1, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = NumberDeviceClass.CURRENT, - allowedtypes = HYBRID, - max_exceptions = MAX_CURRENTS, - entity_category = EntityCategory.CONFIG, + name="Timed Charge Current", + key="timed_charge_current", + register=43141, + fmt="f", + native_min_value=0, + native_max_value=20, + native_step=1, + scale=0.1, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=NumberDeviceClass.CURRENT, + allowedtypes=HYBRID, + max_exceptions=MAX_CURRENTS, + entity_category=EntityCategory.CONFIG, ), SolisModbusNumberEntityDescription( - name = "Timed Discharge Current", - key = "timed_discharge_current", - register = 43142, - fmt = "f", - native_min_value = 0, - native_max_value = 20, - native_step = 1, - scale = 0.1, - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = NumberDeviceClass.CURRENT, - allowedtypes = HYBRID, - max_exceptions = MAX_CURRENTS, - entity_category = EntityCategory.CONFIG, + name="Timed Discharge Current", + key="timed_discharge_current", + register=43142, + fmt="f", + native_min_value=0, + native_max_value=20, + native_step=1, + scale=0.1, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=NumberDeviceClass.CURRENT, + allowedtypes=HYBRID, + max_exceptions=MAX_CURRENTS, + entity_category=EntityCategory.CONFIG, ), ] @@ -742,69 +836,68 @@ def value_function_pv4_power(initval, descr, datadict): SELECT_TYPES = [ SolisModbusSelectEntityDescription( - name = "Backflow Power Switch", - key = "backflow_power_switch", - register = 43073, - option_dict = { - 0: "Off", - 16: "On", - }, - allowedtypes = HYBRID | X1, - icon = "mdi:dip-switch", + name="Backflow Power Switch", + key="backflow_power_switch", + register=43073, + option_dict={ + 0: "Off", + 16: "On", + }, + allowedtypes=HYBRID | X1, + icon="mdi:dip-switch", ), SolisModbusSelectEntityDescription( - name = "Backflow Power Switch", - key = "backflow_power_switch", - register = 43073, - option_dict = { - 0: "Off & Balanced output", - 16: "On & Balanced output", - 64: "Off & Unbalanced output", - 80: "On & Unbalanced output" - }, - allowedtypes = HYBRID | X3, - icon = "mdi:dip-switch", + name="Backflow Power Switch", + key="backflow_power_switch", + register=43073, + option_dict={ + 0: "Off & Balanced output", + 16: "On & Balanced output", + 64: "Off & Unbalanced output", + 80: "On & Unbalanced output", + }, + allowedtypes=HYBRID | X3, + icon="mdi:dip-switch", ), SolisModbusSelectEntityDescription( - name = "Energy Storage Control Switch", - key = "energy_storage_control_switch", - register = 43110, - option_dict = { - 1: "Self-Use - No Grid Charging", - 3: "Timed Charge/Discharge - No Grid Charging", - 17: "Backup/Reserve - No Grid Charging", - 33: "Self-Use - No Timed Charge/Discharge", - 35: "Self-Use", - 37: "Off-Grid Mode", - 41: "Battery Awaken", - 43: "Battery Awaken + Timed Charge/Discharge", - 49: "Backup/Reserve - No Timed Charge/Discharge", - 51: "Backup/Reserve", - 64: "Feed-in priority - No Grid Charging", - 96: "Feed-in priority - No Timed Charge/Discharge", - 98: "Feed-in priority", - }, - allowedtypes = HYBRID, - icon = "mdi:dip-switch", + name="Energy Storage Control Switch", + key="energy_storage_control_switch", + register=43110, + option_dict={ + 1: "Self-Use - No Grid Charging", + 3: "Timed Charge/Discharge - No Grid Charging", + 17: "Backup/Reserve - No Grid Charging", + 33: "Self-Use - No Timed Charge/Discharge", + 35: "Self-Use", + 37: "Off-Grid Mode", + 41: "Battery Awaken", + 43: "Battery Awaken + Timed Charge/Discharge", + 49: "Backup/Reserve - No Timed Charge/Discharge", + 51: "Backup/Reserve", + 64: "Feed-in priority - No Grid Charging", + 96: "Feed-in priority - No Timed Charge/Discharge", + 98: "Feed-in priority", + }, + allowedtypes=HYBRID, + icon="mdi:dip-switch", ), SolisModbusSelectEntityDescription( - name = "Power Switch", - key = "power_switch", - register = 43007, - option_dict = { - 190: "On", - 222: "Off", - }, - allowedtypes = HYBRID, - icon = "mdi:dip-switch", + name="Power Switch", + key="power_switch", + register=43007, + option_dict={ + 190: "On", + 222: "Off", + }, + allowedtypes=HYBRID, + icon="mdi:dip-switch", ), ] # ================================= Sennsor Declarations ============================================================ SENSOR_TYPES: list[SolisModbusSensorEntityDescription] = [ - - #SolisModbusSensorEntityDescription( + # SolisModbusSensorEntityDescription( # name = "Serial Number", # key = "serialnumber", # register = 33004, @@ -817,1639 +910,1661 @@ def value_function_pv4_power(initval, descr, datadict): # allowedtypes = HYBRID, # entity_category = EntityCategory.DIAGNOSTIC, # icon = "mdi:information", - #), - SolisModbusSensorEntityDescription( - name = "RTC", - key = "rtc", - register = 33022, - ignore_readerror = True, - register_type = REG_INPUT, - unit = REGISTER_WORDS, - wordcount = 6, - scale = value_function_rtc_ymd, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.DIAGNOSTIC, - icon = "mdi:clock", - ), - SolisModbusSensorEntityDescription( - name = "Power Generation Total", - key = "power_generation_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - icon = "mdi:solar-power", - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 33029, - register_type = REG_INPUT, - unit = REGISTER_U32, - sleepmode = SLEEPMODE_LASTAWAKE, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Power Generation This Month", - key = "power_generation_this_month", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - icon = "mdi:solar-power", - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 33031, - register_type = REG_INPUT, - unit = REGISTER_U32, - sleepmode = SLEEPMODE_LASTAWAKE, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Power Generation Last Month", - key = "power_generation_last_month", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - icon = "mdi:solar-power", - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 33033, - register_type = REG_INPUT, - unit = REGISTER_U32, - sleepmode = SLEEPMODE_LASTAWAKE, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Power Generation Today", - key = "power_generation_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - icon = "mdi:solar-power", - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 33035, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - sleepmode = SLEEPMODE_LASTAWAKE, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Power Generation Yesterday", - key = "power_generation_yesterday", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - icon = "mdi:solar-power", - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 33036, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - sleepmode = SLEEPMODE_LASTAWAKE, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Power Generation This Year", - key = "power_generation_this_year", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - icon = "mdi:solar-power", - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 33037, - register_type = REG_INPUT, - unit = REGISTER_U32, - sleepmode = SLEEPMODE_LASTAWAKE, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Power Generation Last Year", - key = "power_generation_last_year", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - icon = "mdi:solar-power", - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 33039, - register_type = REG_INPUT, - unit = REGISTER_U32, - sleepmode = SLEEPMODE_LASTAWAKE, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "PV Voltage 1", - key = "pv_voltage_1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - state_class = SensorStateClass.MEASUREMENT, - register = 33049, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "PV Current 1", - key = "pv_current_1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - state_class = SensorStateClass.MEASUREMENT, - register = 33050, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - icon = "mdi:current-dc", - ), - SolisModbusSensorEntityDescription( - name = "PV Power 1", - key = "pv_power_1", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - value_function = value_function_pv1_power, - allowedtypes = HYBRID, - icon = "mdi:solar-power-variant", - ), - SolisModbusSensorEntityDescription( - name = "PV Voltage 2", - key = "pv_voltage_2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - state_class = SensorStateClass.MEASUREMENT, - register = 33051, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "PV Current 2", - key = "pv_current_2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - state_class = SensorStateClass.MEASUREMENT, - register = 33052, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - icon = "mdi:current-dc", - ), - SolisModbusSensorEntityDescription( - name = "PV Power 2", - key = "pv_power_2", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - value_function = value_function_pv2_power, - allowedtypes = HYBRID, - icon = "mdi:solar-power-variant", - ), - SolisModbusSensorEntityDescription( - name = "PV Voltage 3", - key = "pv_voltage_3", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - state_class = SensorStateClass.MEASUREMENT, - register = 33053, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | MPPT4 | MPPT3, - ), - SolisModbusSensorEntityDescription( - name = "PV Current 3", - key = "pv_current_3", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - state_class = SensorStateClass.MEASUREMENT, - register = 33054, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | MPPT4 | MPPT3, - icon = "mdi:current-dc", - ), - SolisModbusSensorEntityDescription( - name = "PV Power 3", - key = "pv_power_3", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - value_function = value_function_pv3_power, - allowedtypes = HYBRID | MPPT4 | MPPT3, - icon = "mdi:solar-power-variant", - ), - SolisModbusSensorEntityDescription( - name = "PV Voltage 4", - key = "pv_voltage_4", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - state_class = SensorStateClass.MEASUREMENT, - register = 33055, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | MPPT4, - ), - SolisModbusSensorEntityDescription( - name = "PV Current 4", - key = "pv_current_4", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - state_class = SensorStateClass.MEASUREMENT, - register = 33056, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | MPPT4, - icon = "mdi:current-dc", - ), - SolisModbusSensorEntityDescription( - name = "PV Power 4", - key = "pv_power_4", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - value_function = value_function_pv4_power, - allowedtypes = HYBRID | MPPT4, - icon = "mdi:solar-power-variant", - ), - SolisModbusSensorEntityDescription( - name = "PV Total Power", - key = "pv_total_power", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 33057, - register_type = REG_INPUT, - unit = REGISTER_U32, - allowedtypes = HYBRID, - icon = "mdi:solar-power-variant", - ), - SolisModbusSensorEntityDescription( - name = "Inverter Voltage", - key = "inverter_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 33073, - scale = 0.1, - register_type = REG_INPUT, - rounding = 1, - allowedtypes = HYBRID | X1, - ), - SolisModbusSensorEntityDescription( - name = "Inverter Voltage L1", - key = "grid_voltage_l1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 33073, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X3, - ), - SolisModbusSensorEntityDescription( - name = "Inverter Voltage L2", - key = "grid_voltage_l2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 33074, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X3, - ), - SolisModbusSensorEntityDescription( - name = "Inverter Voltage L3", - key = "grid_voltage_l3", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 33075, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X3, - ), - SolisModbusSensorEntityDescription( - name = "Inverter Current", - key = "inverter_current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 33076, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X1, - ), - SolisModbusSensorEntityDescription( - name = "Inverter Current L1", - key = "grid_current_l1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 33076, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X3, - ), - SolisModbusSensorEntityDescription( - name = "Inverter Current L2", - key = "grid_current_l2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 33077, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X3, - ), - SolisModbusSensorEntityDescription( - name = "Inverter Current L3", - key = "grid_current_l3", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 33078, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X3, - ), - SolisModbusSensorEntityDescription( - name = "Active Power", - key = "active_power", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 33079, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Reactive Power", - key = "reactive_power", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - register = 33081, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Apparent Power", - key = "apparent_power", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - register = 33083, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Inverter Temperature", - key = "inverter_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 33093, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolisModbusSensorEntityDescription( - name = "Inverter Frequency", - key = "inverter_frequency", - native_unit_of_measurement = UnitOfFrequency.HERTZ, - device_class = SensorDeviceClass.FREQUENCY, - state_class = SensorStateClass.MEASUREMENT, - register = 33094, - register_type = REG_INPUT, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Inverter Status", - key = "inverter_status", - register = 33095, - register_type = REG_INPUT, - scale = { - 0: "Waiting", - 1: "Open Operating", - 2: "Soft Run", - 3: "Generating", - 4: "Bypass Inverter Running", - 5: "Bypass Inverter Sync", - 6: "Bypass Grid Running", - 15: "Normal Running", - 4100: "Grid Off", - 61456: "Grid Surge", - 61457: "Fan Fault", - 4112: "Grid Overvoltage", - 4113: "Grid Undervoltage", - 4114: "Grid Overfrequency", - 4115: "Grid Underfrequency", - 4116: "Grid Reverse Current", - 4117: "No-Grid", - 4118: "Grid Unbalanced", - 4119: "Grid Frequency Fluctuation", - 4120: "Grid Overcurrent", - 4121: "Grid Current Sampling Error", - 4128: "DC Overvoltage", - 4129: "DC Bus Overvoltage", - 4130: "DC Bus Unbalanced", - 4131: "DC Bus Undervoltage", - 4132: "DC Bus Unbalanced 2", - 4133: "DC(Channel A) Overcurrent", - 4134: "DC(Channel B) Overcurrent", - 4135: "DC Interference", - 4136: "DC Reverse", - 4137: "PV Midpoint Grounding", - 4144: "Grid Interference Protection", - 4145: "DSP Inital Protection", - 4146: "Over Temperature Protection", - 4147: "PV Insulation Fault", - 4148: "Leakage Current Protection", - 4149: "Relay Check Protection", - 4150: "DSP_B Protection", - 4151: "DC Injection Protection", - 4152: "12V Undervoltage Faulty", - 4153: "Leakage Current Check Protection", - 4154: "Under Temperature Protection", - 4160: "AFCI Check Fault", - 4161: "AFCI Fault", - 4162: "DSP Chip SRAM Fault", - 4163: "DSP Chip FLASH Fault", - 4164: "DSP Chip PC Pointer Fault", - 4165: "DSP Chip Register Fault", - 4166: "Grid Interference Protection 02", - 4167: "Grid Current Sampling Error", - 4168: "IGBT Overcurrent", - 4176: "Grid Transient Overcurrent", - 4177: "Battery Hardware Overvoltage fault", - 4178: "LLC Hardware Overcurrent", - 4179: "Battery Overvoltage", - 4180: "Battery Undervoltage", - 4181: "Battery Not Connected", - 4182: "Backup Overvoltage", - 4183: "Backup Overload", - 4184: "DSP Selfcheck Error", - 8208: "Fail Safe", - 8209: "Meter COM Fail", - 8210: "Battery COM Fail", - 8212: "DSP COM Fail", - 8213: "BMS Alarm", - 8214: "BatName-FAIL", - 8215: "BMS Alarm 2", - 8216: "DRM Connect Fail", - 8217: "Meter Select Fail", - 8224: "Lead-acid Battery High Temp", - 8225: "Lead-acid Battery Low Temp", - }, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Meter Total ActivePower", - key = "meter_total_activepower", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - register = 33126, - register_type = REG_INPUT, - unit = REGISTER_U32, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Meter Voltage", - key = "meter_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - state_class = SensorStateClass.MEASUREMENT, - register = 33128, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Meter Current", - key = "meter_current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - state_class = SensorStateClass.MEASUREMENT, - register = 33129, - register_type = REG_INPUT, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Meter Active Power", - key = "meter_active_power", - state_class = SensorStateClass.MEASUREMENT, - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - register = 33130, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Energy Storage Control Switch", - key = "energy_storage_control_switch", - register = 33132, - register_type = REG_INPUT, - scale = { - 1: "Self-Use - No Grid Charging", - 3: "Timed Charge/Discharge - No Grid Charging", - 17: "Backup/Reserve - No Grid Charging", - 33: "Self-Use - No Timed Charge/Discharge", - 35: "Self-Use", - 37: "Off-Grid Mode", - 41: "Battery Awaken", - 43: "Battery Awaken + Timed Charge/Discharge", - 49: "Backup/Reserve - No Timed Charge/Discharge", - 51: "Backup/Reserve", - 64: "Feed-in priority - No Grid Charging", - 96: "Feed-in priority - No Timed Charge/Discharge", - 98: "Feed-in priority", - }, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Battery Voltage", - key = "battery_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - state_class = SensorStateClass.MEASUREMENT, - register = 33133, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Battery Current", - key = "battery_current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - state_class = SensorStateClass.MEASUREMENT, - register = 33134, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Battery Charge Direction", - key = "battery_charge_direction", - register = 33135, - register_type = REG_INPUT, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Battery SOC", - key = "battery_soc", - native_unit_of_measurement = PERCENTAGE, - device_class = SensorDeviceClass.BATTERY, - state_class = SensorStateClass.MEASUREMENT, - register = 33139, - register_type = REG_INPUT, - sleepmode = SLEEPMODE_LASTAWAKE, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Battery SOH", - key = "battery_soh", - native_unit_of_measurement = PERCENTAGE, - state_class = SensorStateClass.MEASUREMENT, - register = 33140, - register_type = REG_INPUT, - allowedtypes = HYBRID, - icon = "mdi:battery-heart", - entity_category = EntityCategory.DIAGNOSTIC, - ), - SolisModbusSensorEntityDescription( - name = "BMS Battery Voltage", - key = "bms_battery_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - state_class = SensorStateClass.MEASUREMENT, - register = 33141, - register_type = REG_INPUT, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "BMS Battery Current", - key = "bms_battery_current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - state_class = SensorStateClass.MEASUREMENT, - register = 33142, - register_type = REG_INPUT, - unit = REGISTER_S16, - scale = 0.1, - rounding = 2, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "BMS Battery Charge Limit", - key = "bms_battery_charge_limit", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - state_class = SensorStateClass.MEASUREMENT, - register = 33143, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "BMS Battery Discharge Limit", - key = "bms_battery_discharge_limit", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - state_class = SensorStateClass.MEASUREMENT, - register = 33144, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "House Load", - key = "house_load", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 33147, - register_type = REG_INPUT, - allowedtypes = HYBRID, - icon = "mdi:home", - ), - SolisModbusSensorEntityDescription( - name = "Bypass Load", - key = "bypass_load", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 33148, - register_type = REG_INPUT, - allowedtypes = HYBRID, - icon = "mdi:home", - ), - SolisModbusSensorEntityDescription( - name = "Battery Power", - key = "battery_power", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 33149, - register_type = REG_INPUT, - unit = REGISTER_S32, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:home", - ), - SolisModbusSensorEntityDescription( - name = "Battery Input Energy", - key = "battery_input_energy", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - value_function = value_function_battery_input_solis, - allowedtypes = HYBRID, - icon = "mdi:battery-arrow-up", - ), - SolisModbusSensorEntityDescription( - name = "Battery Output Energy", - key = "battery_output_energy", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - value_function = value_function_battery_output_solis, - allowedtypes = HYBRID, - icon = "mdi:battery-arrow-down", - ), - SolisModbusSensorEntityDescription( - name = "Total Battery Charge", - key = "total_battery_charge", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - register = 33161, - register_type = REG_INPUT, - unit = REGISTER_U32, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Battery Charge Today", - key = "battery_charge_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 33163, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - sleepmode = SLEEPMODE_LASTAWAKE, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Battery Charge Yesterday", - key = "battery_charge_yesterday", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - register = 33164, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Total Battery Discharge", - key = "total_battery_discharge", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - register = 33165, - register_type = REG_INPUT, - unit = REGISTER_U32, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Battery Discharge Today", - key = "battery_discharge_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 33167, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - sleepmode = SLEEPMODE_LASTAWAKE, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Battery Discharge Yesterday", - key = "battery_discharge_yesterday", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - register = 33168, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Grid Import Total", - key = "grid_import_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 33169, - register_type = REG_INPUT, - unit = REGISTER_U32, - entity_registry_enabled_default = False, - sleepmode = SLEEPMODE_LASTAWAKE, - allowedtypes = HYBRID, - icon = "mdi:home-import-outline", - ), - SolisModbusSensorEntityDescription( - name = "Grid Import Today", - key = "grid_import_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 33171, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - sleepmode = SLEEPMODE_LASTAWAKE, - allowedtypes = HYBRID, - icon = "mdi:home-import-outline", - ), - SolisModbusSensorEntityDescription( - name = "Grid Import Yesterday", - key = "grid_import_yesterday", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 33172, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - sleepmode = SLEEPMODE_LASTAWAKE, - allowedtypes = HYBRID, - icon = "mdi:home-import-outline", - ), - SolisModbusSensorEntityDescription( - name = "Grid Export Total", - key = "grid_export_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 33173, - register_type = REG_INPUT, - unit = REGISTER_U32, - entity_registry_enabled_default = False, - sleepmode = SLEEPMODE_LASTAWAKE, - allowedtypes = HYBRID, - icon = "mdi:home-export-outline", - ), - SolisModbusSensorEntityDescription( - name = "Grid Export Today", - key = "grid_export_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 33175, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - sleepmode = SLEEPMODE_LASTAWAKE, - allowedtypes = HYBRID, - icon = "mdi:home-export-outline", - ), - SolisModbusSensorEntityDescription( - name = "Grid Export Yesterday", - key = "grid_export_yesterday", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 33176, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - sleepmode = SLEEPMODE_LASTAWAKE, - allowedtypes = HYBRID, - icon = "mdi:home-export-outline", - ), - SolisModbusSensorEntityDescription( - name = "House Load Total", - key = "house_load_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 33177, - register_type = REG_INPUT, - unit = REGISTER_U32, - rounding = 1, - sleepmode = SLEEPMODE_LASTAWAKE, - allowedtypes = HYBRID, - icon = "mdi:home", - ), - SolisModbusSensorEntityDescription( - name = "House Load Today", - key = "house_load_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 33179, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - sleepmode = SLEEPMODE_LASTAWAKE, - allowedtypes = HYBRID, - icon = "mdi:home", - ), - SolisModbusSensorEntityDescription( - name = "House Load Yesterday", - key = "house_load_yesterday", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 33180, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - sleepmode = SLEEPMODE_LASTAWAKE, - allowedtypes = HYBRID, - icon = "mdi:home", - ), - SolisModbusSensorEntityDescription( - name = "Battery Charge Current Limit", - key = "battery_charge_current_limit", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 33206, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X1, - ), - SolisModbusSensorEntityDescription( - name = "Battery Discharge Current Limit", - key = "battery_discharge_current_limit", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 33207, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X1, - ), - SolisModbusSensorEntityDescription( - name = "Meter AC Voltage", - key = "meter_ac_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 33251, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X1, - ), - SolisModbusSensorEntityDescription( - name = "Meter AC Current", - key = "meter_ac_current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 33252, - register_type = REG_INPUT, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X1, - ), - SolisModbusSensorEntityDescription( - name = "Meter AC Voltage L1", - key = "meter_ac_voltage_l1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 33251, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X3, - ), - SolisModbusSensorEntityDescription( - name = "Meter AC Current L1", - key = "meter_ac_current_l1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 33252, - register_type = REG_INPUT, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X3, - ), - SolisModbusSensorEntityDescription( - name = "Meter AC Voltage L2", - key = "meter_ac_voltage_l2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 33253, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X3, - ), - SolisModbusSensorEntityDescription( - name = "Meter AC Current L2", - key = "meter_ac_current_l2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 33254, - register_type = REG_INPUT, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X3, - ), - SolisModbusSensorEntityDescription( - name = "Meter AC Voltage L3", - key = "meter_ac_voltage_l3", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 33255, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X3, - ), - SolisModbusSensorEntityDescription( - name = "Meter AC Current L3", - key = "meter_ac_current_l3", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 33256, - register_type = REG_INPUT, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID | X3, - ), - SolisModbusSensorEntityDescription( - name = "Meter Active Power L1", - key = "meter_active_power_l1", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - register = 33257, - register_type = REG_INPUT, - unit = REGISTER_S32, - scale = 0.001, - rounding = 3, - allowedtypes = HYBRID | X3, - ), - SolisModbusSensorEntityDescription( - name = "Meter Active Power L2", - key = "meter_active_power_l2", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - register = 33259, - register_type = REG_INPUT, - unit = REGISTER_S32, - scale = 0.001, - rounding = 3, - allowedtypes = HYBRID | X3, - ), - SolisModbusSensorEntityDescription( - name = "Meter Active Power L3", - key = "meter_active_power_l3", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - register = 33261, - register_type = REG_INPUT, - unit = REGISTER_S32, - scale = 0.001, - rounding = 3, - allowedtypes = HYBRID | X3, - ), - SolisModbusSensorEntityDescription( - name = "Meter Active Power Total", - key = "meter_active_power_total", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - register = 33263, - register_type = REG_INPUT, - unit = REGISTER_S32, - scale = 0.001, - rounding = 3, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Meter Reactive Power", - key = "meter_reactive_power", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - register = 33265, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = HYBRID | X1, - ), - SolisModbusSensorEntityDescription( - name = "Meter Reactive Power L1", - key = "meter_reactive_power_l1", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - register = 33265, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = HYBRID | X3, - ), - SolisModbusSensorEntityDescription( - name = "Meter Reactive Power L2", - key = "meter_reactive_power_l2", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - register = 33267, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = HYBRID | X3, - ), - SolisModbusSensorEntityDescription( - name = "Meter Reactive Power L3", - key = "meter_reactive_power_l3", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - register = 33269, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = HYBRID | X3, - ), - SolisModbusSensorEntityDescription( - name = "Meter Reactive Power Total", - key = "meter_reactive_power_total", - native_unit_of_measurement = UnitOfReactivePower.VOLT_AMPERE_REACTIVE, - device_class = SensorDeviceClass.REACTIVE_POWER, - register = 33271, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Meter Apparent Power", - key = "meter_apparent_power", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - register = 33273, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = HYBRID | X1, - ), - SolisModbusSensorEntityDescription( - name = "Meter Apparent Power L1", - key = "meter_apparent_power_l1", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - register = 33273, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = HYBRID | X3, - ), - SolisModbusSensorEntityDescription( - name = "Meter Apparent Power L2", - key = "meter_apparent_power_L2", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - register = 33275, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = HYBRID | X3, - ), - SolisModbusSensorEntityDescription( - name = "Meter Apparent Power L3", - key = "meter_apparent_power_l3", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - register = 33277, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = HYBRID | X3, - ), - SolisModbusSensorEntityDescription( - name = "Meter Apparent Power Total", - key = "meter_apparent_power_total", - native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, - device_class = SensorDeviceClass.APPARENT_POWER, - register = 33279, - register_type = REG_INPUT, - unit = REGISTER_S32, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Meter Power Factor", - key = "meter_power_factor", - native_unit_of_measurement = None, - device_class = SensorDeviceClass.POWER_FACTOR, - state_class = SensorStateClass.MEASUREMENT, - register = 33281, - register_type = REG_INPUT, - unit = REGISTER_S16, - allowedtypes = HYBRID, - scale = 0.01, - rounding = 2, - ), - SolisModbusSensorEntityDescription( - name = "Meter Grid Frequency", - key = "meter_grid_frequency", - native_unit_of_measurement = UnitOfFrequency.HERTZ, - device_class = SensorDeviceClass.FREQUENCY, - register = 33282, - register_type = REG_INPUT, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Meter Grid Import Total", - key = "meter_grid_import_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 33283, - register_type = REG_INPUT, - unit = REGISTER_U32, - scale = 0.01, - rounding = 2, - sleepmode = SLEEPMODE_LASTAWAKE, - allowedtypes = HYBRID, - icon = "mdi:home-import-outline", - ), - SolisModbusSensorEntityDescription( - name = "Meter Grid Export Total", - key = "meter_grid_export_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 33285, - register_type = REG_INPUT, - unit = REGISTER_U32, - scale = 0.01, - rounding = 2, - sleepmode = SLEEPMODE_LASTAWAKE, - allowedtypes = HYBRID, - icon = "mdi:home-export-outline", - ), - SolisModbusSensorEntityDescription( - name = "Power Switch", - key = "power_switch", - register = 43007, - scale = { - 190: "On", - 222: "Off", }, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - ), - SolisModbusSensorEntityDescription( - name = "Battery Minimum SOC", - key = "battery_minimum_soc", - register = 43011, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-sync", - ), - SolisModbusSensorEntityDescription( - name = "Force Charge SOC", - key = "force_charge_soc", - register = 43018, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-sync", - ), - SolisModbusSensorEntityDescription( - name = "Backup Mode SOC", - key = "backup_mode_soc", - register = 43024, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:battery-sync", - ), - SolisModbusSensorEntityDescription( - name = "Backflow Power Switch", - key = "backflow_power_switch", - register = 43073, - scale = { - 0: "Off", - 16: "On", - }, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | X1, - ), - SolisModbusSensorEntityDescription( - name = "Backflow Power Switch", - key = "backflow_power_switch", - register = 43073, - scale = { - 0: "Off & Balanced output", - 16: "On & Balanced output", - 64: "Off & Unbalanced output", - 80: "On & Unbalanced output" - }, - entity_registry_enabled_default = False, - allowedtypes = HYBRID | X3, - ), - SolisModbusSensorEntityDescription( - name = "Backflow Power", - key = "backflow_power", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 43074, - scale = 100, - rounding = 0, - allowedtypes = HYBRID, - entity_registry_enabled_default = False, - ), - SolisModbusSensorEntityDescription( - name = "Battery ChargeDischarge Current", - key = "battery_chargedischarge_current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - state_class = SensorStateClass.MEASUREMENT, - register = 43116, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - entity_registry_enabled_default = False, - entity_category = EntityCategory.CONFIG, - ), - SolisModbusSensorEntityDescription( - name = "Battery Charge Current", - key = "battery_charge_current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - state_class = SensorStateClass.MEASUREMENT, - register = 43117, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - entity_registry_enabled_default = False, - entity_category = EntityCategory.CONFIG, - ), - SolisModbusSensorEntityDescription( - name = "Battery Discharge Current", - key = "battery_discharge_current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - state_class = SensorStateClass.MEASUREMENT, - register = 43118, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.CONFIG, - ), - SolisModbusSensorEntityDescription( - name = "Timed Charge Current", - key = "timed_charge_current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - state_class = SensorStateClass.MEASUREMENT, - register = 43141, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.CONFIG, - ), - SolisModbusSensorEntityDescription( - name = "Timed Discharge Current", - key = "timed_discharge_current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - state_class = SensorStateClass.MEASUREMENT, - register = 43142, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.CONFIG, - ), - SolisModbusSensorEntityDescription( - name = "Timed Charge Start Hours", - key = "timed_charge_start_hours", - register = 43143, - native_unit_of_measurement = UnitOfTime.HOURS, - entity_registry_enabled_default = False, - allowedtypes =HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - ), - SolisModbusSensorEntityDescription( - name = "Timed Charge Start Minutes", - key = "timed_charge_start_minutes", - register = 43144, - native_unit_of_measurement = UnitOfTime.MINUTES, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - ), - SolisModbusSensorEntityDescription( - name = "Timed Charge End Hours", - key = "timed_charge_end_hours", - register = 43145, - native_unit_of_measurement = UnitOfTime.HOURS, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - ), - SolisModbusSensorEntityDescription( - name = "Timed Charge End Minutes", - key = "timed_charge_end_minutes", - register = 43146, - native_unit_of_measurement = UnitOfTime.MINUTES, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - ), - SolisModbusSensorEntityDescription( - name = "Timed Discharge Start Hours", - key = "timed_discharge_start_hours", - register = 43147, - native_unit_of_measurement = UnitOfTime.HOURS, - entity_registry_enabled_default = False, - allowedtypes =HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - ), - SolisModbusSensorEntityDescription( - name = "Timed Discharge Start Minutes", - key = "timed_discharge_start_minutes", - register = 43148, - native_unit_of_measurement = UnitOfTime.MINUTES, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - ), - SolisModbusSensorEntityDescription( - name = "Timed Discharge End Hours", - key = "timed_discharge_end_hours", - register = 43149, - native_unit_of_measurement = UnitOfTime.HOURS, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - ), - SolisModbusSensorEntityDescription( - name = "Timed Discharge End Minutes", - key = "timed_discharge_end_minutes", - register = 43150, - native_unit_of_measurement = UnitOfTime.MINUTES, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", + # ), + SolisModbusSensorEntityDescription( + name="RTC", + key="rtc", + register=33022, + ignore_readerror=True, + register_type=REG_INPUT, + unit=REGISTER_WORDS, + wordcount=6, + scale=value_function_rtc_ymd, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:clock", + ), + SolisModbusSensorEntityDescription( + name="Power Generation Total", + key="power_generation_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33029, + register_type=REG_INPUT, + unit=REGISTER_U32, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Power Generation This Month", + key="power_generation_this_month", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33031, + register_type=REG_INPUT, + unit=REGISTER_U32, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Power Generation Last Month", + key="power_generation_last_month", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33033, + register_type=REG_INPUT, + unit=REGISTER_U32, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Power Generation Today", + key="power_generation_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33035, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Power Generation Yesterday", + key="power_generation_yesterday", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33036, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Power Generation This Year", + key="power_generation_this_year", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33037, + register_type=REG_INPUT, + unit=REGISTER_U32, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Power Generation Last Year", + key="power_generation_last_year", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33039, + register_type=REG_INPUT, + unit=REGISTER_U32, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="PV Voltage 1", + key="pv_voltage_1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=33049, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="PV Current 1", + key="pv_current_1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=33050, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + icon="mdi:current-dc", + ), + SolisModbusSensorEntityDescription( + name="PV Power 1", + key="pv_power_1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + value_function=value_function_pv1_power, + allowedtypes=HYBRID, + icon="mdi:solar-power-variant", + ), + SolisModbusSensorEntityDescription( + name="PV Voltage 2", + key="pv_voltage_2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=33051, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="PV Current 2", + key="pv_current_2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=33052, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + icon="mdi:current-dc", + ), + SolisModbusSensorEntityDescription( + name="PV Power 2", + key="pv_power_2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + value_function=value_function_pv2_power, + allowedtypes=HYBRID, + icon="mdi:solar-power-variant", + ), + SolisModbusSensorEntityDescription( + name="PV Voltage 3", + key="pv_voltage_3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=33053, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | MPPT4 | MPPT3, + ), + SolisModbusSensorEntityDescription( + name="PV Current 3", + key="pv_current_3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=33054, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | MPPT4 | MPPT3, + icon="mdi:current-dc", + ), + SolisModbusSensorEntityDescription( + name="PV Power 3", + key="pv_power_3", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + value_function=value_function_pv3_power, + allowedtypes=HYBRID | MPPT4 | MPPT3, + icon="mdi:solar-power-variant", + ), + SolisModbusSensorEntityDescription( + name="PV Voltage 4", + key="pv_voltage_4", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=33055, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | MPPT4, + ), + SolisModbusSensorEntityDescription( + name="PV Current 4", + key="pv_current_4", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=33056, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | MPPT4, + icon="mdi:current-dc", + ), + SolisModbusSensorEntityDescription( + name="PV Power 4", + key="pv_power_4", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + value_function=value_function_pv4_power, + allowedtypes=HYBRID | MPPT4, + icon="mdi:solar-power-variant", + ), + SolisModbusSensorEntityDescription( + name="PV Total Power", + key="pv_total_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=33057, + register_type=REG_INPUT, + unit=REGISTER_U32, + allowedtypes=HYBRID, + icon="mdi:solar-power-variant", + ), + SolisModbusSensorEntityDescription( + name="Inverter Voltage", + key="inverter_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=33073, + scale=0.1, + register_type=REG_INPUT, + rounding=1, + allowedtypes=HYBRID | X1, + ), + SolisModbusSensorEntityDescription( + name="Inverter Voltage L1", + key="grid_voltage_l1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=33073, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Inverter Voltage L2", + key="grid_voltage_l2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=33074, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Inverter Voltage L3", + key="grid_voltage_l3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=33075, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Inverter Current", + key="inverter_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=33076, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X1, + ), + SolisModbusSensorEntityDescription( + name="Inverter Current L1", + key="grid_current_l1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=33076, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Inverter Current L2", + key="grid_current_l2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=33077, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Inverter Current L3", + key="grid_current_l3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=33078, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Active Power", + key="active_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=33079, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Reactive Power", + key="reactive_power", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=33081, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Apparent Power", + key="apparent_power", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=33083, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Inverter Temperature", + key="inverter_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=33093, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolisModbusSensorEntityDescription( + name="Inverter Frequency", + key="inverter_frequency", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + device_class=SensorDeviceClass.FREQUENCY, + state_class=SensorStateClass.MEASUREMENT, + register=33094, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Inverter Status", + key="inverter_status", + register=33095, + register_type=REG_INPUT, + scale={ + 0: "Waiting", + 1: "Open Operating", + 2: "Soft Run", + 3: "Generating", + 4: "Bypass Inverter Running", + 5: "Bypass Inverter Sync", + 6: "Bypass Grid Running", + 15: "Normal Running", + 4100: "Grid Off", + 61456: "Grid Surge", + 61457: "Fan Fault", + 4112: "Grid Overvoltage", + 4113: "Grid Undervoltage", + 4114: "Grid Overfrequency", + 4115: "Grid Underfrequency", + 4116: "Grid Reverse Current", + 4117: "No-Grid", + 4118: "Grid Unbalanced", + 4119: "Grid Frequency Fluctuation", + 4120: "Grid Overcurrent", + 4121: "Grid Current Sampling Error", + 4128: "DC Overvoltage", + 4129: "DC Bus Overvoltage", + 4130: "DC Bus Unbalanced", + 4131: "DC Bus Undervoltage", + 4132: "DC Bus Unbalanced 2", + 4133: "DC(Channel A) Overcurrent", + 4134: "DC(Channel B) Overcurrent", + 4135: "DC Interference", + 4136: "DC Reverse", + 4137: "PV Midpoint Grounding", + 4144: "Grid Interference Protection", + 4145: "DSP Inital Protection", + 4146: "Over Temperature Protection", + 4147: "PV Insulation Fault", + 4148: "Leakage Current Protection", + 4149: "Relay Check Protection", + 4150: "DSP_B Protection", + 4151: "DC Injection Protection", + 4152: "12V Undervoltage Faulty", + 4153: "Leakage Current Check Protection", + 4154: "Under Temperature Protection", + 4160: "AFCI Check Fault", + 4161: "AFCI Fault", + 4162: "DSP Chip SRAM Fault", + 4163: "DSP Chip FLASH Fault", + 4164: "DSP Chip PC Pointer Fault", + 4165: "DSP Chip Register Fault", + 4166: "Grid Interference Protection 02", + 4167: "Grid Current Sampling Error", + 4168: "IGBT Overcurrent", + 4176: "Grid Transient Overcurrent", + 4177: "Battery Hardware Overvoltage fault", + 4178: "LLC Hardware Overcurrent", + 4179: "Battery Overvoltage", + 4180: "Battery Undervoltage", + 4181: "Battery Not Connected", + 4182: "Backup Overvoltage", + 4183: "Backup Overload", + 4184: "DSP Selfcheck Error", + 8208: "Fail Safe", + 8209: "Meter COM Fail", + 8210: "Battery COM Fail", + 8212: "DSP COM Fail", + 8213: "BMS Alarm", + 8214: "BatName-FAIL", + 8215: "BMS Alarm 2", + 8216: "DRM Connect Fail", + 8217: "Meter Select Fail", + 8224: "Lead-acid Battery High Temp", + 8225: "Lead-acid Battery Low Temp", + }, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Meter Total ActivePower", + key="meter_total_activepower", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + register=33126, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.01, + rounding=2, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Meter Voltage", + key="meter_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=33128, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Meter Current", + key="meter_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=33129, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Meter Active Power", + key="meter_active_power", + state_class=SensorStateClass.MEASUREMENT, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + register=33130, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Energy Storage Control Switch", + key="energy_storage_control_switch", + register=33132, + register_type=REG_INPUT, + scale={ + 1: "Self-Use - No Grid Charging", + 3: "Timed Charge/Discharge - No Grid Charging", + 17: "Backup/Reserve - No Grid Charging", + 33: "Self-Use - No Timed Charge/Discharge", + 35: "Self-Use", + 37: "Off-Grid Mode", + 41: "Battery Awaken", + 43: "Battery Awaken + Timed Charge/Discharge", + 49: "Backup/Reserve - No Timed Charge/Discharge", + 51: "Backup/Reserve", + 64: "Feed-in priority - No Grid Charging", + 96: "Feed-in priority - No Timed Charge/Discharge", + 98: "Feed-in priority", + }, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Battery Voltage", + key="battery_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=33133, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Battery Current", + key="battery_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=33134, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Battery Charge Direction", + key="battery_charge_direction", + register=33135, + register_type=REG_INPUT, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Battery SOC", + key="battery_soc", + native_unit_of_measurement=PERCENTAGE, + device_class=SensorDeviceClass.BATTERY, + state_class=SensorStateClass.MEASUREMENT, + register=33139, + register_type=REG_INPUT, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Battery SOH", + key="battery_soh", + native_unit_of_measurement=PERCENTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=33140, + register_type=REG_INPUT, + allowedtypes=HYBRID, + icon="mdi:battery-heart", + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolisModbusSensorEntityDescription( + name="BMS Battery Voltage", + key="bms_battery_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=33141, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="BMS Battery Current", + key="bms_battery_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=33142, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=2, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="BMS Battery Charge Limit", + key="bms_battery_charge_limit", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=33143, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="BMS Battery Discharge Limit", + key="bms_battery_discharge_limit", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=33144, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="House Load", + key="house_load", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=33147, + register_type=REG_INPUT, + allowedtypes=HYBRID, + icon="mdi:home", + ), + SolisModbusSensorEntityDescription( + name="Bypass Load", + key="bypass_load", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=33148, + register_type=REG_INPUT, + allowedtypes=HYBRID, + icon="mdi:home", + ), + SolisModbusSensorEntityDescription( + name="Battery Power", + key="battery_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=33149, + register_type=REG_INPUT, + unit=REGISTER_S32, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:home", + ), + SolisModbusSensorEntityDescription( + name="Battery Input Energy", + key="battery_input_energy", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + value_function=value_function_battery_input_solis, + allowedtypes=HYBRID, + icon="mdi:battery-arrow-up", + ), + SolisModbusSensorEntityDescription( + name="Battery Output Energy", + key="battery_output_energy", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + value_function=value_function_battery_output_solis, + allowedtypes=HYBRID, + icon="mdi:battery-arrow-down", + ), + SolisModbusSensorEntityDescription( + name="Total Battery Charge", + key="total_battery_charge", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + register=33161, + register_type=REG_INPUT, + unit=REGISTER_U32, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Battery Charge Today", + key="battery_charge_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33163, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Battery Charge Yesterday", + key="battery_charge_yesterday", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + register=33164, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Total Battery Discharge", + key="total_battery_discharge", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + register=33165, + register_type=REG_INPUT, + unit=REGISTER_U32, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Battery Discharge Today", + key="battery_discharge_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33167, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Battery Discharge Yesterday", + key="battery_discharge_yesterday", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + register=33168, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Grid Import Total", + key="grid_import_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33169, + register_type=REG_INPUT, + unit=REGISTER_U32, + entity_registry_enabled_default=False, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + icon="mdi:home-import-outline", + ), + SolisModbusSensorEntityDescription( + name="Grid Import Today", + key="grid_import_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33171, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + icon="mdi:home-import-outline", + ), + SolisModbusSensorEntityDescription( + name="Grid Import Yesterday", + key="grid_import_yesterday", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33172, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + icon="mdi:home-import-outline", + ), + SolisModbusSensorEntityDescription( + name="Grid Export Total", + key="grid_export_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33173, + register_type=REG_INPUT, + unit=REGISTER_U32, + entity_registry_enabled_default=False, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + icon="mdi:home-export-outline", + ), + SolisModbusSensorEntityDescription( + name="Grid Export Today", + key="grid_export_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33175, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + icon="mdi:home-export-outline", + ), + SolisModbusSensorEntityDescription( + name="Grid Export Yesterday", + key="grid_export_yesterday", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33176, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + icon="mdi:home-export-outline", + ), + SolisModbusSensorEntityDescription( + name="House Load Total", + key="house_load_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33177, + register_type=REG_INPUT, + unit=REGISTER_U32, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + icon="mdi:home", + ), + SolisModbusSensorEntityDescription( + name="House Load Today", + key="house_load_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33179, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + icon="mdi:home", + ), + SolisModbusSensorEntityDescription( + name="House Load Yesterday", + key="house_load_yesterday", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33180, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + icon="mdi:home", + ), + SolisModbusSensorEntityDescription( + name="Battery Charge Current Limit", + key="battery_charge_current_limit", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=33206, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X1, + ), + SolisModbusSensorEntityDescription( + name="Battery Discharge Current Limit", + key="battery_discharge_current_limit", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=33207, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X1, + ), + SolisModbusSensorEntityDescription( + name="Meter AC Voltage", + key="meter_ac_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=33251, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X1, + ), + SolisModbusSensorEntityDescription( + name="Meter AC Current", + key="meter_ac_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=33252, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X1, + ), + SolisModbusSensorEntityDescription( + name="Meter AC Voltage L1", + key="meter_ac_voltage_l1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=33251, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter AC Current L1", + key="meter_ac_current_l1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=33252, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter AC Voltage L2", + key="meter_ac_voltage_l2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=33253, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter AC Current L2", + key="meter_ac_current_l2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=33254, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter AC Voltage L3", + key="meter_ac_voltage_l3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=33255, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter AC Current L3", + key="meter_ac_current_l3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=33256, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter Active Power L1", + key="meter_active_power_l1", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=33257, + register_type=REG_INPUT, + unit=REGISTER_S32, + scale=0.001, + rounding=3, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter Active Power L2", + key="meter_active_power_l2", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=33259, + register_type=REG_INPUT, + unit=REGISTER_S32, + scale=0.001, + rounding=3, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter Active Power L3", + key="meter_active_power_l3", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=33261, + register_type=REG_INPUT, + unit=REGISTER_S32, + scale=0.001, + rounding=3, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter Active Power Total", + key="meter_active_power_total", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=33263, + register_type=REG_INPUT, + unit=REGISTER_S32, + scale=0.001, + rounding=3, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Meter Reactive Power", + key="meter_reactive_power", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=33265, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID | X1, + ), + SolisModbusSensorEntityDescription( + name="Meter Reactive Power L1", + key="meter_reactive_power_l1", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=33265, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter Reactive Power L2", + key="meter_reactive_power_l2", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=33267, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter Reactive Power L3", + key="meter_reactive_power_l3", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=33269, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter Reactive Power Total", + key="meter_reactive_power_total", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=33271, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Meter Apparent Power", + key="meter_apparent_power", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=33273, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID | X1, + ), + SolisModbusSensorEntityDescription( + name="Meter Apparent Power L1", + key="meter_apparent_power_l1", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=33273, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter Apparent Power L2", + key="meter_apparent_power_L2", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=33275, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter Apparent Power L3", + key="meter_apparent_power_l3", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=33277, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter Apparent Power Total", + key="meter_apparent_power_total", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=33279, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Meter Power Factor", + key="meter_power_factor", + native_unit_of_measurement=None, + device_class=SensorDeviceClass.POWER_FACTOR, + state_class=SensorStateClass.MEASUREMENT, + register=33281, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=HYBRID, + scale=0.01, + rounding=2, + ), + SolisModbusSensorEntityDescription( + name="Meter Grid Frequency", + key="meter_grid_frequency", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + device_class=SensorDeviceClass.FREQUENCY, + register=33282, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Meter Grid Import Total", + key="meter_grid_import_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33283, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.01, + rounding=2, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + icon="mdi:home-import-outline", + ), + SolisModbusSensorEntityDescription( + name="Meter Grid Export Total", + key="meter_grid_export_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33285, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.01, + rounding=2, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + icon="mdi:home-export-outline", + ), + SolisModbusSensorEntityDescription( + name="Power Switch", + key="power_switch", + register=43007, + scale={ + 190: "On", + 222: "Off", + }, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Battery Minimum SOC", + key="battery_minimum_soc", + register=43011, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-sync", + ), + SolisModbusSensorEntityDescription( + name="Force Charge SOC", + key="force_charge_soc", + register=43018, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-sync", + ), + SolisModbusSensorEntityDescription( + name="Backup Mode SOC", + key="backup_mode_soc", + register=43024, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-sync", + ), + SolisModbusSensorEntityDescription( + name="Backflow Power Switch", + key="backflow_power_switch", + register=43073, + scale={ + 0: "Off", + 16: "On", + }, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | X1, + ), + SolisModbusSensorEntityDescription( + name="Backflow Power Switch", + key="backflow_power_switch", + register=43073, + scale={ + 0: "Off & Balanced output", + 16: "On & Balanced output", + 64: "Off & Unbalanced output", + 80: "On & Unbalanced output", + }, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Backflow Power", + key="backflow_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=43074, + scale=100, + rounding=0, + allowedtypes=HYBRID, + entity_registry_enabled_default=False, + ), + SolisModbusSensorEntityDescription( + name="Battery ChargeDischarge Current", + key="battery_chargedischarge_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=43116, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + entity_registry_enabled_default=False, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Battery Charge Current", + key="battery_charge_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=43117, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + entity_registry_enabled_default=False, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Battery Discharge Current", + key="battery_discharge_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=43118, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Current", + key="timed_charge_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=43141, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Current", + key="timed_discharge_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=43142, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Start Hours", + key="timed_charge_start_hours", + register=43143, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Start Minutes", + key="timed_charge_start_minutes", + register=43144, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge End Hours", + key="timed_charge_end_hours", + register=43145, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge End Minutes", + key="timed_charge_end_minutes", + register=43146, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Start Hours", + key="timed_discharge_start_hours", + register=43147, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Start Minutes", + key="timed_discharge_start_minutes", + register=43148, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge End Hours", + key="timed_discharge_end_hours", + register=43149, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge End Minutes", + key="timed_discharge_end_minutes", + register=43150, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", ), # ============================ TimeSlot2 ============================== SolisModbusSensorEntityDescription( - name = "Timed Charge Start Hours 2", - key = "timed_charge_start_hours_2", - register = 43153, - native_unit_of_measurement = UnitOfTime.HOURS, - entity_registry_enabled_default = False, - allowedtypes =HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - ), - SolisModbusSensorEntityDescription( - name = "Timed Charge Start Minutes 2", - key = "timed_charge_start_minutes_2", - register = 43154, - native_unit_of_measurement = UnitOfTime.MINUTES, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - ), - SolisModbusSensorEntityDescription( - name = "Timed Charge End Hours 2", - key = "timed_charge_end_hours_2", - register = 43155, - native_unit_of_measurement = UnitOfTime.HOURS, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - ), - SolisModbusSensorEntityDescription( - name = "Timed Charge End Minutes 2", - key = "timed_charge_end_minutes_2", - register = 43156, - native_unit_of_measurement = UnitOfTime.MINUTES, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - ), - SolisModbusSensorEntityDescription( - name = "Timed Discharge Start Hours 2", - key = "timed_discharge_start_hours_2", - register = 43157, - native_unit_of_measurement = UnitOfTime.HOURS, - entity_registry_enabled_default = False, - allowedtypes =HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - ), - SolisModbusSensorEntityDescription( - name = "Timed Discharge Start Minutes 2", - key = "timed_discharge_start_minutes_2", - register = 43158, - native_unit_of_measurement = UnitOfTime.MINUTES, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - ), - SolisModbusSensorEntityDescription( - name = "Timed Discharge End Hours 2", - key = "timed_discharge_end_hours_2", - register = 43159, - native_unit_of_measurement = UnitOfTime.HOURS, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - ), - SolisModbusSensorEntityDescription( - name = "Timed Discharge End Minutes 2", - key = "timed_discharge_end_minutes_2", - register = 43160, - native_unit_of_measurement = UnitOfTime.MINUTES, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", + name="Timed Charge Start Hours 2", + key="timed_charge_start_hours_2", + register=43153, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Start Minutes 2", + key="timed_charge_start_minutes_2", + register=43154, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge End Hours 2", + key="timed_charge_end_hours_2", + register=43155, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge End Minutes 2", + key="timed_charge_end_minutes_2", + register=43156, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Start Hours 2", + key="timed_discharge_start_hours_2", + register=43157, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Start Minutes 2", + key="timed_discharge_start_minutes_2", + register=43158, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge End Hours 2", + key="timed_discharge_end_hours_2", + register=43159, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge End Minutes 2", + key="timed_discharge_end_minutes_2", + register=43160, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", ), # ============================ TimeSlot3 ============================== SolisModbusSensorEntityDescription( - name = "Timed Charge Start Hours 3", - key = "timed_charge_start_hours_3", - register = 43163, - native_unit_of_measurement = UnitOfTime.HOURS, - entity_registry_enabled_default = False, - allowedtypes =HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - ), - SolisModbusSensorEntityDescription( - name = "Timed Charge Start Minutes 3", - key = "timed_charge_start_minutes_3", - register = 43164, - native_unit_of_measurement = UnitOfTime.MINUTES, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - ), - SolisModbusSensorEntityDescription( - name = "Timed Charge End Hours 3", - key = "timed_charge_end_hours_3", - register = 43165, - native_unit_of_measurement = UnitOfTime.HOURS, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - ), - SolisModbusSensorEntityDescription( - name = "Timed Charge End Minutes 3", - key = "timed_charge_end_minutes_3", - register = 43166, - native_unit_of_measurement = UnitOfTime.MINUTES, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - ), - SolisModbusSensorEntityDescription( - name = "Timed Discharge Start Hours 3", - key = "timed_discharge_start_hours_3", - register = 43167, - native_unit_of_measurement = UnitOfTime.HOURS, - entity_registry_enabled_default = False, - allowedtypes =HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - ), - SolisModbusSensorEntityDescription( - name = "Timed Discharge Start Minutes 3", - key = "timed_discharge_start_minutes_3", - register = 43168, - native_unit_of_measurement = UnitOfTime.MINUTES, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - ), - SolisModbusSensorEntityDescription( - name = "Timed Discharge End Hours 3", - key = "timed_discharge_end_hours_3", - register = 43169, - native_unit_of_measurement = UnitOfTime.HOURS, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", - ), - SolisModbusSensorEntityDescription( - name = "Timed Discharge End Minutes 3", - key = "timed_discharge_end_minutes_3", - register = 43170, - native_unit_of_measurement = UnitOfTime.MINUTES, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - entity_category = EntityCategory.CONFIG, - icon = "mdi:battery-clock", + name="Timed Charge Start Hours 3", + key="timed_charge_start_hours_3", + register=43163, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Start Minutes 3", + key="timed_charge_start_minutes_3", + register=43164, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge End Hours 3", + key="timed_charge_end_hours_3", + register=43165, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge End Minutes 3", + key="timed_charge_end_minutes_3", + register=43166, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Start Hours 3", + key="timed_discharge_start_hours_3", + register=43167, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Start Minutes 3", + key="timed_discharge_start_minutes_3", + register=43168, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge End Hours 3", + key="timed_discharge_end_hours_3", + register=43169, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge End Minutes 3", + key="timed_discharge_end_minutes_3", + register=43170, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", ), ] # ============================ plugin declaration ================================================= + @dataclass class solis_plugin(plugin_base): async def async_determineInverterType(self, hub, configdict): _LOGGER.info(f"{hub.name}: trying to determine inverter type") - seriesnumber = await async_read_serialnr(hub, 33004, swapbytes = False) + seriesnumber = await async_read_serialnr(hub, 33004, swapbytes=False) if not seriesnumber: _LOGGER.error(f"{hub.name}: cannot find serial number, even not for other Inverter") seriesnumber = "unknown" # derive invertertype from seriiesnumber - if seriesnumber.startswith('1801'): invertertype = HYBRID | X1 # PV Only S6-GR1P 1-3K - elif seriesnumber.startswith('1802'): invertertype = HYBRID | X1 # PV Only S6-GR1P 2.5-6K - elif seriesnumber.startswith('0602'): invertertype = HYBRID | X1 # Hybrid Gen5 3kW - 48v - elif seriesnumber.startswith('0102'): invertertype = HYBRID | X1 # AC? Gen5 3kW - 48v - elif seriesnumber.startswith('010F'): invertertype = HYBRID | X1 # Hybrid Gen5 3kW - 48v - elif seriesnumber.startswith('110F'): invertertype = HYBRID | X1 # Hybrid Gen5 5kW - 48v - elif seriesnumber.startswith('114F'): invertertype = HYBRID | X1 # Hybrid Gen5 6K - 48V - elif seriesnumber.startswith('134F'): invertertype = HYBRID | X1 # Hybrid Gen5 5kW - 48V - elif seriesnumber.startswith('140C'): invertertype = HYBRID | X1 # Hybrid Gen5 5kW - HV - elif seriesnumber.startswith('143'): invertertype = HYBRID | X1 # Hybrid Gen5 5kW - 48V - elif seriesnumber.startswith('160F3'): invertertype = HYBRID | X1 # Hybrid Gen5 5kW - 48v - elif seriesnumber.startswith('160F4'): invertertype = HYBRID | X1 # Hybrid Gen5 3.6kW - 48v - elif seriesnumber.startswith('160F5'): invertertype = HYBRID | X1 # Hybrid Gen5 3.6kW - 48v - elif seriesnumber.startswith('103305'): invertertype = HYBRID | X3 | MPPT4 # Hybrid Gen6 8kW - HV - elif seriesnumber.startswith('103306'): invertertype = HYBRID | X3 | MPPT4 # Hybrid Gen6 10kW - HV - elif seriesnumber.startswith('110C'): invertertype = HYBRID | X3 # Hybrid Gen5 0CA2 / 0C92 10kW - HV - elif seriesnumber.startswith('114C'): invertertype = HYBRID | X3 # Hybrid Gen5 10kW - HV - elif seriesnumber.startswith('1805'): invertertype = HYBRID | X3 # PV Only Gen5 5-20kW - elif seriesnumber.startswith('6031'): invertertype = HYBRID | X1 # Hybrid Gen5 3105 / 3122 Model 6kW - 48V - elif seriesnumber.startswith('1031'): invertertype = HYBRID | X1 # Hybrid Gen5 3104 Model 5kW - 48V - #elif seriesnumber.startswith('abc123'): invertertype = PV | X3 # Comment + if seriesnumber.startswith("1801"): + invertertype = HYBRID | X1 # PV Only S6-GR1P 1-3K + elif seriesnumber.startswith("1802"): + invertertype = HYBRID | X1 # PV Only S6-GR1P 2.5-6K + elif seriesnumber.startswith("0602"): + invertertype = HYBRID | X1 # Hybrid Gen5 3kW - 48v + elif seriesnumber.startswith("0102"): + invertertype = HYBRID | X1 # AC? Gen5 3kW - 48v + elif seriesnumber.startswith("010F"): + invertertype = HYBRID | X1 # Hybrid Gen5 3kW - 48v + elif seriesnumber.startswith("110F"): + invertertype = HYBRID | X1 # Hybrid Gen5 5kW - 48v + elif seriesnumber.startswith("114F"): + invertertype = HYBRID | X1 # Hybrid Gen5 6K - 48V + elif seriesnumber.startswith("134F"): + invertertype = HYBRID | X1 # Hybrid Gen5 5kW - 48V + elif seriesnumber.startswith("140C"): + invertertype = HYBRID | X1 # Hybrid Gen5 5kW - HV + elif seriesnumber.startswith("143"): + invertertype = HYBRID | X1 # Hybrid Gen5 5kW - 48V + elif seriesnumber.startswith("160F3"): + invertertype = HYBRID | X1 # Hybrid Gen5 5kW - 48v + elif seriesnumber.startswith("160F4"): + invertertype = HYBRID | X1 # Hybrid Gen5 3.6kW - 48v + elif seriesnumber.startswith("160F5"): + invertertype = HYBRID | X1 # Hybrid Gen5 3.6kW - 48v + elif seriesnumber.startswith("103305"): + invertertype = HYBRID | X3 | MPPT4 # Hybrid Gen6 8kW - HV + elif seriesnumber.startswith("103306"): + invertertype = HYBRID | X3 | MPPT4 # Hybrid Gen6 10kW - HV + elif seriesnumber.startswith("110C"): + invertertype = HYBRID | X3 # Hybrid Gen5 0CA2 / 0C92 10kW - HV + elif seriesnumber.startswith("114C"): + invertertype = HYBRID | X3 # Hybrid Gen5 10kW - HV + elif seriesnumber.startswith("1805"): + invertertype = HYBRID | X3 # PV Only Gen5 5-20kW + elif seriesnumber.startswith("6031"): + invertertype = HYBRID | X1 # Hybrid Gen5 3105 / 3122 Model 6kW - 48V + elif seriesnumber.startswith("1031"): + invertertype = HYBRID | X1 # Hybrid Gen5 3104 Model 5kW - 48V + # elif seriesnumber.startswith('abc123'): invertertype = PV | X3 # Comment else: invertertype = 0 @@ -2458,35 +2573,39 @@ async def async_determineInverterType(self, hub, configdict): if invertertype > 0: read_eps = configdict.get(CONF_READ_EPS, DEFAULT_READ_EPS) read_dcb = configdict.get(CONF_READ_DCB, DEFAULT_READ_DCB) - if read_eps: invertertype = invertertype | EPS - if read_dcb: invertertype = invertertype | DCB + if read_eps: + invertertype = invertertype | EPS + if read_dcb: + invertertype = invertertype | DCB return invertertype - def matchInverterWithMask (self, inverterspec, entitymask, serialnumber = 'not relevant', blacklist = None): + def matchInverterWithMask(self, inverterspec, entitymask, serialnumber="not relevant", blacklist=None): # returns true if the entity needs to be created for an inverter - genmatch = ((inverterspec & entitymask & ALL_GEN_GROUP) != 0) or (entitymask & ALL_GEN_GROUP == 0) - xmatch = ((inverterspec & entitymask & ALL_X_GROUP) != 0) or (entitymask & ALL_X_GROUP == 0) + genmatch = ((inverterspec & entitymask & ALL_GEN_GROUP) != 0) or (entitymask & ALL_GEN_GROUP == 0) + xmatch = ((inverterspec & entitymask & ALL_X_GROUP) != 0) or (entitymask & ALL_X_GROUP == 0) hybmatch = ((inverterspec & entitymask & ALL_TYPE_GROUP) != 0) or (entitymask & ALL_TYPE_GROUP == 0) - epsmatch = ((inverterspec & entitymask & ALL_EPS_GROUP) != 0) or (entitymask & ALL_EPS_GROUP == 0) - dcbmatch = ((inverterspec & entitymask & ALL_DCB_GROUP) != 0) or (entitymask & ALL_DCB_GROUP == 0) - mpptmatch = ((inverterspec & entitymask & ALL_MPPT_GROUP) != 0) or (entitymask & ALL_MPPT_GROUP == 0) + epsmatch = ((inverterspec & entitymask & ALL_EPS_GROUP) != 0) or (entitymask & ALL_EPS_GROUP == 0) + dcbmatch = ((inverterspec & entitymask & ALL_DCB_GROUP) != 0) or (entitymask & ALL_DCB_GROUP == 0) + mpptmatch = ((inverterspec & entitymask & ALL_MPPT_GROUP) != 0) or (entitymask & ALL_MPPT_GROUP == 0) blacklisted = False if blacklist: for start in blacklist: - if serialnumber.startswith(start) : blacklisted = True + if serialnumber.startswith(start): + blacklisted = True return (genmatch and xmatch and hybmatch and epsmatch and dcbmatch and mpptmatch) and not blacklisted plugin_instance = solis_plugin( - plugin_name = 'Solis', - plugin_manufacturer = 'Ginlog Solis', - SENSOR_TYPES = SENSOR_TYPES, - NUMBER_TYPES = NUMBER_TYPES, - BUTTON_TYPES = BUTTON_TYPES, - SELECT_TYPES = SELECT_TYPES, - block_size = 40, - order16 = Endian.BIG, - order32 = Endian.BIG, - auto_block_ignore_readerror = True - ) + plugin_name="Solis", + plugin_manufacturer="Ginlog Solis", + SENSOR_TYPES=SENSOR_TYPES, + NUMBER_TYPES=NUMBER_TYPES, + BUTTON_TYPES=BUTTON_TYPES, + SELECT_TYPES=SELECT_TYPES, + SWITCH_TYPES=[], + block_size=40, + order16=Endian.BIG, + order32=Endian.BIG, + auto_block_ignore_readerror=True, +) diff --git a/custom_components/solax_modbus/plugin_solis_fb00.py b/custom_components/solax_modbus/plugin_solis_fb00.py new file mode 100644 index 00000000..c55d4f5e --- /dev/null +++ b/custom_components/solax_modbus/plugin_solis_fb00.py @@ -0,0 +1,4451 @@ +import logging +from dataclasses import dataclass + +# from homeassistant.components.number import NumberEntityDescription +# from homeassistant.components.select import SelectEntityDescription +# from homeassistant.components.button import ButtonEntityDescription +# from homeassistant.components.switch import SwitchEntityDescription +from pymodbus.payload import BinaryPayloadBuilder, BinaryPayloadDecoder, Endian +from .const import * + +_LOGGER = logging.getLogger(__name__) + +""" ============================================================================================ +bitmasks definitions to characterize inverters, ogranized by group +these bitmasks are used in entitydeclarations to determine to which inverters the entity applies +within a group, the bits in an entitydeclaration will be interpreted as OR +between groups, an AND condition is applied, so all gruoups must match. +An empty group (group without active flags) evaluates to True. +example: GEN3 | GEN4 | X1 | X3 | EPS +means: any inverter of tyoe (GEN3 or GEN4) and (X1 or X3) and (EPS) +An entity can be declared multiple times (with different bitmasks) if the parameters are different for each inverter type +""" + +GEN = 0x0001 # base generation for MIC, PV, AC +GEN2 = 0x0002 +GEN3 = 0x0004 +GEN4 = 0x0008 +ALL_GEN_GROUP = GEN2 | GEN3 | GEN4 | GEN + +X1 = 0x0100 +X3 = 0x0200 +ALL_X_GROUP = X1 | X3 + +PV = 0x0400 # Needs further work on PV Only Inverters +AC = 0x0800 +HYBRID = 0x1000 +MIC = 0x2000 +ALL_TYPE_GROUP = PV | AC | HYBRID | MIC + +EPS = 0x8000 +ALL_EPS_GROUP = EPS + +DCB = 0x10000 # dry contact box - gen4 +ALL_DCB_GROUP = DCB + +MPPT3 = 0x40000 +MPPT4 = 0x80000 +MPPT6 = 0x100000 +MPPT8 = 0x200000 +MPPT10 = 0x400000 +ALL_MPPT_GROUP = MPPT3 | MPPT4 | MPPT6 | MPPT8 | MPPT10 + +ALLDEFAULT = 0 # should be equivalent to HYBRID | AC | GEN2 | GEN3 | GEN4 | X1 | X3 + +# ======================= end of bitmask handling code ============================================= + +# ====================== find inverter type and details =========================================== + + +async def async_read_serialnr(hub, address, swapbytes): + res = None + try: + inverter_data = await hub.async_read_input_registers(unit=hub._modbus_addr, address=address, count=8) + if not inverter_data.isError(): + decoder = BinaryPayloadDecoder.fromRegisters(inverter_data.registers, byteorder=Endian.BIG) + res = decoder.decode_string(14).decode("ascii") + if swapbytes: + ba = bytearray(res, "ascii") # convert to bytearray for swapping + ba[0::2], ba[1::2] = ba[1::2], ba[0::2] # swap bytes ourselves - due to bug in Endian.LITTLE ? + res = str(ba, "ascii") # convert back to string + hub.seriesnumber = res + except Exception as ex: + _LOGGER.warning(f"{hub.name}: attempt to read serialnumber failed at 0x{address:x}", exc_info=True) + if not res: + _LOGGER.warning( + f"{hub.name}: reading serial number from address 0x{address:x} failed; other address may succeed" + ) + _LOGGER.info(f"Read {hub.name} 0x{address:x} serial number: {res}, swapped: {swapbytes}") + return res + + +# ================================================================================================= + + +@dataclass +class SolisModbusButtonEntityDescription(BaseModbusButtonEntityDescription): + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + + +@dataclass +class SolisModbusNumberEntityDescription(BaseModbusNumberEntityDescription): + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + + +@dataclass +class SolisModbusSelectEntityDescription(BaseModbusSelectEntityDescription): + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + + +@dataclass +class SolisModbusSwitchEntityDescription(BaseModbusSwitchEntityDescription): + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + + +@dataclass +class SolisModbusSensorEntityDescription(BaseModbusSensorEntityDescription): + """A class that describes Solis Modbus sensor entities.""" + + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + order16: int = Endian.BIG + order32: int = Endian.BIG + unit: int = REGISTER_U16 + register_type: int = REG_HOLDING + + +# ====================================== Computed value functions ================================================= + + +# ============================================= Charging =========================================================== +# This value function converts the bits to the number +def value_function_timing_on_off(bit: int, state: int, descr: str, datadict: dict): + value = datadict.get(descr, 0) + _LOGGER.debug(f">>> Old value of {descr}: {value}") + new_value = (value & ~(1 << bit)) | (state << bit) + return new_value + + +def value_function_timingmode_charge_1(initval, descr, datadict): + return [ + ( + "timed_charge_start_hours", + datadict.get("timed_charge_start_hours", 0), + ), + ( + "timed_charge_start_minutes", + datadict.get("timed_charge_start_minutes", 0), + ), + ( + "timed_charge_end_hours", + datadict.get("timed_charge_end_hours", 0), + ), + ( + "timed_charge_end_minutes", + datadict.get("timed_charge_end_minutes", 0), + ), + ] + + +def value_function_timingmode_charge_2(initval, descr, datadict): + return [ + ( + "timed_charge_start_hours_2", + datadict.get("timed_charge_start_hours_2", 0), + ), + ( + "timed_charge_start_minutes_2", + datadict.get("timed_charge_start_minutes_2", 0), + ), + ( + "timed_charge_end_hours_2", + datadict.get("timed_charge_end_hours_2", 0), + ), + ( + "timed_charge_end_minutes_2", + datadict.get("timed_charge_end_minutes_2", 0), + ), + ] + + +def value_function_timingmode_charge_3(initval, descr, datadict): + return [ + ( + "timed_charge_start_hours_3", + datadict.get("timed_charge_start_hours_3", 0), + ), + ( + "timed_charge_start_minutes_3", + datadict.get("timed_charge_start_minutes_3", 0), + ), + ( + "timed_charge_end_hours_3", + datadict.get("timed_charge_end_hours_3", 0), + ), + ( + "timed_charge_end_minutes_3", + datadict.get("timed_charge_end_minutes_3", 0), + ), + ] + + +def value_function_timingmode_charge_4(initval, descr, datadict): + return [ + ( + "timed_charge_start_hours_4", + datadict.get("timed_charge_start_hours_4", 0), + ), + ( + "timed_charge_start_minutes_4", + datadict.get("timed_charge_start_minutes_4", 0), + ), + ( + "timed_charge_end_hours_4", + datadict.get("timed_charge_end_hours_4", 0), + ), + ( + "timed_charge_end_minutes_4", + datadict.get("timed_charge_end_minutes_4", 0), + ), + ] + + +def value_function_timingmode_charge_5(initval, descr, datadict): + return [ + ( + "timed_charge_start_hours_5", + datadict.get("timed_charge_start_hours_5", 0), + ), + ( + "timed_charge_start_minutes_5", + datadict.get("timed_charge_start_minutes_5", 0), + ), + ( + "timed_charge_end_hours_5", + datadict.get("timed_charge_end_hours_5", 0), + ), + ( + "timed_charge_end_minutes_5", + datadict.get("timed_charge_end_minutes_5", 0), + ), + ] + + +def value_function_timingmode_charge_6(initval, descr, datadict): + return [ + ( + "timed_charge_start_hours_6", + datadict.get("timed_charge_start_hours_6", 0), + ), + ( + "timed_charge_start_minutes_6", + datadict.get("timed_charge_start_minutes_6", 0), + ), + ( + "timed_charge_end_hours_6", + datadict.get("timed_charge_end_hours_6", 0), + ), + ( + "timed_charge_end_minutes_6", + datadict.get("timed_charge_end_minutes_6", 0), + ), + ] + + +# ============================================ Discharging ========================================================= + + +def value_function_timingmode_discharge_1(initval, descr, datadict): + return [ + ( + "timed_discharge_start_hours", + datadict.get("timed_discharge_start_hours", 0), + ), + ( + "timed_discharge_start_minutes", + datadict.get("timed_discharge_start_minutes", 0), + ), + ( + "timed_discharge_end_hours", + datadict.get("timed_discharge_end_hours", 0), + ), + ( + "timed_discharge_end_minutes", + datadict.get("timed_discharge_end_minutes", 0), + ), + ] + + +def value_function_timingmode_discharge_2(initval, descr, datadict): + return [ + ( + "timed_discharge_start_hours_2", + datadict.get("timed_discharge_start_hours_2", 0), + ), + ( + "timed_discharge_start_minutes_2", + datadict.get("timed_discharge_start_minutes_2", 0), + ), + ( + "timed_discharge_end_hours_2", + datadict.get("timed_discharge_end_hours_2", 0), + ), + ( + "timed_discharge_end_minutes_2", + datadict.get("timed_discharge_end_minutes_2", 0), + ), + ] + + +def value_function_timingmode_discharge_3(initval, descr, datadict): + return [ + ( + "timed_discharge_start_hours_3", + datadict.get("timed_discharge_start_hours_3", 0), + ), + ( + "timed_discharge_start_minutes_3", + datadict.get("timed_discharge_start_minutes_3", 0), + ), + ( + "timed_discharge_end_hours_3", + datadict.get("timed_discharge_end_hours_3", 0), + ), + ( + "timed_discharge_end_minutes_3", + datadict.get("timed_discharge_end_minutes_3", 0), + ), + ] + + +def value_function_timingmode_discharge_4(initval, descr, datadict): + return [ + ( + "timed_discharge_start_hours_4", + datadict.get("timed_discharge_start_hours_4", 0), + ), + ( + "timed_discharge_start_minutes_4", + datadict.get("timed_discharge_start_minutes_4", 0), + ), + ( + "timed_discharge_end_hours_4", + datadict.get("timed_discharge_end_hours_4", 0), + ), + ( + "timed_discharge_end_minutes_4", + datadict.get("timed_discharge_end_minutes_4", 0), + ), + ] + + +def value_function_timingmode_discharge_5(initval, descr, datadict): + return [ + ( + "timed_discharge_start_hours_5", + datadict.get("timed_discharge_start_hours_5", 0), + ), + ( + "timed_discharge_start_minutes_5", + datadict.get("timed_discharge_start_minutes_5", 0), + ), + ( + "timed_discharge_end_hours_5", + datadict.get("timed_discharge_end_hours_5", 0), + ), + ( + "timed_discharge_end_minutes_5", + datadict.get("timed_discharge_end_minutes_5", 0), + ), + ] + + +def value_function_timingmode_discharge_6(initval, descr, datadict): + return [ + ( + "timed_discharge_start_hours_6", + datadict.get("timed_discharge_start_hours_6", 0), + ), + ( + "timed_discharge_start_minutes_6", + datadict.get("timed_discharge_start_minutes_6", 0), + ), + ( + "timed_discharge_end_hours_6", + datadict.get("timed_discharge_end_hours_6", 0), + ), + ( + "timed_discharge_end_minutes_6", + datadict.get("timed_discharge_end_minutes_6", 0), + ), + ] + + +def value_function_pv1_power(initval, descr, datadict): + return datadict.get("pv_voltage_1", 0) * datadict.get("pv_current_1", 0) + + +def value_function_pv2_power(initval, descr, datadict): + return datadict.get("pv_voltage_2", 0) * datadict.get("pv_current_2", 0) + + +def value_function_pv3_power(initval, descr, datadict): + return datadict.get("pv_voltage_3", 0) * datadict.get("pv_current_3", 0) + + +def value_function_pv4_power(initval, descr, datadict): + return datadict.get("pv_voltage_4", 0) * datadict.get("pv_current_4", 0) + + +# ================================= Button Declarations ============================================================ + +BUTTON_TYPES = [ + SolisModbusButtonEntityDescription( + name="Sync RTC", + key="sync_rtc", + register=43000, + allowedtypes=HYBRID, + write_method=WRITE_MULTI_MODBUS, + icon="mdi:home-clock", + value_function=value_function_sync_rtc_ymd, + ), + SolisModbusButtonEntityDescription( + name="Update Charge Times", + key="update_charge_times", + register=43711, + allowedtypes=HYBRID, + write_method=WRITE_MULTI_MODBUS, + icon="mdi:battery-clock", + value_function=value_function_timingmode_charge_1, + ), + SolisModbusButtonEntityDescription( + name="Update Charge Times 2", + key="update_charge_times_2", + register=43718, + allowedtypes=HYBRID, + write_method=WRITE_MULTI_MODBUS, + icon="mdi:battery-clock", + value_function=value_function_timingmode_charge_2, + ), + SolisModbusButtonEntityDescription( + name="Update Charge Times 3", + key="update_charge_times_3", + register=43725, + allowedtypes=HYBRID, + write_method=WRITE_MULTI_MODBUS, + icon="mdi:battery-clock", + value_function=value_function_timingmode_charge_3, + ), + SolisModbusButtonEntityDescription( + name="Update Charge Times 4", + key="update_charge_times_4", + register=43732, + allowedtypes=HYBRID, + write_method=WRITE_MULTI_MODBUS, + icon="mdi:battery-clock", + value_function=value_function_timingmode_charge_4, + ), + SolisModbusButtonEntityDescription( + name="Update Charge Times 5", + key="update_charge_times_5", + register=43739, + allowedtypes=HYBRID, + write_method=WRITE_MULTI_MODBUS, + icon="mdi:battery-clock", + value_function=value_function_timingmode_charge_5, + ), + SolisModbusButtonEntityDescription( + name="Update Charge Times 6", + key="update_charge_times_6", + register=43736, + allowedtypes=HYBRID, + write_method=WRITE_MULTI_MODBUS, + icon="mdi:battery-clock", + value_function=value_function_timingmode_charge_6, + ), + SolisModbusButtonEntityDescription( + name="Update Discharge Times", + key="update_discharge_times", + register=43753, + allowedtypes=HYBRID, + write_method=WRITE_MULTI_MODBUS, + icon="mdi:battery-clock", + value_function=value_function_timingmode_discharge_1, + ), + SolisModbusButtonEntityDescription( + name="Update Discharge Times 2", + key="update_discharge_times_2", + register=43760, + allowedtypes=HYBRID, + write_method=WRITE_MULTI_MODBUS, + icon="mdi:battery-clock", + value_function=value_function_timingmode_discharge_2, + ), + SolisModbusButtonEntityDescription( + name="Update Discharge Times 3", + key="update_discharge_times_3", + register=43767, + allowedtypes=HYBRID, + write_method=WRITE_MULTI_MODBUS, + icon="mdi:battery-clock", + value_function=value_function_timingmode_discharge_3, + ), + SolisModbusButtonEntityDescription( + name="Update Discharge Times 4", + key="update_discharge_times_4", + register=43774, + allowedtypes=HYBRID, + write_method=WRITE_MULTI_MODBUS, + icon="mdi:battery-clock", + value_function=value_function_timingmode_discharge_4, + ), + SolisModbusButtonEntityDescription( + name="Update Discharge Times 5", + key="update_discharge_times_5", + register=43781, + allowedtypes=HYBRID, + write_method=WRITE_MULTI_MODBUS, + icon="mdi:battery-clock", + value_function=value_function_timingmode_discharge_5, + ), + SolisModbusButtonEntityDescription( + name="Update Discharge Times 6", + key="update_discharge_times_6", + register=43787, + allowedtypes=HYBRID, + write_method=WRITE_MULTI_MODBUS, + icon="mdi:battery-clock", + value_function=value_function_timingmode_discharge_6, + ), +] + +# ================================= Number Declarations ============================================================ + +MAX_CURRENTS = [ + ("0602", 62.5), # 3kW 48v + ("0102", 62.5), # 3kW 48v AC Only? + ("110F", 62.5), # 3.6kW 48v + ("160F3", 100), # 5kW 48v + ("160F4", 60), # 3.6kW 48v + ("160F5", 62.5), # 3.6kW 48v + ("1031", 100), # 5kW 48v + ("134F", 100), # 5kW 48v + ("6031", 100), # 6kW 48v + ("110C", 25), # 10kW HV +] + +NUMBER_TYPES = [ + ### + # + # Data only number types + # + ### + SolisModbusNumberEntityDescription( + name="Sync RTC Offset", + key="sync_rtc_offset", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=-3600, + native_max_value=3600, + native_step=1, + native_unit_of_measurement=UnitOfTime.SECONDS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:home-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge Start Hours", + key="timed_charge_start_hours", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge Start Minutes", + key="timed_charge_start_minutes", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge End Hours", + key="timed_charge_end_hours", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge End Minutes", + key="timed_charge_end_minutes", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Start Hours", + key="timed_discharge_start_hours", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Start Minutes", + key="timed_discharge_start_minutes", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge End Hours", + key="timed_discharge_end_hours", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge End Minutes", + key="timed_discharge_end_minutes", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + ### TimeSlot2 + SolisModbusNumberEntityDescription( + name="Timed Charge Start Hours 2", + key="timed_charge_start_hours_2", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge Start Minutes 2", + key="timed_charge_start_minutes_2", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge End Hours 2", + key="timed_charge_end_hours_2", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge End Minutes 2", + key="timed_charge_end_minutes_2", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Start Hours 2", + key="timed_discharge_start_hours_2", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Start Minutes 2", + key="timed_discharge_start_minutes_2", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge End Hours 2", + key="timed_discharge_end_hours_2", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge End Minutes 2", + key="timed_discharge_end_minutes_2", + fmt="i", + unit=REGISTER_U16, + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + ###TimeSlot3 + SolisModbusNumberEntityDescription( + name="Timed Charge Start Hours 3", + key="timed_charge_start_hours_3", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge Start Minutes 3", + key="timed_charge_start_minutes_3", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge End Hours 3", + key="timed_charge_end_hours_3", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge End Minutes 3", + key="timed_charge_end_minutes_3", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Start Hours 3", + key="timed_discharge_start_hours_3", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Start Minutes 3", + key="timed_discharge_start_minutes_3", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge End Hours 3", + key="timed_discharge_end_hours_3", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge End Minutes 3", + key="timed_discharge_end_minutes_3", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + ### TimeSlot4 + SolisModbusNumberEntityDescription( + name="Timed Charge Start Hours 4", + key="timed_charge_start_hours_4", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge Start Minutes 4", + key="timed_charge_start_minutes_4", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge End Hours 4", + key="timed_charge_end_hours_4", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge End Minutes 4", + key="timed_charge_end_minutes_4", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Start Hours 4", + key="timed_discharge_start_hours_4", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Start Minutes 4", + key="timed_discharge_start_minutes_4", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge End Hours 4", + key="timed_discharge_end_hours_4", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge End Minutes 4", + key="timed_discharge_end_minutes_4", + fmt="i", + unit=REGISTER_U16, + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + ### TimeSlot5 + SolisModbusNumberEntityDescription( + name="Timed Charge Start Hours 5", + key="timed_charge_start_hours_5", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge Start Minutes 5", + key="timed_charge_start_minutes_5", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge End Hours 5", + key="timed_charge_end_hours_5", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge End Minutes 5", + key="timed_charge_end_minutes_5", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Start Hours 5", + key="timed_discharge_start_hours_5", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Start Minutes 5", + key="timed_discharge_start_minutes_5", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge End Hours 5", + key="timed_discharge_end_hours_5", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge End Minutes 5", + key="timed_discharge_end_minutes_5", + fmt="i", + unit=REGISTER_U16, + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + ### TimeSlot6 + SolisModbusNumberEntityDescription( + name="Timed Charge Start Hours 6", + key="timed_charge_start_hours_6", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge Start Minutes 6", + key="timed_charge_start_minutes_6", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge End Hours 6", + key="timed_charge_end_hours_6", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge End Minutes 6", + key="timed_charge_end_minutes_6", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Start Hours 6", + key="timed_discharge_start_hours_6", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Start Minutes 6", + key="timed_discharge_start_minutes_6", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge End Hours 6", + key="timed_discharge_end_hours_6", + unit=REGISTER_U16, + fmt="i", + initvalue=0, + native_min_value=0, + native_max_value=23, + native_step=1, + native_unit_of_measurement=UnitOfTime.HOURS, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge End Minutes 6", + key="timed_discharge_end_minutes_6", + fmt="i", + unit=REGISTER_U16, + initvalue=0, + native_min_value=0, + native_max_value=59, + native_step=1, + native_unit_of_measurement=UnitOfTime.MINUTES, + allowedtypes=HYBRID, + write_method=WRITE_DATA_LOCAL, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + prevent_update=True, + ), + ### + # + # Normal number types + # + ### + SolisModbusNumberEntityDescription( + name="Battery Minimum SOC", + key="battery_minimum_soc", + register=43011, + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=HYBRID, + icon="mdi:battery-sync", + ), + SolisModbusNumberEntityDescription( + name="Force Charge SOC", + key="force_charge_soc", + register=43018, + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=HYBRID, + icon="mdi:battery-sync", + ), + SolisModbusNumberEntityDescription( + name="Backup Mode SOC", + key="backup_mode_soc", + register=43024, + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + native_unit_of_measurement=PERCENTAGE, + allowedtypes=HYBRID, + icon="mdi:battery-sync", + ), + SolisModbusNumberEntityDescription( + name="Backflow Power", + key="backflow_power", + register=43074, + fmt="i", + native_min_value=0, + native_max_value=9900, + native_step=100, + scale=100, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=NumberDeviceClass.POWER, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Battery ChargeDischarge Current", + key="battery_chargedischarge_current", + register=43116, + fmt="f", + native_min_value=0, + native_max_value=20, + native_step=1, + scale=0.1, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=NumberDeviceClass.CURRENT, + allowedtypes=HYBRID, + max_exceptions=MAX_CURRENTS, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Battery Charge Current", + key="battery_charge_current", + register=43117, + fmt="f", + native_min_value=0, + native_max_value=20, + native_step=1, + scale=0.1, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=NumberDeviceClass.CURRENT, + allowedtypes=HYBRID, + max_exceptions=MAX_CURRENTS, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Battery Discharge Current", + key="battery_discharge_current", + register=43118, + fmt="f", + native_min_value=0, + native_max_value=20, + native_step=1, + scale=0.1, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=NumberDeviceClass.CURRENT, + allowedtypes=HYBRID, + max_exceptions=MAX_CURRENTS, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge Discharge On Off", + key="timed_charge_discharge_on_off", + register=43707, + icon="mdi:switch", + fmt="i", + native_min_value=0, + native_max_value=4096, + native_step=1, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + # ============================ TimeSlot 1 ============================== + SolisModbusNumberEntityDescription( + name="Timed Charge SOC", + key="timed_charge_soc", + register=43708, + native_unit_of_measurement=PERCENTAGE, + device_class=NumberDeviceClass.BATTERY, + icon="mdi:battery-sync", + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge Volt", + key="timed_charge_volt", + register=43710, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=NumberDeviceClass.VOLTAGE, + fmt="f", + scale=0.1, + native_step=0.1, + native_min_value=49, + native_max_value=54, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge Current", + key="timed_charge_current", + register=43709, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + device_class=NumberDeviceClass.CURRENT, + fmt="f", + scale=0.1, + native_step=1, + native_min_value=0, + native_max_value=20, + max_exceptions=MAX_CURRENTS, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge SOC", + key="timed_discharge_soc", + register=43750, + native_unit_of_measurement=PERCENTAGE, + device_class=NumberDeviceClass.BATTERY, + icon="mdi:battery-sync", + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Volt", + key="timed_discharge_volt", + register=43752, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=NumberDeviceClass.VOLTAGE, + fmt="f", + scale=0.1, + native_step=0.1, + native_min_value=49, + native_max_value=54, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Current", + key="timed_discharge_current", + register=43751, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + device_class=NumberDeviceClass.CURRENT, + fmt="f", + scale=0.1, + native_step=1, + native_min_value=0, + native_max_value=20, + max_exceptions=MAX_CURRENTS, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + # ============================ TimeSlot 2 ============================== + SolisModbusNumberEntityDescription( + name="Timed Charge Soc 2", + key="timed_charge_soc_2", + register=43715, + native_unit_of_measurement=PERCENTAGE, + device_class=NumberDeviceClass.BATTERY, + icon="mdi:battery-sync", + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge Volt 2", + key="timed_charge_volt_2", + register=43717, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=NumberDeviceClass.VOLTAGE, + fmt="f", + scale=0.1, + native_step=0.1, + native_min_value=49, + native_max_value=54, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge Current 2", + key="timed_charge_current_2", + register=43716, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + device_class=NumberDeviceClass.CURRENT, + fmt="f", + scale=0.1, + native_step=1, + native_min_value=0, + native_max_value=20, + max_exceptions=MAX_CURRENTS, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Soc 2", + key="timed_discharge_soc_2", + register=43757, + native_unit_of_measurement=PERCENTAGE, + device_class=NumberDeviceClass.BATTERY, + icon="mdi:battery-sync", + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Volt 2", + key="timed_discharge_volt_2", + register=43759, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=NumberDeviceClass.VOLTAGE, + fmt="f", + scale=0.1, + native_step=0.1, + native_min_value=49, + native_max_value=54, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Current 2", + key="timed_discharge_current_2", + register=43758, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + device_class=NumberDeviceClass.CURRENT, + fmt="f", + scale=0.1, + native_step=1, + native_min_value=0, + native_max_value=20, + max_exceptions=MAX_CURRENTS, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + # ============================ TimeSlot 3 ============================== + SolisModbusNumberEntityDescription( + name="Timed Charge Soc 3", + key="timed_charge_soc_3", + register=43722, + native_unit_of_measurement=PERCENTAGE, + device_class=NumberDeviceClass.BATTERY, + icon="mdi:battery-sync", + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge Volt 3", + key="timed_charge_volt_3", + register=43724, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=NumberDeviceClass.VOLTAGE, + fmt="f", + scale=0.1, + native_step=0.1, + native_min_value=49, + native_max_value=54, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge Current 3", + key="timed_charge_current_3", + register=43723, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + device_class=NumberDeviceClass.CURRENT, + fmt="f", + scale=0.1, + native_step=1, + native_min_value=0, + native_max_value=20, + max_exceptions=MAX_CURRENTS, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Soc 3", + key="timed_discharge_soc_3", + register=43764, + native_unit_of_measurement=PERCENTAGE, + device_class=NumberDeviceClass.BATTERY, + icon="mdi:battery-sync", + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Volt 3", + key="timed_discharge_volt_3", + register=43766, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=NumberDeviceClass.VOLTAGE, + fmt="f", + scale=0.1, + native_step=0.1, + native_min_value=49, + native_max_value=54, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Current 3", + key="timed_discharge_current_3", + register=43765, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + device_class=NumberDeviceClass.CURRENT, + fmt="f", + scale=0.1, + native_step=1, + native_min_value=0, + native_max_value=20, + max_exceptions=MAX_CURRENTS, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + # ============================ TimeSlot 4 ============================== + SolisModbusNumberEntityDescription( + name="Timed Charge Soc 4", + key="timed_charge_soc_4", + register=43729, + native_unit_of_measurement=PERCENTAGE, + device_class=NumberDeviceClass.BATTERY, + icon="mdi:battery-sync", + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge Volt 4", + key="timed_charge_volt_4", + register=43731, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=NumberDeviceClass.VOLTAGE, + fmt="f", + scale=0.1, + native_step=0.1, + native_min_value=49, + native_max_value=54, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge Current 4", + key="timed_charge_current_4", + register=43730, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + device_class=NumberDeviceClass.CURRENT, + fmt="f", + scale=0.1, + native_step=1, + native_min_value=0, + native_max_value=20, + max_exceptions=MAX_CURRENTS, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Soc 4", + key="timed_discharge_soc_4", + register=43771, + native_unit_of_measurement=PERCENTAGE, + device_class=NumberDeviceClass.BATTERY, + icon="mdi:battery-sync", + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Volt 4", + key="timed_discharge_volt_4", + register=43773, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=NumberDeviceClass.VOLTAGE, + fmt="f", + scale=0.1, + native_step=0.1, + native_min_value=49, + native_max_value=54, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Current 4", + key="timed_discharge_current_4", + register=43772, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + device_class=NumberDeviceClass.CURRENT, + fmt="f", + scale=0.1, + native_step=1, + native_min_value=0, + native_max_value=20, + max_exceptions=MAX_CURRENTS, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + # ============================ TimeSlot 5 ============================== + SolisModbusNumberEntityDescription( + name="Timed Charge Soc 5", + key="timed_charge_soc_5", + register=43736, + native_unit_of_measurement=PERCENTAGE, + device_class=NumberDeviceClass.BATTERY, + icon="mdi:battery-sync", + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge Volt 5", + key="timed_charge_volt_5", + register=43738, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=NumberDeviceClass.VOLTAGE, + fmt="f", + scale=0.1, + native_step=0.1, + native_min_value=49, + native_max_value=54, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge Current 5", + key="timed_charge_current_5", + register=43737, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + device_class=NumberDeviceClass.CURRENT, + fmt="f", + scale=0.1, + native_step=1, + native_min_value=0, + native_max_value=20, + max_exceptions=MAX_CURRENTS, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Soc 5", + key="timed_discharge_soc_5", + register=43778, + native_unit_of_measurement=PERCENTAGE, + device_class=NumberDeviceClass.BATTERY, + icon="mdi:battery-sync", + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Volt 5", + key="timed_discharge_volt_5", + register=43780, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=NumberDeviceClass.VOLTAGE, + fmt="f", + scale=0.1, + native_step=0.1, + native_min_value=49, + native_max_value=54, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Current 5", + key="timed_discharge_current_5", + register=43779, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + device_class=NumberDeviceClass.CURRENT, + fmt="f", + scale=0.1, + native_step=1, + native_min_value=0, + native_max_value=20, + max_exceptions=MAX_CURRENTS, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + # ============================ TimeSlot 6 ============================== + SolisModbusNumberEntityDescription( + name="Timed Charge Soc 6", + key="timed_charge_soc_6", + register=43743, + native_unit_of_measurement=PERCENTAGE, + device_class=NumberDeviceClass.BATTERY, + icon="mdi:battery-sync", + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge Volt 6", + key="timed_charge_volt_6", + register=43745, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=NumberDeviceClass.VOLTAGE, + fmt="f", + scale=0.1, + native_step=0.1, + native_min_value=49, + native_max_value=54, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Charge Current 6", + key="timed_charge_current_6", + register=43744, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + device_class=NumberDeviceClass.CURRENT, + fmt="f", + scale=0.1, + native_step=1, + native_min_value=0, + native_max_value=20, + max_exceptions=MAX_CURRENTS, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Soc 6", + key="timed_discharge_soc_6", + register=43785, + native_unit_of_measurement=PERCENTAGE, + device_class=NumberDeviceClass.BATTERY, + icon="mdi:battery-sync", + fmt="i", + native_min_value=10, + native_max_value=100, + native_step=1, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Volt 6", + key="timed_discharge_volt_6", + register=43787, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=NumberDeviceClass.VOLTAGE, + fmt="f", + scale=0.1, + native_step=0.1, + native_min_value=49, + native_max_value=54, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusNumberEntityDescription( + name="Timed Discharge Current 6", + key="timed_discharge_current_6", + register=43786, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + device_class=NumberDeviceClass.CURRENT, + fmt="f", + scale=0.1, + native_step=1, + native_min_value=0, + native_max_value=20, + max_exceptions=MAX_CURRENTS, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), +] + +# ================================= Select Declarations ============================================================ +SWITCH_TYPES = [ + SolisModbusSwitchEntityDescription( + name="Timed Charge Slot 1 Enable", + key="timed_charge_slot_1_enable", + register=43707, + icon="mdi:switch", + register_bit=0, + sensor_key="timed_charge_discharge_on_off", + value_function=value_function_timing_on_off, + ), + SolisModbusSwitchEntityDescription( + name="Timed Charge Slot 2 Enable", + key="timed_charge_slot_2_enable", + register=43707, + icon="mdi:switch", + register_bit=1, + sensor_key="timed_charge_discharge_on_off", + value_function=value_function_timing_on_off, + ), + SolisModbusSwitchEntityDescription( + name="Timed Charge Slot 3 Enable", + key="timed_charge_slot_3_enable", + register=43707, + icon="mdi:switch", + register_bit=2, + sensor_key="timed_charge_discharge_on_off", + value_function=value_function_timing_on_off, + ), + SolisModbusSwitchEntityDescription( + name="Timed Charge Slot 4 Enable", + key="timed_charge_slot_4_enable", + register=43707, + icon="mdi:switch", + register_bit=3, + sensor_key="timed_charge_discharge_on_off", + value_function=value_function_timing_on_off, + ), + SolisModbusSwitchEntityDescription( + name="Timed Charge Slot 5 Enable", + key="timed_charge_slot_5_enable", + register=43707, + icon="mdi:switch", + register_bit=4, + sensor_key="timed_charge_discharge_on_off", + value_function=value_function_timing_on_off, + ), + SolisModbusSwitchEntityDescription( + name="Timed Charge Slot 6 Enable", + key="timed_charge_slot_6_enable", + register=43707, + icon="mdi:switch", + register_bit=5, + sensor_key="timed_charge_discharge_on_off", + value_function=value_function_timing_on_off, + ), + SolisModbusSwitchEntityDescription( + name="Timed Discharge Slot 1 Enable", + key="timed_discharge_slot_1_enable", + register=43707, + icon="mdi:switch", + register_bit=6, + sensor_key="timed_charge_discharge_on_off", + value_function=value_function_timing_on_off, + ), + SolisModbusSwitchEntityDescription( + name="Timed Discharge Slot 2 Enable", + key="timed_discharge_slot_2_enable", + register=43707, + icon="mdi:switch", + register_bit=7, + sensor_key="timed_charge_discharge_on_off", + value_function=value_function_timing_on_off, + ), + SolisModbusSwitchEntityDescription( + name="Timed Discharge Slot 3 Enable", + key="timed_discharge_slot_3_enable", + register=43707, + icon="mdi:switch", + register_bit=8, + sensor_key="timed_charge_discharge_on_off", + value_function=value_function_timing_on_off, + ), + SolisModbusSwitchEntityDescription( + name="Timed Discharge Slot 4 Enable", + key="timed_discharge_slot_4_enable", + register=43707, + icon="mdi:switch", + register_bit=9, + sensor_key="timed_charge_discharge_on_off", + value_function=value_function_timing_on_off, + ), + SolisModbusSwitchEntityDescription( + name="Timed Discharge Slot 5 Enable", + key="timed_discharge_slot_5_enable", + register=43707, + icon="mdi:switch", + register_bit=10, + sensor_key="timed_charge_discharge_on_off", + value_function=value_function_timing_on_off, + ), + SolisModbusSwitchEntityDescription( + name="Timed Discharge Slot 6 Enable", + key="timed_discharge_slot_6_enable", + register=43707, + icon="mdi:switch", + register_bit=11, + sensor_key="timed_charge_discharge_on_off", + value_function=value_function_timing_on_off, + ), +] + +SELECT_TYPES = [ + SolisModbusSelectEntityDescription( + name="Backflow Power Switch", + key="backflow_power_switch", + register=43073, + option_dict={ + 0: "Off", + 16: "On", + }, + allowedtypes=HYBRID | X1, + icon="mdi:dip-switch", + ), + SolisModbusSelectEntityDescription( + name="Backflow Power Switch", + key="backflow_power_switch", + register=43073, + option_dict={ + 0: "Off & Balanced output", + 16: "On & Balanced output", + 64: "Off & Unbalanced output", + 80: "On & Unbalanced output", + }, + allowedtypes=HYBRID | X3, + icon="mdi:dip-switch", + ), + SolisModbusSelectEntityDescription( + name="Energy Storage Control Switch", + key="energy_storage_control_switch", + register=43110, + option_dict={ + 1: "Self-Use - No Grid Charging", + 5: "Off-Grid Mode", + 9: "Battery Awaken - No Grid Charging", + 33: "Self-Use", + 41: "Battery Awaken", + 49: "Backup/Reserve", + 64: "Feed-in priority", + }, + allowedtypes=HYBRID, + icon="mdi:dip-switch", + ), + SolisModbusSelectEntityDescription( + name="Power Switch", + key="power_switch", + register=43007, + option_dict={ + 190: "On", + 222: "Off", + }, + allowedtypes=HYBRID, + icon="mdi:dip-switch", + ), +] + +# ================================= Sensor Declarations ============================================================ + + +SENSOR_TYPES: list[SolisModbusSensorEntityDescription] = [ + # SolisModbusSensorEntityDescription( + # name = "Serial Number", + # key = "serialnumber", + # register = 33004, + # ignore_readerror = True, + # register_type = REG_INPUT, + # unit = REGISTER_STR, + # wordcount=8, + # entity_registry_enabled_default = False, + # sleepmode = SLEEPMODE_LASTAWAKE, + # allowedtypes = HYBRID, + # entity_category = EntityCategory.DIAGNOSTIC, + # icon = "mdi:information", + # ), + SolisModbusSensorEntityDescription( + name="RTC", + key="rtc", + register=33022, + ignore_readerror=True, + register_type=REG_INPUT, + unit=REGISTER_WORDS, + wordcount=6, + scale=value_function_rtc_ymd, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:clock", + ), + SolisModbusSensorEntityDescription( + name="Power Generation Total", + key="power_generation_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33029, + register_type=REG_INPUT, + unit=REGISTER_U32, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Power Generation This Month", + key="power_generation_this_month", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33031, + register_type=REG_INPUT, + unit=REGISTER_U32, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Power Generation Last Month", + key="power_generation_last_month", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33033, + register_type=REG_INPUT, + unit=REGISTER_U32, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Power Generation Today", + key="power_generation_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33035, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Power Generation Yesterday", + key="power_generation_yesterday", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33036, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Power Generation This Year", + key="power_generation_this_year", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33037, + register_type=REG_INPUT, + unit=REGISTER_U32, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Power Generation Last Year", + key="power_generation_last_year", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33039, + register_type=REG_INPUT, + unit=REGISTER_U32, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="PV Voltage 1", + key="pv_voltage_1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=33049, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="PV Current 1", + key="pv_current_1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=33050, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + icon="mdi:current-dc", + ), + SolisModbusSensorEntityDescription( + name="PV Power 1", + key="pv_power_1", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + value_function=value_function_pv1_power, + allowedtypes=HYBRID, + icon="mdi:solar-power-variant", + ), + SolisModbusSensorEntityDescription( + name="PV Voltage 2", + key="pv_voltage_2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=33051, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="PV Current 2", + key="pv_current_2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=33052, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + icon="mdi:current-dc", + ), + SolisModbusSensorEntityDescription( + name="PV Power 2", + key="pv_power_2", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + value_function=value_function_pv2_power, + allowedtypes=HYBRID, + icon="mdi:solar-power-variant", + ), + SolisModbusSensorEntityDescription( + name="PV Voltage 3", + key="pv_voltage_3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=33053, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | MPPT4 | MPPT3, + ), + SolisModbusSensorEntityDescription( + name="PV Current 3", + key="pv_current_3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=33054, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | MPPT4 | MPPT3, + icon="mdi:current-dc", + ), + SolisModbusSensorEntityDescription( + name="PV Power 3", + key="pv_power_3", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + value_function=value_function_pv3_power, + allowedtypes=HYBRID | MPPT4 | MPPT3, + icon="mdi:solar-power-variant", + ), + SolisModbusSensorEntityDescription( + name="PV Voltage 4", + key="pv_voltage_4", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=33055, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | MPPT4, + ), + SolisModbusSensorEntityDescription( + name="PV Current 4", + key="pv_current_4", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=33056, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | MPPT4, + icon="mdi:current-dc", + ), + SolisModbusSensorEntityDescription( + name="PV Power 4", + key="pv_power_4", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + value_function=value_function_pv4_power, + allowedtypes=HYBRID | MPPT4, + icon="mdi:solar-power-variant", + ), + SolisModbusSensorEntityDescription( + name="PV Total Power", + key="pv_total_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=33057, + register_type=REG_INPUT, + unit=REGISTER_U32, + allowedtypes=HYBRID, + icon="mdi:solar-power-variant", + ), + SolisModbusSensorEntityDescription( + name="Inverter Voltage", + key="inverter_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=33073, + scale=0.1, + register_type=REG_INPUT, + rounding=1, + allowedtypes=HYBRID | X1, + ), + SolisModbusSensorEntityDescription( + name="Inverter Voltage L1", + key="grid_voltage_l1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=33073, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Inverter Voltage L2", + key="grid_voltage_l2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=33074, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Inverter Voltage L3", + key="grid_voltage_l3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=33075, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Inverter Current", + key="inverter_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=33076, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X1, + ), + SolisModbusSensorEntityDescription( + name="Inverter Current L1", + key="grid_current_l1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=33076, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Inverter Current L2", + key="grid_current_l2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=33077, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Inverter Current L3", + key="grid_current_l3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=33078, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Active Power", + key="active_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=33079, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Reactive Power", + key="reactive_power", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=33081, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Apparent Power", + key="apparent_power", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=33083, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Inverter Temperature", + key="inverter_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=33093, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolisModbusSensorEntityDescription( + name="Inverter Frequency", + key="inverter_frequency", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + device_class=SensorDeviceClass.FREQUENCY, + state_class=SensorStateClass.MEASUREMENT, + register=33094, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Inverter Status", + key="inverter_status", + register=33095, + register_type=REG_INPUT, + scale={ + 0: "Waiting", + 1: "Open Operating", + 2: "Soft Run", + 3: "Generating", + 4: "Bypass Inverter Running", + 5: "Bypass Inverter Sync", + 6: "Bypass Grid Running", + 15: "Normal Running", + 4100: "Grid Off", + 61456: "Grid Surge", + 61457: "Fan Fault", + 4112: "Grid Overvoltage", + 4113: "Grid Undervoltage", + 4114: "Grid Overfrequency", + 4115: "Grid Underfrequency", + 4116: "Grid Reverse Current", + 4117: "No-Grid", + 4118: "Grid Unbalanced", + 4119: "Grid Frequency Fluctuation", + 4120: "Grid Overcurrent", + 4121: "Grid Current Sampling Error", + 4128: "DC Overvoltage", + 4129: "DC Bus Overvoltage", + 4130: "DC Bus Unbalanced", + 4131: "DC Bus Undervoltage", + 4132: "DC Bus Unbalanced 2", + 4133: "DC(Channel A) Overcurrent", + 4134: "DC(Channel B) Overcurrent", + 4135: "DC Interference", + 4136: "DC Reverse", + 4137: "PV Midpoint Grounding", + 4144: "Grid Interference Protection", + 4145: "DSP Inital Protection", + 4146: "Over Temperature Protection", + 4147: "PV Insulation Fault", + 4148: "Leakage Current Protection", + 4149: "Relay Check Protection", + 4150: "DSP_B Protection", + 4151: "DC Injection Protection", + 4152: "12V Undervoltage Faulty", + 4153: "Leakage Current Check Protection", + 4154: "Under Temperature Protection", + 4160: "AFCI Check Fault", + 4161: "AFCI Fault", + 4162: "DSP Chip SRAM Fault", + 4163: "DSP Chip FLASH Fault", + 4164: "DSP Chip PC Pointer Fault", + 4165: "DSP Chip Register Fault", + 4166: "Grid Interference Protection 02", + 4167: "Grid Current Sampling Error", + 4168: "IGBT Overcurrent", + 4176: "Grid Transient Overcurrent", + 4177: "Battery Hardware Overvoltage fault", + 4178: "LLC Hardware Overcurrent", + 4179: "Battery Overvoltage", + 4180: "Battery Undervoltage", + 4181: "Battery Not Connected", + 4182: "Backup Overvoltage", + 4183: "Backup Overload", + 4184: "DSP Selfcheck Error", + 8208: "Fail Safe", + 8209: "Meter COM Fail", + 8210: "Battery COM Fail", + 8212: "DSP COM Fail", + 8213: "BMS Alarm", + 8214: "BatName-FAIL", + 8215: "BMS Alarm 2", + 8216: "DRM Connect Fail", + 8217: "Meter Select Fail", + 8224: "Lead-acid Battery High Temp", + 8225: "Lead-acid Battery Low Temp", + }, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Meter Total ActivePower", + key="meter_total_activepower", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + register=33126, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.01, + rounding=2, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Meter Voltage", + key="meter_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=33128, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Meter Current", + key="meter_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=33129, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Meter Active Power", + key="meter_active_power", + state_class=SensorStateClass.MEASUREMENT, + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + register=33130, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Energy Storage Control Switch", + key="energy_storage_control_switch", + register=33132, + register_type=REG_INPUT, + scale={ + 3: "Self-Use - No Grid Charging", + 33: "Self-Use", + 37: "Off-Grid Mode", + 41: "Battery Awaken", + 51: "Backup/Reserve", + 98: "Feed-in priority", + }, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Battery Voltage", + key="battery_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=33133, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Battery Current", + key="battery_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=33134, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Battery Charge Direction", + key="battery_charge_direction", + register=33135, + register_type=REG_INPUT, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Battery SOC", + key="battery_soc", + native_unit_of_measurement=PERCENTAGE, + device_class=SensorDeviceClass.BATTERY, + state_class=SensorStateClass.MEASUREMENT, + register=33139, + register_type=REG_INPUT, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Battery SOH", + key="battery_soh", + native_unit_of_measurement=PERCENTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=33140, + register_type=REG_INPUT, + allowedtypes=HYBRID, + icon="mdi:battery-heart", + entity_category=EntityCategory.DIAGNOSTIC, + ), + SolisModbusSensorEntityDescription( + name="BMS Battery Voltage", + key="bms_battery_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, + register=33141, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="BMS Battery Current", + key="bms_battery_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=33142, + register_type=REG_INPUT, + unit=REGISTER_S16, + scale=0.1, + rounding=2, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="BMS Battery Charge Limit", + key="bms_battery_charge_limit", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=33143, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="BMS Battery Discharge Limit", + key="bms_battery_discharge_limit", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=33144, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="House Load", + key="house_load", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=33147, + register_type=REG_INPUT, + allowedtypes=HYBRID, + icon="mdi:home", + ), + SolisModbusSensorEntityDescription( + name="Bypass Load", + key="bypass_load", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=33148, + register_type=REG_INPUT, + allowedtypes=HYBRID, + icon="mdi:home", + ), + SolisModbusSensorEntityDescription( + name="Battery Power", + key="battery_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=33149, + register_type=REG_INPUT, + unit=REGISTER_S32, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:home", + ), + SolisModbusSensorEntityDescription( + name="Battery Input Energy", + key="battery_input_energy", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + value_function=value_function_battery_input_solis, + allowedtypes=HYBRID, + icon="mdi:battery-arrow-up", + ), + SolisModbusSensorEntityDescription( + name="Battery Output Energy", + key="battery_output_energy", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + value_function=value_function_battery_output_solis, + allowedtypes=HYBRID, + icon="mdi:battery-arrow-down", + ), + SolisModbusSensorEntityDescription( + name="Total Battery Charge", + key="total_battery_charge", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + register=33161, + register_type=REG_INPUT, + unit=REGISTER_U32, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Battery Charge Today", + key="battery_charge_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33163, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Battery Charge Yesterday", + key="battery_charge_yesterday", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + register=33164, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Total Battery Discharge", + key="total_battery_discharge", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + register=33165, + register_type=REG_INPUT, + unit=REGISTER_U32, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Battery Discharge Today", + key="battery_discharge_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33167, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Battery Discharge Yesterday", + key="battery_discharge_yesterday", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + register=33168, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Grid Import Total", + key="grid_import_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33169, + register_type=REG_INPUT, + unit=REGISTER_U32, + entity_registry_enabled_default=False, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + icon="mdi:home-import-outline", + ), + SolisModbusSensorEntityDescription( + name="Grid Import Today", + key="grid_import_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33171, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + icon="mdi:home-import-outline", + ), + SolisModbusSensorEntityDescription( + name="Grid Import Yesterday", + key="grid_import_yesterday", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33172, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + icon="mdi:home-import-outline", + ), + SolisModbusSensorEntityDescription( + name="Grid Export Total", + key="grid_export_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33173, + register_type=REG_INPUT, + unit=REGISTER_U32, + entity_registry_enabled_default=False, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + icon="mdi:home-export-outline", + ), + SolisModbusSensorEntityDescription( + name="Grid Export Today", + key="grid_export_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33175, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + icon="mdi:home-export-outline", + ), + SolisModbusSensorEntityDescription( + name="Grid Export Yesterday", + key="grid_export_yesterday", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33176, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + icon="mdi:home-export-outline", + ), + SolisModbusSensorEntityDescription( + name="House Load Total", + key="house_load_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33177, + register_type=REG_INPUT, + unit=REGISTER_U32, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + icon="mdi:home", + ), + SolisModbusSensorEntityDescription( + name="House Load Today", + key="house_load_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33179, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + icon="mdi:home", + ), + SolisModbusSensorEntityDescription( + name="House Load Yesterday", + key="house_load_yesterday", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33180, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + icon="mdi:home", + ), + SolisModbusSensorEntityDescription( + name="Battery Charge Current Limit", + key="battery_charge_current_limit", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=33206, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X1, + ), + SolisModbusSensorEntityDescription( + name="Battery Discharge Current Limit", + key="battery_discharge_current_limit", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=33207, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X1, + ), + SolisModbusSensorEntityDescription( + name="Meter AC Voltage", + key="meter_ac_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=33251, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X1, + ), + SolisModbusSensorEntityDescription( + name="Meter AC Current", + key="meter_ac_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=33252, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X1, + ), + SolisModbusSensorEntityDescription( + name="Meter AC Voltage L1", + key="meter_ac_voltage_l1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=33251, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter AC Current L1", + key="meter_ac_current_l1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=33252, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter AC Voltage L2", + key="meter_ac_voltage_l2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=33253, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter AC Current L2", + key="meter_ac_current_l2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=33254, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter AC Voltage L3", + key="meter_ac_voltage_l3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=33255, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter AC Current L3", + key="meter_ac_current_l3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=33256, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter Active Power L1", + key="meter_active_power_l1", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=33257, + register_type=REG_INPUT, + unit=REGISTER_S32, + scale=0.001, + rounding=3, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter Active Power L2", + key="meter_active_power_l2", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=33259, + register_type=REG_INPUT, + unit=REGISTER_S32, + scale=0.001, + rounding=3, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter Active Power L3", + key="meter_active_power_l3", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=33261, + register_type=REG_INPUT, + unit=REGISTER_S32, + scale=0.001, + rounding=3, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter Active Power Total", + key="meter_active_power_total", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=33263, + register_type=REG_INPUT, + unit=REGISTER_S32, + scale=0.001, + rounding=3, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Meter Reactive Power", + key="meter_reactive_power", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=33265, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID | X1, + ), + SolisModbusSensorEntityDescription( + name="Meter Reactive Power L1", + key="meter_reactive_power_l1", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=33265, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter Reactive Power L2", + key="meter_reactive_power_l2", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=33267, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter Reactive Power L3", + key="meter_reactive_power_l3", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=33269, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter Reactive Power Total", + key="meter_reactive_power_total", + native_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE, + device_class=SensorDeviceClass.REACTIVE_POWER, + register=33271, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Meter Apparent Power", + key="meter_apparent_power", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=33273, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID | X1, + ), + SolisModbusSensorEntityDescription( + name="Meter Apparent Power L1", + key="meter_apparent_power_l1", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=33273, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter Apparent Power L2", + key="meter_apparent_power_L2", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=33275, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter Apparent Power L3", + key="meter_apparent_power_l3", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=33277, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Meter Apparent Power Total", + key="meter_apparent_power_total", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, + register=33279, + register_type=REG_INPUT, + unit=REGISTER_S32, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Meter Power Factor", + key="meter_power_factor", + native_unit_of_measurement=None, + device_class=SensorDeviceClass.POWER_FACTOR, + state_class=SensorStateClass.MEASUREMENT, + register=33281, + register_type=REG_INPUT, + unit=REGISTER_S16, + allowedtypes=HYBRID, + scale=0.01, + rounding=2, + ), + SolisModbusSensorEntityDescription( + name="Meter Grid Frequency", + key="meter_grid_frequency", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + device_class=SensorDeviceClass.FREQUENCY, + register=33282, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Meter Grid Import Total", + key="meter_grid_import_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33283, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.01, + rounding=2, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + icon="mdi:home-import-outline", + ), + SolisModbusSensorEntityDescription( + name="Meter Grid Export Total", + key="meter_grid_export_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=33285, + register_type=REG_INPUT, + unit=REGISTER_U32, + scale=0.01, + rounding=2, + sleepmode=SLEEPMODE_LASTAWAKE, + allowedtypes=HYBRID, + icon="mdi:home-export-outline", + ), + SolisModbusSensorEntityDescription( + name="Power Switch", + key="power_switch", + register=43007, + scale={ + 190: "On", + 222: "Off", + }, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + ), + SolisModbusSensorEntityDescription( + name="Battery Minimum SOC", + key="battery_minimum_soc", + register=43011, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-sync", + ), + SolisModbusSensorEntityDescription( + name="Force Charge SOC", + key="force_charge_soc", + register=43018, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-sync", + ), + SolisModbusSensorEntityDescription( + name="Backup Mode SOC", + key="backup_mode_soc", + register=43024, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:battery-sync", + ), + SolisModbusSensorEntityDescription( + name="Backflow Power Switch", + key="backflow_power_switch", + register=43073, + scale={ + 0: "Off", + 16: "On", + }, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | X1, + ), + SolisModbusSensorEntityDescription( + name="Backflow Power Switch", + key="backflow_power_switch", + register=43073, + scale={ + 0: "Off & Balanced output", + 16: "On & Balanced output", + 64: "Off & Unbalanced output", + 80: "On & Unbalanced output", + }, + entity_registry_enabled_default=False, + allowedtypes=HYBRID | X3, + ), + SolisModbusSensorEntityDescription( + name="Backflow Power", + key="backflow_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=43074, + scale=100, + rounding=0, + allowedtypes=HYBRID, + entity_registry_enabled_default=False, + ), + SolisModbusSensorEntityDescription( + name="Battery ChargeDischarge Current", + key="battery_chargedischarge_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=43116, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + entity_registry_enabled_default=False, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Battery Charge Current", + key="battery_charge_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=43117, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + entity_registry_enabled_default=False, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Battery Discharge Current", + key="battery_discharge_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, + register=43118, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + # ============================ TimeSlot 1 ============================== + SolisModbusSensorEntityDescription( + name="Timed Charge Start Hours", + key="timed_charge_start_hours", + register=43711, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Start Minutes", + key="timed_charge_start_minutes", + register=43712, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge End Hours", + key="timed_charge_end_hours", + register=43713, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge End Minutes", + key="timed_charge_end_minutes", + register=43714, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Discharge On Off", + key="timed_charge_discharge_on_off", + register=43707, + icon="mdi:switch", + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Charge SOC", + key="timed_charge_soc", + register=43708, + native_unit_of_measurement=PERCENTAGE, + icon="mdi:battery-sync", + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Volt", + key="timed_charge_volt", + register=43710, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Current", + key="timed_charge_current", + register=43709, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Start Hours", + key="timed_discharge_start_hours", + register=43753, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Start Minutes", + key="timed_discharge_start_minutes", + register=43754, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge End Hours", + key="timed_discharge_end_hours", + register=43755, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge End Minutes", + key="timed_discharge_end_minutes", + register=43756, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge SOC", + key="timed_discharge_soc", + register=43750, + native_unit_of_measurement=PERCENTAGE, + icon="mdi:battery-sync", + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Volt", + key="timed_discharge_volt", + register=43752, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Current", + key="timed_discharge_current", + register=43751, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + # ============================ TimeSlot 2 ============================== + SolisModbusSensorEntityDescription( + name="Timed Charge Start Hours 2", + key="timed_charge_start_hours_2", + register=43718, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Start Minutes 2", + key="timed_charge_start_minutes_2", + register=43719, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge End Hours 2", + key="timed_charge_end_hours_2", + register=43720, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge End Minutes 2", + key="timed_charge_end_minutes_2", + register=43721, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Soc 2", + key="timed_charge_soc_2", + register=43715, + native_unit_of_measurement=PERCENTAGE, + icon="mdi:battery-sync", + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Volt 2", + key="timed_charge_volt_2", + register=43717, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Current 2", + key="timed_charge_current_2", + register=43716, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Start Hours 2", + key="timed_discharge_start_hours_2", + register=43760, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Start Minutes 2", + key="timed_discharge_start_minutes_2", + register=43761, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge End Hours 2", + key="timed_discharge_end_hours_2", + register=43762, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge End Minutes 2", + key="timed_discharge_end_minutes_2", + register=43763, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Soc 2", + key="timed_discharge_soc_2", + register=43757, + native_unit_of_measurement=PERCENTAGE, + icon="mdi:battery-sync", + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Volt 2", + key="timed_discharge_volt_2", + register=43759, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Current 2", + key="timed_discharge_current_2", + register=43758, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + # ============================ TimeSlot 3 ============================== + SolisModbusSensorEntityDescription( + name="Timed Charge Start Hours 3", + key="timed_charge_start_hours_3", + register=43725, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Start Minutes 3", + key="timed_charge_start_minutes_3", + register=43726, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge End Hours 3", + key="timed_charge_end_hours_3", + register=43727, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge End Minutes 3", + key="timed_charge_end_minutes_3", + register=43728, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Soc 3", + key="timed_charge_soc_3", + register=43722, + native_unit_of_measurement=PERCENTAGE, + icon="mdi:battery-sync", + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Volt 3", + key="timed_charge_volt_3", + register=43724, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Current 3", + key="timed_charge_current_3", + register=43723, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Start Hours 3", + key="timed_discharge_start_hours_3", + register=43767, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Start Minutes 3", + key="timed_discharge_start_minutes_3", + register=43768, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge End Hours 3", + key="timed_discharge_end_hours_3", + register=43769, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge End Minutes 3", + key="timed_discharge_end_minutes_3", + register=43770, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Soc 3", + key="timed_discharge_soc_3", + register=43764, + native_unit_of_measurement=PERCENTAGE, + icon="mdi:battery-sync", + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Volt 3", + key="timed_discharge_volt_3", + register=43766, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Current 3", + key="timed_discharge_current_3", + register=43765, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + # ============================ TimeSlot 4 ============================== + SolisModbusSensorEntityDescription( + name="Timed Charge Start Hours 4", + key="timed_charge_start_hours_4", + register=43732, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Start Minutes 4", + key="timed_charge_start_minutes_4", + register=43733, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge End Hours 4", + key="timed_charge_end_hours_4", + register=43734, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge End Minutes 4", + key="timed_charge_end_minutes_4", + register=43735, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Soc 4", + key="timed_charge_soc_4", + register=43729, + native_unit_of_measurement=PERCENTAGE, + icon="mdi:battery-sync", + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Volt 4", + key="timed_charge_volt_4", + register=43731, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Current 4", + key="timed_charge_current_4", + register=43730, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Start Hours 4", + key="timed_discharge_start_hours_4", + register=43774, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Start Minutes 4", + key="timed_discharge_start_minutes_4", + register=43775, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge End Hours 4", + key="timed_discharge_end_hours_4", + register=43776, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge End Minutes 4", + key="timed_discharge_end_minutes_4", + register=43777, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Soc 4", + key="timed_discharge_soc_4", + register=43771, + native_unit_of_measurement=PERCENTAGE, + icon="mdi:battery-sync", + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Volt 4", + key="timed_discharge_volt_4", + register=43773, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Current 4", + key="timed_discharge_current_4", + register=43772, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + # ============================ TimeSlot 5 ============================== + SolisModbusSensorEntityDescription( + name="Timed Charge Start Hours 5", + key="timed_charge_start_hours_5", + register=43739, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Start Minutes 5", + key="timed_charge_start_minutes_5", + register=43740, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge End Hours 5", + key="timed_charge_end_hours_5", + register=43741, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge End Minutes 5", + key="timed_charge_end_minutes_5", + register=43742, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Soc 5", + key="timed_charge_soc_5", + register=43736, + native_unit_of_measurement=PERCENTAGE, + icon="mdi:battery-sync", + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Volt 5", + key="timed_charge_volt_5", + register=43738, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Current 5", + key="timed_charge_current_5", + register=43737, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Start Hours 5", + key="timed_discharge_start_hours_5", + register=43781, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Start Minutes 5", + key="timed_discharge_start_minutes_5", + register=43782, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge End Hours 5", + key="timed_discharge_end_hours_5", + register=43783, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge End Minutes 5", + key="timed_discharge_end_minutes_5", + register=43784, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Soc 5", + key="timed_discharge_soc_5", + register=43778, + native_unit_of_measurement=PERCENTAGE, + icon="mdi:battery-sync", + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Volt 5", + key="timed_discharge_volt_5", + register=43780, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Current 5", + key="timed_discharge_current_5", + register=43779, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + # ============================ TimeSlot 6 ============================== + SolisModbusSensorEntityDescription( + name="Timed Charge Start Hours 6", + key="timed_charge_start_hours_6", + register=43746, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Start Minutes 6", + key="timed_charge_start_minutes_6", + register=43747, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge End Hours 6", + key="timed_charge_end_hours_6", + register=43748, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge End Minutes 6", + key="timed_charge_end_minutes_6", + register=43749, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Soc 6", + key="timed_charge_soc_6", + register=43743, + native_unit_of_measurement=PERCENTAGE, + icon="mdi:battery-sync", + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Volt 6", + key="timed_charge_volt_6", + register=43745, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Charge Current 6", + key="timed_charge_current_6", + register=43744, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Start Hours 6", + key="timed_discharge_start_hours_6", + register=43788, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Start Minutes 6", + key="timed_discharge_start_minutes_6", + register=43789, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge End Hours 6", + key="timed_discharge_end_hours_6", + register=43790, + native_unit_of_measurement=UnitOfTime.HOURS, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge End Minutes 6", + key="timed_discharge_end_minutes_6", + register=43791, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + icon="mdi:battery-clock", + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Soc 6", + key="timed_discharge_soc_6", + register=43785, + native_unit_of_measurement=PERCENTAGE, + icon="mdi:battery-sync", + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Volt 6", + key="timed_discharge_volt_6", + register=43787, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), + SolisModbusSensorEntityDescription( + name="Timed Discharge Current 6", + key="timed_discharge_current_6", + register=43786, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + icon="mdi:dc-current", + scale=0.1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + entity_category=EntityCategory.CONFIG, + ), +] + + +# ============================ plugin declaration ================================================= +@dataclass +class solis_fb00_plugin(plugin_base): + + async def async_determineInverterType(self, hub, configdict): + _LOGGER.info(f"{hub.name}: trying to determine inverter type") + seriesnumber = await async_read_serialnr(hub, 33004, swapbytes=False) + if not seriesnumber: + _LOGGER.error(f"{hub.name}: cannot find serial number, even not for other Inverter") + seriesnumber = "unknown" + + # derive invertertype from seriiesnumber + if seriesnumber.startswith("1801"): + invertertype = HYBRID | X1 # PV Only S6-GR1P 1-3K + elif seriesnumber.startswith("1802"): + invertertype = HYBRID | X1 # PV Only S6-GR1P 2.5-6K + elif seriesnumber.startswith("0602"): + invertertype = HYBRID | X1 # Hybrid Gen5 3kW - 48v + elif seriesnumber.startswith("0102"): + invertertype = HYBRID | X1 # AC? Gen5 3kW - 48v + elif seriesnumber.startswith("010F"): + invertertype = HYBRID | X1 # Hybrid Gen5 3kW - 48v + elif seriesnumber.startswith("110F"): + invertertype = HYBRID | X1 # Hybrid Gen5 5kW - 48v + elif seriesnumber.startswith("114F"): + invertertype = HYBRID | X1 # Hybrid Gen5 6K - 48V + elif seriesnumber.startswith("134F"): + invertertype = HYBRID | X1 # Hybrid Gen5 5kW - 48V + elif seriesnumber.startswith("140C"): + invertertype = HYBRID | X1 # Hybrid Gen5 5kW - HV + elif seriesnumber.startswith("143"): + invertertype = HYBRID | X1 # Hybrid Gen5 5kW - 48V + elif seriesnumber.startswith("160F3"): + invertertype = HYBRID | X1 # Hybrid Gen5 5kW - 48v + elif seriesnumber.startswith("160F4"): + invertertype = HYBRID | X1 # Hybrid Gen5 3.6kW - 48v + elif seriesnumber.startswith("160F5"): + invertertype = HYBRID | X1 # Hybrid Gen5 3.6kW - 48v + elif seriesnumber.startswith("103305"): + invertertype = HYBRID | X3 | MPPT4 # Hybrid Gen6 8kW - HV + elif seriesnumber.startswith("103306"): + invertertype = HYBRID | X3 | MPPT4 # Hybrid Gen6 10kW - HV + elif seriesnumber.startswith("110C"): + invertertype = HYBRID | X3 # Hybrid Gen5 0CA2 / 0C92 10kW - HV + elif seriesnumber.startswith("114C"): + invertertype = HYBRID | X3 # Hybrid Gen5 10kW - HV + elif seriesnumber.startswith("1805"): + invertertype = HYBRID | X3 # PV Only Gen5 5-20kW + elif seriesnumber.startswith("6031"): + invertertype = HYBRID | X1 # Hybrid Gen5 3105 / 3122 Model 6kW - 48V + elif seriesnumber.startswith("1031"): + invertertype = HYBRID | X1 # Hybrid Gen5 3104 Model 5kW - 48V + # elif seriesnumber.startswith('abc123'): invertertype = PV | X3 # Comment + + else: + invertertype = 0 + _LOGGER.error(f"unrecognized {hub.name} inverter type - serial number : {seriesnumber}") + + if invertertype > 0: + read_eps = configdict.get(CONF_READ_EPS, DEFAULT_READ_EPS) + read_dcb = configdict.get(CONF_READ_DCB, DEFAULT_READ_DCB) + if read_eps: + invertertype = invertertype | EPS + if read_dcb: + invertertype = invertertype | DCB + + return invertertype + + def matchInverterWithMask(self, inverterspec, entitymask, serialnumber="not relevant", blacklist=None): + # returns true if the entity needs to be created for an inverter + genmatch = ((inverterspec & entitymask & ALL_GEN_GROUP) != 0) or (entitymask & ALL_GEN_GROUP == 0) + xmatch = ((inverterspec & entitymask & ALL_X_GROUP) != 0) or (entitymask & ALL_X_GROUP == 0) + hybmatch = ((inverterspec & entitymask & ALL_TYPE_GROUP) != 0) or (entitymask & ALL_TYPE_GROUP == 0) + epsmatch = ((inverterspec & entitymask & ALL_EPS_GROUP) != 0) or (entitymask & ALL_EPS_GROUP == 0) + dcbmatch = ((inverterspec & entitymask & ALL_DCB_GROUP) != 0) or (entitymask & ALL_DCB_GROUP == 0) + mpptmatch = ((inverterspec & entitymask & ALL_MPPT_GROUP) != 0) or (entitymask & ALL_MPPT_GROUP == 0) + blacklisted = False + if blacklist: + for start in blacklist: + if serialnumber.startswith(start): + blacklisted = True + return (genmatch and xmatch and hybmatch and epsmatch and dcbmatch and mpptmatch) and not blacklisted + + +plugin_instance = solis_fb00_plugin( + plugin_name="Solis FB00", + plugin_manufacturer="Ginlog Solis", + SENSOR_TYPES=SENSOR_TYPES, + NUMBER_TYPES=NUMBER_TYPES, + BUTTON_TYPES=BUTTON_TYPES, + SELECT_TYPES=SELECT_TYPES, + SWITCH_TYPES=SWITCH_TYPES, + block_size=40, + order16=Endian.BIG, + order32=Endian.BIG, + auto_block_ignore_readerror=True, +) diff --git a/custom_components/solax_modbus/plugin_solis_old.py b/custom_components/solax_modbus/plugin_solis_old.py index bdd99837..035ff85b 100644 --- a/custom_components/solax_modbus/plugin_solis_old.py +++ b/custom_components/solax_modbus/plugin_solis_old.py @@ -19,36 +19,37 @@ An entity can be declared multiple times (with different bitmasks) if the parameters are different for each inverter type """ -GEN = 0x0001 # base generation for MIC, PV, AC -GEN2 = 0x0002 -GEN3 = 0x0004 -GEN4 = 0x0008 -ALL_GEN_GROUP = GEN2 | GEN3 | GEN4 | GEN - -X1 = 0x0100 -X3 = 0x0200 -ALL_X_GROUP = X1 | X3 - -PV = 0x0400 # Needs further work on PV Only Inverters -AC = 0x0800 -HYBRID = 0x1000 -MIC = 0x2000 +GEN = 0x0001 # base generation for MIC, PV, AC +GEN2 = 0x0002 +GEN3 = 0x0004 +GEN4 = 0x0008 +ALL_GEN_GROUP = GEN2 | GEN3 | GEN4 | GEN + +X1 = 0x0100 +X3 = 0x0200 +ALL_X_GROUP = X1 | X3 + +PV = 0x0400 # Needs further work on PV Only Inverters +AC = 0x0800 +HYBRID = 0x1000 +MIC = 0x2000 ALL_TYPE_GROUP = PV | AC | HYBRID | MIC -EPS = 0x8000 -ALL_EPS_GROUP = EPS +EPS = 0x8000 +ALL_EPS_GROUP = EPS -DCB = 0x10000 # dry contact box - gen4 -ALL_DCB_GROUP = DCB +DCB = 0x10000 # dry contact box - gen4 +ALL_DCB_GROUP = DCB -MPPT3 = 0x40000 -MPPT4 = 0x80000 -MPPT6 = 0x100000 -MPPT8 = 0x200000 -MPPT10 = 0x400000 +MPPT3 = 0x40000 +MPPT4 = 0x80000 +MPPT6 = 0x100000 +MPPT8 = 0x200000 +MPPT10 = 0x400000 ALL_MPPT_GROUP = MPPT3 | MPPT4 | MPPT6 | MPPT8 | MPPT10 -ALLDEFAULT = 0 # should be equivalent to HYBRID | AC | GEN2 | GEN3 | GEN4 | X1 | X3 +ALLDEFAULT = 0 # should be equivalent to HYBRID | AC | GEN2 | GEN3 | GEN4 | X1 | X3 + async def async_read_serialnr(hub, address): res = None @@ -59,31 +60,43 @@ async def async_read_serialnr(hub, address): decoder = BinaryPayloadDecoder.fromRegisters(inverter_data.registers, byteorder=Endian.BIG) res = decoder.decode_string(8).decode("ascii") hub.seriesnumber = res - except Exception as ex: _LOGGER.warning(f"{hub.name}: attempt to read serialnumber failed at 0x{address:x} data: {inverter_data}", exc_info=True) - if not res: _LOGGER.warning(f"{hub.name}: reading serial number from address 0x{address:x} failed; other address may succeed") + except Exception as ex: + _LOGGER.warning( + f"{hub.name}: attempt to read serialnumber failed at 0x{address:x} data: {inverter_data}", exc_info=True + ) + if not res: + _LOGGER.warning( + f"{hub.name}: reading serial number from address 0x{address:x} failed; other address may succeed" + ) _LOGGER.info(f"Read {hub.name} 0x{address:x} serial number before potential swap: {res}") return res + @dataclass class SolisModbusButtonEntityDescription(BaseModbusButtonEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class SolisModbusNumberEntityDescription(BaseModbusNumberEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class SolisModbusSelectEntityDescription(BaseModbusSelectEntityDescription): - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + @dataclass class SolisModbusSensorEntityDescription(BaseModbusSensorEntityDescription): """A class that describes Solis Old Modbus sensor entities.""" - allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice - #order16: int = Endian.BIG - #order32: int = Endian.BIG + + allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice + # order16: int = Endian.BIG + # order32: int = Endian.BIG unit: int = REGISTER_U16 - register_type: int= REG_HOLDING + register_type: int = REG_HOLDING + # ================================= Button Declarations ============================================================ @@ -92,343 +105,351 @@ class SolisModbusSensorEntityDescription(BaseModbusSensorEntityDescription): SELECT_TYPES = [] SENSOR_TYPES: list[SolisModbusSensorEntityDescription] = [ SolisModbusSensorEntityDescription( - name = "ActivePower", - key = "activepower", - native_unit_of_measurement = UnitOfPower.KILO_WATT, - device_class = SensorDeviceClass.POWER, - register = 3005, - register_type = REG_INPUT, - unit = REGISTER_U32, - allowedtypes = HYBRID, + name="ActivePower", + key="activepower", + native_unit_of_measurement=UnitOfPower.KILO_WATT, + device_class=SensorDeviceClass.POWER, + register=3005, + register_type=REG_INPUT, + unit=REGISTER_U32, + allowedtypes=HYBRID, ), SolisModbusSensorEntityDescription( - name = "PV Total Power", - key = "pv_total_power", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 3007, - register_type = REG_INPUT, - unit = REGISTER_U32, - allowedtypes = HYBRID, - icon = "mdi:solar-power-variant", + name="PV Total Power", + key="pv_total_power", + native_unit_of_measurement=UnitOfPower.WATT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, + register=3007, + register_type=REG_INPUT, + unit=REGISTER_U32, + allowedtypes=HYBRID, + icon="mdi:solar-power-variant", ), SolisModbusSensorEntityDescription( - name = "Power Generation Total", - key = "power_generation_total", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - icon = "mdi:solar-power", - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 3009, - register_type = REG_INPUT, - unit = REGISTER_U32, - allowedtypes = HYBRID, + name="Power Generation Total", + key="power_generation_total", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=3009, + register_type=REG_INPUT, + unit=REGISTER_U32, + allowedtypes=HYBRID, ), SolisModbusSensorEntityDescription( - name = "Power Generation This Month", - key = "power_generation_this_month", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - icon = "mdi:solar-power", - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 3011, - register_type = REG_INPUT, - unit = REGISTER_U32, - allowedtypes = HYBRID, + name="Power Generation This Month", + key="power_generation_this_month", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=3011, + register_type=REG_INPUT, + unit=REGISTER_U32, + allowedtypes=HYBRID, ), SolisModbusSensorEntityDescription( - name = "Power Generation Last Month", - key = "power_generation_last_month", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - icon = "mdi:solar-power", - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 3013, - register_type = REG_INPUT, - unit = REGISTER_U32, - allowedtypes = HYBRID, + name="Power Generation Last Month", + key="power_generation_last_month", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=3013, + register_type=REG_INPUT, + unit=REGISTER_U32, + allowedtypes=HYBRID, ), SolisModbusSensorEntityDescription( - name = "Power Generation Today", - key = "power_generation_today", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - icon = "mdi:solar-power", - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 3015, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, + name="Power Generation Today", + key="power_generation_today", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=3015, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, ), SolisModbusSensorEntityDescription( - name = "Power Generation Yesterday", - key = "power_generation_yesterday", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - icon = "mdi:solar-power", - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 3016, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, + name="Power Generation Yesterday", + key="power_generation_yesterday", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=3016, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, ), SolisModbusSensorEntityDescription( - name = "Power Generation This Year", - key = "power_generation_this_year", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - icon = "mdi:solar-power", - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 3017, - register_type = REG_INPUT, - unit = REGISTER_U32, - allowedtypes = HYBRID, + name="Power Generation This Year", + key="power_generation_this_year", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=3017, + register_type=REG_INPUT, + unit=REGISTER_U32, + allowedtypes=HYBRID, ), SolisModbusSensorEntityDescription( - name = "Power Generation Last Year", - key = "power_generation_last_year", - native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, - icon = "mdi:solar-power", - device_class = SensorDeviceClass.ENERGY, - state_class = SensorStateClass.TOTAL_INCREASING, - register = 3019, - register_type = REG_INPUT, - unit = REGISTER_U32, - allowedtypes = HYBRID, + name="Power Generation Last Year", + key="power_generation_last_year", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + icon="mdi:solar-power", + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + register=3019, + register_type=REG_INPUT, + unit=REGISTER_U32, + allowedtypes=HYBRID, ), SolisModbusSensorEntityDescription( - name = "PV Voltage 1", - key = "pv_voltage_1", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 3022, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, + name="PV Voltage 1", + key="pv_voltage_1", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=3022, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, ), SolisModbusSensorEntityDescription( - name = "PV Current 1", - key = "pv_current_1", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 3023, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - icon = "mdi:current-dc", + name="PV Current 1", + key="pv_current_1", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=3023, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + icon="mdi:current-dc", ), SolisModbusSensorEntityDescription( - name = "PV Voltage 2", - key = "pv_voltage_2", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 3024, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, + name="PV Voltage 2", + key="pv_voltage_2", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=3024, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, ), SolisModbusSensorEntityDescription( - name = "PV Current 2", - key = "pv_current_2", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 3025, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - icon = "mdi:current-dc", + name="PV Current 2", + key="pv_current_2", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=3025, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + icon="mdi:current-dc", ), SolisModbusSensorEntityDescription( - name = "PV Voltage 3", - key = "pv_voltage_3", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 3026, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, + name="PV Voltage 3", + key="pv_voltage_3", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=3026, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, ), SolisModbusSensorEntityDescription( - name = "PV Current 3", - key = "pv_current_3", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 3027, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:current-dc", + name="PV Current 3", + key="pv_current_3", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=3027, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:current-dc", ), SolisModbusSensorEntityDescription( - name = "PV Voltage 4", - key = "pv_voltage_4", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 3028, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, + name="PV Voltage 4", + key="pv_voltage_4", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=3028, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, ), SolisModbusSensorEntityDescription( - name = "PV Current 4", - key = "pv_current_4", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 3029, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - entity_registry_enabled_default = False, - allowedtypes = HYBRID, - icon = "mdi:current-dc", + name="PV Current 4", + key="pv_current_4", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=3029, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + entity_registry_enabled_default=False, + allowedtypes=HYBRID, + icon="mdi:current-dc", ), SolisModbusSensorEntityDescription( - name = "Inverter Voltage", - key = "inverter_voltage", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 3034, - scale = 0.1, - register_type = REG_INPUT, - rounding = 1, - allowedtypes = HYBRID | X1, + name="Inverter Voltage", + key="inverter_voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=3034, + scale=0.1, + register_type=REG_INPUT, + rounding=1, + allowedtypes=HYBRID | X1, ), SolisModbusSensorEntityDescription( - name = "Inverter Voltage R", - key = "grid_voltage_r", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 3034, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X3, + name="Inverter Voltage R", + key="grid_voltage_r", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=3034, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, ), SolisModbusSensorEntityDescription( - name = "Inverter Voltage S", - key = "grid_voltage_s", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 3035, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X3, + name="Inverter Voltage S", + key="grid_voltage_s", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=3035, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, ), SolisModbusSensorEntityDescription( - name = "Inverter Voltage T", - key = "grid_voltage_t", - native_unit_of_measurement = UnitOfElectricPotential.VOLT, - device_class = SensorDeviceClass.VOLTAGE, - register = 3036, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X3, + name="Inverter Voltage T", + key="grid_voltage_t", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + device_class=SensorDeviceClass.VOLTAGE, + register=3036, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, ), SolisModbusSensorEntityDescription( - name = "Inverter Current", - key = "inverter_current", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 3037, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X1, + name="Inverter Current", + key="inverter_current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=3037, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X1, ), SolisModbusSensorEntityDescription( - name = "Inverter Current R", - key = "grid_current_r", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 3037, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X3, + name="Inverter Current R", + key="grid_current_r", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=3037, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, ), SolisModbusSensorEntityDescription( - name = "Inverter Current S", - key = "grid_current_s", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 3038, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X3, + name="Inverter Current S", + key="grid_current_s", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=3038, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, ), SolisModbusSensorEntityDescription( - name = "Inverter Current T", - key = "grid_current_t", - native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, - device_class = SensorDeviceClass.CURRENT, - register = 3039, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID | X3, + name="Inverter Current T", + key="grid_current_t", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + device_class=SensorDeviceClass.CURRENT, + register=3039, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID | X3, ), SolisModbusSensorEntityDescription( - name = "Inverter Temperature", - key = "inverter_temperature", - native_unit_of_measurement = UnitOfTemperature.CELSIUS, - device_class = SensorDeviceClass.TEMPERATURE, - state_class = SensorStateClass.MEASUREMENT, - register = 3042, - register_type = REG_INPUT, - scale = 0.1, - rounding = 1, - allowedtypes = HYBRID, - entity_category = EntityCategory.DIAGNOSTIC, + name="Inverter Temperature", + key="inverter_temperature", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + register=3042, + register_type=REG_INPUT, + scale=0.1, + rounding=1, + allowedtypes=HYBRID, + entity_category=EntityCategory.DIAGNOSTIC, ), SolisModbusSensorEntityDescription( - name = "Inverter Frequency", - key = "grid_frequency", - native_unit_of_measurement = UnitOfFrequency.HERTZ, - device_class = SensorDeviceClass.FREQUENCY, - register = 3043, - register_type = REG_INPUT, - scale = 0.01, - rounding = 2, - allowedtypes = HYBRID, + name="Inverter Frequency", + key="grid_frequency", + native_unit_of_measurement=UnitOfFrequency.HERTZ, + device_class=SensorDeviceClass.FREQUENCY, + register=3043, + register_type=REG_INPUT, + scale=0.01, + rounding=2, + allowedtypes=HYBRID, ), ] # ============================ plugin declaration ================================================= + @dataclass class solis_old_plugin(plugin_base): async def async_determineInverterType(self, hub, configdict): _LOGGER.info(f"{hub.name}: trying to determine inverter type") - seriesnumber = await async_read_serialnr(hub, 3061, swapbytes = False) + seriesnumber = await async_read_serialnr(hub, 3061, swapbytes=False) if not seriesnumber: _LOGGER.error(f"{hub.name}: cannot find serial number, even not for other Inverter") seriesnumber = "unknown" # derive invertertype from seriiesnumber - if seriesnumber.startswith('303105'): invertertype = HYBRID | X1 # Hybrid Gen5 3kW - elif seriesnumber.startswith('363105'): invertertype = HYBRID | X1 # Hybrid Gen5 3.6kW - elif seriesnumber.startswith('463105'): invertertype = HYBRID | X1 # Hybrid Gen5 4.6kW - elif seriesnumber.startswith('503105'): invertertype = HYBRID | X1 # Hybrid Gen5 5kW - elif seriesnumber.startswith('603105'): invertertype = HYBRID | X1 # Hybrid Gen5 6kW - elif seriesnumber.startswith('603122'): invertertype = HYBRID | X1 # Hybrid Gen5 3.6kW - elif seriesnumber.startswith('110CA22'): invertertype = HYBRID | X3 # Hybrid Gen5 10kW 3Phase + if seriesnumber.startswith("303105"): + invertertype = HYBRID | X1 # Hybrid Gen5 3kW + elif seriesnumber.startswith("363105"): + invertertype = HYBRID | X1 # Hybrid Gen5 3.6kW + elif seriesnumber.startswith("463105"): + invertertype = HYBRID | X1 # Hybrid Gen5 4.6kW + elif seriesnumber.startswith("503105"): + invertertype = HYBRID | X1 # Hybrid Gen5 5kW + elif seriesnumber.startswith("603105"): + invertertype = HYBRID | X1 # Hybrid Gen5 6kW + elif seriesnumber.startswith("603122"): + invertertype = HYBRID | X1 # Hybrid Gen5 3.6kW + elif seriesnumber.startswith("110CA22"): + invertertype = HYBRID | X3 # Hybrid Gen5 10kW 3Phase else: invertertype = 0 @@ -437,34 +458,39 @@ async def async_determineInverterType(self, hub, configdict): if invertertype > 0: read_eps = configdict.get(CONF_READ_EPS, DEFAULT_READ_EPS) read_dcb = configdict.get(CONF_READ_DCB, DEFAULT_READ_DCB) - if read_eps: invertertype = invertertype | EPS - if read_dcb: invertertype = invertertype | DCB + if read_eps: + invertertype = invertertype | EPS + if read_dcb: + invertertype = invertertype | DCB return invertertype - def matchInverterWithMask (self, inverterspec, entitymask, serialnumber = 'not relevant', blacklist = None): + def matchInverterWithMask(self, inverterspec, entitymask, serialnumber="not relevant", blacklist=None): # returns true if the entity needs to be created for an inverter - genmatch = ((inverterspec & entitymask & ALL_GEN_GROUP) != 0) or (entitymask & ALL_GEN_GROUP == 0) - xmatch = ((inverterspec & entitymask & ALL_X_GROUP) != 0) or (entitymask & ALL_X_GROUP == 0) + genmatch = ((inverterspec & entitymask & ALL_GEN_GROUP) != 0) or (entitymask & ALL_GEN_GROUP == 0) + xmatch = ((inverterspec & entitymask & ALL_X_GROUP) != 0) or (entitymask & ALL_X_GROUP == 0) hybmatch = ((inverterspec & entitymask & ALL_TYPE_GROUP) != 0) or (entitymask & ALL_TYPE_GROUP == 0) - epsmatch = ((inverterspec & entitymask & ALL_EPS_GROUP) != 0) or (entitymask & ALL_EPS_GROUP == 0) - dcbmatch = ((inverterspec & entitymask & ALL_DCB_GROUP) != 0) or (entitymask & ALL_DCB_GROUP == 0) - mpptmatch = ((inverterspec & entitymask & ALL_MPPT_GROUP) != 0) or (entitymask & ALL_MPPT_GROUP == 0) + epsmatch = ((inverterspec & entitymask & ALL_EPS_GROUP) != 0) or (entitymask & ALL_EPS_GROUP == 0) + dcbmatch = ((inverterspec & entitymask & ALL_DCB_GROUP) != 0) or (entitymask & ALL_DCB_GROUP == 0) + mpptmatch = ((inverterspec & entitymask & ALL_MPPT_GROUP) != 0) or (entitymask & ALL_MPPT_GROUP == 0) blacklisted = False if blacklist: for start in blacklist: - if serialnumber.startswith(start) : blacklisted = True + if serialnumber.startswith(start): + blacklisted = True return (genmatch and xmatch and hybmatch and epsmatch and dcbmatch and mpptmatch) and not blacklisted + plugin_instance = solis_old_plugin( - plugin_name = 'Solis Old', - plugin_manufacturer = 'Ginlog Solis', - SENSOR_TYPES = SENSOR_TYPES, - NUMBER_TYPES = NUMBER_TYPES, - BUTTON_TYPES = BUTTON_TYPES, - SELECT_TYPES = SELECT_TYPES, - block_size = 48, - order16 = Endian.BIG, - order32 = Endian.BIG, - auto_block_ignore_readerror = True - ) \ No newline at end of file + plugin_name="Solis Old", + plugin_manufacturer="Ginlog Solis", + SENSOR_TYPES=SENSOR_TYPES, + NUMBER_TYPES=NUMBER_TYPES, + BUTTON_TYPES=BUTTON_TYPES, + SELECT_TYPES=SELECT_TYPES, + SWITCH_TYPES=[], + block_size=48, + order16=Endian.BIG, + order32=Endian.BIG, + auto_block_ignore_readerror=True, +) diff --git a/custom_components/solax_modbus/switch.py b/custom_components/solax_modbus/switch.py new file mode 100644 index 00000000..d8b23f65 --- /dev/null +++ b/custom_components/solax_modbus/switch.py @@ -0,0 +1,105 @@ +from .const import DOMAIN, CONF_MODBUS_ADDR, DEFAULT_MODBUS_ADDR, DEBOUNCE_TIME +from .const import WRITE_DATA_LOCAL, WRITE_MULTISINGLE_MODBUS, WRITE_SINGLE_MODBUS +from homeassistant.components.switch import SwitchEntity +from homeassistant.const import CONF_NAME +from typing import Any, Dict, Optional +from datetime import datetime +import logging + +_LOGGER = logging.getLogger(__name__) + + +async def async_setup_entry(hass, entry, async_add_entities) -> None: + if entry.data: # old style - remove soon + hub_name = entry.data[CONF_NAME] + modbus_addr = entry.data.get(CONF_MODBUS_ADDR, DEFAULT_MODBUS_ADDR) + else: + hub_name = entry.options[CONF_NAME] # new style + modbus_addr = entry.options.get(CONF_MODBUS_ADDR, DEFAULT_MODBUS_ADDR) # new style + hub = hass.data[DOMAIN][hub_name]["hub"] + + plugin = hub.plugin # getPlugin(hub_name) + inverter_name_suffix = "" + if hub.inverterNameSuffix is not None and hub.inverterNameSuffix != "": + inverter_name_suffix = hub.inverterNameSuffix + " " + + entities = [] + + for switch_info in plugin.SWITCH_TYPES: + if plugin.matchInverterWithMask( + hub._invertertype, switch_info.allowedtypes, hub.seriesnumber, switch_info.blacklist + ): + if not (switch_info.name.startswith(inverter_name_suffix)): + switch_info.name = inverter_name_suffix + switch_info.name + switch = SolaXModbusSwitch(hub_name, hub, modbus_addr, hub.device_info, switch_info) + if switch_info.value_function: + hub.computedSwitches[switch_info.key] = switch_info + if switch_info.sensor_key is not None: + hub.writeLocals[switch_info.sensor_key] = switch_info + entities.append(switch) + + async_add_entities(entities) + return True + + +class SolaXModbusSwitch(SwitchEntity): + """Representation of an SolaX Modbus select.""" + + def __init__(self, platform_name, hub, modbus_addr, device_info, switch_info) -> None: + super().__init__() + self._platform_name = platform_name + self._hub = hub + self._modbus_addr = modbus_addr + self._attr_device_info = device_info + self.entity_id = f"switch.{platform_name}_{switch_info.key}" + self._name = switch_info.name + self._key = switch_info.key + self._register = switch_info.register + self.entity_description = switch_info + self._write_method = switch_info.write_method + self._sensor_key = switch_info.sensor_key + self._attr_is_on = False + self._bit = switch_info.register_bit + self._value_function = switch_info.value_function + self._last_command_time = None # Tracks last user action + + async def async_turn_on(self, **kwargs): + """Turn the switch on.""" + self._attr_is_on = True + self._last_command_time = datetime.now() # Record user action time + self.async_write_ha_state() + await self._write_switch_to_modbus() + + async def async_turn_off(self, **kwargs): + """Turn the switch off.""" + self._attr_is_on = False + self._last_command_time = datetime.now() # Record user action time + self.async_write_ha_state() + await self._write_switch_to_modbus() + + async def _write_switch_to_modbus(self): + if self._value_function is None: + _LOGGER.debug(f"No value function for switch {self._key}") + return + + payload = self._value_function(self._bit, self._attr_is_on, self._sensor_key, self._hub.data) + _LOGGER.debug(f"Writing {self._platform_name} {self._key} to register {self._register} with value {payload}") + await self._hub.async_write_registers_single(unit=self._modbus_addr, address=self._register, payload=payload) + + @property + def is_on(self): + """Return the state of the switch.""" + # Prioritize user action within debounce time + if self._last_command_time and datetime.now() - self._last_command_time < DEBOUNCE_TIME: + return self._attr_is_on + + # Otherwise, return the sensor state + if self._sensor_key and self._sensor_key in self._hub.data: + sensor_value = int(self._hub.data[self._sensor_key]) + return bool(sensor_value & (1 << self._bit)) + + return self._attr_is_on + + @property + def unique_id(self) -> Optional[str]: + return f"{self._platform_name}_{self._key}"