As part of a larger effort to get a better understanding of our energy consumption and production, I wanted to log the power generated by the photovoltaic installation in our house. We use a Solax system consisting of 8 solar panels, a Solax X1 inverter and the Solax Pocket Wifi 2.0 device. Via this manual I will explain how I got the data extracted. In the rest of the text I assume you have managed to setup the Solax Pocket Wifi system and are able to read out the unit via the SolaxCloud App.

Inverter in the network

The Pocket Wifi drive is installed on the Solax X1 inverter. It runs a local wireless network that you can connect to and set it up so that it is connected to your local wifi and the internet. This allows it to communicate to the Solax servers, so that you can then access this information via the SolaxCloud app.

The device itself has IP address 5.8.8.8 in its local network, but can have any local IP address within your local network after you have set it up. For example, 192.168.30.10. You can find the IP address of the device by logging into your router, and browsing for the connected devices there, or use an IP Scanner, such as Angry IP Scanner, to scan for the device. Alternatively, you can connect directly to the dongle (see the manual) and find the local IP. When you are connected to that local network directly, you can browse to http://5.8.8.8 to read the settings, including the local IP address that was assigned to the dongle by your DHCP server.

Aside: Because I do not trust any Internet-of-Things (IoT) device with access to my local network, I set it up so that it sits in its own virtual lan. This virtual lan is fully isolated from the rest of the network and only intra-VLAN communication is allowed. I think it is wise to do so, because the Solax Pocket WiFi 2.0 dongle is pretty much wide open. For example, the dongle has an open network, of which the password is in the SSID of the network itself. Most people do not change this password upon configuration, and this leaves a simple vulnerability to your network. Isolate it as much as you can to keep your other devices safe.

Connecting to the device directly

There is officially no support from Solax to talk to the device directly. You can use the Solax API and talk to the cloud environment as I will explain below.

You will need the IP-address of the inverter inside your own network and the serial number of the Pocket WiFi device. You can find the latter on the box of that the Pocket WiFi dongle came in, or on the sticker on the dongle itself. It uses the format “SW4TZYXXXXX”.

The dongle runs a little webserver inside and accept HTTP POST and GET commands to provide information back to the end-user. The response is in a JSON format that can be parsed easily using e.g. Python. You will find that if you try sending the required request to the device directly, that you will get an empty response. There will be no error, but not response either. The trick is to spoof the IP address by adding the HTTP header X-Forwarded-For: 5.8.8.8. (remember, this is the local IP address of the device) [1]. In essence this tells the Pocket Wifi dongle “I am sending this on behalf of 5.8.8.8, so ignore my actual IP”.

Once you are able to succesfully send the POST requests and get a response from the Pocket Wifi dongle, you will have to parse the JSON data that comes back. This data contains several named fields, such as “information”, “SN” and “type”. These fields contain meta-information on the inverter that we will not need to check on a regular basis. The interesting information is hidden in the “Data” field, which contains a long array of unnamed fields. What information is contained in this fields is mostly a mystery, but some of these fields can be decoded if you keep the Solax Cloud App open at the same time. You just have to match the numbers in the app, to the numbers in the array. User Doublet of the Home-Assistant community did this for the Solax X1 [3], but I have found other sources that this this for the other inverter types. It appears that the order of the data varies from model to model, and is probably related also to the number of supported phases on the inverter. The X1 supports only one phase, while the X3 supports three and likely spits out more information because of it. Your mileage may vary and you will probably have to do some reverse engineering yourself.

If you want this a try without writing any line of code, and you are running linux/unix/MacOS, you can use the curl command to send the HTTP request from a terminal.

curl -d "optType=ReadRealTimeData&pwd=SW4XXXXXXX" --header "X-Forwarded-For: 5.8.8.8" -X POST http://192.168.30.10

Below I’ve written a verbose version of some Python 3.x code to connect to the device, send the HTTP requests and parse the data. Because the inverter and thus also the dongle goes offline when the generated power of the array is too low, we will get connection errors at night. Therefore we need to catch some errors and ignore them if we want to run this 24/7.

import request    # Python library for sending HTTP requests

def solax_reader():
  # Address of the Solax inverter. 
  # Fill in the local ip address of the dongle here.
  inverter_address = 'http://192.168.30.10'
  
  # Fill in the serial number of the Pocket Wifi dongle here
  inverter_ID = "SW4XXXXXXX"
  
  # local ip address of the inverter
  inverter_IP = "5.8.8.8"
  
  # The payload of the POST request we are going to send to the dongle
  # it tells the dongle that we want the real-time data, and passes
  # the device serial number as the password.
  post_data = f"optType=ReadRealTimeData&pwd={inverter_ID}"
  
  # Loop until we interrupt the program
  while True:
  
    try:
      # Send the POST request to the dongle and store the response
      response = requests.post(inverter_address, 
                headers={"X-Forwarded-For" : inverter_IP}, 
                data=post_data, timeout = 3)
      # Store JSON data in API_Data 
      response_json = response.json()
      
      # Parse the information (Solax X1 format)
      # You may have to do some reverse engineering here
      # Yourself with the Solax Cloud app open for reference
      information = response_json["Information"]
      data = response_json["Data"]
      serial_number = response_json["SN"]
      inverter_type = response_json["type"]
      firmware_version = response_json["ver"]
      
      operation_modes = {0: "Waiting", 1: "Checking", 
      2: "Normal", 3: "Off", 4: "Permanent Fault", 
      5: "Updating", 6: "EPS Check", 7: "EPS Mode", 
      8: "Self Test", 9: "Idle", 10: "Standby"} 
      
      operation_mode = operation_modes[data[68]]
      
      inverter_nominal_power = information[0]
      inverter_nominal_power_unit = "kWh"
      
      dc_current = data[0]
      dc_current_unit = "A"
      
      dc_voltage = data[2]
      dc_voltage_unit = "V"
      
      ac_output_current = data[4]
      ac_output_current_unit = "A"
      
      ac_output_voltage = data[5]
      ac_output_voltage_unit = "V"
      
      ac_power = data[6]
      ac_power_unit = "W"
      
      daily_yield = data[8]
      daily_yield_unit = "kWh"
      
      total_energy = data[9]
      total_energy_unit = "kWh"
      
      dc_power = data[11]
      dc_power_unit = "W"
      
      ac_frequency = data[50]
      ac_frequency_unit = "Hz"
    except:
      # Something went wrong
      ac_power = 0
      dc_power = 0
      pass
    finally:
      print(f"  PV: {timestamp}, DC power: {dc_power} W, AC power: {ac_power} W")  
      
if __name__ == "__main__": 
  # If we are in the main process, run the solax_reader.
  solax_reader()  

Connecting via the Solax API

Solax provides an access point to their cloud environment, that allows you to perform less than 10 calls/minute with a maximum of 10,000 calls per day. Depending on your needs, this will be a simple system to setup if you already have the inverter connected to the internet anyway. Solax provides official support for this and have a manual available [2].

Connecting to the Solax API works similarly as connecting to the Weerlive API. I will not work it our further here. Use the example of the Weerlive API here to make your own version for the Solax Cloud API.

Bibliography

[1] User Markvan of the Home-Assistant Community, “SolaX inverter Wifi Reverse Proxy setup”, URL: https://community.home-assistant.io/t/solax-inverter-wifi-reverse-proxy-setup/347430/73, Accessed: 30 june 2024

[2] Solax Power, “Solax Cloud API for End-user”, URL: https://www.eu.solaxcloud.com/phoebus/resource/files/userGuide/Solax_API_for_End-user_V1.0.pdf, Accessed: 30 june 2024

[3] User Doublet of the Home-Assistant Community, “Solax X1 Boost Air Mini : local data”, URL: https://community.home-assistant.io/t/solax-x1-boost-air-mini-local-data/535197, Accessed: 30 june 2024

Back to Top