diff --git a/CHANGELOG.md b/CHANGELOG.md index a3bc961..84b7d3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] +- add PROD_COMPL_TYPE to trace - add SolarmanV5 messages builder - report inverter alarms and faults per MQTT [#7](https://github.com/s-allius/tsun-gen3-proxy/issues/7) diff --git a/app/src/gen3/infos_g3.py b/app/src/gen3/infos_g3.py index 950a956..97a4f5e 100644 --- a/app/src/gen3/infos_g3.py +++ b/app/src/gen3/infos_g3.py @@ -84,6 +84,7 @@ class RegisterMap: 0x000012c0: {'reg': Register.RATED_LEVEL}, 0x00001324: {'reg': Register.INPUT_COEFFICIENT, 'ratio': 100/1024}, 0x00001388: {'reg': Register.GRID_VOLT_CAL_COEF}, + 0x00002710: {'reg': Register.PROD_COMPL_TYPE}, 0x00003200: {'reg': Register.OUTPUT_COEFFICIENT, 'ratio': 100/1024}, } diff --git a/app/src/gen3plus/infos_g3p.py b/app/src/gen3plus/infos_g3p.py index aec8bfb..b866fea 100644 --- a/app/src/gen3plus/infos_g3p.py +++ b/app/src/gen3plus/infos_g3p.py @@ -91,7 +91,8 @@ class RegisterMap: 0x4201012c: {'reg': Register.GRID_VOLT_CAL_COEF, 'fmt': '!H'}, 0x4201012e: {'reg': None, 'fmt': '!H', 'const': 1024}, # noqa: E501 0x42010130: {'reg': None, 'fmt': FMT_4_16BIT_VAL, 'const': (1024, 1, 0xffff, 1)}, # noqa: E501 - 0x42010138: {'reg': None, 'fmt': FMT_4_16BIT_VAL, 'const': (6, 0x68, 0x68, 0x500)}, # noqa: E501 + 0x42010138: {'reg': Register.PROD_COMPL_TYPE, 'fmt': '!H'}, + 0x4201013a: {'reg': None, 'fmt': FMT_3_16BIT_VAL, 'const': (0x68, 0x68, 0x500)}, # noqa: E501 0x42010140: {'reg': None, 'fmt': FMT_4_16BIT_VAL, 'const': (0x9cd, 0x7b6, 0x139c, 0x1324)}, # noqa: E501 0x42010148: {'reg': None, 'fmt': FMT_4_16BIT_VAL, 'const': (1, 0x7ae, 0x40f, 0x41)}, # noqa: E501 0x42010150: {'reg': None, 'fmt': FMT_4_16BIT_VAL, 'const': (0xf, 0xa64, 0xa64, 0x6)}, # noqa: E501 diff --git a/app/src/infos.py b/app/src/infos.py index e899f00..fb8f0d1 100644 --- a/app/src/infos.py +++ b/app/src/infos.py @@ -30,6 +30,7 @@ class Register(Enum): INPUT_COEFFICIENT = 28 GRID_VOLT_CAL_COEF = 29 OUTPUT_COEFFICIENT = 30 + PROD_COMPL_TYPE = 31 INVERTER_CNT = 50 UNKNOWN_SNR = 51 UNKNOWN_MSG = 52 @@ -511,6 +512,7 @@ class Infos: Register.OUTPUT_SHUTDOWN: {'name': ['other', 'Output_Shutdown'], 'level': logging.DEBUG, 'unit': ''}, # noqa: E501 Register.RATED_LEVEL: {'name': ['other', 'Rated_Level'], 'level': logging.DEBUG, 'unit': ''}, # noqa: E501 Register.GRID_VOLT_CAL_COEF: {'name': ['other', 'Grid_Volt_Cal_Coef'], 'level': logging.DEBUG, 'unit': ''}, # noqa: E501 + Register.PROD_COMPL_TYPE: {'name': ['other', 'Prod_Compliance_Type'], 'level': logging.INFO, 'unit': ''}, # noqa: E501 Register.INV_UNKNOWN_1: {'name': ['inv_unknown', 'Unknown_1'], 'level': logging.DEBUG, 'unit': ''}, # noqa: E501 } diff --git a/app/src/modbus.py b/app/src/modbus.py index ace14fe..8c88537 100644 --- a/app/src/modbus.py +++ b/app/src/modbus.py @@ -44,11 +44,11 @@ class Modbus(): 0x2001: {'reg': Register.DSP_STATUS, 'fmt': '!H'}, # noqa: E501 0x2003: {'reg': Register.WORK_MODE, 'fmt': '!H'}, 0x2006: {'reg': Register.OUTPUT_SHUTDOWN, 'fmt': '!H'}, - 0x2007: {'reg': Register.MAX_DESIGNED_POWER, 'fmt': '!H', 'ratio': 1}, # noqa: E501 + 0x2007: {'reg': Register.MAX_DESIGNED_POWER, 'fmt': '!H', 'ratio': 1}, # noqa: E501 0x2008: {'reg': Register.RATED_LEVEL, 'fmt': '!H'}, 0x2009: {'reg': Register.INPUT_COEFFICIENT, 'fmt': '!H', 'ratio': 100/1024}, # noqa: E501 0x200a: {'reg': Register.GRID_VOLT_CAL_COEF, 'fmt': '!H'}, - + 0x2010: {'reg': Register.PROD_COMPL_TYPE, 'fmt': '!H'}, 0x202c: {'reg': Register.OUTPUT_COEFFICIENT, 'fmt': '!H', 'ratio': 100/1024}, # noqa: E501 0x3000: {'reg': Register.INVERTER_STATUS, 'fmt': '!H'}, # noqa: E501 diff --git a/app/tests/test_infos_g3p.py b/app/tests/test_infos_g3p.py index 51af74d..150a666 100644 --- a/app/tests/test_infos_g3p.py +++ b/app/tests/test_infos_g3p.py @@ -120,7 +120,7 @@ def test_parse_4210(inverter_data: bytes): "pv4": {"Voltage": 1.7, "Current": 0.01, "Power": 0.0, "Total_Generation": 15.58}}, "total": {"Daily_Generation": 0.11, "Total_Generation": 101.36}, "inv_unknown": {"Unknown_1": 512}, - "other": {"Output_Shutdown": 65535, "Rated_Level": 3, "Grid_Volt_Cal_Coef": 1024} + "other": {"Output_Shutdown": 65535, "Rated_Level": 3, "Grid_Volt_Cal_Coef": 1024, "Prod_Compliance_Type": 6} }) def test_build_4210(inverter_data: bytes): diff --git a/app/tests/test_solarman_emu.py b/app/tests/test_solarman_emu.py index 32787ab..0eadbc6 100644 --- a/app/tests/test_solarman_emu.py +++ b/app/tests/test_solarman_emu.py @@ -170,6 +170,7 @@ async def test_snd_inv_data(config_tsun_inv1, inverter_ind_msg, inverter_rsp_msg inv.db.set_db_def_value(Register.GRID_VOLTAGE, 224.8) inv.db.set_db_def_value(Register.GRID_CURRENT, 0.73) inv.db.set_db_def_value(Register.GRID_FREQUENCY, 50.05) + inv.db.set_db_def_value(Register.PROD_COMPL_TYPE, 6) assert asyncio.get_running_loop() == inv.mb_timer.loop await inv.send_start_cmd(get_sn_int(), str_test_ip, False, inv.mb_first_timeout) inv.db.set_db_def_value(Register.DATA_UP_INTERVAL, 17) # set test value