Open Ralle opened 2 weeks ago
Hello,
To achieve what you want, you can add a shell command to your YAML configuration and create a switch to toggle the "Solar Sell" mode. Here's how you can do it:
First, add these shell commands to your YAML file:
shell_command:
sell_on: 'python /config/python_scripts/test.py on'
sell_off: 'python /config/python_scripts/test.py off'
Then, add a switch configuration:
switch:
- platform: template
switches:
sell:
unique_id: "switch.sell"
turn_on:
service: shell_command.sell_on
turn_off:
service: shell_command.sell_off
Next, use the following Python script in the /config/python_scripts/test.py file:
from pysolarmanv5 import PySolarmanV5
import sys
mode = 2
if len(sys.argv) > 1 and sys.argv[1] == 'on':
mode = 0
modbus = PySolarmanV5('x.x.x.x', sernum, port=8899, mb_slave_id=1, verbose=0)
modbus.write_multiple_holding_registers(register_addr=142, values=[mode])
Replace x.x.x.x with the IP address of your inverter and sernum with the serial number.
more information on the modbus interface check https://github.com/RPJacobs/Kiwatt
Hope this helps!
Thank you so much for this thorough description.
Can you elaborate on what “my yaml file” is? When setting up this project you have the option to do manual configuration. I didn’t do this. Is it a requirement? Otherwise I don’t have a yaml file do I?
Hey @RPJacobs thank you so much for getting me started on this.
Alright. So I got the test.py running. But this is what I get:
python test.py on
System Work Mode = Selling Frist (yes it has a typo in SolarMan web app)
python.test.py off
System Work Mode = Zero Export to CT
Solar Sell = Enable
Unless I miss my guess. I am using the wrong register here. OR I don't understand the settings of my inverter.
EDIT: Apparently register 145 means solar sell and values 0 and 1 disable and enable it.
Thanks for all your help :)
Well done.
Hello,
I have the 12 kw Deye Hybrid inverter with SolarMan datalogger. I want to be able to set the "Solar Sell" value from HA automations. I already installed the Nordpool add-on so I can watch for energy prices and then I want to toggle "Solar Sell" accordingly.
I have searched the issues and found people talking about Modbus and the datalogger and I am not sure what I actually need to accomplish this. Many things feel a little bit implied from the conversations I've seen. I cannot understand it at least.
I have this project installed in HACS and can see values from my inverter. Works perfect. What's next?