Twisted is not needed, that’s an incorrect message from pymodbus.
I think it should work now
Hey! Updated the files… 3 errors still popping up…
Log Details (ERROR)
Logger: huawei_solar.huawei_solar
Source: custom_components/huawei_solar/sensor.py:98
First occurred: 11:30:18 PM (1 occurrences)
Last logged: 11:30:18 PM
could not read register value, is an other device already connected?
Log Details (WARNING)
Logger: homeassistant.components.sensor
Source: __main__.py:347
Integration: Sensor (documentation, issues)
First occurred: 11:30:15 PM (1 occurrences)
Last logged: 11:30:15 PM
Setup of sensor platform huawei_solar is taking over 10 seconds.
Log Details (WARNING)
Logger: pymodbus.client.asynchronous
Source: custom_components/huawei_solar/sensor.py:4
First occurred: 11:30:05 PM (1 occurrences)
Last logged: 11:30:05 PM
Not Importing deprecated clients. Dependency Twisted is not Installed
OOOOOOO Hang on… Another reboot might have fixed the issues!
Wow, it worked now! Many thanks @Emilv2!
Dummy question…
How do I get a state value to be shown in Lovelace, I managed only to show a entity but did’t to show a state of an instance… Tried to search with no lucky…
entity: sensor.sun2000l_5ktl
daily_yield: 11.33
@ligeza, well done, beautiful cards configuration! How did you manage put the “image” of the lines with the inverter, strings, and so on?
Guys, it has been quite a steep learning curve getting to know home assistant, but now i could really need some help. I have followed your instructions and installed the sensor.py (not async), init.py and manifest.json in the folder config/custom_components/huawei_solar/.
I also added to the configuration.yaml:
sensor:
- platform: huawei_solar
host: '192.168.8.3'
I also added the connection to the SUN2000 internal wifi (192.168.8.3) to home assistant via the USB method. When i check with nmcli (on SSH & Web Terminal) using “nmcli con show” i can see i’m both connected to my ethernet as well as the SUN2000 internal wifi. However my log shows the inverter is not reachable. I tried to ping and result is “disconnected”. What am i missing?
Below the log output:
2020-05-20 12:48:56 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for huawei_solar which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.
2020-05-20 12:48:56 WARNING (MainThread) [pymodbus.client.asynchronous] Not Importing deprecated clients. Dependency Twisted is not Installed
2020-05-20 12:48:59 ERROR (SyncWorker_17) [pymodbus.client.sync] Connection to (192.168.8.3, 502) failed: [Errno 113] Host is unreachable
2020-05-20 12:49:02 ERROR (SyncWorker_17) [pymodbus.client.sync] Connection to (192.168.8.3, 502) failed: [Errno 113] Host is unreachable
2020-05-20 12:49:02 ERROR (SyncWorker_17) [huawei_solar.huawei_solar] failed to connect to device, is the host correct?
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/huawei_solar/huawei_solar.py", line 147, in read_register
response = self.client.read_holding_registers(register, length)
File "/usr/local/lib/python3.7/site-packages/pymodbus/client/common.py", line 114, in read_holding_registers
return self.execute(request)
File "/usr/local/lib/python3.7/site-packages/pymodbus/client/sync.py", line 107, in execute
raise ConnectionException("Failed to connect[%s]" % (self.__str__()))
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.8.3:502)]
2020-05-20 12:49:02 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up huawei_solar platform for sensor
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/huawei_solar/huawei_solar.py", line 147, in read_register
response = self.client.read_holding_registers(register, length)
File "/usr/local/lib/python3.7/site-packages/pymodbus/client/common.py", line 114, in read_holding_registers
return self.execute(request)
File "/usr/local/lib/python3.7/site-packages/pymodbus/client/sync.py", line 107, in execute
raise ConnectionException("Failed to connect[%s]" % (self.__str__()))
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.8.3:502)]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
return fut.result()
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/huawei_solar/sensor.py", line 78, in setup_platform
entities.append(HuaweiSolarSensor(inverter))
File "/config/custom_components/huawei_solar/sensor.py", line 90, in __init__
self._name = self._inverter.get("model_name").value
File "/usr/local/lib/python3.7/site-packages/huawei_solar/huawei_solar.py", line 40, in get
response = self.read_register(reg.register, reg.length)
File "/usr/local/lib/python3.7/site-packages/huawei_solar/huawei_solar.py", line 150, in read_register
raise ConnectionException(ex)
huawei_solar.huawei_solar.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.8.3:502)]
If you can’t even ping to your inverter the problem is not with Home Assistant but with your network configuration. Maybe @ligeza can help you with how he did this configuration?
What do you mean by:
My inverter default IP is 192.168.8.1 did you change it?
I didn’t setup WiFi upon installation of the Pi so use the method in which I connect a USB stick named “CONFIG” with directory network and a file named “my-network” with below code. (I’m on the road now so not able to give you the exact code, but below my best recollection)
[connection]
id=my-network
uuid=72111c67-4a5d-4d5c-925e-f8ee26efb3c3
type=802-11-wireless
[802-11-wireless]
mode=infrastructure
ssid= SUN2000-HV1990005631
# Uncomment below if your SSID is not broadcasted
#hidden=true
[802-11-wireless-security]
auth-alg=open
key-mgmt=wpa-psk
psk=Changeme
[ipv4]
method=auto
[ipv6]
addr-gen-mode=stable-privacy
method=auto
I don’t have PI, but if I correctly understand you are connected to home network with ethernet cable and with inverter by WiFi. Can you check your network status if Pi is connected correctly?
sudo ip addr show
You should see two ip addresses. One for home network and second for inverter.
Indeed Rafal, I have two connections. One on Ethernet cabled home network and a wlan to inverter WiFi.
Don’t have the nmcli screen print here, but the IP details match the one I got on my iPhone when connected to the SUN WiFi and ran Net Analyzer app. Gateway is at 192.168.8.3 and WiFi is at 192.168.8.3.
From screenshot I see that gateway is 192.168.8.1 so you should use this IP in configuration.
sensor:
- platform: huawei_solar
host: '192.168.8.1'
192.168.8.3 is IP given to your Iphone.
Do anyone experiencing problems after updating to Home Assistant 0.110.1?
Now I get this Log:
Translation Error: The intl string context variable "Level" was not provided to the string "Detalhes do log ({Level})"
Logger: homeassistant.config
Source: custom_components/huawei_solar/sensor.py:4
First occurred: 19:37:46 (1 occurrences)
Last logged: 19:37:46
Platform error: sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config.py", line 777, in async_process_component_config
platform = p_integration.get_platform(domain)
File "/usr/src/homeassistant/homeassistant/loader.py", line 273, in get_platform
f"{self.pkg_path}.{platform_name}"
File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/config/custom_components/huawei_solar/sensor.py", line 4, in <module>
from huawei_solar import HuaweiSolar, ReadException
ModuleNotFoundError: No module named 'huawei_solar'
I’m not sure what is causing this, I think you can fix it for now by commenting out (adding #
in front of it) all the _LOGGER
lines.
Whoop whoop! You solved it. Many thanks for your help! I’ve got my sensor set up now as you can see in my pic
. Will start building a dashboard in Lovelace now. Hoping I can mimic yours. Should keep me busy for a while!Another question: how do you store data long term? As rules in the Netherlands will change in ‘23 (no longer able to net the power bought with the power returned to the network) I probably need to look into hooking up a battery. For this I want to have enough historical data to make a return analysis based on period averages as well as intraday profile of power usage and generation from my panels. So what would be the application best used for building a local database?