Skip to content

Commit

Permalink
Merge pull request #37 from Gentleman1983/24-error-indexerror-list-in…
Browse files Browse the repository at this point in the history
…dex-out-of-range
  • Loading branch information
TobiO79 authored Jun 16, 2023
2 parents 4fc8090 + 849048c commit 905bb2b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 32 deletions.
62 changes: 31 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,37 @@ and just vary the deviceId in the environment variables.

### Environment variables

| Environment variable | Required | Description | Default value |
|------------------------------------------------|----------|---------------------------------------------------------------------------------------------------------------------------------------|------------------------------|
| LOG_LEVEL | No | Logging level (ERROR, INFO, DEBUG) | `INFO` |
| SOLIS_CLOUD_API_KEY_ID | Yes | API Key ID | *empty* |
| SOLIS_CLOUD_API_KEY_SECRET | Yes | API Key Secret | *empty* |
| SOLIS_CLOUD_API_URL | No | API URL | `https://www.soliscloud.com` |
| SOLIS_CLOUD_API_PORT | No | API Port | `13333` |
| SOLIS_CLOUD_API_INVERTER_ID | No | Ginlong Solis device ID<br/>(only required if auto-detect fails or if you have more than one device) | *empty* |
| SOLIS_CLOUD_API_OVERRIDE_SINGLE_PHASE_INVERTER | No | Override to provide correct calculations for single phase inverters if Solis Cloud API provides wrong data. Simply switch to `true` | *empty* |
| USE_INFLUX | No | Set to true if you want to use InfluxDB as output | `false` |
| INFLUX_DATABASE | No | InfluxDB DB name | `influxdb` |
| INFLUX_SERVER | No | InfluxDB server | `localhost` |
| INFLUX_PORT | No | InfluxDB server port | `8086` |
| INFLUX_USER | No | InfluxDB User | *empty* |
| INFLUX_PASSWORD | No | InfluxDB Password | *empty* |
| INFLUX_MEASUREMENT | No | InfluxDB measurement type | `PV` |
| USE_PVOUTPUT | No | Set to true if you want to use PvOutput as output | `false` |
| PVOUTPUT_API_KEY | No | PvOutput API key | *empty* |
| PVOUTPUT_SYSTEM_ID | No | PvOutput system ID | *empty* |
| PVOUTPUT_EXTENDED_V7 | No | Set Extendet Output v7 to this API Key from inverterDetail (leave blank if not donated) | *empty* |
| PVOUTPUT_EXTENDED_V8 | No | Set Extendet Output v8 to this API Key from inverterDetail (leave blank if not donated) | *empty* |
| PVOUTPUT_EXTENDED_V9 | No | Set Extendet Output v9 to this API Key from inverterDetail (leave blank if not donated) | *empty* |
| PVOUTPUT_EXTENDED_V10 | No | Set Extendet Output v10 to this API Key from inverterDetail (leave blank if not donated) | *empty* |
| PVOUTPUT_EXTENDED_V11 | No | Set Extendet Output v11 to this API Key from inverterDetail (leave blank if not donated) | *empty* |
| PVOUTPUT_EXTENDED_V12 | No | Set Extendet Output v12 to this API Key from inverterDetail (leave blank if not donated) | *empty* |
| USE_MQTT | No | Set to true if you want to use MQTT as output | `false` |
| MQTT_CLIENT_ID | No | MQTT client ID | `pv` |
| MQTT_SERVER | No | MQTT server | `localhost` |
| MQTT_USERNAME | No | MQTT username | *empty* |
| MQTT_PASSWORD | No | MQTT password | *empty* |
| TZ | No | TimeZone e.g Australia/Sydney | *empty* |
| Environment variable | Required | Description | Default value |
|------------------------------------------------|----------|-------------------------------------------------------------------------------------------------------------------------------------|------------------------------|
| LOG_LEVEL | No | Logging level (ERROR, INFO, DEBUG) | `INFO` |
| SOLIS_CLOUD_API_KEY_ID | Yes | API Key ID | *empty* |
| SOLIS_CLOUD_API_KEY_SECRET | Yes | API Key Secret | *empty* |
| SOLIS_CLOUD_API_URL | No | API URL | `https://www.soliscloud.com` |
| SOLIS_CLOUD_API_PORT | No | API Port | `13333` |
| SOLIS_CLOUD_API_INVERTER_ID | No | Ginlong Solis device ID<br/>(only required if auto-detect fails or if you have more than one device) | `0` or *empty* |
| SOLIS_CLOUD_API_OVERRIDE_SINGLE_PHASE_INVERTER | No | Override to provide correct calculations for single phase inverters if Solis Cloud API provides wrong data. Simply switch to `true` | *empty* |
| USE_INFLUX | No | Set to true if you want to use InfluxDB as output | `false` |
| INFLUX_DATABASE | No | InfluxDB DB name | `influxdb` |
| INFLUX_SERVER | No | InfluxDB server | `localhost` |
| INFLUX_PORT | No | InfluxDB server port | `8086` |
| INFLUX_USER | No | InfluxDB User | *empty* |
| INFLUX_PASSWORD | No | InfluxDB Password | *empty* |
| INFLUX_MEASUREMENT | No | InfluxDB measurement type | `PV` |
| USE_PVOUTPUT | No | Set to true if you want to use PvOutput as output | `false` |
| PVOUTPUT_API_KEY | No | PvOutput API key | *empty* |
| PVOUTPUT_SYSTEM_ID | No | PvOutput system ID | *empty* |
| PVOUTPUT_EXTENDED_V7 | No | Set Extendet Output v7 to this API Key from inverterDetail (leave blank if not donated) | *empty* |
| PVOUTPUT_EXTENDED_V8 | No | Set Extendet Output v8 to this API Key from inverterDetail (leave blank if not donated) | *empty* |
| PVOUTPUT_EXTENDED_V9 | No | Set Extendet Output v9 to this API Key from inverterDetail (leave blank if not donated) | *empty* |
| PVOUTPUT_EXTENDED_V10 | No | Set Extendet Output v10 to this API Key from inverterDetail (leave blank if not donated) | *empty* |
| PVOUTPUT_EXTENDED_V11 | No | Set Extendet Output v11 to this API Key from inverterDetail (leave blank if not donated) | *empty* |
| PVOUTPUT_EXTENDED_V12 | No | Set Extendet Output v12 to this API Key from inverterDetail (leave blank if not donated) | *empty* |
| USE_MQTT | No | Set to true if you want to use MQTT as output | `false` |
| MQTT_CLIENT_ID | No | MQTT client ID | `pv` |
| MQTT_SERVER | No | MQTT server | `localhost` |
| MQTT_USERNAME | No | MQTT username | *empty* |
| MQTT_PASSWORD | No | MQTT password | *empty* |
| TZ | No | TimeZone e.g Australia/Sydney | *empty* |

Note that if you have more than 1 device - then it is not readily apparent where to get the Device ID
In that case - setup the script, and set `LOG_LEVEL` to `DEBUG`, then view the logs and search for deviceId -
Expand Down
12 changes: 11 additions & 1 deletion ginlong_solis_api_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,17 @@ def get_solis_cloud_data(url_part, data) -> str:
def get_inverter_ids():
body = '{"userid":"' + api_key_id + '"}'
data_content = get_solis_cloud_data(endpoint_station_list, body)
station_info = json.loads(data_content)["data"]["page"]["records"][0]
data_json = json.loads(data_content)["data"]["page"]["records"]
entries = len(data_json)
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))
station_info = data_json[device_id]
station_id = station_info["id"]

body = '{"stationId":"' + station_id + '"}'
Expand Down

0 comments on commit 905bb2b

Please sign in to comment.