Skip to content

Commit 4df7b64

Browse files
authored
Merge pull request #1499 from thomas7475/main
fix: Prevent NoneType error in async_read_serialnr in plugin_growatt.py
2 parents b86c349 + 553a52a commit 4df7b64

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

custom_components/solax_modbus/plugin_growatt.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async def async_read_serialnr(hub, address):
6262
res = None
6363
try:
6464
inverter_data = await hub.async_read_holding_registers(unit=hub._modbus_addr, address=address, count=5)
65-
if not inverter_data.isError():
65+
if inverter_data and not inverter_data.isError():
6666
decoder = BinaryPayloadDecoder.fromRegisters(inverter_data.registers, byteorder=Endian.BIG)
6767
res = decoder.decode_string(10).decode("ascii")
6868
hub.seriesnumber = res
@@ -2436,6 +2436,21 @@ def value_function_inverter_module(initval, descr, datadict):
24362436
allowedtypes = GEN2 | GEN3 | GEN4,
24372437
internal = True,
24382438
),
2439+
GrowattModbusSensorEntityDescription(
2440+
name="PV Isolation Resistance",
2441+
key="pv_isolation_resistance",
2442+
register=200,
2443+
register_type=REG_INPUT,
2444+
native_unit_of_measurement="kΩ",
2445+
state_class=SensorStateClass.MEASUREMENT,
2446+
# Register 200 is used to avoid a conflict with the 'BMS 1 Serial Number'
2447+
# entity on some GEN4 hybrid models (e.g., TL-XH) which uses 3087.
2448+
# Confirmed working on GEN4 PV models (MIC 600TL-X).
2449+
allowedtypes=GEN2 | GEN3 | GEN4,
2450+
entity_category=EntityCategory.DIAGNOSTIC,
2451+
entity_registry_enabled_default=True,
2452+
icon="mdi:omega",
2453+
),
24392454

24402455
# Not documented, source: https://www.photovoltaikforum.com/thread/192228-growatt-sph-modbus-rtu-rj45-pinout-und-register-beschreibung/?postID=3017838#post3017838
24412456
GrowattModbusSensorEntityDescription(

0 commit comments

Comments
 (0)