Skip to content

Commit

Permalink
Fixed hourlycount to actually work
Browse files Browse the repository at this point in the history
  • Loading branch information
jclarke0000 committed Mar 8, 2018
1 parent 40fcb53 commit 522ceb4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
27 changes: 20 additions & 7 deletions MMM-MyWeather.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,12 @@ Module.register("MMM-MyWeather", {
}

if (this.config.hourly == 1) {
for (f in this.forecast) {
forecast = this.hourlyforecast[f * this.config.hourlyinterval];
// for (f in this.forecast) {
// forecast = this.hourlyforecast[f * this.config.hourlyinterval];

var counter = 0;
for (var i = Number(this.config.hourlyinterval) - 1; i < this.hourlyforecast.length; i += Number(this.config.hourlyinterval)) {
forecast = this.hourlyforecast[i];

row = document.createElement("tr");
table.appendChild(row);
Expand Down Expand Up @@ -431,7 +435,8 @@ Module.register("MMM-MyWeather", {
mmCell.className = "align-right mm";
row.appendChild(mmCell);

if (f > this.config.hourlycount) {
counter = counter + 1;
if (counter == Number(this.config.hourlycount)) {
break;
}

Expand Down Expand Up @@ -639,8 +644,13 @@ Module.register("MMM-MyWeather", {
row_pop = document.createElement("tr");
row_wind = document.createElement("tr");

for (f in this.forecast) {
forecast = this.hourlyforecast[f * this.config.hourlyinterval];

// for (f in this.forecast) {
// forecast = this.hourlyforecast[f * Number(this.config.hourlyinterval)];

var counter = 0;
for (var i = Number(this.config.hourlyinterval) - 1; i < this.hourlyforecast.length; i += Number(this.config.hourlyinterval)) {
forecast = this.hourlyforecast[i];

hourCell = document.createElement("td");
hourCell.className = "hour";
Expand Down Expand Up @@ -721,7 +731,8 @@ Module.register("MMM-MyWeather", {
row_wind = document.createElement("tr");
}

if (f > this.config.hourlycount) {
counter = counter + 1;
if (counter == Number(this.config.hourlycount)) {
break;
}
}
Expand Down Expand Up @@ -1019,7 +1030,7 @@ Module.register("MMM-MyWeather", {


this.forecast = [];
for (i = this.config.fcdaystart, count = data.forecast.simpleforecast.forecastday.length; i < this.config.fcdaycount; i++) {
for (i = this.config.fcdaystart, count = data.forecast.simpleforecast.forecastday.length; i < Number(this.config.fcdaycount) + 1; i++) {

forecast = data.forecast.simpleforecast.forecastday[i];

Expand Down Expand Up @@ -1072,6 +1083,8 @@ Module.register("MMM-MyWeather", {
this.hourlyforecast = [];
for (i = 0, count = data.hourly_forecast.length; i < count; i++) {

// count = 0;
// for (i = this.config.hourlyinterval, i < data.hourly_forecast.length; i = i + this.config.hourlyinterval) {
var hourlyforecast = data.hourly_forecast[i];

if (this.config.units == "metric") {
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ The following properties can be configured:
<td><code>hourlycount</code></td>
<td>How many hourly forecasts. Specified by config.js<br>
<br><b>Possible values:</b> <code>0</code> - <code>24</code>
<br><b>Default value:</b> <code>3</code> (Will display 4 hourly forecasts)
<br>This value is optional. By default the 4 hourly forecasts will be displayed.
<br><b>Default value:</b> <code>2</code>
<br>This value is optional. By default 2 hourly forecasts will be displayed.
</td>
</tr>
<tr>
Expand Down
3 changes: 3 additions & 0 deletions node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ module.exports = NodeHelper.create({
if(notification === "GET_WUNDERGROUND"){

this.config = payload;

console.log(JSON.stringify(payload));

if ( this.config.debug === 1 ) {
console.log('Lets get WunderGround');
}
Expand Down

0 comments on commit 522ceb4

Please sign in to comment.