- Register an account with Solis Cloud and raise a ticket for API access. Within 2 days they will provide the access for it. Learn more
- Go to SolisCloud API Manage.
- Activate API management and agree with the usage conditions and do the rest.
- Note down the API Key, API Secret and URL in a notepad and keep it safe for later.
-
Install Docker Engine. In my case it is running on top of Debian (Proxmox container). For more
-
Update apt repository and upgrade packages if available:
sudo apt update && sudo apt upgrade -y -
Install Portainer for ease of use. For more
-
Open Portainer & Deploy a New Container
- Log in to Portainer.
- Go to Containers → Add Container.
- Set Name:
influxdb. - In Image, enter:
influxdb:latest
-
Configure Ports
In "Advanced container settings" → "Network", add:
- Host Port:
8086 - Container Port:
8086
- Host Port:
-
Set Up Persistent Storage (Recommended)
In Volumes, create a bind mount:
- Container Path:
/var/lib/influxdb2 - Host Path:
/path/to/influxdb/data(choose a directory on your VM)
- Container Path:
-
Add Environment Variables (for InfluxDB 2.x)
In the "Env" tab, add:
DOCKER_INFLUXDB_INIT_MODE→setupDOCKER_INFLUXDB_INIT_USERNAME→adminDOCKER_INFLUXDB_INIT_PASSWORD→yourpasswordDOCKER_INFLUXDB_INIT_ORG→yourorgDOCKER_INFLUXDB_INIT_BUCKET→yourbucketDOCKER_INFLUXDB_INIT_RETENTION→30d(optional, sets retention policy to 30 days)
-
Deploy the Container
Click Deploy the container and wait for it to start.
-
Access InfluxDB Web UI
- Open your browser and go to:
http://<your_vm_ip>:8086 - Log in with the username and password you set.
- Open your browser and go to:
-
Navigate to
Load Data > API Tokens > Generate API Token > Custom API Token > "Name the token"> Buckets > "Select appropriate bucket" > "give read and write access". Click "Generate". Copy the generated token into a notepad.
Note: Don't use the "Copy to Clipboard" button to copy the token. You may face issues later. Just use the cursor to copy.
- Check if python3 is installed in your Docker Engine:
python3 --versionIf this returns value like '3.xx.x' then the python interpreter is available else install itsudo apt install python3 python3-pip - If you get
error: externally-managed-environmentrefer Jeff Geerling blog -
- Create a directory in
/homecalledsolis_logging(you may keep anything). Copyrequirements.txt,solis_logging.py,secret.jsonandDockerfile.
- Create a directory in
- Install dependencies and libraries using requirements.txt:
pip install -r requirements.txt - Modify the Dockerfile with appropriate Python version, python script name (if filename is changed) and working directory.
- Modify secret.json with appropriate details that you copied earlier.
- Modify solis_logging.py with appropriate
TZ,START_TIME,END_TIMEandrefresh_time. - Comment / Uncomment necessary parameters. You may even add / remove as per your use case.
- Run the script within docker and check whether it is able to add the data retrieved from Solis Cloud to the InfluxDB database.
python3 solis_logging.py - If the script is successfully adding the data to InfluxDB, then proceed to configure Grafana for data visualization.
- First, create a Docker network (if you haven't already):
docker network create monitoring - In portainer, click
Container>Add ContainerName:grafanaImage:grafana/grafana-oss:latestPort mapping:3000:3000Network:monitoringVolume: Create a new volume/var/lib/grafana - After containers are running:
- Access Grafana at http://your-ip:3000
- Default login: admin/admin
- You'll be prompted to change password
- To connect InfluxDB to Grafana:
- Go to Configuration > Data Sources
- Add data source > Select InfluxDB
- Set these fields:
URL:
http://{your_influxdb_IP_address}:8086Organization:yourorgToken:token_that_you_generated_earlierDefault Bucket:yourbucketVersion: Flux - Click "Save & Test"
- Go to
Dashboard>New>New Dashboard>Add Visualization. Select your InfluxDB bucket as data source. - Now you can create dashboards in Grafana to visualize your solar data. Some example queries to get you started:
from(bucket: "solar_metrics")
|> range(start: -24h)
|> filter(fn: (r) => r._measurement == "station_metrics")
|> filter(fn: (r) => r._field == "power")
Here 'solar_metrics' is taken as an example bucket name, 'station_metrics' as example point name and 'power' as example field name.
-
Alternatively you can also import [[solis_grafana.json]] and set up the visualization.
-
Go to
Dashboard>New>Import Dashboard. Selectsolis_grafana.jsonfile . Choose appropriate dashboard name, and InfluxDB source. -
Remember to change UID with appropriate values (some random characters+numbers except special values).
-
Click
Import
You will now be able to visualize the data from your InfluxDB.
In order to containerize and automate the python script to run in background, we need to do a few more steps.
- Log into the machine running Docker and
cdinto the directory where the python script resides. - Get the Dockerfile, and requirements.txt and modify it accordingly.
- Run these commands:
docker build -t solis-logging-app .solis-logging-appis just the container name. Be sure to correct mention the python script name in the Dockerfile..Specifies that the Dockerfile is in the current directory.
docker run -d --name solis_logging solis-logging-app--name solis_logging→ Assigns the container a custom name:solis_logging(instead of a random name).solis-logging-app→ Uses thesolis-logging-appimage to create the container.
- That's it. You will now be able to run the python script automatically in the background. Just make sure to change
Restart PoliciesfromNonetoUnless Stopped.
