Hi all,
I have a Deye SUN-M80G4-EU-Q0 micro-inverter.
It is connected (only) to a battery, so I need to control the power that it injects into the grid. Otherwise the inverter just dumps the entire battery power to the grid until the battery is empty.
I managed to write a (test) Python script that uses the Deye Cloud OpenAPI.
That way, I can set the MAX_SOLAR_POWER parameter, to define the max power into the grid.
That basically works, but the OpenAPI commands go over the Deye servers.
I fear that sooner or later, Deye will put some limitations on that, concerning the maximum rate of API calls that users make. Although for the moment, they do not do that yet.
So, I am looking for a way to control the Deye inverter 'locally'. So, not passing via the Deye servers.
The obvious way seems to be to use the Modbus protocol.
I've been trying to write a Python script to make a Modbus connection and communication with my Deye, but I can't get it to work.
Apparantly, a client connection is made, but when I try to access a register, the inverter does not respond. The connection always times out.
These are the main parameters that I use:
I haven't tried connecting to "10.10.100.254", because my controller (that runs Python) needs to also connect to the internet.
This script does not work:
The strange thing is that using AT-commands using this tool works fine!
So, I also have been trying to use AT-commands via a Python script, and it also does not work ...
Does anybody have any suggestions of things to try?
I have a Deye SUN-M80G4-EU-Q0 micro-inverter.
It is connected (only) to a battery, so I need to control the power that it injects into the grid. Otherwise the inverter just dumps the entire battery power to the grid until the battery is empty.
I managed to write a (test) Python script that uses the Deye Cloud OpenAPI.
That way, I can set the MAX_SOLAR_POWER parameter, to define the max power into the grid.
That basically works, but the OpenAPI commands go over the Deye servers.
I fear that sooner or later, Deye will put some limitations on that, concerning the maximum rate of API calls that users make. Although for the moment, they do not do that yet.
So, I am looking for a way to control the Deye inverter 'locally'. So, not passing via the Deye servers.
The obvious way seems to be to use the Modbus protocol.
I've been trying to write a Python script to make a Modbus connection and communication with my Deye, but I can't get it to work.
Apparantly, a client connection is made, but when I try to access a register, the inverter does not respond. The connection always times out.
These are the main parameters that I use:
Code:
modbus_host = "192.168.0.187"
modbus_port = 8899
slave_id = 1
I haven't tried connecting to "10.10.100.254", because my controller (that runs Python) needs to also connect to the internet.
This script does not work:
Python:
from pyModbusTCP.client import ModbusClient
modbus_host = "192.168.0.187"
modbus_port = 8899
slave_id = 1
register_address = 40
register_count = 1
client = ModbusClient(host=modbus_host, port=modbus_port, unit_id=slave_id, timeout=30.00, auto_open=False)
print(client.open())
print(client)
try:
if client.open():
print("Successfully connected to the Modbus server!")
else:
print("Failed to connect to the Modbus server. Check IP, Port, Firewall.")
except Exception as e:
print(f"An error occurred during connection: {e}")
if client.is_open:
print("Client connection is currently open.")
else:
print("Client connection is not open.")
response_registers = client.read_input_registers(0, 1)
#response_registers = client.read_holding_registers(0, 1)
if response_registers is not None:
print(f"Server responded successfully. Value: {response_registers[0]}")
else:
print("Failed to read from server or no response.")
print(f"Last error: {client.last_error_as_txt}")
client.close()
exit()
So, I also have been trying to use AT-commands via a Python script, and it also does not work ...
Does anybody have any suggestions of things to try?