Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR IndexError : list index out of range #77

Open
Livingdead1989 opened this issue Nov 4, 2024 · 1 comment
Open

ERROR IndexError : list index out of range #77

Livingdead1989 opened this issue Nov 4, 2024 · 1 comment

Comments

@Livingdead1989
Copy link

I am using the container with multiple inverters (3), I can see that the cloud API is working but I am getting IndexError and no data within InfluxDB.

2024-11-04 09:36:07,996 ERROR IndexError : list index out of range
2024-11-04 09:36:07,997 INFO Next run is scheduled at 04/11/2024 09:41:00

Container - I get the same error if I set the Inverter ID to 2.

  scraper:
    image: gentleman1983/ginlong-solis-api-connector
    container_name: scraper
    networks:
      - solis
    environment:
      - LOG_LEVEL=DEBUG
      - SOLIS_CLOUD_API_KEY_ID=REMOVED
      - SOLIS_CLOUD_API_KEY_SECRET=REMOVED
      - SOLIS_CLOUD_API_URL=https://www.soliscloud.com
      - SOLIS_CLOUD_API_PORT=13333
      - SOLIS_CLOUD_API_INVERTER_ID=0
      - USE_INFLUX=true
      - INFLUX_DATABASE=REMOVED
      - INFLUX_SERVER=REMOVED
      - INFLUX_PORT=8086
      - INFLUX_USER=REMOVED
      - INFLUX_PASSWORD=REMOVED
      - INFLUX_MEASUREMENT=PV
      - USE_MQTT=false
      - TZ=Europe/London

Debug below

2024-11-04 09:36:07,
841 DEBUG Decoded content: {
    "success":true,
    "code":"0",
    "msg":"success",
    "data":{
        "inverterStatusVo":{
            "all":3,
            "normal":3,
            "fault":0,
            "offline":0,
            "mppt":0
        },
        "page":{
            "records":[
                {
                    "id":"ID NUMBER",
                    "sn":"SERIAL NUMBER",
                    "collectorSn":"SERIAL NUMBER",
                    "userId":"ID NUMBER",
                    "productModel":"0506",
                    "model":"0506",
                    "nationalStandards":"62",
                    "inverterSoftwareVersion":"330038",
                    "inverterSoftwareVersion2":"030000",
                    "dcInputType":1,
                    "acOutputType":1,
                    "name":"NAME",
                    "stationName":"NAME",
                    "stationType":1,
                    "stationId":"1298491919449296813",
                    "tag":"NAME",
                    "rs485ComAddr":"101",
                    "simFlowState":-5,
                    "power":10.000,
                    "power1":10000.0,
                    "powerStr":"kW",
                    "powerPercent":0.08,
                    "powerPercentStr":"8.00%",
                    "pac":0.800,
                    "pac1":800.000,
                    "pacStr":"kW",
                    "state":1,
                    "stateExceptionFlag":0,
                    "ivSupport":1,
                    "inverterConfig":"0",
                    "fullHour":0.08,
                    "totalFullHour":1149.6,
                    "maxDcBusTime":"1730712800504",
                    "maxUac":249.8,
                    "maxUacTime":"1718805199973",
                    "maxUpv":770.4,
                    "maxUpvTime":"1713544530524",
                    "timeZone":0.00,
                    "timeZoneStr":"(UTC+00:00)",
                    "timeZoneName":"(UTC+00:00) 都柏林,爱丁堡,伦敦,里斯本",
                    "dataTimestamp":"1730712800504",
                    "dataTimestampStr":"2024-11-04 09:33:20 (UTC+00:00)",
                    "fisTime":"1704296941698",
                    "fisTimeStr":"2024-01-03 15:49:01 (UTC+00:00)",
                    "fisGenerateTime":1707300653000,
                    "fisGenerateTimeStr":"2024-02-07 10:10:53 (UTC+00:00)",
                    "inverterMeterModel":1,
                    "updateShelfBeginTime":1684771200000,
                    "updateShelfEndTime":1842624000000,
                    "updateShelfEndTimeStr":"2028-05-23",
                    "updateShelfTime":"5",
                    "shelfState":"0",
                    "collectorId":"ID NUMBER",
                    "dispersionRate":0.0,
                    "currentState":"3",
                    "pow1":532.64,
                    "pow2":470.89,
                    "pow3":0.0,
                    "pow4":0.0,
                    "pow5":0.0,
                    "pow6":0.0,
                    "pow7":0.0,
                    "pow8":0.0,
                    "pow9":0.0,
                    "pow10":0.0,
                    "pow11":0.0,
                    "pow12":0.0,
                    "pow13":0.0,
                    "pow14":0.0,
                    "pow15":0.0,
                    "pow16":0.0,
                    "pow17":0.0,
                    "pow18":0.0,
                    "pow19":0.0,
                    "pow20":0.0,
                    "pow21":0.0,
                    "pow22":0.0,
                    "pow23":0.0,
                    "pow24":0.0,
                    "pow25":0.0,
                    "pow26":0.0,
                    "pow27":0.0,
                    "pow28":0.0,
                    "pow29":0.0,
                    "pow30":0.0,
                    "pow31":0.0,
                    "pow32":0.0,
                    "gridPurchasedTodayEnergy":0.000,
                    "gridPurchasedTodayEnergyStr":"kWh",
                    "gridSellTodayEnergy":0.000,
                    "gridSellTodayEnergyStr":"kWh",
                    "psumCalPec":"1",
                    "batteryPower":0.000,
                    "batteryPowerStr":"kW",
                    "batteryPowerPec":"1",
                    "batteryCapacitySoc":0.000,
                    "parallelStatus":0,
                    "parallelAddr":0,
                    "parallelPhase":0,
                    "parallelBattery":0,
                    "batteryTodayChargeEnergy":0.000,
                    "batteryTodayChargeEnergyStr":"kWh",
                    "batteryTotalChargeEnergy":0.000,
                    "batteryTotalChargeEnergyStr":"kWh",
                    "batteryTodayDischargeEnergy":0.000,
                    "batteryTodayDischargeEnergyStr":"kWh",
                    "batteryTotalDischargeEnergy":0.000,
                    "batteryTotalDischargeEnergyStr":"kWh",
                    "bypassLoadPower":0.000,
                    "bypassLoadPowerStr":"kW",
                    "backupTodayEnergy":0.000,
                    "backupTodayEnergyStr":"kWh",
                    "backupTotalEnergy":0.000,
                    "backupTotalEnergyStr":"kWh",
                    "familyLoadPower":0.000,
                    "familyLoadPowerStr":"kW",
                    "totalLoadPower":0.000,
                    "totalLoadPowerStr":"kW",
                    "homeLoadTodayEnergy":0.000,
                    "homeLoadTodayEnergyStr":"kWh",
                    "isS5":0,
                    "bypassAcOnoffSet":0.0,
                    "parallelOnoff01":0.000,
                    "parallelOnoff02":0.000,
                    "rfState":1,
                    "etoday1":0.800,
                    "etotal1":11496.000,
                    "etoday":0.800,
                    "etotal":11.496,
                    "psum":0.000,
                    "psumCal":0.800,
                    "offlineLongStr":"--",
                    "psumCalStr":"kW",
                    "etotalStr":"MWh",
                    "etodayStr":"kWh",
                    "psumStr":"kW"
                },    
                {
                    "id":"ID NUMBER",
                    "sn":"SERIAL NUMBER",
                    "collectorSn":"SERIAL NUMBER",
                    "userId":"ID NUMBER",
                    "productModel":"0506",
                    "model":"0506",
                    "nationalStandards":"62",
                    "inverterSoftwareVersion":"800038",
                    "inverterSoftwareVersion2":"140000",
                    "dcInputType":1,
                    "acOutputType":1,
                    "name":"NAME",
                    "stationName":"NAME",
                    "stationType":1,
                    "stationId":"1298491919449296813",
                    "tag":"NAME",
                    "rs485ComAddr":"101",
                    "simFlowState":-5,
                    "power":10.000,
                    "power1":10000.0,
                    "powerStr":"kW",
                    "powerPercent":0.074,
                    "powerPercentStr":"7.40%",
                    "pac":0.740,
                    "pac1":740.000,
                    "pacStr":"kW",
                    "state":1,
                    "stateExceptionFlag":0,
                    "ivSupport":1,
                    "inverterConfig":"0",
                    "fullHour":0.07,
                    "totalFullHour":962.4,
                    "maxDcBusTime":"1730712859832",
                    "maxUac":252.7,
                    "maxUacTime":"1718643789925",
                    "maxUpv":739.0,
                    "maxUpvTime":"1707728951064",
                    "timeZone":0.00,
                    "timeZoneStr":"(UTC+00:00)",
                    "timeZoneName":"(UTC+00:00) 都柏林,爱丁堡,伦敦,里斯本",
                    "dataTimestamp":"1730712859832",
                    "dataTimestampStr":"2024-11-04 09:34:19 (UTC+00:00)",
                    "fisTime":"1707300231746",
                    "fisTimeStr":"2024-02-07 10:03:51 (UTC+00:00)",
                    "fisGenerateTime":1707300232000,
                    "fisGenerateTimeStr":"2024-02-07 10:03:52 (UTC+00:00)",
                    "inverterMeterModel":1,
                    "updateShelfBeginTime":1684771200000,
                    "updateShelfEndTime":1842624000000,
                    "updateShelfEndTimeStr":"2028-05-23",
                    "updateShelfTime":"5",
                    "shelfState":"0",
                    "collectorId":"ID NUMBER",
                    "dispersionRate":0.0,
                    "currentState":"3",
                    "pow1":498.16,
                    "pow2":456.96,
                    "pow3":0.0,
                    "pow4":0.0,
                    "pow5":0.0,
                    "pow6":0.0,
                    "pow7":0.0,
                    "pow8":0.0,
                    "pow9":0.0,
                    "pow10":0.0,
                    "pow11":0.0,
                    "pow12":0.0,
                    "pow13":0.0,
                    "pow14":0.0,
                    "pow15":0.0,
                    "pow16":0.0,
                    "pow17":0.0,
                    "pow18":0.0,
                    "pow19":0.0,
                    "pow20":0.0,
                    "pow21":0.0,
                    "pow22":0.0,
                    "pow23":0.0,
                    "pow24":0.0,
                    "pow25":0.0,
                    "pow26":0.0,
                    "pow27":0.0,
                    "pow28":0.0,
                    "pow29":0.0,
                    "pow30":0.0,
                    "pow31":0.0,
                    "pow32":0.0,
                    "gridPurchasedTodayEnergy":0.000,
                    "gridPurchasedTodayEnergyStr":"kWh",
                    "gridSellTodayEnergy":0.000,
                    "gridSellTodayEnergyStr":"kWh",
                    "psumCalPec":"1",
                    "batteryPower":0.000,
                    "batteryPowerStr":"kW",
                    "batteryPowerPec":"1",
                    "batteryCapacitySoc":0.000,
                    "parallelStatus":0,
                    "parallelAddr":0,
                    "parallelPhase":0,
                    "parallelBattery":0,
                    "batteryTodayChargeEnergy":0.000,
                    "batteryTodayChargeEnergyStr":"kWh",
                    "batteryTotalChargeEnergy":0.000,
                    "batteryTotalChargeEnergyStr":"kWh",
                    "batteryTodayDischargeEnergy":0.000,
                    "batteryTodayDischargeEnergyStr":"kWh",
                    "batteryTotalDischargeEnergy":0.000,
                    "batteryTotalDischargeEnergyStr":"kWh",
                    "bypassLoadPower":0.000,
                    "bypassLoadPowerStr":"kW",
                    "backupTodayEnergy":0.000,
                    "backupTodayEnergyStr":"kWh",
                    "backupTotalEnergy":0.000,
                    "backupTotalEnergyStr":"kWh",
                    "familyLoadPower":0.000,
                    "familyLoadPowerStr":"kW",
                    "totalLoadPower":0.000,
                    "totalLoadPowerStr":"kW",
                    "homeLoadTodayEnergy":0.000,
                    "homeLoadTodayEnergyStr":"kWh",
                    "isS5":0,
                    "bypassAcOnoffSet":0.0,
                    "parallelOnoff01":0.000,
                    "parallelOnoff02":0.000,
                    "rfState":1,
                    "etoday1":0.700,
                    "etotal1":9624.000,
                    "etoday":0.700,
                    "etotal":9.624,
                    "psum":0.000,
                    "psumCal":0.740,
                    "offlineLongStr":"--",
                    "psumCalStr":"kW",
                    "etotalStr":"MWh",
                    "etodayStr":"kWh",
                    "psumStr":"kW"
                },
                {
                    "id":"ID NUMBER",
                    "sn":"SERIAL NUMBER",
                    "collectorSn":"SERIAL NUMBER",
                    "userId":"ID NUMBER",
                    "productModel":"D6",
                    "model":"D6",
                    "nationalStandards":"62",
                    "inverterSoftwareVersion":"0c0230",
                    "inverterSoftwareVersion2":"000000",
                    "dcInputType":7,
                    "acOutputType":3,
                    "name":"NAME",
                    "stationName":"NAME",
                    "stationType":1,
                    "stationId":"1298491919449296813",
                    "tag":"NAME",
                    "rs485ComAddr":"101",
                    "simFlowState":-5,
                    "power":36.000,
                    "power1":36000.0,
                    "powerStr":"kW",
                    "powerPercent":0.0656,
                    "powerPercentStr":"6.56%",
                    "pac":2.360,
                    "pac1":2360.000,
                    "pacStr":"kW",
                    "state":1,
                    "stateExceptionFlag":0,
                    "ivSupport":0,
                    "inverterConfig":"0",
                    "fullHour":0.07,
                    "totalFullHour":2582.86,
                    "maxDcBusTime":"1730712877688",
                    "maxUac":251.8,
                    "maxUacTime":"1712041657990",
                    "maxUpv":634.5,
                    "maxUpvTime":"1721199523506",
                    "timeZone":0.00,
                    "timeZoneStr":"(UTC+00:00)",
                    "timeZoneName":"(UTC+00:00) 都柏林,爱丁堡,伦敦,里斯本",
                    "dataTimestamp":"1730712877688",
                    "dataTimestampStr":"2024-11-04 09:34:37 (UTC+00:00)",
                    "fisTime":"1707300378221",
                    "fisTimeStr":"2024-02-07 10:06:18 (UTC+00:00)",
                    "fisGenerateTime":1707300378000,
                    "fisGenerateTimeStr":"2024-02-07 10:06:18 (UTC+00:00)",
                    "inverterMeterModel":1,
                    "updateShelfBeginTime":1648396800000,
                    "updateShelfEndTime":1806163200000,
                    "updateShelfEndTimeStr":"2027-03-28",
                    "updateShelfTime":"5",
                    "shelfState":"0",
                    "collectorId":"1306858901388153939",
                    "dispersionRate":22.98684541,
                    "currentState":"3",
                    "pow1":335.58,
                    "pow2":335.58,
                    "pow3":336.18,
                    "pow4":448.24,
                    "pow5":291.18,
                    "pow6":291.18,
                    "pow7":267.0,
                    "pow8":44.5,
                    "pow9":0.0,
                    "pow10":0.0,
                    "pow11":0.0,
                    "pow12":0.0,
                    "pow13":0.0,
                    "pow14":0.0,
                    "pow15":0.0,
                    "pow16":0.0,
                    "pow17":0.0,
                    "pow18":0.0,
                    "pow19":0.0,
                    "pow20":0.0,
                    "pow21":0.0,
                    "pow22":0.0,
                    "pow23":0.0,
                    "pow24":0.0,
                    "pow25":0.0,
                    "pow26":0.0,
                    "pow27":0.0,
                    "pow28":0.0,
                    "pow29":0.0,
                    "pow30":0.0,
                    "pow31":0.0,
                    "pow32":0.0,
                    "gridPurchasedTodayEnergy":0.000,
                    "gridPurchasedTodayEnergyStr":"kWh",
                    "gridSellTodayEnergy":0.000,
                    "gridSellTodayEnergyStr":"kWh",
                    "psumCalPec":"1",
                    "batteryPower":0.000,
                    "batteryPowerStr":"kW",
                    "batteryPowerPec":"1",
                    "batteryCapacitySoc":0.000,
                    "parallelStatus":0,
                    "parallelAddr":0,
                    "parallelPhase":0,
                    "parallelBattery":0,
                    "batteryTodayChargeEnergy":0.000,
                    "batteryTodayChargeEnergyStr":"kWh",
                    "batteryTotalChargeEnergy":0.000,
                    "batteryTotalChargeEnergyStr":"kWh",
                    "batteryTodayDischargeEnergy":0.000,
                    "batteryTodayDischargeEnergyStr":"kWh",
                    "batteryTotalDischargeEnergy":0.000,
                    "batteryTotalDischargeEnergyStr":"kWh",
                    "bypassLoadPower":0.000,
                    "bypassLoadPowerStr":"kW",
                    "backupTodayEnergy":0.000,
                    "backupTodayEnergyStr":"kWh",
                    "backupTotalEnergy":0.000,
                    "backupTotalEnergyStr":"kWh",
                    "familyLoadPower":0.000,
                    "familyLoadPowerStr":"kW",
                    "totalLoadPower":0.000,
                    "totalLoadPowerStr":"kW",
                    "homeLoadTodayEnergy":0.000,
                    "homeLoadTodayEnergyStr":"kWh",
                    "isS5":0,
                    "bypassAcOnoffSet":0.0,
                    "parallelOnoff01":0.000,
                    "parallelOnoff02":0.000,
                    "rfState":1,
                    "etoday1":2.500,
                    "etotal1":92983.000,
                    "etoday":2.500,
                    "etotal":92.983,
                    "psum":0.000,
                    "psumCal":2.360,
                    "offlineLongStr":"--",
                    "psumCalStr":"kW",
                    "etotalStr":"MWh",
                    "etodayStr":"kWh",
                    "psumStr":"kW"
                }
            ],
        "total":3,
        "size":20,
        "current":1,
        "pages":1
        },
    "mpptSwitch":0
    }
}

Please let me know if I can assist in finding a resolution.
Many thanks.

@oli99-nl
Copy link

I am having the same issue. I think the endpoints (and some fields) are not correct. With only one inverter this does not make a difference, but with two or more, one only gets the data for the first, and trying to accept the second gives the error.
This piece of code for get_inverte_ids() seems to work (I have renamed a number of variables in order to better reflect what purpose they serve):

def get_inverter_ids():
    body = '{"userid":"' + api_key_id + '"}'
    data_content = get_solis_cloud_data(endpoint_inverter_list, body)
    data_json = json.loads(data_content)["data"]["inverterStatusVo"]
    entries = data_json["all"]-1
    if device_id < 0:
        logging.error("'SOLIS_CLOUD_API_INVERTER_ID' has to be greater or equal to 0 " + \
                      "and lower than %s.", str(entries))
    if device_id > entries:
        logging.error("Your 'SOLIS_CLOUD_API_INVERTER_ID' (%s" + \
                      ") is larger than or equal to the available number of inverters (" + \
                      "%s). Please select a value between '0' and '%s'.", str(device_id),
                      str(entries), str(entries - 1))
    data_content = get_solis_cloud_data(endpoint_inverter_list, body)
    data_json = json.loads(data_content)["data"]["page"]["records"]
    inverter_info = data_json[device_id]
    inverter_id = inverter_info["id"]

    body = '{"id":"' + inverter_id + '"}'
    logging.debug("get_inverter_ids: id(inverter_id):" + inverter_id)
    data_content = get_solis_cloud_data(endpoint_inverter_detail, body)
    inverter_info = json.loads(data_content)["data"]            #["page"]["records"][device_id]
    return inverter_info["id"], inverter_info["sn"]

Invoking get_solis_cloud_data(endpoint_inverter_detail, body) with the id of the inverter gives only one record with the inverter_id and its corresponding serial number.
I haven't fully verified the correctness of the data retrieved yet.
The code pulls a lot of information from the cloud, and I am not sure whether this could be streamlined.

When running two containers, one with SOLIS_CLOUD_API_INVERTER_ID="0" and one with SOLIS_CLOUD_API_INVERTER_ID="1", I am getting data from each of the two inverters, and two data sets with different inverter IDs.

In view of this, the name get_inverter_ids() seems to be somewhat misleading because what the code does is to look up the ID and serial number of the inverter identified by SOLIS_CLOUD_API_INVERTER_ID (0, 1, 2, 3, ...).

Maybe someone could merge the fix into the container, provided that it can be confirmed that it is OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants