Skip to main content

Overview Zendure Schedule Management

Background

The Zendure App “net-zero” option did not work properly because the P1 data lags by up to 20 seconds. A datagram is sent every second, but the values are delayed too much. As far as I have been able to determine, this is caused by the smart meter, the Landis+Gyr meter.

In addition, I want to be able to combine the different modes from the Zendure app myself. Ultimately, I want more control over charging and discharging the battery.

Local control

For this I use an old Raspberry Pi 2. What you use does not matter, as long as it is on the same network as the battery and the P1 meter. The Python script reads a charge/discharge schedule and acts according to this schedule. The schedule defines when the battery should charge or discharge and at how many watts. In addition, I added two special modes: NetZero and NetZero+.

NetZero is net-zero and attempts to compensate your consumption by discharging the battery.

NetZero+ is net-zero, but only for charging. So all electricity that would otherwise be fed back into the grid is stored.

Managing the schedule

The schedule is stored in JSON format and can be accessed via an API. The schedule can be hosted on any web server (PHP, CSS, JS) and is modified and/or retrieved via API calls. This ensures that the schedule management component can be hosted on any server.

Because we use a standard JSON schema, we can manage and/or modify the schedule using different tools.

Automation System

Within the local LAN there is a simple computer such as a Raspberry Pi. This reads the schedule and controls the Zendure battery.

The automaiton script is written in Python and run on any system supporting Python.

The automation system makes 6 different types of API calls:

  1. Control the Zendure battery via LAN (write)
    Set charge/discharge level or set the battery in stand-by mode.
    This is done via the LAN access to the local API port of teh battery.
  2. Read Zendure battery status via LAN
    Checks the level of charge in the battery. Mainly used for keeping the charge in between the set limts. These limits are set in the config of the application.
  3. Read P1 meter data via LAN
    Needs to know the home usage in order to run NetZero (or NetZero+)
  4. Store data
    Store P1 and Zendure data (read by 2 and 3) via API to the main web server on the Internet.
  5. Fetch charge schedule
    Every 5 minutes the schedule is loaded from the Internet. 
  6. Post automation status updates
    Status, show the last charge/discharge command and a timestamp to indicate that the process is still alive.

The autoamtion system is run via a bash script. This script checks if we are already running, if not we start. This pricess is started via CRONTAB each hour. So when the system crashed it will be restarted on teh top of every hour.

ToDo: ipnumers are now statical defined in the config. THey should be discovered on the LAN.