Git Product home page Git Product logo

homeassistant-sungrow's People

Contributors

alangibson avatar alexanderlanin avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

kalaws djp3k05

homeassistant-sungrow's Issues

Added a HACS integration and...

... now what? Sorry if this is an absolute newbie question but what should happen now? What else do I need to configure after adding the integration as instructed to be able to read values from my inverter? What am I supposed to do?

OK, I need to configure a couple of things manually I guess...

Well, I set up a config.yaml which is working for my local SunGather clone in combination with my inverter but here nothing happens. Nothing pops up in Home Assistant. What have I missed?

Feature Request: config of integrations

Integrations should be configurable.

Just collecting ideas:

  • Change name, since one integration = one device we can have that as an integration config
    image
  • Battery available?
  • SCAN_INTERVAL
  • TIMEOUT
  • Smart Meter availability
  • "level" (how many entities to show)
  • Single/Master/Slave -> for now only since some entities like "Daily Grid Import Energy" don't make sense for slaves

Sungrow SH6.0RT: NOT all parameters read properly

Please let me know how can I try to fix manualy at least " total_battery_charge_energy_from_pv" - so I could have proper data in HA energy card. Everything else is read OK,

Logger: custom_components.sungrow.sensor
Source: custom_components/sungrow/sensor.py:210
Integration: Sungrow (documentation)

Sensor lookup value is not available in data array: daily_battery_charge_energy_from_pv
Sensor lookup value is not available in data array: total_battery_charge_energy_from_pv
Sensor lookup value is not available in data array: daily_export_power_from_pv
Sensor lookup value is not available in data array: total_export_power_from_pv
Sensor lookup value is not available in data array: meter_power

I'm connected via http mode

Sungrow SG10RT Configuration Help

Hi Guys.

Happy I stumbled upon this. I have a SG10RT and looks like the sensors are collecting information bar a few of them.

I want to set this up in the energy section of home assistant, but I get errors when adding feeds for sensors to:

  • Grid Consumption
  • Return to Grid
  • Solar Production

What are the correct sensors, I should be using?

If I take a look at the integration the following date points appear to be right.

  • sensor.sg10rt_a2313001072_current_active_power shows active solar being generated
  • sg10rt_a2313001072_current_export_power shows solar being sent to the grid
  • sg10rt_a2313001072_current_load_power shows consumption of my home

Any guidance is appreciated.

If I add in say sensor.sg10rt_a2313001072_daily_direct_energy_consumption to Grid consumption, I get an error:

statistics_not_defined
sensor.sg10rt_a2313001072_daily_direct_energy_consumption
Entity unavailable
The state of these configured entities are currently not available:
sensor.sg10rt_a2313001072_daily_direct_energy_consumption (unknown)

Feature Request: extend validation before adding device

Things like "Unknown Type Code Detected" should not be hidden in the log after seemingly successfully adding a device.
Although some kind of bug or whatever.... anyway unique_id should be ensured before adding the device.

2 sungrow inverter

Thank you for your work, at the moment is not possible to add more then one sungrow inverter. I have 2 sungrow inverter 1x sg40cx + 1x sg50cx.

Discussion: fork

I've started a fork to create some pull requests. Which was fine for a while. But much sooner than anticipated my code diverged significantly. I've also addressed this in Discord with @mkraiser and @bohdan-s, so far there is no clear statement on their side. From the looks of it @bohdan-s doesn't have much time either way, while @mkaiser might jump on.
Anyway, back to our repos: by now there is not a single line in common between them. That's not intentional! But a byproduct of many many refactorings.

Differences:

  • Dropped non modus for now.
  • Less model info hardcoded in yaml, more via auto detection by "groups".
  • Expose everything from the model to HA.
  • Native support+detection for master/slave.
  • Simplify yaml maintanance by removing register info. Also from inverter.py etc.
  • Simplify code by shortening functions. (However, overall it's much more code now.)
  • Started test suite

Link: https://github.com/AlexanderLanin/homeassistant-sungrow

Defaults mismatch

Defaults/explanations could be better:

Default connection type in https://github.com/bohdan-s/SunGather/blob/main/SunGather/config-example.yaml is modbus
Default port therefore 502. Can you add a comment explaining the different default ports?
Inverter model is missing a hint that this should/can be kept empty
Connection timeout 10 vs 3
Hostname/Port should contain "of Inverter"
"Data request level" is missing any explanation. Can you make it a selection like "Connection Type"?

Installation fails

Hi,

When installing integration this error comes up:

{"message":"Invalid handler specified"}

And i stops there. Any suggestions?

Logger: homeassistant.config_entries
Källa: config_entries.py:2444
Inträffade först: 10:35:16 (1 händelser)
Senast loggade: 10:35:16

Error occurred loading flow for integration sungrow: cannot import name 'Defaults' from 'pymodbus.constants' (/usr/local/lib/python3.12/site-packages/pymodbus/constants.py)

Need-Help: development environment

I need some help with the development environment.
In the end we could document how to do this, so this ticket has real benefit :-)

  • Option: Studio Code Server Addon
    Pro: Super Easy
    Con:

    • No git integration (and completely different structure)
    • Not all VS-Code extensions available
    • No access to home assistant code (e.g. base classes, parameters of called functions, ...)
  • Option: Terminal & SSH Addon + Local VS Code instance connected via SSH
    Pro: all extensions available (e.g. GitHub Copilot)
    Con:

    • Python not available (no linter, no auto formatting)
    • Different structure in git
    • No access to home assistant code (e.g. base classes, parameters of called functions, ...)
  • Option: work on branch and reload integration in home assistant via HACS
    (not yet attempted)

  • Option: work locally and copy files via bash script over SSH
    (not yet attempted. Sounds promising!)

Is there some more clever way? Since home assistant core seems to have a full development environment ready to use...

Not a repository

Hi,
I am switching over from my own setup to HA and thereby I am switching over from sungather to this plugin (as sungather does not install).
How ever with current version of HA I cannot add the repository either:
grafik

Am I doing something wrong here?
Best and thanks for feedback

Blank Page

Keen to try this (am a HA newb)

Get a blank page like so, any pointers anyone?

Xnip2024-02-20_12-22-57

Thanks.

HA
Core 2024.2.2
Supervisor 2024.01.1
Operating System 11.5
Frontend 20240207.1

How do I get the IP of the inverter?

I have looked at all the IP's connected to my router and when I input them during the configuration they all fail, saying the inverter wasn't found. I know it is just me being dense but I just can't work this out.

Discussion: detect inverters based on IP only

I wrote a little proof of concept which works fine for me. In its current state it takes ~20 seconds to run for a single IP and it does find my inverters. Not sure why it takes that long.

Does it make sense to pursue this further?
Maybe there can be two options to add devices, a simple and a manual one?

Assuming we somehow get the IP-Address, we could extend this to proper auto detection...

Output:

Running Sungrow auto detection on 192.168.13.79...
Found 2 inverter(s):
  A2350415770 (Type 0xe12) at 192.168.13.79:502 (unit 1) via modbus
  A2350415770 (Type 0xe12) at 192.168.13.79:502 (unit 1) via sungrow
Running Sungrow auto detection on 192.168.13.80...
Found 2 inverter(s):
  A2350415779 (Type 0xe12) at 192.168.13.80:502 (unit 2) via modbus
  A2350415779 (Type 0xe12) at 192.168.13.80:502 (unit 2) via sungrow

Note: for me sungrow works <50% of the time, while modbus is reliable.
(edit: Actually "sungrow" is not maintained anymore. Doesn't even make much sense to keep it?!)

For reference here is the script:

#!/usr/bin/env python3

from pprint import pprint
from pymodbus.client.sync import ModbusTcpClient
from SungrowModbusTcpClient.SungrowModbusTcpClient import SungrowModbusTcpClient
from SungrowModbusWebClient.SungrowModbusWebClient import SungrowModbusWebClient
from concurrent.futures import ThreadPoolExecutor
from queue import Queue
import logging

logger = logging.getLogger(__name__)


def try_connect_and_find_correct_unit(
    exectutor: ThreadPoolExecutor, client_class, connection_type: str, host, port
):
    """Try to connect to the inverter and find the correct unit id."""

    successfull_connections = []

    try:
        client = client_class(host=host, port=port)
        if client.connect():
            logger.debug(
                f"{connection_type} connected to {host}:{port}. Looking for unit id..."
            )

            future = {}

            # It seems that usually the unit is 1 or 2, so scanning 1-4 should be enough
            for unit in range(1, 5):
                # Note: The serial number is stored in the inverter at address 4990 (-1), and is 10 bytes long.
                # Right after the serial number, we have the device type, which is 2 bytes long.
                future[unit] = exectutor.submit(
                    client.read_input_registers,
                    4989,
                    count=11,
                    unit=unit,
                    retries=1,
                    timeout=3,
                )

            for unit in range(1, 5):
                result = future[unit].result()
                if not result.isError():
                    # Decode the serial number as UTF-8
                    serial_number = "".join(
                        [chr(c >> 8) + chr(c & 0xFF) for c in result.registers[:10]]
                    ).strip("\x00")

                    device_type = hex(result.registers[10])

                    successfull_connections.append(
                        {
                            "connection_type": connection_type,
                            "host": host,
                            "port": port,
                            "unit": unit,
                            "serial_number": serial_number,
                            "device_type": device_type,
                        }
                    )
                    logger.debug(f"Found valid unit: {successfull_connections[-1]}")

            client.close()
    except Exception as e:
        logger.debug(f"Exception in try_connect: {e}")

    return successfull_connections


def scan_ip(ip):
    with ThreadPoolExecutor() as ex:
        modbus = ex.submit(
            try_connect_and_find_correct_unit,
            ex,
            ModbusTcpClient,
            "modbus",
            ip,
            port=502,
        )
        http = ex.submit(
            try_connect_and_find_correct_unit,
            ex,
            SungrowModbusWebClient,
            "http",
            ip,
            port=8082,
        )

        # SungrowModbusTcpClient cannot run in parallel with ModbusTcpClient!
        # The inverter then drops all connections.
        modbus.result()

        sungrow = try_connect_and_find_correct_unit(
            ex, SungrowModbusTcpClient, "sungrow", ip, port=502
        )

        successfull_connections = modbus.result() + http.result() + sungrow

    return successfull_connections


def scan_and_print(host):
    print(f"Running Sungrow auto detection on {host}...")
    scan_result = scan_ip(host)

    print(f"Found {len(scan_result)} inverter(s):")
    for inverter in scan_result:
        print(
            f"  {inverter['serial_number']} (Type {inverter['device_type']}) at {inverter['host']}:{inverter['port']} (unit {inverter['unit']}) via {inverter['connection_type']}"
        )


if __name__ == "__main__":
    logging.basicConfig()
    logger.setLevel(logging.INFO)

    scan_and_print("192.168.13.79")
    scan_and_print("192.168.13.80")

Deprecated constants

Hi there,
I just saw in the log that this happened:

DEVICE_CLASS_ENERGY was used from sungrow, this is a deprecated constant which will be removed in HA Core 2025.1. Use SensorDeviceClass.ENERGY instead, please report it to the author of the 'sungrow' custom integration ENERGY_KILO_WATT_HOUR was used from sungrow, this is a deprecated constant which will be removed in HA Core 2025.1. Use UnitOfEnergy.KILO_WATT_HOUR instead, please report it to the author of the 'sungrow' custom integration POWER_WATT was used from sungrow, this is a deprecated constant which will be removed in HA Core 2025.1. Use UnitOfPower.WATT instead, please report it to the author of the 'sungrow' custom integration DEVICE_CLASS_POWER was used from sungrow, this is a deprecated constant which will be removed in HA Core 2025.1. Use SensorDeviceClass.POWER instead, please report it to the author of the 'sungrow' custom integration

At least to me it seems that this should be updated in source code. As far as I can see, anything could be changed accordingly in config.py.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.