richardlevy / solis-cloud-scraper

Node script to scrape daily solar stats from Solis Cloud website and expose data locally via an easily accessible endpoint.
5 stars 3 forks source link

Solis Cloud Scraper

The Solis Cloud scraper does the following

The Solis Cloud Scraper requires node.js

Data scraped

The following data is made available

Installation

Scraping Data

To scrape data from the Solis Cloud website and expose via the endpoints, run the following command once all installation steps are complete

This will start the scraper on port 5561, perform an initial scrape and make the /data endpoint available. The port can be changed from the configuration.

Refreshing Scraped Data

To instruct the scraper to refresh the data (scrape again), call the /refresh endpoint

This endpoint is secured with basic authentication, with configuration in the scraper.properties file

Refreshing automatically

An optional refresh script is also provided. By default it will request a data refresh every 6 minutes between 6am and 11pm. This can be changed in the configuration.

To start the refresher run the command

Retrieving the scraped data

This data is made available at the following endpoints

Note /data and /v1/data are identical.

The endpoints are secured with basic authentication, with configuration in the scraper.properties file

V1 Endpoint(s)

The V1 (or just /data) endpoint returns all values as strings without any form of parsing. These are the values as they appear on the Solis website.

The response to this call will look like this:

{
   "totalYield":"5.4kWh",
   "currentGen":"0kW",
   "batteryCharge":"21%",
   "drawFromBattery":"0.079kW",
   "todaysCharging":"8kWh",
   "todaysDischarging":"10kWh",
   "todayFromGrid":"3.22kWh",
   "todayToGrid":"0.53kWh",
   "currentGridInOut":"0.249kW",
   "currentHouseDraw":"0.328kW",
   "totalHouseConsumption":"13.22kWh",
   "scrapeStartDurationMs":1668713753046,
   "scrapeEndTimeMs":1668713766326
}

V2 Endpoint

The V2 endpoint returns values appropriately typed. It will also return a negative value for currentBatteryUsage to indicate battery discharge and a negative value for currentGridUsage to indicate grid import.

The response to this call will look like this:

{
  "currentYield": 1.124,
  "currentYieldUnit": "kW",
  "currentBatteryCharge": 16,
  "currentBatteryChargeUnit": "%",
  "currentBatteryUsage": 0.021,
  "currentBatteryUsageUnit": "kW",
  "currentGridUsage": 0,
  "currentGridUsageUnit": "kW",
  "currentHouseConsumption": 1.103,
  "currentHouseConsumptionUnit": "kW",
  "todayYield": 1.3,
  "todayYieldUnit": "kWh",
  "todaysCharging": 3.4,
  "todaysChargingUnit": "kWh",
  "todaysDischarging": 3.4,
  "todaysDischargingUnit": "kWh",
  "todayGridImport": 2.2,
  "todayGridImportUnit": "kWh",
  "todayGridExport": 0.1,
  "todayGridExportUnit": "kWh",
  "stationCapacity": 5.175,
  "stationCapacityUnit": "kWp",
  "scrapeStartDurationMs": 1676370170785,
  "scrapeEndTimeMs": 1676370185058
}

You can use curl to check it's working properly using the command

Configuration

Configuration is held in the file scraper.properties which should be in the same folder as the scraper.js file.

Note that some properties are shared if running both index.js and refresher.js from the same location.

The following configuration values are required by the scraper.js script

The following configuration values are required by the refresher.js script

An example config looks like:

# Details for accessing solis cloud used by scraper.js
solis.url = https://soliscloud.com
solis.username = richs-email@gmail.com
solis.password = crazyPassw0rd!
solis.maxSelectorRetries = 5
service.port = 5561

# Authentication details shared by scraper.js and refresher.js
service.username = scrape-master
service.password = gimme-some-data

# Details to refresh the scraped data used by refresher.js
service.refresh.url = http://scraper.domain.com:5561/refresh
refresh.interval-mins = 6
refresh.start-hour = 6
refresh.end-hour = 23

Restrictions/Limitations