misc/soliscloud-inverter-control#1: Charge Timings Format



Issue Information

Issue Type: issue
Status: closed
Reported By: btasker
Assigned To: btasker

Milestone: PoC
Created: 31-Dec-24 16:29



Description

The manufacturer docs say that we need to request cid 103 from /v2/api/atRead

When I run the read command, this results in the following output (pretty printed for convenience)

{
  "msg": "success",
  "code": "0",
  "data": {
    "msg": "20,55,00:00-06:00,00:00-00:00,0,0,12:00-16:00,00:00-00:00,0,0,00:00-00:00,00:00-00:00",
    "yuanzhi": "20,55,00:00-06:00,00:00-00:00,0,0,12:00-16:00,00:00-00:00,0,0,00:00-00:00,00:00-00:00",
    "command": "AT+TEST=GIN485:01 03 a8 85 00 1e f4 4b",
    "needLoop": "false"
  },
  "orderId": "1735662097308_195",
  "time": "1735662097308"
}

This differs to the value that the docs say we have to post to change values:

[{"name": "Charge current 1", "value": "1", "type": "1", "unit": "A", "min":0, "max":100},{"name": "Discharge current 1", "value": "1", "type": "1", "unit": "A", "min":0," max":100},{"name": "Charge time 1", "name1": "Start time", "name2": "End time", "value": "1", "type": "0"},{"name": "Discharge time 1", "name1": "Start time", "name2": "End time"," value": "1", "type": "0"},{"name": "Charge current 2", "value": "1", "type": "1", "unit": "A", "min":0, "max":100},{"name": "Discharge current 2", "value": "1", "type": "1" , "unit": "A", "min":0, "max":100},{"name": "Charge Time 2", "name1": "Start Time", "name2": "End Time", "value": "1", "type": "0"},{"name": "Discharge Time 2", "name1": "Start Time ", "name2": "End time", "value": "1", "type": "0"},{"name": "Charge current 3", "value": "1", "type": "1", "unit": "A", "min":0, "max":100},{"name": "Discharge current 3"," value": "1", "type": "1", "unit": "A", "min":0, "max":100},{"name": "Charge time 3", "name1": "Start time", "name2": "End time", "value": "1", "type": "0"},{"name". "Discharge Time 3", "name1": "Start Time", "name2": "End Time", "value": "1", "type": "0"}]

The break down into individual times and currents is reminscent of the old control interface - earlier in 2024 Solis revised it and current is only defined once now.

The docs spreadsheet also has a sheet called Demo with an example that's noted as

For hybrid inverter, Set the charging current to 50A & discharging current to 20A, also set the battery force charge at 2:00-3:00, battery force discharge at 3:00-4:00.

The example payload looks more like the one that I've just retrieved:

{
    "cid":"103",
    "inverterSn":"xxxx",
    "value":"50,20,02:00-03:00,03:00-04:00,0,0,00:00-00:00,00:00-00:00,0,0,00:00-00:00,00:00-00:00",
    "language":"2"
}

An additional note is given

Notice:1. Please set the working mode first. Voltage and current settings can only be set once, for all time periods

So, although there appears to be slots for current before other timeslots, those presumably aren't honoured.

I think we need to stick with that format and ignore the API doc



Toggle State Changes

Activity


assigned to @btasker

verified

mentioned in commit 526b322ced31f4efc53b43566d0a395a292e9252

Commit: 526b322ced31f4efc53b43566d0a395a292e9252 
Author: B Tasker                            
                            
Date: 2024-12-31T16:36:39.000+00:00 

Message

feat: process the read response according to spec (misc/soliscloud-inverter-control#1)

+24 -2 (26 lines changed)

OK, I've been able to change the value

 res = soliscloud.readChargeDischargeSchedule(config['inverter'])

# Testing
res['slots'][2][0] = "19:00-19:30"

res2 = soliscloud.setChargeDischargeTimings(config['inverter'], res)

When I logged into Soliscloud to check, it had changed:

image

That period can be disabled by setting it back to 00:00-00:00

I'll commit the current state, but it's not particularly intuitive to use at the moment, I think we should probably abstract out to a dict so that things can be labelled charge and discharge

verified

mentioned in commit a9a8070732d4186f29e3ef108f0bd840a899b5a4

Commit: a9a8070732d4186f29e3ef108f0bd840a899b5a4 
Author: B Tasker                            
                            
Date: 2024-12-31T17:48:46.000+00:00 

Message

chore: make timings object more intuitive (misc/soliscloud-inverter-control#1)

+75 -14 (89 lines changed)
verified

mentioned in commit 5249849b2f89b06fa6de58e8c6c5a34528128536

Commit: 5249849b2f89b06fa6de58e8c6c5a34528128536 
Author: B Tasker                            
                            
Date: 2024-12-31T17:54:00.000+00:00 

Message

fix: force type of currents (misc/soliscloud-inverter-control#1)

The API requires a string, but it'd be easy to forget and pass an int

+2 -2 (4 lines changed)

OK, the format of the timings dict has been made more intuitive.

It can be created as follows:

timings = {
  "charge_current" : "20",
  "discharge_current" : "55",
  "slots" : { 
     "slot1": { "charge": "00:00-01:00", "discharge": "02:00-03:00"},
     "slot2": { "charge": "12:00-21:00", "discharge": "00:00-00:00"},
     "slot3": { "charge": "00:00-00:00", "discharge": "00:00-00:00"}
  }
}

Timings must be format HH:MM-HH:MM. All slots are mandatory but a value of 00:00-00:00 means nothing will happen/change.

charge_current and discharge_current should be provided as strings, but will be caste to strings by the class.

There are now three class methods:

  • readChargeDischargeSchedule(sn) Read timings information from the inverter with serial number sn (will return a timings dict)
  • setChargeDischargeTimings(sn, timings) Set timings information for the inverter with serial number sn
  • validateTimingsObj(timings) Validate a timings dict (is called automatically by setChargeDischargeTimings)