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.

Schedule

heThe base of the systesystem is builsbuilt around a  schedule. The schedule is a JSON file with keys that define a date/time and a value that defines a chaerge/charge/discharge action.

There is a system, tthe he schedule manager, that is used to manualmanually mamagemanage the system by changing the entries in the JSON. This is the main GUI. At thisthe moemntmoment there'sthere is both a mobile-mobile and a desktop version.

The actual battery manager is the system that reads the schedule and uses thisit to managecontrol the battery,battery.

Because we use a standard JSON schema, we can manage and/or modify the schedule using different tools. We can also create smart systems that willautomatically create or alter the schedule.

Battery Manager

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 yourfor household consumption by discharging the battery.

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

Automation System

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

The automaitonautomation script is written in Python and can run on any system supportingthat supports Python.

API Calls used by the Automation System

The automation system makes 6 different types of API calls:

  1. Control the Zendure battery via LAN (write)
    Set the charge/discharge level or setput the battery ininto stand-bystandby mode.
    This is done via the LAN access to the local API port of tehthe battery.
  2. Read Zendure battery status via LAN
    Checks the levelstate of charge inof the battery. MainlyThis is mainly used forto keepingkeep the charge in betweenwithin the setconfigured limts.limits. These limits are setdefined in the configapplication of the application.configuration.
  3. Read P1 meter data via LAN
    NeedsThis is required to knowdetermine thehousehold homepower usage in order to run NetZero (or NetZero+).
  4. Store data
    Store P1 and Zendure data (read by steps 2 and 3) via an API toon 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,Posts showstatus information, including the last charge/discharge command and a timestamptimestamp, to indicate that the process is still alive.running.

The autoamtionAutomation systemSystem is runstarted via a bashBash script. This script checks ifwhether wethe aresystem is already running,running; if notnot, weit start.starts it. This pricessprocess is startedtriggered via CRONTAB eachevery hour. So whenIf the system crashedcrashes, it will be restarted onat tehthe top of everythe next hour.

ToDo: ipnumersIP addresses are nowcurrently staticalstatically defined in the config.configuration. THeyThey should be discovered automatically on the LAN.

The Automation System uses P1 data,data. thisThis can become from any systemsystem, as long as we can read the actual Powerpower Usage.usage can be read. The codedefault as configured by defaultconfiguration uses the HomeWizard P1 meter from Home Wizzard. meter.

Smooth charging/discharging

Because of the delay in the P1 metermeter, the control system suesuses a smoothsmoothing algorithm. It willonly oly pollpolls the actual honehousehold usage once every 20 seconds and itlimits will limitsudden changes. ItBoth willthe has a configurablemaximum charge/discharge limitrate and athe configurablemaximum change limit.rate are configurable. This will makemakes the battery less agile.responsive. The drawback is that weconsumption areis not completelyperfectly gettingzero. aIn zero usage, but in practivepractice, this means that the usage is maybe +/- 50 wattHourresults in a worsedeviation caseof scenario,approximately ±50 watt-hours in the worst case, and on average Icloser think it is more liketo 25 wattHour.watt-hours.

Schedule Manager

The schedule is stored in JSON format and can be accessed via an API. The scheduleIt 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.

The schedule manager hasincludes a Dynamicdynamic Priceprice graph for the electroctyelectricity prices for today and tomorrowtomorrow, when available. These prices are collectedretrieved via a public API.API The prices areand cached in JSON.JSON format.

Schedule (JSON)

Example schedule:

{
    "********0000": 0,
    "********1200": "netzero+",
    "********1500": 0,
    "202601241700": "netzero",
    "202601241900": -100,
    "202601242100": 0
}

The JSON key represents a date and time and may contain wildcards (*).

The value is either a number (negative, zero, or positive), netzero, or netzero+.

A non-wildcard entry takes precedence over a wildcard entry.

In the example above, every day at 12:00 the system starts storing solar energy that would otherwise be exported to the grid, and stops at 15:00. On January 24th at 17:00, the system starts compensating household usage to achieve net-zero. At 19:00 it starts discharging at 100 watts, and at 21:00 all charging and discharging stops.

Installation 

stepStep 1 

Install the Automation systemSystem and use a simple fixed schedule that you can editbe edited by directly changingmodifying the JSON.JSON file.