Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions MMM-SolarEdge.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Module.register("MMM-SolarEdge",{
// Logging appears in Chrome developer tools console
Log.info("Starting module: " + this.name);

this.titles = ["Current Power:", "Daily Energy:", "Last Month:", "Last Year:", "Lifetime Energy:"];
this.titles = ["Current Power:", "Current Load:", "Feed to Grid:", "Daily Energy:", "Last Month:", "Last Year:", "Lifetime Energy:"];
this.suffixes = ["Watts", "kWh", "kWh", "kWh", "MWh"];
this.results = ["Loading", "Loading", "Loading", "Loading", "Loading"];
this.results = ["Loading", "Loading", "Loading", "Loading", "Loading", "Loading", "Loading"];
this.loaded = false;
this.getSolarData();

Expand Down Expand Up @@ -61,13 +61,17 @@ Module.register("MMM-SolarEdge",{
} else {
this.results[0] = currentPower + " Watts";
}
this.results[1] = (payload.overview.lastDayData.energy / 1000).toFixed(2) + " kWh";
this.results[2] = (payload.overview.lastMonthData.energy / 1000).toFixed(2) + " kWh";
this.results[3] = (payload.overview.lastYearData.energy / 1000).toFixed(2) + " kWh";
this.results[4] = (payload.overview.lifeTimeData.energy / 1000000).toFixed(2) + " MWh";
this.results[3] = (payload.overview.lastDayData.energy / 1000).toFixed(2) + " kWh";
this.results[4] = (payload.overview.lastMonthData.energy / 1000).toFixed(2) + " kWh";
this.results[5] = (payload.overview.lastYearData.energy / 1000).toFixed(2) + " kWh";
this.results[6] = (payload.overview.lifeTimeData.energy / 1000000).toFixed(2) + " MWh";
this.loaded = true;
this.updateDom(1000);
}
if(notification === "POWER_FLOW") {
this.results[1] = (payload.siteCurrentPowerFlow.LOAD.currentPower).toFixed(2) + " kWh";
this.results[2] = (payload.siteCurrentPowerFlow.GRID.currentPower).toFixed(2) + " kWh";
}
},

// Override dom generator.
Expand Down Expand Up @@ -112,7 +116,7 @@ Module.register("MMM-SolarEdge",{

titleTr.innerHTML = this.titles[i];
// dataTr.innerHTML = this.results[i] + " " + this.suffixes[i];
dataTr.innerHTML = this.results[i];
dataTr.innerHTML = this.results[i];
titleTr.className += " medium regular bright";
dataTr.classname += " medium light normal";

Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ A Solar Module for MagicMirror2 designed to integrate with a SolarEdge System
1. Clone repo into MagicMirror/modules directory
2. Get a SolarEdge API key and authorize your application (instructions below).
3. Create an entry in 'config/config.js' with your API Key, SiteID, and any config options.
4. If the module does start with an error ` code: 'MODULE_NOT_FOUND',`it might be necessary to run `npm install request`

**Example:**
```
{
module: 'MMM-SolarEdge',
position: 'bottom_left',
config: {
apiKey: "################################", //Requires your own API Key
siteId: "12345", //SolarEdge site ID
}
position: 'bottom_left',
config: {
apiKey: "################################", //Requires your own API Key
siteId: "12345", //SolarEdge site ID
}
},
```
**Note:** Only enter your API Key in the `config.js` file. Your API Key is yours alone, _do not_ post or use it elsewhere.
Expand All @@ -26,8 +27,8 @@ A Solar Module for MagicMirror2 designed to integrate with a SolarEdge System
![alt text](https://github.com/bertieuk/MMM-SolarEdge/blob/master/SolarEdge.png "Example")

## Optional Config
| **Option** | **Description** |
| --- | --- |
| **Option** | **Description** |
| ------------- | ---------------------------------------------------------------------------------------------- |
| `basicHeader` | Set to `true` to substitute the 'Solar PV' text and graphic for the default MagicMirror header |

## API Key
Expand Down
10 changes: 10 additions & 0 deletions node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ module.exports = NodeHelper.create({
self.sendSocketNotification("SOLAR_DATA", jsonData);
}
});

var powerFlowUrl = payload.config.url + payload.config.siteId + "/currentPowerFlow?api_key=" + payload.config.apiKey;
request(powerFlowUrl, function (error, response, body) {
if (!error && response.statusCode == 200) {
var jsonData = JSON.parse(body);
self.sendSocketNotification("POWER_FLOW", jsonData);
}
});
}


},
});