Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Showing non-existing batteries #68

Open
addiejanssen opened this issue Dec 29, 2022 · 5 comments
Open

Showing non-existing batteries #68

addiejanssen opened this issue Dec 29, 2022 · 5 comments

Comments

@addiejanssen
Copy link

addiejanssen commented Dec 29, 2022

Hi,

First of all: thanks for the library. It enabled me to create a nice Domoticz plugin to monitor my solar installation.

Recently I have added support for meters to my plugin and that is working fine.
I am now working on supporting batteries as well and run into some strange things.
When testing with my inverter (which has no batteries connected to it), I found that the library reports batteries...
When running the example.py, I get this output:

{
    "c_id": "SunS",
    "c_did": 1,
    "c_length": 65,
    "c_manufacturer": "SolarEdge",
    "c_model": "SE7K",
    "c_version": "0003.2251",
    "c_serialnumber": "removed",
    "c_deviceaddress": 1,
    "c_sunspec_did": 103,
    "c_sunspec_length": 50,
    "current": 181,
    "l1_current": 60,
    "l2_current": 59,
    "l3_current": 61,
    "current_scale": -2,
    "l1_voltage": 3980,
    "l2_voltage": 3975,
    "l3_voltage": 3994,
    "l1n_voltage": 2276,
    "l2n_voltage": 2310,
    "l3n_voltage": 2294,
    "voltage_scale": -1,
    "power_ac": 13900,
    "power_ac_scale": -2,
    "frequency": 4994,
    "frequency_scale": -2,
    "power_apparent": 4149,
    "power_apparent_scale": -1,
    "power_reactive": -3910,
    "power_reactive_scale": -1,
    "power_factor": -3342,
    "power_factor_scale": -2,
    "energy_total": 21869076,
    "energy_total_scale": 0,
    "current_dc": 18877,
    "current_dc_scale": -5,
    "voltage_dc": 7475,
    "voltage_dc_scale": -1,
    "power_dc": 14111,
    "power_dc_scale": -2,
    "temperature": 3199,
    "temperature_scale": -2,
    "status": 4,
    "vendor_status": 0,
    "rrcr_state": 0,
    "active_power_limit": 100,
    "cosphi": 0,
    "meters": {},
    "batteries": {
        "Battery1": {
            "c_manufacturer": "\u0002",
            "c_model": "False",
            "c_version": "False",
            "c_serialnumber": "False",
            "c_deviceaddress": 15,
            "c_sunspec_did": 0,
            "rated_energy": -3.4028234663852886e+38,
            "maximum_charge_continuous_power": -3.4028234663852886e+38,
            "maximum_discharge_continuous_power": -3.4028234663852886e+38,
            "maximum_charge_peak_power": -3.4028234663852886e+38,
            "maximum_discharge_peak_power": -3.4028234663852886e+38,
            "average_temperature": -3.4028234663852886e+38,
            "maximum_temperature": 0.0,
            "instantaneous_voltage": -3.4028234663852886e+38,
            "instantaneous_current": -3.4028234663852886e+38,
            "instantaneous_power": 0.0,
            "lifetime_export_energy_counter": 0,
            "lifetime_import_energy_counter": 0,
            "maximum_energy": -3.4028234663852886e+38,
            "available_energy": -3.4028234663852886e+38,
            "soh": -3.4028234663852886e+38,
            "soe": -3.4028234663852886e+38,
            "status": 7,
            "status_internal": 0,
            "event_log": 0,
            "event_log_internal": 0
        },
        "Battery2": {
            "c_manufacturer": "\u0002",
            "c_model": "False",
            "c_version": "False",
            "c_serialnumber": "False",
            "c_deviceaddress": 14,
            "c_sunspec_did": 0,
            "rated_energy": -3.4028234663852886e+38,
            "maximum_charge_continuous_power": -3.4028234663852886e+38,
            "maximum_discharge_continuous_power": -3.4028234663852886e+38,
            "maximum_charge_peak_power": -3.4028234663852886e+38,
            "maximum_discharge_peak_power": -3.4028234663852886e+38,
            "average_temperature": -3.4028234663852886e+38,
            "maximum_temperature": 0.0,
            "instantaneous_voltage": -3.4028234663852886e+38,
            "instantaneous_current": -3.4028234663852886e+38,
            "instantaneous_power": 0.0,
            "lifetime_export_energy_counter": 0,
            "lifetime_import_energy_counter": 0,
            "maximum_energy": -3.4028234663852886e+38,
            "available_energy": -3.4028234663852886e+38,
            "soh": -3.4028234663852886e+38,
            "soe": -3.4028234663852886e+38,
            "status": 7,
            "status_internal": 0,
            "event_log": 0,
            "event_log_internal": 0
        }
    }
}

So, for some reason, it detects non-existing batteries and reports invalid information for them.
Hope you can help me out with this one.

@nmakel
Copy link
Owner

nmakel commented Dec 31, 2022

Hey Addie, I can't reproduce with the latest version on a SE3500K.

There are two registers that indicate the presence of batteries. If these are not "255" (the unset value) then the entire battery block is read. So, in your case these registers are something other than "255". Could you add print(batteries) to line 525 of __init__.py and run example.py again?

@addiejanssen
Copy link
Author

Line 525 is in the middle of the definition of the meters. I assume you mean line 492.
This is what I did:
image

And this is the outcome:

[15, 14]
(0, 15)
(1, 14)
{
    "c_id": "SunS",
    "c_did": 1,
    "c_length": 65,
    "c_manufacturer": "SolarEdge",
    "c_model": "SE7K",
    "c_version": "0003.2251",
    "c_serialnumber": "removed",
    "c_deviceaddress": 1,
    "c_sunspec_did": 103,
    "c_sunspec_length": 50,
    "current": 189,
    "l1_current": 49,
    "l2_current": 69,
    "l3_current": 71,
    "current_scale": -2,
    "l1_voltage": 3980,
    "l2_voltage": 3985,
    "l3_voltage": 3997,
    "l1n_voltage": 2304,
    "l2n_voltage": 2291,
    "l3n_voltage": 2294,
    "voltage_scale": -1,
    "power_ac": 4400,
    "power_ac_scale": -2,
    "frequency": 4998,
    "frequency_scale": -2,
    "power_apparent": 4312,
    "power_apparent_scale": -1,
    "power_reactive": -4290,
    "power_reactive_scale": -1,
    "power_factor": -9356,
    "power_factor_scale": -3,
    "energy_total": 21870964,
    "energy_total_scale": 0,
    "current_dc": 5967,
    "current_dc_scale": -5,
    "voltage_dc": 7485,
    "voltage_dc_scale": -1,
    "power_dc": 4467,
    "power_dc_scale": -2,
    "temperature": 3449,
    "temperature_scale": -2,
    "status": 4,
    "vendor_status": 0,
    "rrcr_state": 0,
    "active_power_limit": 100,
    "cosphi": 0,
    "meters": {},
    "batteries": {
        "Battery1": {
            "c_manufacturer": "\u0002",
            "c_model": "False",
            "c_version": "False",
            "c_serialnumber": "False",
            "c_deviceaddress": 15,
            "c_sunspec_did": 0,
            "rated_energy": -3.4028234663852886e+38,
            "maximum_charge_continuous_power": -3.4028234663852886e+38,
            "maximum_discharge_continuous_power": -3.4028234663852886e+38,
            "maximum_charge_peak_power": -3.4028234663852886e+38,
            "maximum_discharge_peak_power": -3.4028234663852886e+38,
            "average_temperature": -3.4028234663852886e+38,
            "maximum_temperature": 0.0,
            "instantaneous_voltage": -3.4028234663852886e+38,
            "instantaneous_current": -3.4028234663852886e+38,
            "instantaneous_power": 0.0,
            "lifetime_export_energy_counter": 0,
            "lifetime_import_energy_counter": 0,
            "maximum_energy": -3.4028234663852886e+38,
            "available_energy": -3.4028234663852886e+38,
            "soh": -3.4028234663852886e+38,
            "soe": -3.4028234663852886e+38,
            "status": 7,
            "status_internal": 0,
            "event_log": 0,
            "event_log_internal": 0
        },
        "Battery2": {
            "c_manufacturer": "\u0002",
            "c_model": "False",
            "c_version": "False",
            "c_serialnumber": "False",
            "c_deviceaddress": 14,
            "c_sunspec_did": 0,
            "rated_energy": -3.4028234663852886e+38,
            "maximum_charge_continuous_power": -3.4028234663852886e+38,
            "maximum_discharge_continuous_power": -3.4028234663852886e+38,
            "maximum_charge_peak_power": -3.4028234663852886e+38,
            "maximum_discharge_peak_power": -3.4028234663852886e+38,
            "average_temperature": -3.4028234663852886e+38,
            "maximum_temperature": 0.0,
            "instantaneous_voltage": -3.4028234663852886e+38,
            "instantaneous_current": -3.4028234663852886e+38,
            "instantaneous_power": 0.0,
            "lifetime_export_energy_counter": 0,
            "lifetime_import_energy_counter": 0,
            "maximum_energy": -3.4028234663852886e+38,
            "available_energy": -3.4028234663852886e+38,
            "soh": -3.4028234663852886e+38,
            "soe": -3.4028234663852886e+38,
            "status": 7,
            "status_internal": 0,
            "event_log": 0,
            "event_log_internal": 0
        }
    }
}

@nmakel
Copy link
Owner

nmakel commented Dec 31, 2022

Ok, so not wholly unexpected. I'd be curious to know what is around those registers. I use the following script to dump large ranges of registers, you could try that and see if there's anything interesting there.

#!/usr/bin/env python3

import argparse

from pymodbus.constants import Endian
from pymodbus.payload import BinaryPayloadDecoder
from pymodbus.client import ModbusTcpClient
from pymodbus.register_read_message import ReadHoldingRegistersResponse


if __name__ == "__main__":
    argparser = argparse.ArgumentParser()
    argparser.add_argument("host", type=str, help="Modbus TCP address")
    argparser.add_argument("port", type=int, help="Modbus TCP port")
    argparser.add_argument("--timeout", type=int, default=1, help="Connection timeout")
    argparser.add_argument("--unit", type=int, default=1, help="Modbus device address")
    args = argparser.parse_args()

    client = ModbusTcpClient(
        host=args.host,
        port=args.port,
        timeout=args.timeout,
    )

    maps = [
        (40000, 40070, "base"),
        (57600, 57665, "battery1"),
        (57865, 57930, "battery2")
    ]

    for start, stop, name in maps:
        print(f"\n{name} block ({start}-{stop})\n")

        for i in range(start, stop):
            result = client.read_holding_registers(i, 1, slave=args.unit)

            if not isinstance(result, ReadHoldingRegistersResponse):
                continue
            if len(result.registers) != 1:
                continue

            value = BinaryPayloadDecoder.fromRegisters(result.registers, byteorder=Endian.Big, wordorder=Endian.Big)

            decoded = value.decode_16bit_uint()
            print(i, decoded)

The output I get is:

battery1 block (57600-57665)

57600 0
57616 0
57632 0
57648 0
57664 255

battery2 block (57865-57930)

57872 0
57888 0
57904 0
57920 255
57921 0

The following is a list of blocks as documented by SolarEdge:

# 40000-40069 base
# 40069-40071 inverter1
# 40120-40190 meter1
# 40295-40364 meter2
# 40469-40539 meter3
# 40171-40241 meter1-synergy2
# 40345-40415 meter2-synergy2
# 40519-40589 meter3-synergy2
# 40191-40261 meter1-synergy3
# 40365-40435 meter2-synergy3
# 40539-40609 meter3-synergy3
# 57600-57665 battery1
# 57865-57921 battery2

@addiejanssen
Copy link
Author

Here's the output of that script: dump.txt

@addiejanssen
Copy link
Author

Hey @nmakel, just a friendly nudge from my side. How to progress with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants