Solution: Reading Solax SK-SU5000(E) inverters & SDM630V2 Modbus Power Meters

Indeed. I have other issues without out of date software. I am resolving these first.

Thanks

1 Like

Thank all, Python3 was the issue and I had to reinstall the missing modules, namely:

pip install toml twisted pymodbus

The script now runs but it sits at:

pi@emonpi:~/PowerScraper $ ./power_scraper.py
Setting up EmonCMS

Thanks for any help, I’m a newbie to this.

1 Like

I’ve just noticed at the top of the file

I’ve created a PR to change the instructions to pip3!

I presume you have created the config.toml and put in your Emoncms details?

Also I think you need to add in the IP of your inverter(s) to the config.

[edit]
I think it should be

inverters = ['5.8.8.8']

based on the URL that worked for you.

Suddenly noticed, I hope you did (although, TBH, I do not understand the difference between pip & pip3 and the relationship to Python 2 & 3).

pip3 install toml twisted pymodbus

Hi @borpin

inverters = ['5.8.8.8']

based on the URL that worked for you.

Yes, this is the IP I have entered in the config file.

Suddenly noticed, I hope you did (although, TBH, I do not understand the difference between pip & pip3 and the relationship to Python 2 & 3).

pip3 install toml twisted pymodbus

Yes, I did this too. The script didn’t like run until I did this.

I think it is getting past communicating with the inverter and trying to communicate with EmonCMS. I can access EmonCMS without issue and all looks good in there.

Have you used the right API key?

What version of emoncms?

Can you click on the button ā€˜copy as markdown’ next to ā€˜Server Information’ and paste here (no further formatting required)

I’ve checked the API key is correct.

Server Information

Server Information

Services

  • emonhub :- Failed Failed
  • emoncms_mqtt :- Active Running
  • feedwriter :- Active Running - sleep 300s 0 feed points pending write
  • service-runner :- Activating Auto-restart
  • emonPiLCD :- Activating Auto-restart
  • redis-server :- Active Running
  • mosquitto :- Active Running
  • demandshaper :- Active Running

Emoncms

Server

  • OS :- Linux 4.19.75-v7+
  • Host :- emonpi | emonpi | (192.168.0.100)
  • Date :- 2019-11-29 18:03:09 UTC
  • Uptime :- 18:03:09 up 4:49, 2 users, load average: 0.01, 0.02, 0.00

Memory

  • RAM :- Used: 18.53%
    • Total :- 926.08 MB
    • Used :- 171.57 MB
    • Free :- 754.51 MB
  • Swap :- Used: 0.00%
    • Total :- 100 MB
    • Used :- 0 B
    • Free :- 100 MB
      Write Load Period

Disk

  • / :- Used: 53.01%
    • Total :- 3.92 GB
    • Used :- 2.08 GB
    • Free :- 1.65 GB
    • Write Load :- 349.53 B/s (4 hours 47 mins)
  • /var/opt/emoncms :- Used: 0.04%
    • Total :- 9.98 GB
    • Used :- 3.77 MB
    • Free :- 9.47 GB
    • Write Load :- 0 B/s (4 hours 47 mins)
  • /boot :- Used: 20.55%
    • Total :- 252.05 MB
    • Used :- 51.79 MB
    • Free :- 200.25 MB
    • Write Load :- 0 B/s (4 hours 47 mins)
  • /var/log :- Used: 9.09%
    • Total :- 50 MB
    • Used :- 4.54 MB
    • Free :- 45.46 MB
    • Write Load :- n/a

HTTP

  • Server :- Apache/2.4.38 (Raspbian) HTTP/1.1 CGI/1.1 80

MySQL

  • Version :- 5.5.5-10.3.17-MariaDB-0+deb10u1
  • Host :- localhost:6379 (127.0.0.1)
  • Date :- 2019-11-29 18:03:08 (UTC 00:00ā€Œā€‹)
  • Stats :- Uptime: 17388 Threads: 13 Questions: 2063 Slow queries: 0 Opens: 46 Flush tables: 1 Open tables: 40 Queries per second avg: 0.118

Redis

  • Version :-
    • Redis Server :- 5.0.3
    • PHP Redis :- 5.0.2
  • Host :- localhost:6379
  • Size :- 24 keys (761.66K)
  • Uptime :- 0 days

MQTT Server

  • Version :- Mosquitto 1.5.7
  • Host :- localhost:1883 (127.0.0.1)

PHP

  • Version :- 7.3.11-1~deb10u1 (Zend Version 3.3.11)
  • Modules :- apache2handler | calendar v7.3.11-1~deb10u1 | Core v7.3.11-1~deb10u1 | ctype v7.3.11-1~deb10u1 | curl v7.3.11-1~deb10u1 | date v7.3.11-1~deb10u1 | dom v20031129 | exif v7.3.11-1~deb10u1 | fileinfo v7.3.11-1~deb10u1 | filter v7.3.11-1~deb10u1 | ftp v7.3.11-1~deb10u1 | gd v7.3.11-1~deb10u1 | gettext v7.3.11-1~deb10u1 | hash v7.3.11-1~deb10u1 | iconv v7.3.11-1~deb10u1 | json v1.7.0 | libxml v7.3.11-1~deb10u1 | mbstring v7.3.11-1~deb10u1 | mosquitto v0.4.0 | mysqli v7.3.11-1~deb10u1 | mysqlnd vmysqlnd 5.0.12-dev - 20150407 - $Id: 7cc7cc96e675f6d72e5cf0f267f48e167c2abb23 $ | openssl v7.3.11-1~deb10u1 | pcre v7.3.11-1~deb10u1 | PDO v7.3.11-1~deb10u1 | pdo_mysql v7.3.11-1~deb10u1 | Phar v7.3.11-1~deb10u1 | posix v7.3.11-1~deb10u1 | readline v7.3.11-1~deb10u1 | redis v5.0.2 | Reflection v7.3.11-1~deb10u1 | session v7.3.11-1~deb10u1 | shmop v7.3.11-1~deb10u1 | SimpleXML v7.3.11-1~deb10u1 | sockets v7.3.11-1~deb10u1 | sodium v7.3.11-1~deb10u1 | SPL v7.3.11-1~deb10u1 | standard v7.3.11-1~deb10u1 | sysvmsg v7.3.11-1~deb10u1 | sysvsem v7.3.11-1~deb10u1 | sysvshm v7.3.11-1~deb10u1 | tokenizer v7.3.11-1~deb10u1 | wddx v7.3.11-1~deb10u1 | xml v7.3.11-1~deb10u1 | xmlreader v7.3.11-1~deb10u1 | xmlwriter v7.3.11-1~deb10u1 | xsl v7.3.11-1~deb10u1 | Zend OPcache v7.3.11-1~deb10u1 | zlib v7.3.11-1~deb10u1

Pi

  • Model :- Raspberry Pi 2 Model B Rev 1.1 - 1GB (Embest)

  • Serial num. :- A2FBF6F

  • Temperature :- 29.86°C - 30.4°C

  • emonpiRelease :- emonSD-17Oct19

  • File-system :- read-write

Client Information

Client Information

HTTP

  • Browser :- Mozilla/5.0 (Linux; Android 9; SM-G975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Mobile Safari/537.36
  • Language :- en-US,en;q=0.9,en-GB;q=0.8

Window

  • Size :- 412 x 771

Screen

  • Resolution :- 412 x 869

Depends on whether or not one’s system has both Python2 and Python3 installed. Viz:

IF python3 is your only python and python3 and python can both start it, then there is no difference. If python starts legacy python and python3 starts, well, python 3 then pip will install for legacy python and pip3 or your python3 example will install for python 3.

Ref: What's the difference between pip and pip3?

1 Like

Would anyone be willing to help me get Modbus working with an FTDI adapter?! I’ve tried modifying the Powerscraper script (with my very basic Python skills) to use serial like the SDM630ModbusV2 but I get the following error and for the life of me I cannot work it out:

pi@emonpi:~/PowerScraper_custom $ ./power_scraper.py
Setting up EmonCMS
Traceback (most recent call last):
  File "./power_scraper.py", line 106, in <module>
    config['Solax-Modbus']['stopbits'], config['Solax-Modbus']['timeout'])
TypeError: __init__() takes 3 positional arguments but 6 were given

This is the section of code I have changed:

if 'Solax-Modbus' in config:
    SolaxModbusInverters = []
    for inverter in config['Solax-Modbus']['ports']:
        modbusInverter = SolaxModbus(inverter, config['Solax-Modbus']['baud'], config['Solax-Modbus']['parity'],
                    config['Solax-Modbus']['stopbits'], config['Solax-Modbus']['timeout'])
        SolaxModbusInverters.append(modbusInverter)
    looperSolaxModbus = task.LoopingCall(inputActions, SolaxModbusInverters)
    looperSolaxModbus.start(config['Solax-Modbus']['poll_period'])

Any help will be greatly appreciated. Let me know if you need more info.

Thanks

Max

You’ll also need to update Inputs/SolaxModbus.py to do something with the new serial arguments you’re passing

That’s your main clue.
You supplied six arguments, but the function only wants three.

Ah okay. The error confused me to think the issue was within power_scraper.py but I need to update SolaxModbus.py!

Thanks, I’ll keep playing.

@Wulfee do you have an example code of how you are controlling your battery to prevent it discharging when charging your car.

I am trying to do the same through Home Assistant. I have got it reading all the Solar data, but struggling with writing commands to the inverter.

I just run a script from a cron job at 00:30 (when my cheap rate starts) to disable and then another at 04:30 (when my cheap rate ends) to re-enable. I’ll post the scripts this evening when I get home.

Hi, I’ve been trying to get PowerScraper script to work. I’m having a few issues which I think are to do with trying to use a new version of pymodbus. However, when downgrading to pymodbus==1.5.1 I’m still having the issue:

pi@emonpi:/opt/PowerScraper $ ./power_scraper.py 
Traceback (most recent call last):
  File "./power_scraper.py", line 38, in <module>
    from Inputs.SolaxModbus import SolaxModbus
  File "/opt/PowerScraper/Inputs/SolaxModbus.py", line 1
    from pymodbus.client.async import ModbusClientProtocol, ModbusClientFactory

Can anyone confirm what version of pymodbus works with PowerScraper?

Thanks for the response @Wulfee

Are you on the Octopus Go tariff?

Have you had any luck getting grid charging working?
Out of curiosity which version of the Solax Inverter do you have? I have an X1-Hybrid Gen3

Yes, it’s the best tariff for EV owners, especially if you have solar too.

I did get it to work but wasn’t exactly sure what I did as it didn’t seem to do what I expected. I stopped fiddling with it for now because I can’t charge from the grid anyway without getting a different generation meter as otherwise the grid charged power will appear as generation when in fact it isn’t.

I have a generation 2 X hybrid.

I’ve placed my scripts in bitbucket here. Your password may be different as you don’t have the same model as me.

Do you have the higher voltage batteries or 48 volt ones?

Thanks.

I was going to use Octopus GO. But I have found I hardly need to charge from home as we have free charging at work. So I am just on the normal Octopus Tariff.

I think the only thing I have been doing wrong is using the installer password and not the user password.
I saw the option to change the user password from the default of 2014 in the webportal on the cloud.

Why I didn’t try 2014 I don’t know?

Will give it another go tonight after work.

I am using a single SolaX Gen2 Triple Power HV 4.5kWh I would like to add a second at a later stage. They are about 100v each.

I have got partial battery control working in Home Assistant now. @Wulfee thanks for pointing the obvious out with the password.

I can prevent the battery from discharging when I charge my car. I can also prevent the battery from charging from Solar.
Still can’t get grid charging to work yet.

If anyone is interested https://github.com/wills106/homeassistant-config/blob/master/packages/solax.yaml

in the SolaxModbus.py change the topline to

from pymodbus.factory import ClientDecoder
from pymodbus.client.asynchronous.twisted import ModbusClientProtocol
from pymodbus.framer.rtu_framer import ModbusRtuFramer
from twisted.internet import defer, reactor, protocol
from twisted.web.client import Agent, readBody