Homey Community Forum

Solar Panels homeyscript

I made sometime ago a script for getting a daily resume and prognosis for my solar panels. I adjusted the script somewhat so you can get a normal prognosis for a day, month or year, but also a prognosis bases of the hours of daylight for a certain day, month or year. The reason is that e.g in June the first day has lesser minutes of daylight as the last day of June. With this script it is possible to get a more accurate prognosis. But you are able to choose. It also works when you just started with your solar panels and you installed your panels e.g in March. I also considered the degeneration of the panels. What you have to investigate yourself is the given prognosis for your panels. I my case i got this prognosis from the installation firm. But on the internet there are some tools to calculate it yourself.

I got a little bit stuck in homeyscript because the script kept growing and growing. The only problem i did nog resolve until now is the prognosis on the first of a month. Because on that day the variables are resettted the prognosis on that day is not good. But on the second day of a month it is right again including the first day.

I made 1 flow in Homey to start the script an mail me my prognosis filled with the 7 text blocks. You can choose between English or Dutch language.

Be my guest to you it and to improve it. I will put the script below in six parts because it is a little bit big…

//SolarPanels script by Marcel
//Fill in the variables from var 'SolarLanguage' until var 'SolarProgDecember'
//Make 3 number variables in Better Logic called "SolarDayLightToday" , "SolarDayLightMonth", "SolarDayLightUntilToday", and "SolarUpdate"
//Make 1 boolean variable called "SolarUpdate"
//Better Logic variable "SolarUpdate" must be set to false, al other number variables must be 0
//If your Solar Panels already are producing before you run this script, you can add the production in the app Power by the Hour. Add it as a negative number.
//All variables are Case Sensitive
//If you want to use the Daylight prognosis make 2 extra variables in Better Logic called "SolarDayLightOldMonth" and "SolarDayLightOldMonthUntilToday"
//Make 6 string variables in Better Logic called "SolarTextBlock1", "SolarTextBlock2",
//"SolarTxtBlock3", "SolarTextBlock4", "SolarTextBlock5" and "SolarTextBlock6"
//Adjust the variables @ "fill in yourself the variables" according your prognosis and needs. You need a prognosis month by month. If ypu don't have these data, google is your friend to find a prognosis calculator
//If you want to use the Daylight prognosis first @  "fill in yourself the variables" you have to set the variable SolarDayProgFirstUpdate to "Yes". Run the script. After running the script adjust to "No"
//Second you have to set the variable SolarDayLightOldUpdate to "Yes". Run the script. After running the script adjust to "No"
//Run the script when you want to know your production at that moment, at least run it every first of a month to get the Daylight prognosis update

//Getting your Device ID

//If you want the ID number of your device, below is a little script for all your devices
//copy the script and add a new script in Homeyscript, call it wathever you want and paste.
//delete '//' for every line and run

//let devices = await Homey.devices.getDevices();
//_.forEach(devices, device =>{
//console.log(device.name, '',device.id);
//})
//return true




//fill in yourself these variables
    var SolarLanguage =               'Dutch';// Fill in between ' ' 'English' or 'Dutch' to get the output in your language
    const PowerByTheHourID =            '6f2f3d04-e088-4c4c-9afb-f19d965b2351';////Fill in between ' ' the Id of Power by the Hour. Look @ Getting your Device ID above to get the correct ID
    var PowerByTheHourType =          'Solaredge_Σpower';//Fill in between ' ' the name your Solar Converter has in the app Power by the Hour, look above @Getting the name of your Device, how to get the correct name
    var SolarInstallYear =            2020;//Fill in installation year of your Solar Panels
    var SolarInstallMonth =           7;//Fill in installation month of your Solar Panels
    var SolarInstallDay =             23; //Fill in installation day of your Solar Panels
    var SolarDayLightOldUpdate =       false //Fill in true for a one time DayLighy prognosis update for the first month of installation when the installation year is this year. If the installation year is before this year, do not try to update. Afterwards return to false, because this has to be done only once
    var SolarDegeneration =           0.004;// Fill in the SolarDegeneration per year (according to some statements on google most common for solarpanels installed after 2010 is 0.004(0,4%) and for solarpanels installed before 2010 is 0.005(0,5%). Solarmanufacturers use 0.0075(0,75%) - 0.01(1%) for warranty issues
    const Latitude =                  53.033548;// Fill in latitude in decimal degrees South add a '-' in front of the degrees
    const Longitude =                 -5.661103;// Fill in longitude in decimal degrees, East add a '-' in front of the degrees
    const SolarDayPrognosis =         true;// Fill in true for Daylight prognosis, for a day prognosis according the daylight length or false for day progosis according a day prognosis month/days
    const SolarDayProgFirstUpdate =   false;//Fill in true if you want to retrieve the data for the daylight prognosis when your starting day of this script is not the first of a month. After you have run the script always fill in false otherwise you will exceed the amount of api requests
    var SolarProgJanuary =            162.49;//Fill in prognosis for January
    var SolarProgFebruary =           268.73;//Fill in prognosis for Februari
    var SolarProgMarch =              531.22;//Fill in prognosis for March
    var SolarProgApril =              756.2;//Fill in prognosis for April
    var SolarProgMay =                837.45;//Fill in prognosis for May
    var SolarProgJune =               824.95;//Fill in prognosis for June
    var SolarProgJuly =               812.45;//Fill in prognosis for July
    var SolarProgAugust =             712.45;//Fill in prognosis for August
    var SolarProgSeptember =          574.96;//Fill in prognosis for September
    var SolarProgOctober =            437.47;//Fill in prognosis for October
    var SolarProgNovember =           206.24;//Fill in prognosis for November
    var SolarProgDecember =           124.99;//Fill in Prognosis for December
//Until here you can fill in yourself the variables, the rest will be done automatically

    let BLApp = await Homey.apps.getApp({id:"net.i-dev.betterlogic" });//Activating better logic
    PowerByTheHourType = await Homey.devices.getDevice({ id: PowerByTheHourID});//Get the device capabilities of your Solar Inverter
    var SolarProductionToday = PowerByTheHourType.capabilitiesObj.kwh_this_day_total;//Get the production of your Solar Panels until now
    SolarProductionToday = SolarProductionToday.value;//Getting the value
    var SolarMonth = PowerByTheHourType.capabilitiesObj.kwh_this_month_total;//Get the production of your Solar Panels this month until now
    SolarMonth = SolarMonth.value;//Getting the value
    var SolarYear = PowerByTheHourType.capabilitiesObj.kwh_this_year_total;//Get the production of your Solar Panles this year until now
    SolarYear = SolarYear.value;
      console.log('Production today until now: ' +SolarProductionToday +' KWh');//Just logging for control purposes
      console.log('SolarMonth until now: ' +SolarMonth +' KWh');//Just logging for control purposes
      console.log('SolarYear until now: ' +SolarYear +' KWh');//Just logging for control purposes
    let SolarUpdate = await BLApp.apiGet('SolarUpdate');//Assigning Better Logic variable SolarUpdate
      console.log('Solarupdate is: '+SolarUpdate.value);// +' SolarupdateDay is: '+SolarUpdateDay);  
    var SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
      console.log('SolarProgYear is : ' +SolarProgYear +' KWh');//Just logging for control purposes
    let SolarDayLightMonth = await BLApp.apiGet('SolarDayLightMonth');//Retrieving Better Logic variable SolarDayLightMonth
    SolarDayLightMonth = Number(SolarDayLightMonth.value);
      console.log('SolarDayLightMonth is : ' +SolarDayLightMonth +' KWh');//Just logging for control purposes
    let SolarDayLightUntilToday = await BLApp.apiGet('SolarDayLightUntilToday');//Retrieving Better Logic variable SolarDayLightUntilToday
    SolarDayLightUntilToday = Number(SolarDayLightUntilToday.value);
        console.log('SolarDayLightUntilToday is : ' +SolarDayLightUntilToday +' seconds');//Just logging for control purposes
    let SolarDayLightToday = await BLApp.apiGet('SolarDayLightToday');//Retrieving Better Logic variable SolarDayLightUntilToday
    SolarDayLightToday = Number(SolarDayLightToday.value);
        console.log('SolarDayLightToday is : ' +SolarDayLightToday +' seconds');//Just logging for control purposes
    let SolarDayLightOldMonth = await BLApp.apiGet('SolarDayLightOldMonth');//Retrieving Better Logic variable SolarDayLightOldMonth
    SolarDayLightOldMonth = Number(SolarDayLightOldMonth.value);
        console.log('SolarDayLightOldMonth is : ' +SolarDayLightOldMonth +' seconds');//Just logging for control purposes
    let SolarDayLightOldMonthUntilToday = await BLApp.apiGet('SolarDayLightOldMonthUntilToday');//Retrieving Better Logic variable SolarDayLightOldMonthUntilToday
    SolarDayLightOldMonthUntilToday = Number(SolarDayLightOldMonthUntilToday.value);
        console.log('SolarDayLightOldMonthUntilTodayis : ' +SolarDayLightOldMonthUntilToday +' seconds');//Just logging for control purposes



//Until here better logic variables are declared    

    var Today = new Date();//Actual Date
       console.log(Today);
    var Year = Today.getFullYear();// Actual Year in numbers
    var Month = Today.getMonth()+1;//Actual Month in numbers
    var Day = Today.getDate();//Actual day in a Month in numbers
      console.log('What day is it today: '+Day);//Just logging for control purposes
    var Hours = Today.getHours();//Actual hours in numbers
      console.log('What hour is it now: '+Hours);
    var GetDaysInMonth = function(month,year){//Calculates amount of days in this month
  return new Date(year, month, 0).getDate();};


if (Day === 1 && SolarUpdate.value === true){//Updating better logic variable SolarMonth to 0 again every first of the month
    SolarDayLightUntilToday = 0;
  BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightUntilToday); 
        console.log('SolarDayLightUntilToday after reset: '+SolarDayLightUntilToday +' seconds');//Just logging for control purposes
     SolarDayLightMonth = 0;
  BLApp.apiPut('SolarDayLightMonth/'+SolarDayLightMonth); 
        console.log('SolarDayLightMonth after reset: '+SolarDayLightMonth +' seconds');}//Just logging for control purposes     

if (SolarUpdate.value === true){//Updating better logic variables once every day
    let urltoday = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=today'+'&formatted=0');
  response = await fetch(urltoday);
    ApiSunriseSunset = await response.json();//Read response body and parse as JSON
    SolarDayLightToday = Number(ApiSunriseSunset.results.day_length);
  BLApp.apiPut('SolarDayLightToday/'+SolarDayLightToday);//Updating better logic variable SolarDayLightUntilToday     
      console.log('SolarDayLightToday after update is : ' +SolarDayLightToday +' seconds');//Just logging for control purposes
    SolarDayLightUntilToday = Number(SolarDayLightUntilToday + SolarDayLightToday);
  BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightUntilToday);//Updating better logic variable SolarDayLightUntilToday     
      console.log('SolarDayLightUntilToday after update is : ' +SolarDayLightUntilToday +' seconds');}//Just logging for control purposes
   

  function wait(ms){//Declaring function wait
   var start = new Date().getTime();
   var end = start;
  while(end < start + ms) {
  end = new Date().getTime();}}


if (GetDaysInMonth(Month, Year) <= 31 && Day === 1 && SolarUpdate.value === true || SolarDayProgFirstUpdate === true){//Api call every 1 of the month for the total seconds of daylight during a month
    SolarDayLightUntilToday = 0;//Resetting better logic variable SolarDayLightUntilToday to 0
    let SolarDayLightMonth = await BLApp.apiGet;('SolarDayLightMonth');//Retrieving better Logic variable SolarDayLightMonth
    SolarDayLightMonth = 0;//resetting SolarDayLightMonth to 0
  BLApp.apiPut('SolarDayLightMonth/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightMonth
    let url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '01' +'&formatted=0');//Api call
    let response = await fetch(url);
    let ApiSunriseSunset = await response.json(); // read response body and parse as JSON
    SolarDayLightMonth = ApiSunriseSunset.results.day_length;//Assigning total seconds of day 1 to variable SolarDayLightMonth
      console.log('Total seconds of daylight day 1 :'+SolarDayLightMonth)
      console.log(ApiSunriseSunset);
      console.log('Daylightseconds day 1 = ' +ApiSunriseSunset.results.day_length);
  wait(1000);

    var SolarDayThisMonth = Day +1;//Api call day 2
    url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '02' +'&formatted=0');//Api call
  response = await fetch(url);
    ApiSunriseSunset = await response.json(); // read response body and parse as JSON
    SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
      console.log('Daylightseconds day 2 = ' +ApiSunriseSunset.results.day_length);
      console.log('Total Daylightseconds until day 2 ='   +SolarDayLightMonth);
  wait(1000);

 if(Day === 2 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
   BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
}; 

    var SolarDayThisMonth = Day +2;//Api call day 3  
    url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '03' +'&formatted=0');//Api call
  response = await fetch(url);
    ApiSunriseSunset = await response.json(); // read response body and parse as JSON
    SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
      console.log('Daylightseconds day 3 = ' +ApiSunriseSunset.results.day_length);
      console.log('Total Daylightseconds until day 3 = ' +SolarDayLightMonth);
  wait(1000);

if(Day === 3 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
   BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
};

    var SolarDayThisMonth = Day +3;//Api call day 4 
    url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '04' +'&formatted=0');//Api call
  response = await fetch(url);
    ApiSunriseSunset = await response.json(); // read response body and parse as JSON
    SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
      console.log('Daylightseconds day 4 = ' +ApiSunriseSunset.results.day_length);
      console.log('Total Daylightseconds until day 4 = ' +SolarDayLightMonth);
  wait(1000);

if(Day === 4 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
   BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
};

    var SolarDayThisMonth = Day +4;//Api call day 5  
    url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '05' +'&formatted=0');//Api call
  response = await fetch(url);
    ApiSunriseSunset = await response.json(); // read response body and parse as JSON
    SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
      console.log('Daylightseconds day 5 = ' +ApiSunriseSunset.results.day_length);
      console.log('Total Daylightseconds until day 5 = ' +SolarDayLightMonth);
  wait(1000);

if(Day === 5 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
   BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
};

    var SolarDayThisMonth = Day +5;//Api call day 6 
    url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '06' +'&formatted=0');//Api call
  response = await fetch(url);
    ApiSunriseSunset = await response.json(); // read response body and parse as JSON
    SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
      console.log('Daylightseconds day 6 = ' +ApiSunriseSunset.results.day_length);
      console.log('Total Daylightseconds until day 6 = ' +SolarDayLightMonth);
  wait(1000);

if(Day === 6 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
   BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
};

    var SolarDayThisMonth = Day +6;//Api call day 7 
    url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '07' +'&formatted=0');//Api call
  response = await fetch(url);
    ApiSunriseSunset = await response.json(); // read response body and parse as JSON
    SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
      console.log('Daylightseconds day 7 = ' +ApiSunriseSunset.results.day_length);
      console.log('Total Daylightseconds until day 7 = ' +SolarDayLightMonth);
  wait(1000);

if(Day === 7 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
   BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
};

    var SolarDayThisMonth = Day +7;//Api call day 8 
    url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '08' +'&formatted=0');//Api call
  response = await fetch(url);
    ApiSunriseSunset = await response.json(); // read response body and parse as JSON
    SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
      console.log('Daylightseconds day 8 = ' +ApiSunriseSunset.results.day_length);
      console.log('Total Daylightseconds until day 8 = ' +SolarDayLightMonth);
  wait(1000);

if(Day === 8 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
   BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
};

    var SolarDayThisMonth = Day +8;//Api call day 9   
    url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '09' +'&formatted=0');//Api call
  response = await fetch(url);
    ApiSunriseSunset = await response.json(); // read response body and parse as JSON
    SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
      console.log('Daylightseconds day 9 = ' +ApiSunriseSunset.results.day_length);
      console.log('Total Daylightseconds until day 9 = ' +SolarDayLightMonth);
  wait(1000);

if(Day === 9 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
   BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
};

    var SolarDayThisMonth = Day +9;//Api call day 10   
    url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '10' +'&formatted=0');//Api call
  response = await fetch(url);
    ApiSunriseSunset = await response.json(); // read response body and parse as JSON
    SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
      console.log('Daylightseconds day 10 = ' +ApiSunriseSunset.results.day_length);
      console.log('Total Daylightseconds until day 10 = ' +SolarDayLightMonth);
  wait(1000);

if(Day === 10 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
   BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
};

    var SolarDayThisMonth = Day +10;//Api call day 11   
    url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '11' +'&formatted=0');//Api call
  response = await fetch(url);
    ApiSunriseSunset = await response.json(); // read response body and parse as JSON
    SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
      console.log('Daylightseconds day 11 = ' +ApiSunriseSunset.results.day_length);
      console.log('Total Daylightseconds until day 11 = ' +SolarDayLightMonth);
  wait(1000);

if(Day === 11 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
   BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
};

    var SolarDayThisMonth = Day +11;//Api call day 12   
    url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '12' +'&formatted=0');//Api call
  response = await fetch(url);
    ApiSunriseSunset = await response.json(); // read response body and parse as JSON
    SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
      console.log('Daylightseconds day 12 = ' +ApiSunriseSunset.results.day_length);
      console.log('Total Daylightseconds until day 12 = ' +SolarDayLightMonth);
  wait(1000);

if(Day === 12 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
   BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
};

    var SolarDayThisMonth = Day +12;//Api call day 13   
    url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '13' +'&formatted=0');//Api call
  response = await fetch(url);
    ApiSunriseSunset = await response.json(); // read response body and parse as JSON
    SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
      console.log('Daylightseconds day 13 = ' +ApiSunriseSunset.results.day_length);
      console.log('Total Daylightseconds until day 13 = ' +SolarDayLightMonth);
  wait(1000);

if(Day === 13 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
   BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
};

    var SolarDayThisMonth = Day +13;//Api call day 14   
    url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '14' +'&formatted=0');//Api call
  response = await fetch(url);
    ApiSunriseSunset = await response.json(); // read response body and parse as JSON
    SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
      console.log('Daylightseconds day 14 = ' +ApiSunriseSunset.results.day_length);
      console.log('Total Daylightseconds until day 14 = ' +SolarDayLightMonth);
  wait(1000);

if(Day === 14 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
   BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
};

    var SolarDayThisMonth = Day +14;//Api call day 15   
    url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '15' +'&formatted=0');//Api call
  response = await fetch(url);
    ApiSunriseSunset = await response.json(); // read response body and parse as JSON
    SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
      console.log('Daylightseconds day 15 = ' +ApiSunriseSunset.results.day_length);
      console.log('Total Daylightseconds until day 15 = ' +SolarDayLightMonth);
  wait(1000);

if(Day === 15 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
   BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
};

    var SolarDayThisMonth = Day +15;//Api call day 16   
    url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '16' +'&formatted=0');//Api call
  response = await fetch(url);
    ApiSunriseSunset = await response.json(); // read response body and parse as JSON
    SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
      console.log('Daylightseconds day 16 = ' +ApiSunriseSunset.results.day_length);
      console.log('Total Daylightseconds until day 16 = ' +SolarDayLightMonth);
  wait(1000);

if(Day === 16 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
   BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
};

    var SolarDayThisMonth = Day +16;//Api call day 17   
    url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '17' +'&formatted=0');//Api call
  response = await fetch(url);
    ApiSunriseSunset = await response.json(); // read response body and parse as JSON
    SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
      console.log('Daylightseconds day 17 = ' +ApiSunriseSunset.results.day_length);
      console.log('Total Daylightseconds until day 17 = ' +SolarDayLightMonth);
  wait(1000);

if(Day === 17 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
   BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
};

    var SolarDayThisMonth = Day +17;//Api call day 18   
    url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '18' +'&formatted=0');//Api call
  response = await fetch(url);
    ApiSunriseSunset = await response.json(); // read response body and parse as JSON
    SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
      console.log('Daylightseconds day 18 = ' +ApiSunriseSunset.results.day_length);
      console.log('Total Daylightseconds until day 18 = ' +SolarDayLightMonth);
  wait(1000);

if(Day === 18 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
   BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
};

    var SolarDayThisMonth = Day +18;//Api call day 19   
    url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '19' +'&formatted=0');//Api call
  response = await fetch(url);
    ApiSunriseSunset = await response.json(); // read response body and parse as JSON
    SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
      console.log('Daylightseconds day 19 = ' +ApiSunriseSunset.results.day_length);
      console.log('Total Daylightseconds until day 19 = ' +SolarDayLightMonth);
  wait(1000);

if(Day === 19 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
   BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
};

    var SolarDayThisMonth = Day +19;//Api call day 20   
    url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '20' +'&formatted=0');//Api call
  response = await fetch(url);
    ApiSunriseSunset = await response.json(); // read response body and parse as JSON
    SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
      console.log('Daylightseconds day 20 = ' +ApiSunriseSunset.results.day_length);
      console.log('Total Daylightseconds until day 20 = ' +SolarDayLightMonth);
  wait(1000);

if(Day === 20 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
   BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
};

    var SolarDayThisMonth = Day +20;//Api call day 21    
    url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '21' +'&formatted=0');//Api call
  response = await fetch(url);
    ApiSunriseSunset = await response.json(); // read response body and parse as JSON
    SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
      console.log('Daylightseconds day 21 = ' +ApiSunriseSunset.results.day_length);
      console.log('Total Daylightseconds until day 21 = ' +SolarDayLightMonth);
  wait(1000);
> 
> if(Day === 21 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
>    BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
> };
> 
>     var SolarDayThisMonth = Day +21;//Api call day 22   
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '22' +'&formatted=0');//Api call
>   response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
>       console.log('Daylightseconds day 22 = ' +ApiSunriseSunset.results.day_length);
>       console.log('Total Daylightseconds until day 22 = ' +SolarDayLightMonth);
>   wait(1000);
> 
> if(Day === 22 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
>    BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
> };
> 
>     var SolarDayThisMonth = Day +22;//Api call day 23   
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '23' +'&formatted=0');//Api call
>   response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
>       console.log('Daylightseconds day 23 = ' +ApiSunriseSunset.results.day_length);
>       console.log('Total Daylightseconds until day 23 = ' +SolarDayLightMonth);
>   wait(1000);
> 
> if(Day === 23 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
>    BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
> };
> 
>     var SolarDayThisMonth = Day +23;//Api call day 24  
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '24' +'&formatted=0');//Api call
>   response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
>       console.log('Daylightseconds day 24 = ' +ApiSunriseSunset.results.day_length);
>       console.log('Total Daylightseconds until day 24 = ' +SolarDayLightMonth);
>   wait(1000);
> 
> if(Day === 24 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
>    BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
> };
> 
>     var SolarDayThisMonth = Day +24;//Api call day 25   
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '25' +'&formatted=0');//Api call
>   response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
>       console.log('Daylightseconds day 25 = ' +ApiSunriseSunset.results.day_length);
>       console.log('Total Daylightseconds until day 25 = ' +SolarDayLightMonth);
>   wait(1000);
> 
> if(Day === 25 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
>    BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
> };
> 
>      var SolarDayThisMonth = Day +25;//Api call day 26    
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '26' +'&formatted=0');//Api call
>   response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;;
>       console.log('Daylightseconds day 26 = ' +ApiSunriseSunset.results.day_length);
>       console.log('Total Daylightseconds until day 26 = ' +SolarDayLightMonth);
>   wait(1000);
> 
> if(Day === 26 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
>    BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
> };
> 
>     var SolarDayThisMonth = Day +26;//Api call day 27  
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '27' +'&formatted=0');//Api call
>   response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
>       console.log('Daylightseconds day 27 = ' +ApiSunriseSunset.results.day_length);
>       console.log('Total Daylightseconds until day 27 = ' +SolarDayLightMonth);
>   wait(1000);
> 
> if(Day === 27 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
>    BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
> };
> 
>     var SolarDayThisMonth = Day +27;//Api call day 28   
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '28' +'&formatted=0');//Api call
>   response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightMonth =SolarDayLightMonth + ApiSunriseSunset.results.day_length;
>       console.log('Daylightseconds day 28 = ' +ApiSunriseSunset.results.day_length);
>       console.log('Total Daylightseconds until day 28 = ' +SolarDayLightMonth);
>   wait(1000);
> 
> if(Day === 28 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
>    BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
> };
> 
>  BLApp.apiPut('SolarDayLightMonth/'+SolarDayLightMonth);
>  
> if (GetDaysInMonth(Month, Year) >28 && Day === 1 || GetDaysInMonth(Month, Year) >28 && SolarDayProgFirstUpdate === true){//Counting total seconds of daylight during a month for every month with 29, 30 and 31 days
>     var SolarDayThisMonth = Day +28;//Api call day 29
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '29' +'&formatted=0');//Api call
>   response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
>       console.log('Daylightseconds day 29 = ' +ApiSunriseSunset.results.day_length);
>       console.log('Total Daylightseconds until day 29 = ' +SolarDayLightMonth);
>   wait(1000);
> 
>   if(Day === 29 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
>    BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
> };
> 
>   BLApp.apiPut('SolarDayLightMonth/'+SolarDayLightMonth);
> 
> 
> if (GetDaysInMonth(Month, Year) >29 && Day === 1 || GetDaysInMonth(Month, Year) >29 && SolarDayProgFirstUpdate === true){//Counting total seconds of daylight during a month for every month with 30 and 31 days
>    var SolarDayThisMonth = Day +29;//Api call day 30  
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '30' +'&formatted=0');//Api call
>   response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
>     console.log('Daylightseconds day 30 = ' +ApiSunriseSunset.results.day_length);
>     console.log('Total Daylightseconds until day 30 = ' +SolarDayLightMonth);
>     wait(1000);
> 
> if(Day === 30 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
>    BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
> };
> 
> BLApp.apiPut('SolarDayLightMonth/'+SolarDayLightMonth);
> 
> 
> if (GetDaysInMonth(Month, Year) >30 && Day === 1 || GetDaysInMonth(Month, Year) >30 && SolarDayProgFirstUpdate === true){//Counting total seconds of daylight during a month for every month with 31 days
>     var SolarDayThisMonth = Day +30;//Api call day 31 
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + Year + '-' + Month + '-' + '31' +'&formatted=0');//Api call
>   response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightMonth = SolarDayLightMonth + ApiSunriseSunset.results.day_length;
>       console.log('Daylightseconds day 31 = ' +ApiSunriseSunset.results.day_length);
>       console.log('Total Daylightseconds until day 31 = ' +SolarDayLightMonth);
>   wait(1000);
> 
> if(Day === 31 ){//Updating better logic variable SolarDayLightUntilToday when the update is not on the first of a month
>    BLApp.apiPut('SolarDayLightUntilToday/'+SolarDayLightMonth);//Updating better logic variable SolarDayLightUntilToday
> };
> 
>   BLApp.apiPut('SolarDayLightMonth/'+SolarDayLightMonth);}}}}
>   
> if(GetDaysInMonth(SolarInstallMonth, SolarInstallYear) <= 31 && SolarDayLightOldUpdate === true ){//Api call every 1 of the month for the total seconds of daylight during a month
>     SolarDayLightOldMonthUntilToday = 0;//Resetting better logic variable SolarDayLightUntilToday to 0
>     SolarDayLightOldMonth = 0;//resetting SolarDayLightMonth to 0
>   BLApp.apiPut('SolarDayLightOldMonth/'+SolarDayLightOldMonth);//Updating better logic variable SolarDayLightMonth
>   BLApp.apiPut('SolarDayLightOldMonthUntilToday/'+SolarDayLightOldMonthUntilToday);//Updating better logic variable SolarDayLightMonth
>      
> // Day 1 
>     let url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '01' +'&formatted=0');//Api call
>     let response = await fetch(url);
>     let ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightOldMonth = ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
>       console.log('Total seconds of daylight day 1 :'+SolarDayLightOldMonth);
>       console.log(ApiSunriseSunset);
>       console.log('Daylightseconds day 1 = ' +ApiSunriseSunset.results.day_length);
>   wait(1000);
> 
> if(1 >= SolarInstallDay ){
>     SolarDayLightOldMonthUntilToday = ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday
>   
> //Day 2  
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '02' +'&formatted=0');//Api call
>      response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
>       console.log('Total seconds of daylight day 2 :'+SolarDayLightOldMonth);
>       console.log('Daylightseconds day 2 = ' +ApiSunriseSunset.results.day_length);
>   wait(1000);
> 
>   
> if(2 >= SolarInstallDay ){
>     SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday
> 
>  //Day 3 
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '03' +'&formatted=0');//Api call
>      response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
>       console.log('Total seconds of daylight day 3 :'+SolarDayLightOldMonth);
>       console.log('Daylightseconds day 3 = ' +ApiSunriseSunset.results.day_length);
>   wait(1000);
> 
>   
> if(3 >= SolarInstallDay ){
>     SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday
>     
>  //Day 4
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '04' +'&formatted=0');//Api call
>      response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
>       console.log('Total seconds of daylight day 4:'+SolarDayLightOldMonth);
>       console.log('Daylightseconds day 4 = ' +ApiSunriseSunset.results.day_length);
>   wait(1000);
> 
>   
> if(4 >= SolarInstallDay ){
>     SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday
>     
>  //Day 5
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '05' +'&formatted=0');//Api call
>      response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
>       console.log('Total seconds of daylight day 5 :'+SolarDayLightOldMonth);
>       console.log('Daylightseconds day 5 = ' +ApiSunriseSunset.results.day_length);
>   wait(1000);
> 
>   
> if(5 >= SolarInstallDay ){
>     SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday
>     
>  //Day 6 
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '06' +'&formatted=0');//Api call
>      response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
>       console.log('Total seconds of daylight day 6 :'+SolarDayLightOldMonth);
>       console.log('Daylightseconds day 6 = ' +ApiSunriseSunset.results.day_length);
>   wait(1000);
> 
>   
> if(6 >= SolarInstallDay ){
>     SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday
>     
>  //Day 7 
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '07' +'&formatted=0');//Api call
>      response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
>       console.log('Total seconds of daylight day 7 :'+SolarDayLightOldMonth);
>       console.log('Daylightseconds day 7 = ' +ApiSunriseSunset.results.day_length);
>   wait(1000);
> 
>   
> if(7 >= SolarInstallDay ){
>     SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday
>     
>  //Day 8 
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '08' +'&formatted=0');//Api call
>      response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
>       console.log('Total seconds of daylight day 8 :'+SolarDayLightOldMonth);
>       console.log('Daylightseconds day 8 = ' +ApiSunriseSunset.results.day_length);
>   wait(1000);
> 
>   
> if(8 >= SolarInstallDay ){
>     SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday
>     
>  //Day 9 
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '09' +'&formatted=0');//Api call
>      response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
>       console.log('Total seconds of daylight day 9 :'+SolarDayLightOldMonth);
>       console.log('Daylightseconds day 9 = ' +ApiSunriseSunset.results.day_length);
>   wait(1000);
> 
>   
> if(9 >= SolarInstallDay ){
>     SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday
>     
>  //Day 10 
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '10' +'&formatted=0');//Api call
>      response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
>       console.log('Total seconds of daylight day 10 :'+SolarDayLightOldMonth);
>        console.log('Daylightseconds day 10 = ' +ApiSunriseSunset.results.day_length);
>   wait(1000);
> 
>   
> if(10 >= SolarInstallDay ){
>     SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday
>     
>  //Day 11
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '11' +'&formatted=0');//Api call
>      response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
>       console.log('Total seconds of daylight day 11 :'+SolarDayLightOldMonth)
>       console.log('Daylightseconds day 11 = ' +ApiSunriseSunset.results.day_length);
>   wait(1000);
> 
>   
> if(11 >= SolarInstallDay ){
>     SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday
>     
>  //Day 12 
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '12' +'&formatted=0');//Api call
>      response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
>       console.log('Total seconds of daylight day 12 :'+SolarDayLightOldMonth)
>       console.log('Daylightseconds day 12 = ' +ApiSunriseSunset.results.day_length);
>   wait(1000);
> 
>   
> if(12 >= SolarInstallDay ){
>     SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday
>     
> //Day 13
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '13' +'&formatted=0');//Api call
>      response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
>       console.log('Total seconds of daylight day 13 :'+SolarDayLightOldMonth)
>       console.log('Daylightseconds day 13 = ' +ApiSunriseSunset.results.day_length);
>   wait(1000);
> 
>   
> if(13 >= SolarInstallDay ){
>     SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday
>     
> //Day 14 
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '14' +'&formatted=0');//Api call
>      response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
>       console.log('Total seconds of daylight day 14 :'+SolarDayLightOldMonth)
>       console.log('Daylightseconds day 14 = ' +ApiSunriseSunset.results.day_length);
>   wait(1000);
> 
>   
> if(14 >= SolarInstallDay ){
>     SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday
>     
> //Day 15
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '15' +'&formatted=0');//Api call
>      response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
>       console.log('Total seconds of daylight day 15 :'+SolarDayLightOldMonth)
>       console.log('Daylightseconds day 15 = ' +ApiSunriseSunset.results.day_length);
>   wait(1000);
> 
>   
> if(15 >= SolarInstallDay ){
>     SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday
>     
> //Day 16
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '16' +'&formatted=0');//Api call
>      response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
>       console.log('Total seconds of daylight day 16 :'+SolarDayLightOldMonth)
>       console.log('Daylightseconds day 16 = ' +ApiSunriseSunset.results.day_length);
>   wait(1000);
> 
>   
> if(16 >= SolarInstallDay ){
>     SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday
>     
> //Day 17
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '17' +'&formatted=0');//Api call
>      response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
>       console.log('Total seconds of daylight day 17 :'+SolarDayLightOldMonth)
>       console.log('Daylightseconds day 17 = ' +ApiSunriseSunset.results.day_length);
>   wait(1000);
> 
>   
> if(17 >= SolarInstallDay ){
>     SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday
>     
> //Day 18
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '18' +'&formatted=0');//Api call
>      response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
>       console.log('Total seconds of daylight day 18 :'+SolarDayLightOldMonth)
>       console.log('Daylightseconds day 18 = ' +ApiSunriseSunset.results.day_length);
>   wait(1000);
> 
>   
> if(18 >= SolarInstallDay ){
>     SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday
>     
> //Day 19 
>     url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '19' +'&formatted=0');//Api call
>      response = await fetch(url);
>     ApiSunriseSunset = await response.json(); // read response body and parse as JSON
>     SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
>       console.log('Total seconds of daylight day 19 :'+SolarDayLightOldMonth)
>       console.log('Daylightseconds day 19 = ' +ApiSunriseSunset.results.day_length);
>   wait(1000);
> 
>   
> if(19 >= SolarInstallDay ){
>     SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday
//Day 20 
url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '20' +'&formatted=0');//Api call
 response = await fetch(url);
ApiSunriseSunset = await response.json(); // read response body and parse as JSON
SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
  console.log('Total seconds of daylight day 20 :'+SolarDayLightOldMonth)
  console.log('Daylightseconds day 20 = ' +ApiSunriseSunset.results.day_length);
  wait(1000);

  
if(20 >= SolarInstallDay ){
SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday

//Day 21
url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '21' +'&formatted=0');//Api call
 response = await fetch(url);
ApiSunriseSunset = await response.json(); // read response body and parse as JSON
SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
  console.log('Total seconds of daylight day 21 :'+SolarDayLightOldMonth)
  console.log('Daylightseconds day 21 = ' +ApiSunriseSunset.results.day_length);
  wait(1000);

  
if(21 >= SolarInstallDay ){
SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday

//Day 22
url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '22' +'&formatted=0');//Api call
 response = await fetch(url);
ApiSunriseSunset = await response.json(); // read response body and parse as JSON
SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
  console.log('Total seconds of daylight day 22 :'+SolarDayLightOldMonth)
  console.log('Daylightseconds day 22 = ' +ApiSunriseSunset.results.day_length);
  wait(1000);

  
if(22 >= SolarInstallDay ){
SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday

//Day 23 
url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '23' +'&formatted=0');//Api call
 response = await fetch(url);
ApiSunriseSunset = await response.json(); // read response body and parse as JSON
SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
  console.log('Total seconds of daylight day 23 :'+SolarDayLightOldMonth)
  console.log('Daylightseconds day 23 = ' +ApiSunriseSunset.results.day_length);
  wait(1000);

  
if(23 >= SolarInstallDay ){
SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday

//Day 24
url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '24' +'&formatted=0');//Api call
 response = await fetch(url);
ApiSunriseSunset = await response.json(); // read response body and parse as JSON
SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
  console.log('Total seconds of daylight day 24 :'+SolarDayLightOldMonth)
  console.log('Daylightseconds day 24 = ' +ApiSunriseSunset.results.day_length);
  wait(1000);

  
if(24 >= SolarInstallDay ){
SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday

//Day 25 
url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '25' +'&formatted=0');//Api call
 response = await fetch(url);
ApiSunriseSunset = await response.json(); // read response body and parse as JSON
SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
  console.log('Total seconds of daylight day 25 :'+SolarDayLightOldMonth)
  console.log('Daylightseconds day 25 = ' +ApiSunriseSunset.results.day_length);
  wait(1000);

  
if(25 >= SolarInstallDay ){
SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday

//Day 26
url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '26' +'&formatted=0');//Api call
 response = await fetch(url);
ApiSunriseSunset = await response.json(); // read response body and parse as JSON
SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
  console.log('Total seconds of daylight day 26 :'+SolarDayLightOldMonth)
  console.log('Daylightseconds day 26 = ' +ApiSunriseSunset.results.day_length);
  wait(1000);

  
if(26 >= SolarInstallDay ){
SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday

//Day 27 
url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '27' +'&formatted=0');//Api call
 response = await fetch(url);
ApiSunriseSunset = await response.json(); // read response body and parse as JSON
SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
  console.log('Total seconds of daylight day 27 :'+SolarDayLightOldMonth)
  console.log('Daylightseconds day 27 = ' +ApiSunriseSunset.results.day_length);
  wait(1000);

  
if(27 >= SolarInstallDay ){
SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length};//Counting up SolarDayLightOldMonthUntilToday

//Day 28
url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '28' +'&formatted=0');//Api call
 response = await fetch(url);
ApiSunriseSunset = await response.json(); // read response body and parse as JSON
SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
  console.log('Total seconds of daylight day 28 :'+SolarDayLightOldMonth)
  console.log('Daylightseconds day 28 = ' +ApiSunriseSunset.results.day_length);
  wait(1000);

  
if(28 >= SolarInstallDay ){
  BLApp.apiPut('SolarDayLightOldMonth/'+SolarDayLightOldMonth);
SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonthUntilToday
  BLApp.apiPut('SolarDayLightOldMonthUntilToday/'+SolarDayLightOldMonthUntilToday)};

//Day 29
if(GetDaysInMonth(SolarInstallMonth, SolarInstallYear) >= 29) {
url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '29' +'&formatted=0');//Api call
 response = await fetch(url);
ApiSunriseSunset = await response.json(); // read response body and parse as JSON
SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
  console.log('Total seconds of daylight day 29 :'+SolarDayLightOldMonth)
  console.log('Daylightseconds day 29 = ' +ApiSunriseSunset.results.day_length);
  wait(1000)};
 
if(29 >= SolarInstallDay ){
  BLApp.apiPut('SolarDayLightOldMonth/'+SolarDayLightOldMonth);
SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonthUntilToday
  BLApp.apiPut('SolarDayLightOldMonthUntilToday/'+SolarDayLightOldMonthUntilToday)};//Counting up SolarDayLightOldMonthUntilToday

//Day 30
if(GetDaysInMonth(SolarInstallMonth, SolarInstallYear) >= 30) {
url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '30' +'&formatted=0');//Api call
 response = await fetch(url);
ApiSunriseSunset = await response.json(); // read response body and parse as JSON
SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
  console.log('Total seconds of daylight day 30 :'+SolarDayLightOldMonth)
  console.log('Daylightseconds day 30 = ' +ApiSunriseSunset.results.day_length);
  wait(1000)};

  
if(30 >= SolarInstallDay ){
BLApp.apiPut('SolarDayLightOldMonth/'+SolarDayLightOldMonth);
SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonthUntilToday
  BLApp.apiPut('SolarDayLightOldMonthUntilToday/'+SolarDayLightOldMonthUntilToday)};//Counting up SolarDayLightOldMonthUntilToday

//Day 31 
if(GetDaysInMonth(SolarInstallMonth, SolarInstallYear) >= 31) {
url = ('https://api.sunrise-sunset.org/json?lat='+Latitude +'&lng='+Longitude +'&date=' + SolarInstallYear + '-' + SolarInstallMonth + '-' + '31' +'&formatted=0');//Api call
 response = await fetch(url);
ApiSunriseSunset = await response.json(); // read response body and parse as JSON
SolarDayLightOldMonth = SolarDayLightOldMonth + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonth
  console.log('Total seconds of daylight day 31 :'+SolarDayLightOldMonth)
  console.log('Daylightseconds day 31 = ' +ApiSunriseSunset.results.day_length);
  wait(1000)};

  
if(31 >= SolarInstallDay ){
BLApp.apiPut('SolarDayLightOldMonth/'+SolarDayLightOldMonth);
SolarDayLightOldMonthUntilToday = SolarDayLightOldMonthUntilToday + ApiSunriseSunset.results.day_length;//Counting up SolarDayLightOldMonthUntilToday
  BLApp.apiPut('SolarDayLightOldMonthUntilToday/'+SolarDayLightOldMonthUntilToday)}};//Counting up SolarDayLightOldMonthUntilToday


var SolarDegenerationYears = Year - SolarInstallYear;//Calculates numbers off years from installing the solar panels untill now
var SolarDegenerationPercentage = SolarDegenerationYears * SolarDegeneration;
  console.log('SolarDegenerationPercentage is: '+SolarDegenerationYears +' * '+SolarDegeneration) +'= '+SolarDegenerationPercentage +' %';//Just logging for control purposes

if (SolarInstallYear < Year){//Prognosis for a whole year including SolarDegeneration

SolarProgJanuary = (SolarProgJanuary - (SolarProgJanuary*SolarDegenerationPercentage));
  console.log('Prognosis January minus a SolarDegenerationPercentage of: ' +SolarDegenerationPercentage +'% Prognosis is: '+SolarProgJanuary +' KWh');//Just logging for control purposes
SolarProgFebruary = (SolarProgFebruary - (SolarProgFebruary*SolarDegenerationPercentage));
  console.log('Prognosis February minus a SolarDegenerationPercentage of: ' +SolarDegenerationPercentage +'% Prognosis is: '+SolarProgFebruary +' KWh');//Just logging for control purposes
SolarProgMarch = (SolarProgMarch - (SolarProgMarch*SolarDegenerationPercentage));
  console.log('Prognosis March minus a SolarDegenerationPercentage of: ' +SolarDegenerationPercentage +'% Prognosis is: '+SolarProgMarch +' KWh');//Just logging for control purposes
SolarProgApril = (SolarProgApril - (SolarProgApril*SolarDegenerationPercentage));
  console.log('Prognosis April minus a SolarDegenerationPercentage of: ' +SolarDegenerationPercentage +'% Prognosis is: '+SolarProgApril +' KWh');//Just logging for control purposes
SolarProgMay = (SolarProgMay - (SolarProgMay*SolarDegenerationPercentage));
  console.log('Prognosis May minus a SolarDegenerationPercentage of: ' +SolarDegenerationPercentage +'% Prognosis is: '+SolarProgMay +' KWh');//Just logging for control purposes
SolarProgJune = (SolarProgJune - (SolarProgJune*SolarDegenerationPercentage));
  console.log('Prognosis June minus a SolarDegenerationPercentage of: ' +SolarDegenerationPercentage +'% Prognosis is: '+SolarProgJune +' KWh');//Just logging for control purposes
SolarProgJuly = (SolarProgJuly - (SolarProgJuly*SolarDegenerationPercentage));
  console.log('Prognosis July minus a SolarDegenerationPercentage of: ' +SolarDegenerationPercentage +'% Prognosis is: '+SolarProgJuly +' KWh');//Just logging for control purposes
SolarProgAugust = (SolarProgAugust - (SolarProgAugust*SolarDegenerationPercentage));
  console.log('Prognosis August minus a SolarDegenerationPercentage of: ' +SolarDegenerationPercentage +'% Prognosis is: '+SolarProgAugust +' KWh');//Just logging for control purposes
SolarProgSeptember = (SolarProgSeptember - (SolarProgSeptember*SolarDegenerationPercentage));
  console.log('Prognosis September minus a SolarDegenerationPercentage of: ' +SolarDegenerationPercentage +'% Prognosis is: '+SolarProgSeptember +' KWh');//Just logging for control purposes
SolarProgOctober = (SolarProgOctober - (SolarProgOctober*SolarDegenerationPercentage));
  console.log('Prognosis October minus a SolarDegenerationPercentage of: ' +SolarDegenerationPercentage +'% Prognosis is: '+SolarProgOctober +' KWh');//Just logging for control purposes
SolarProgNovember = (SolarProgNovember - (SolarProgNovember*SolarDegenerationPercentage));
  console.log('Prognosis November minus a SolarDegenerationPercentage of: ' +SolarDegenerationPercentage +'% Prognosis is: '+SolarProgNovember +' KWh');//Just logging for control purposes
SolarProgDecember = (SolarProgDecember - (SolarProgDecember*SolarDegenerationPercentage));
  console.log('Prognosis December minus a SolarDegenerationPercentage of: ' +SolarDegenerationPercentage +'% Prognosis is: '+SolarProgDecember +' KWh');//Just logging for control purposes
SolarProgYear = (SolarProgYear - (SolarProgYear*SolarDegenerationPercentage));
  console.log('Prognosis this year minus a SolarDegenerationPercentage of: ' +SolarDegenerationPercentage +'% Prognosis is: '+SolarProgYear +' KWh');//Just logging for control purposes
}
else {SolarProgThisMonth = SolarInstallMonth;//Prognosis will be adjust according to the date of installing your solar panels
  switch (SolarProgThisMonth){
  case 1:{

if (SolarDayPrognosis === false){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = (SolarProgFebruary/(GetDaysInMonth(1, Year)))*((GetDaysInMonth(1, Year)) - (SolarInstallDay - 1));
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Standard prognosis january when the installation date is this year: '+SolarProgJanuary);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;} 

if (SolarDayPrognosis === true){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = (SolarProgJanuary / SolarDayLightOldMonth) *SolarDayLightOldMonthUntilToday;//Using the 'Daylight' prognosis because the 'Daylight'prognosis.
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Daylight prognosis january when the installation date is this year: '+SolarProgJanuary);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes   
break;}}

  case 2:{

if (SolarDayPrognosis === false){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = 0;
SolarProgFebruary = (SolarProgFebruary/(GetDaysInMonth(2, Year)))*((GetDaysInMonth(2, Year)) - (SolarInstallDay - 1));
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Standard prognosis february when the installation date is this year: '+SolarProgFebruary);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}

if (SolarDayPrognosis === true){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = 0;
   SolarProgFebruary = (SolarFebruary / SolarDayLightOldMonth) *SolarDayLightOldMonthUntilToday;//Using the 'Daylight' prognosis because the 'Daylight'prognosis.
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Daylight prognosis february when the installation date is this year: '+SolarProgFebruary);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes   
break;}}   

  case 3:{

if (SolarDayPrognosis === false){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = 0; SolarProgFebruary = 0; 
SolarProgMarch = (SolarProgMarch/(GetDaysInMonth(3, Year)))*((GetDaysInMonth(3, Year)) - (SolarInstallDay - 1));
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Standard prognosis march when the installation date is this year: '+SolarProgMarch);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}

  if (SolarDayPrognosis === true){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = 0; SolarProgFebruary = 0;
SolarProgMarch = (SolarProgMarch / SolarDayLightOldMonth) *SolarDayLightOldMonthUntilToday;//Using the 'Daylight' prognosis because the 'Daylight'prognosis.
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Daylight prognosis march when the installation date is this year: '+SolarProgMarch);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes   
break;}}

  case 4:{

if (SolarDayPrognosis === false){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = 0; SolarProgFebruary = 0; SolarProgMarch = 0;
SolarProgApril = (SolarProgApril/(GetDaysInMonth(4, Year)))*((GetDaysInMonth(4, Year)) - (SolarInstallDay - 1));
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Standard prognosis april when the installation date is this year: '+SolarProgApril);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}

 if (SolarDayPrognosis === true){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = 0;SolarProgFebruary = 0; SolarProgMarch = 0;
SolarProgApril = (SolarProgApril / SolarDayLightOldMonth) *SolarDayLightOldMonthUntilToday;//Using the 'Daylight' prognosis because the 'Daylight'prognosis.
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Daylight prognosis april when the installation date is this year: '+SolarProgApril);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes   
break;}} 

  case 5:{

if (SolarDayPrognosis === false){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = 0; SolarProgFebruary = 0; SolarProgMarch = 0; SolarProgApril = 0;
SolarProgMay = (SolarProgMay/(GetDaysInMonth(5, Year)))*((GetDaysInMonth(5, Year)) - (SolarInstallDay - 1));
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Standard prognosis may when the installation date is this year: '+SolarProgMay);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}

if (SolarDayPrognosis === true){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = 0;SolarProgFebruary = 0; SolarProgMarch = 0; SolarProgApril = 0;
SolarProgMay = (SolarProgMay / SolarDayLightOldMonth) *SolarDayLightOldMonthUntilToday;//Using the 'Daylight' prognosis because the 'Daylight'prognosis.
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Daylight prognosis may when the installation date is this year: '+SolarProgMay);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes   
break;}}

  case 6:{

if (SolarDayPrognosis === false){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = 0; SolarProgFebruary = 0; SolarProgMarch = 0; SolarProgApril = 0; SolarProgMay = 0;
SolarProgJune = (SolarProgJune/(GetDaysInMonth(6, Year)))*((GetDaysInMonth(6, Year)) - (SolarInstallDay - 1));
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Standard prognosis june when the installation date is this year: '+SolarProgJune);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}
if (SolarDayPrognosis === true){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = 0;SolarProgFebruary = 0; SolarProgMarch = 0; SolarProgApril = 0; SolarProgMay = 0;
SolarProgJune = (SolarProgJune / SolarDayLightOldMonth) *SolarDayLightOldMonthUntilToday;//Using the 'Daylight' prognosis because the 'Daylight'prognosis.
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Daylight prognosis june when the installation date is this year: '+SolarProgJune);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes   
break;}}

  case 7:{

if (SolarDayPrognosis === false){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = 0; SolarProgFebruary = 0; SolarProgMarch = 0; SolarProgApril = 0; SolarProgMay = 0; SolarProgJune = 0;
SolarProgJuly = (SolarProgJuly/(GetDaysInMonth(7, Year)))*((GetDaysInMonth(7, Year)) - (SolarInstallDay - 1));
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Standard prognosis july when the installation date is this year: '+SolarProgJuly);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}

if (SolarDayPrognosis === true){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = 0;SolarProgFebruary = 0; SolarProgMarch = 0; SolarProgApril = 0; SolarProgMay = 0; SolarProgJune = 0;
SolarProgJuly = (SolarProgJuly / SolarDayLightOldMonth) *SolarDayLightOldMonthUntilToday;//Using the 'Daylight' prognosis because the 'Daylight'prognosis.
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Daylight prognosis july when the installation date is this year: '+SolarProgJuly);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes   
break;}}

  case 8:{

if (SolarDayPrognosis === false){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = 0; SolarProgFebruary = 0; SolarProgMarch = 0; SolarProgApril = 0; SolarProgMay = 0; SolarProgJune = 0; SolarProgJuly = 0;
SolarProgAugust = (SolarProgAugust/(GetDaysInMonth(8, Year)))*((GetDaysInMonth(8, Year)) - (SolarInstallDay - 1));
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Standard prognosis august when installation date is this year: '+SolarProgAugust);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}

if (SolarDayPrognosis === true){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = 0;SolarProgFebruary = 0; SolarProgMarch = 0; SolarProgApril = 0; SolarProgMay = 0; SolarProgJune = 0; SolarProgJuly = 0;
SolarProgAugust = (SolarProgAugust / SolarDayLightOldMonth) *SolarDayLightOldMonthUntilToday;//Using the 'Daylight' prognosis because the 'Daylight'prognosis.
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Daylight prognosis august when the installation date is this year: '+SolarProgAugust);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes   
break;}} 

  case 9:{

if (SolarDayPrognosis === false){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = 0; SolarProgFebruary = 0; SolarProgMarch = 0; SolarProgApril = 0; SolarProgMay = 0; SolarProgJune = 0; SolarProgJuly = 0; SolarProgAugust = 0;
SolarProgSeptember = (SolarProgSeptember/(GetDaysInMonth(9, Year)))*((GetDaysInMonth(9, Year)) - (SolarInstallDay - 1));
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Standard prognosis september when the installation date is this year: '+SolarProgSeptember);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}

if (SolarDayPrognosis === true){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = 0;SolarProgFebruary = 0; SolarProgMarch = 0; SolarProgApril = 0; SolarProgMay = 0; SolarProgJune = 0; SolarProgJuly = 0;SolarProgAugust = 0;
SolarProgSeptember = (SolarProgSeptember / SolarDayLightOldMonth) *SolarDayLightOldMonthUntilToday;//Using the 'Daylight' prognosis because the 'Daylight'prognosis.
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Daylight prognosis september when the installation date is this year: '+SolarProgSeptember);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes   
break;}} 


  case 10:{

if (SolarDayPrognosis === false){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = 0; SolarProgFebruary = 0; SolarProgMarch = 0; SolarProgApril = 0; SolarProgMay = 0; SolarProgJune = 0; SolarProgJuly = 0; SolarProgAugust = 0; SolarProgSeptember = 0;
SolarProgOctober = (SolarProgOctober/(GetDaysInMonth(10, Year)))*((GetDaysInMonth(10, Year)) - (SolarInstallDay - 1));
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Standard prognosis october when the installation date is this year: '+SolarProgOctober);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}

if (SolarDayPrognosis === true){//Determine the prognosis when the solarpanels were installed this year 
 SolarProgJanuary = 0; SolarProgFebruary = 0; SolarProgMarch = 0; SolarProgApril = 0; SolarProgMay = 0; SolarProgJune = 0; SolarProgJuly = 0; SolarProgAugust = 0; SolarProgSeptember = 0;
SolarProgOctober = (SolarProgOctober / SolarDayLightOldMonth) *SolarDayLightOldMonthUntilToday;//Using the 'Daylight' prognosis because the 'Daylight'prognosis.
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Daylight prognosis october when the installation date is this year: '+SolarProgOctober);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes   
break;}}

  case 11:{
   
if (SolarDayPrognosis === false){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = 0; SolarProgFebruary = 0; SolarProgMarch = 0; SolarProgApril = 0; SolarProgMay = 0; SolarProgJune = 0; SolarProgJuly = 0; SolarProgAugust = 0; SolarProgSeptember = 0; SolarProgOctober = 0;
SolarProgNovember = (SolarProgNovember/(GetDaysInMonth(11, Year)))*((GetDaysInMonth(11, Year)) - (SolarInstallDay - 1));
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Standard prognosis november when the installation date is this year: '+SolarProgNovember);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}

if (SolarDayPrognosis === true){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = 0; SolarProgFebruary = 0; SolarProgMarch = 0; SolarProgApril = 0; SolarProgMay = 0; SolarProgJune = 0; SolarProgJuly = 0; SolarProgAugust = 0; SolarProgSeptember = 0; SolarProgOctober = 0;
SolarProgNovember = (SolarProgNovember / SolarDayLightOldMonth) *SolarDayLightOldMonthUntilToday;//Using the 'Daylight' prognosis because the 'Daylight'prognosis.
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Daylight prognosis november when the installation date is this year: '+SolarProgNovember);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes   
break;}} 

  case 12:{

if (SolarDayPrognosis === false){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = 0; SolarProgFebruary = 0; SolarProgMarch = 0; SolarProgApril = 0; SolarProgMay = 0; SolarProgJune = 0; SolarProgJuly = 0; SolarProgAugust = 0; SolarProgSeptember = 0; SolarProgOctober = 0; SolarProgNovember = 0;
SolarProgDecember = (SolarProgDecember/(GetDaysInMonth(12, Year)))*((GetDaysInMonth(12, Year)) - (SolarInstallDay - 1));
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember);
  console.log('Standard prognosis december when the installation date is this year: '+SolarProgDecember);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}
  
if (SolarDayPrognosis === true){//Determine the prognosis when the solarpanels were installed this year 
SolarProgJanuary = 0; SolarProgFebruary = 0; SolarProgMarch = 0; SolarProgApril = 0; SolarProgMay = 0; SolarProgJune = 0; SolarProgJuly = 0; SolarProgAugust = 0; SolarProgSeptember = 0; SolarProgOctober = 0; SolarProgNovember = 0
SolarProgDecember = (SolarProgDecember / SolarDayLightOldMonth) *SolarDayLightOldMonthUntilToday;//Using the 'Daylight' prognosis because the 'Daylight'prognosis.
SolarProgYear = (SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember + SolarProgDecember)
  console.log('Daylight prognosis december when the installation date is this year: '+SolarProgDecember);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes   
break;}}}}

var SolarProgThisMonth = Month;//Determing which prognosis should be used this month, also calculating the prognosis untill today in a certain month instead of a prognosis for the whole month
  switch(SolarProgThisMonth){
  
  case 1:{SolarProgThisMonth = SolarProgJanuary

if (SolarDayPrognosis === false){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = (SolarProgThisMonth/(GetDaysInMonth(1, Year))*Day);
var SolarProgYearUntilToday = (SolarProgThisMonth/(GetDaysInMonth(1, Year))*Day);      
  console.log('Standard prognosis SolarProgMonthUntilToday in January is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Standard prognosis SolarProgYearUntilToday in January is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
break;} 

if (SolarDayPrognosis === true){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = ((SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
var SolarProgYearUntilToday = ((SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
   console.log('Daylight prognosis SolarProgMonthUntilToday in January is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Daylight prognosis SolarProgYearUntilToday in January is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
break;}}

  case 2:{SolarProgThisMonth = SolarProgFebruary

if (SolarDayPrognosis === false){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = (SolarProgThisMonth/(GetDaysInMonth(2, Year))*Day);
var SolarProgYearUntilToday = ((SolarProgJanuary) + (SolarProgThisMonth/(GetDaysInMonth(2, Year))*Day));
  console.log('Standard prognosis SolarProgMonthUntilToday in February is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Standard prognosis SolarProgYearUntilToday in February is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}

if (SolarDayPrognosis === true){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = ((SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
var SolarProgYearUntilToday = ((SolarProgJanuary) + (SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
  console.log('Daylight prognosis SolarProgMonthUntilToday in February is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Daylight prognosis SolarProgYearUntilToday in February is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}}

  case 3:{SolarProgThisMonth = SolarProgMarch

if (SolarDayPrognosis === false){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = (SolarProgThisMonth/(GetDaysInMonth(3, Year))*Day);
var SolarProgYearUntilToday = ((SolarProgJanuary + SolarProgFebruary) + (SolarProgThisMonth/(GetDaysInMonth(3, Year))*Day));
  console.log('Standard prognosis SolarProgMonthUntilToday in March is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Standard prognosis SolarProgYearUntilToday in March is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}

if (SolarDayPrognosis === true){//Determine wich prognosis should be used 
   var SolarProgMonthUntilToday = ((SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
var SolarProgYearUntilToday = ((SolarProgJanuary + SolarProgFebruary) + (SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
  console.log('Daylight prognosis SolarProgMonthUntilToday in March is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Daylight prognosis SolarProgYearUntilToday in March is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
break;}} 

  case 4:{SolarProgThisMonth = SolarProgApril

if (SolarDayPrognosis === false){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = (SolarProgThisMonth/(GetDaysInMonth(4, Year))*Day)
var SolarProgYearUntilToday = ((SolarProgJanuary + SolarProgFebruary + SolarProgMarch) + (SolarProgThisMonth/(GetDaysInMonth(4, Year))*Day))
  console.log('Standard prognosis SolarProgMonthUntilToday in April is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Standard prognosis SolarProgYearUntilToday in April is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}

if (SolarDayPrognosis === true){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = ((SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
   var SolarProgYearUntilToday = ((SolarProgJanuary + SolarProgFebruary + SolarProgMarch) + (SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
  console.log('Daylight prognosis SolarProgMonthUntilToday in April is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Daylight prognosis SolarProgYearUntilToday in April is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}}

  case 5:{SolarProgThisMonth = SolarProgMay

  if (SolarDayPrognosis === false){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = (SolarProgThisMonth/(GetDaysInMonth(5, Year))*Day)
var SolarProgYearUntilToday = ((SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril) + (SolarProgThisMonth/(GetDaysInMonth(5, Year))*Day));
  console.log('Standard prognosis SolarProgMonthUntilToday in May is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Standard prognosis SolarProgYearUntilToday in May is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}

if (SolarDayPrognosis === true){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = ((SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
var SolarProgYearUntilToday = ((SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril) + (SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
  console.log('Daylight prognosis SolarProgMonthUntilToday in May is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Daylight prognosis SolarProgYearUntilToday in May is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}}

  case 6:{SolarProgThisMonth = SolarProgJune
if (SolarDayPrognosis === false){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = (SolarProgThisMonth/(GetDaysInMonth(6, Year))*Day)
var SolarProgYearUntilToday = ((SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay) + (SolarProgThisMonth/(GetDaysInMonth(6, Year))*Day));
  console.log('Standard prognosis SolarProgMonthUntilToday in June is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Standard prognosis SolarProgYearUntilToday in June is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}

if (SolarDayPrognosis === true){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = ((SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
var SolarProgYearUntilToday = ((SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay) + (SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
  console.log('Daylight prognosis SolarProgMonthUntilToday in May is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Daylight prognosis SolarProgYearUntilToday in May is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}}


  case 7:{SolarProgThisMonth = SolarProgJuly
if (SolarDayPrognosis === false){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = (SolarProgThisMonth/(GetDaysInMonth(7, Year))*Day)
var SolarProgYearUntilToday = ((SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune) + (SolarProgThisMonth/(GetDaysInMonth(7, Year))*Day));
  console.log('Standard prognosis SolarProgMonthUntilToday in July is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Standard prognosis SolarProgYearUntilToday in July is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}

if (SolarDayPrognosis === true){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = ((SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
var SolarProgYearUntilToday = ((SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune) + (SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
  console.log('Daylight prognosis SolarProgMonthUntilToday in July is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Daylight prognosis SolarProgYearUntilToday in July is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}}

  case 8:{SolarProgThisMonth = SolarProgAugust
if (SolarDayPrognosis === false){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = (SolarProgThisMonth/(GetDaysInMonth(8, Year))*Day);
var SolarProgYearUntilToday = ((SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly) + (SolarProgThisMonth/(GetDaysInMonth(8, Year))*Day));
  console.log('Standard prognosis SolarProgMonthUntilToday in August is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Standard prognosis SolarProgYearUntilToday in August is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}

if (SolarDayPrognosis === true){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = ((SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
var SolarProgYearUntilToday = ((SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly) + (SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
  console.log('Daylight prognosis SolarProgMonthUntilToday in August is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Daylight prognosis SolarProgYearUntilToday in August is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}}

  case 9: {SolarProgThisMonth = SolarProgSeptember
if (SolarDayPrognosis === false){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = (SolarProgThisMonth/(GetDaysInMonth(9, Year))*Day);
var SolarProgYearUntilToday = ((SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust) + (SolarProgThisMonth/(GetDaysInMonth(9, Year))*Day));
  console.log('Standard prognosis SolarProgMonthUntilToday in September is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Standard prognosis SolarProgYearUntilToday in September is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}

if (SolarDayPrognosis === true){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = ((SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
   var SolarProgYearUntilToday = ((SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust) + (SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
  console.log('Daylight prognosis SolarProgMonthUntilToday in September is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Daylight prognosis SolarProgYearUntilToday in September is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}}

  case 10:{SolarProgThisMonth = SolarProgOctober
if (SolarDayPrognosis === false){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = (SolarProgThisMonth/(GetDaysInMonth(10, Year))*Day);
var SolarProgYearUntilToday = ((SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember) + (SolarProgThisMonth/(GetDaysInMonth(10, Year))*Day));
  console.log('Standard prognosis SolarProgMonthUntilToday in October is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Standard prognosis SolarProgYearUntilToday in October is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}

if (SolarDayPrognosis === true){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = ((SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
var SolarProgYearUntilToday = ((SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember) + (SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
  console.log('Daylight prognosis SolarProgMonthUntilToday in October is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Daylight prognosis SolarProgYearUntilToday in October is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}} 

  case 11:{SolarProgThisMonth = SolarProgNovember
if (SolarDayPrognosis === false){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = (SolarProgThisMonth/(GetDaysInMonth(11, Year))*Day);
var SolarProgYearUntilToday = ((SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober) + (SolarProgThisMonth/(GetDaysInMonth(11, Year))*Day));
  console.log('Standard prognosis SolarProgMonthUntilToday in November is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Standard prognosis SolarProgYearUntilToday in November is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}

if (SolarDayPrognosis === true){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = ((SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
   var SolarProgYearUntilToday = ((SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober) + (SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
  console.log('Daylight prognosis SolarProgMonthUntilToday in November is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Daylight prognosis SolarProgYearUntilToday in November is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}}

  case 12:{SolarProgThisMonth = SolarProgDecember
if (SolarDayPrognosis === false){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = (SolarProgThisMonth/(GetDaysInMonth(12, Year))*Day);
var SolarProgYearUntilToday = ((SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember) + (SolarProgThisMonth/(GetDaysInMonth(12, Year))*Day));
  console.log('Standard prognosis SolarProgMonthUntilToday in December is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Standard prognosis SolarProgYearUntilToday in December is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}

if (SolarDayPrognosis === true){//Determine wich prognosis should be used 
var SolarProgMonthUntilToday = ((SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
var SolarProgYearUntilToday = ((SolarProgJanuary + SolarProgFebruary + SolarProgMarch + SolarProgApril + SolarProgMay + SolarProgJune + SolarProgJuly + SolarProgAugust + SolarProgSeptember + SolarProgOctober + SolarProgNovember) + (SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightUntilToday);
  console.log('Daylight prognosis SolarProgMonthUntilToday in December is: '+SolarProgMonthUntilToday);//Just logging for control purposes
  console.log('Daylight prognosis SolarProgYearUntilToday in December is: '+SolarProgYearUntilToday);//Just logging for control purposes
  console.log(SolarProgJanuary, SolarProgFebruary, SolarProgMarch, SolarProgApril, SolarProgMay, SolarProgJune, SolarProgJuly, SolarProgAugust, SolarProgSeptember, SolarProgOctober, SolarProgNovember, SolarProgDecember);//Just logging for control purposes
  break;}}}


var SolarDifferenceYear = (SolarYear - SolarProgYear).toFixed(2);//Calculating differences between the prognosis and realized production
  console.log('Difference between the Year prognosis and production including todays production untill now: '+SolarDifferenceYear);//Just logging for control purposes
  console.log('SolarProgYear is: '+SolarProgYear);//Just logging for control purposes
  console.log('SolarYear is: '+SolarYear);//Just logging for control purposes
  console.log('SolarProductionToday is: ' + SolarProductionToday);//Just logging for control purposes
var SolarDifferenceYearTillToday = (SolarYear - SolarProgYearUntilToday).toFixed(2);
  console.log('Difference between the Year prognosis untill today and production including todays production untill now: '+SolarDifferenceYearTillToday);//Just logging for control purposes
  console.log('SolarYear is: '+SolarYear);//Just logging for control purposes
  console.log('SolarProductionToday is: ' + SolarProductionToday);//Just logging for control purposes
  console.log('SolarProgYearUntilToday is: '+SolarProgYearUntilToday);//Just logging for control purposes
var SolarDifferenceMonth = (SolarMonth - SolarProgThisMonth).toFixed(2);
  console.log('Difference between the Month prognosis and production including todays production untill now '+SolarDifferenceMonth);
var SolarDifferenceMonthTillToday = (SolarMonth - SolarProgMonthUntilToday).toFixed(2);
  console.log('Difference between the Month prognosis untill today and production including todays production untill now '+SolarDifferenceMonthTillToday);//Just logging for control purposes
if (SolarDayPrognosis === false){//Determine wich prognosis should be used 
var SolarProgDay = (SolarProgThisMonth/GetDaysInMonth(Month, Year))};
if (SolarDayPrognosis === true){//Determine wich prognosis should be used 
 var SolarProgDay = ((SolarProgThisMonth/SolarDayLightMonth)*SolarDayLightToday)};
  console.log('Daily prognosis this month: '+SolarProgDay +' KWh');//Just logging for control purposes
var SolarDifferenceDay = (SolarProductionToday - SolarProgDay).toFixed(2);
  console.log('Difference between the Day prognosis and production including todays production untill now: '+SolarDifferenceDay);//Just logging for control purposes


if (SolarLanguage == 'English')//Determine wich language should be used 
{
var TxtKWh = 'KWh';//English Textblock
var TxtProgRealizedExact = 'The prognosis has been realized exactly.';//English Textblock
var TxtProgYearRealized =  'The prognosis has been realized, surplus: '+SolarDifferenceYear +' '+TxtKWh +'.';//English Textblock
var TxtProgYearNotRealized = 'To realize the prognosis ' +(SolarDifferenceYear * -1) +' '+ TxtKWh +' are needed. ';//English Textblock 
var TxtYearProductionTillToday = 'Year production until now ';//English Textblock
var TxtYearProductionTillTodayInNumbers = (SolarYear).toFixed(2);//English TextBlock
var TxtYearProductionDifference = ' Difference%20=> '+(SolarYear - SolarProgYearUntilToday).toFixed(2);//English textblock
var TxtProgYear = 'Year prognosis: ';//English Textblock
var TxtProgMonthRealized = 'The prognosis has been realized, surplus: '+SolarDifferenceMonth +' '+TxtKWh +'.';//English Textblock
var TxtProgMonthNotRealized = 'To realize the prognosis ' +(SolarDifferenceMonth * -1) +' '+TxtKWh + ' are needed. ';//English Textblock
var TxtMonthProductionTillToday = 'Month production until now: ';//English Textblock
var TxtMonthProductionTillTodayInNumbers = (SolarMonth).toFixed(2);//English TextBlock
var TxtMonthProductionDifference = ' Difference%20=> '+(SolarMonth - SolarProgMonthUntilToday).toFixed(2);//English Textblock
var TxtProgMonth = 'Month prognosis: ';//English Textblock
var TxtProgDayRealized =  'The prognosis has been realized, surplus: '+SolarDifferenceDay +' '+TxtKWh +'.';//English Textblock
var TxtProgDayNotRealized = 'To realize the prognosis ' +SolarDifferenceDay +' '+TxtKWh +' are needed. ';//English Textblock
var TxtDayProductionTillToday = 'Day production until now: ';//English Textblock
var TxtDayProductionDifference = ' Difference%20=> '+SolarDifferenceDay//english Textblock
var TxtProgBracketLeft = ' %28Prognosis: ';//English Textblock
var TxtProgBracketLeftTillToday = ' %28Prognosis until now: ';//English Textblock
var TxtProgBracketRight = ' %29';//English Textblock
}
else if (SolarLanguage == 'Dutch')//Determine wich language should be used
{
var TxtKWh = 'KWh'//Dutch Textblock
var TxtProgRealizedExact = 'De prognose is precies gehaald.';//Dutch Textblock
var TxtProgYearRealized =  'De prognose is gehaald, het overschot dit jaar is: '+SolarDifferenceYear +' '+TxtKWh +'.';//Dutch Textblock
var TxtProgYearNotRealized = 'Er moet nog ' +(SolarDifferenceYear * -1) +' '+TxtKWh +' worden geproduceerd om de prognose te halen.';//Dutch Textblock
var TxtYearProductionTillToday = 'Jaarproductie tot nu toe: ';//Dutch Textblock
var TxtYearProductionTillTodayInNumbers = (SolarYear).toFixed(2);//Dutch TextBlock
var TxtYearProductionDifference = ' Verschil%20=> '+(SolarYear - SolarProgYearUntilToday).toFixed(2);//Dutch Textblock
var TxtProgYear = 'Jaar prognose: ';//Dutch Textblock
var TxtProgMonthRealized = 'De prognose is gehaald, overschot is: ' +SolarDifferenceMonth +' ' +TxtKWh +'.';//Dutch Textblock
var TxtProgMonthNotRealized = 'Er moet nog ' +(SolarDifferenceMonth * -1) +' '+TxtKWh +' worden geproduceerd om de prognose te halen.';//Dutch Textblock
var TxtMonthProductionTillToday = 'Maandproductie tot nu toe: ';//Dutch Textblock
var TxtMonthProductionTillTodayInNumbers = (SolarMonth).toFixed(2);//Dutch TextBlock
var TxtMonthProductionDifference = ' Verschil%20=> '+(SolarMonth - SolarProgMonthUntilToday).toFixed(2);//Dutch Textblock
var TxtProgMonth = 'Maand prognose: ';//Dutch Textblock
var TxtProgDayRealized =  'De prognose is gehaald, het overschot vandaag is: '+SolarDifferenceDay +' '+TxtKWh +'.';//Dutch Textblock
var TxtProgDayNotRealized = 'Er moet nog ' +SolarDifferenceDay +' '+TxtKWh + ' worden geproduceerd om de prognose te halen.';//Dutch Textblock
var TxtDayProductionTillToday = 'Dagproductie tot nu toe: ';//Dutch Textblock
var TxtDayProductionDifference = ' Verschil%20=> '+SolarDifferenceDay;//Dutch Textblock
var TxtProgBracketLeft = ' %28Prognose: ';//Dutch Textblock
var TxtProgBracketLeftTillToday = ' %28Prognose tot nu toe: ';//Dutch Textblock
var TxtProgBracketRight = ' %29';//Dutch Textblock
}

if (SolarDifferenceYear == 0){//Determine wich textblock should be used if year prognosis has been met, realized or not realized
var SolarYearTxt = TxtProgRealizedExact
  console.log('Text year prognosis exactly realized: ' +SolarYearTxt)}//Just logging for control purposes

else if (SolarDifferenceYear < 0) {
var SolarYearTxt = TxtProgYearNotRealized
  console.log('Text year prognosis not realized: ' +SolarYearTxt)}//Just logging for control purposes

else if (SolarDifferenceYear > 0 ) {
var SolarYearTxt = TxtProgYearRealized
  console.log('Text year prognosis realized: ' +SolarYearTxt)};//Just logging for control purposes


if (SolarDifferenceMonth == 0){//Determine wich textblock should be used if month prognosis has been met, realized or not realized
var SolarMonthTxt = TxtProgRealizedExact
  console.log('Text month prognosis exactly realized: ' +SolarMonthTxt)}//Just logging for control purposes

else if (SolarDifferenceMonth < 0) {
var SolarMonthTxt = TxtProgMonthNotRealized
  console.log('Text month prognosis not realized : ' +SolarMonthTxt)}//Just logging for control purposes

else if (SolarDifferenceMonth > 0 ) {
var SolarMonthTxt = TxtProgMonthRealized
  console.log('Text month prognosis realized: ' +SolarMonthTxt)};//Just logging for control purposes

if (SolarDifferenceDay == 0){//Determine wich textblock should be used if fay prognosis has been met, realized or not realized
SolarDayTxt = TxtProgRealizedExact
  console.log('Text day prognosis exactly realized: ' +SolarDayTxt)}//Just logging for control purposes

else if (SolarDifferenceDay < 0) {
SolarDayTxt = TxtProgDayNotRealized
  console.log('Text day prognosis not realized: ' +SolarDayTxt)}//Just logging for control purposes

else if (SolarDifferenceDay > 0 ) {
SolarDayTxt = TxtProgDayRealized
  console.log('Text day prognosis realized: ' +SolarDayTxt)};//Just logging for control purposes


//Making the textblocks for the better logic variables in Homey
var SolarTextBlock1 = TxtDayProductionTillToday +SolarProductionToday +' '+TxtKWh +TxtProgBracketLeft +SolarProgDay.toFixed(2) +' '+TxtKWh +TxtDayProductionDifference +TxtProgBracketRight +'.';
var SolarTextBlock2 = TxtMonthProductionTillToday +TxtMonthProductionTillTodayInNumbers +' '+TxtKWh +TxtProgBracketLeftTillToday +SolarProgMonthUntilToday.toFixed(2) +' '+TxtKWh +TxtMonthProductionDifference +TxtProgBracketRight +'.';
var SolarTextBlock3 = TxtProgMonth +SolarProgThisMonth.toFixed(2) +' ' +TxtKWh +'.';
var SolarTextBlock4 = SolarMonthTxt;
var SolarTextBlock5 = TxtYearProductionTillToday +TxtYearProductionTillTodayInNumbers +' '+TxtKWh +TxtProgBracketLeftTillToday +SolarProgYearUntilToday.toFixed(2) +' '+TxtKWh +TxtYearProductionDifference +TxtProgBracketRight +'.';
var SolarTextBlock6 = TxtProgYear +SolarProgYear.toFixed(2) +' '+TxtKWh +'.';
var SolarTextBlock7 = SolarYearTxt;

  BLApp.apiPut('SolarTextBlock1/'+SolarTextBlock1);//Updating the better logic variables
  BLApp.apiPut('SolarTextBlock2/'+SolarTextBlock2);
  BLApp.apiPut('SolarTextBlock3/'+SolarTextBlock3);
  BLApp.apiPut('SolarTextBlock4/'+SolarTextBlock4);
  BLApp.apiPut('SolarTextBlock5/'+SolarTextBlock5);
  BLApp.apiPut('SolarTextBlock6/'+SolarTextBlock6);
  BLApp.apiPut('SolarTextBlock7/'+SolarTextBlock7);

//if (Day === SolarUpdate.value + 0.5){;//Setting better logic variable SolarUpdate to a whole number for the next day
SolarUpdate = false;
BLApp.apiPut('SolarUpdate/'+SolarUpdate);//Updating better logic variable SolarUpdate     
console.log('SolarUpdate after update is : ' +SolarUpdate);//Just logging for control purposes

//if (Day === SolarUpdate.value + 0.75){;//Setting better logic variable SolarUpdate to whole number for the next day
//    SolarUpdate = SolarUpdate.value + 0.25;
//    BLApp.apiPut('SolarUpdate/'+SolarUpdate);//Updating better logic variable SolarUpdate    
//    console.log('SolarUpdate after update is : ' +SolarUpdate);}//Just logging for control purposes
   
//if (Day === GetDaysInMonth){//Setting better logic variable SolarUpdate to 1 at the last day of a month fot the next month
//    SolarUpdate = 1;
//    BLApp.apiPut('SolarUpdate/'+SolarUpdate);//Updating better logic variable SolarUpdate     
//    console.log('SolarUpdate reset every first of a month : ' +SolarUpdate);}//Just logging for control purposes

This a no-no in Javascript: you’re blocking the event loop which can cause issues.

Instead, here’s a non-blocking variant:

const wait = ms => new Promise(resolve => setTimeout(resolve, ms));

// to use:
await wait(1234);

Also: times in Homeyscript under SDKv3 is always one or two hours behind local time, because all SDKv3 apps run in the UTC timezone. It’s difficult to say if this may be of consequence in your script.

2 Likes

Hello Marcel,

Thanks for sharing your script. This thread took my attention because i have a similar script, though less advanced. Scrolling through your script i think some things could be optimised using arrays and loops. The length of the script will be much shorter that way.

Maybe you can add an example of the message coming out of your script so we have a better understanding of what the script results in exactly?

My script is using the app “power by the hour” also. It calculates the yield prognose of day, month and year. I run the script once a day (at sunset) and get a notification with the yield of the day and the percentage of the day, month and year prognose yield. My script doesn’t take degradation and hours of sunlight per day into account.

Example of the notification:

At this moment, the day yield is on 21% of what it should be for a day in april. The month yield is at 64 % of what it should be on the 9th of april, and the year yield is at 90% of what it should be on this day of the year. (yes this hasn’t been a good year for solar panels in the Netherlands so far :frowning: )

If you like i can share my script in this thread also.

Yes I would like you to share, so that way we can optimize the script. My script is this long because i didn’t know anything of javascript, and still don’t know very much of it. But i got it working.

This is the message i receive once at the moment the production is < 50kw per hour.

Ok, here we go (excuse me for dutch variable names and remarks, i hope the script explains itself, else i will explain).

// Relatieve opbrengst voor zonnepanelen
// Output tags: relatieve dagopbrengst, relatieve maandopbrengs, relatieve jaaropbrengst

const PBTHID = ‘//your power by the hour solar panel device id here//’;
const PBTH_device = await Homey.devices.getDevice({id: PBTHID});
const dagopbrengst = PBTH_device.capabilitiesObj.kwh_this_day_total.value;
const maandopbrengst = PBTH_device.capabilitiesObj.kwh_this_month_total.value;
const jaaropbrengst = PBTH_device.capabilitiesObj.kwh_this_year_total.value;

// De verwachte maandopbrengsten voor mijn zonnepanelen (berekend met Photovoltaic Geographical Information System (PVGIS) | EU Science Hub)

//const maanddoelen = [142,202,415,568,581,553,556,513,405,301,155,122];
// De verwachte maandopbrengsten voor mijn zonnepanelen op basis van historisch data pv-output
const maanddoelen = [106,250,418,607,697,613,635,578,437,301,174,87];

//bepalen maand (0-11) en dag van de maand
const datum = new Date();
const dag = datum.getDate();
const maand = datum.getMonth();

//berekenen aantal dagen in deze maand
const dagen_in_maand = new Date(datum.getYear(), maand+1, 0).getDate();
//bereken van de (prognose) doelen
const dagdoel = maanddoelen[maand]/dagen_in_maand;
const prognose_maanddoel = (maanddoelen[maand]*(dag/dagen_in_maand));
const prognose_jaardoel = maanddoelen.reduce((a,b,i) => i < maand ? a + b : a, 0) + prognose_maanddoel;

console.log (prognose_jaardoel, prognose_maanddoel);

//berekenen van de relatieve opbrengst tov proportionele doel
let rel_dagopbrengst = (dagopbrengst/dagdoel).toFixed(2);
let rel_maandopbrengst = (maandopbrengst/prognose_maanddoel).toFixed(2);
let rel_jaaropbrengst = (jaaropbrengst/prognose_jaardoel).toFixed(2);

console.log(rel_dagopbrengst, rel_maandopbrengst, rel_jaaropbrengst);

//terug geven via tags voor gebruik in flow.
await tag(‘Relatieve_Dagopbrengst’, rel_dagopbrengst);
await tag(‘Relatieve_Maandopbrengst’, rel_maandopbrengst);
await tag(‘Relatieve_Jaaropbrengst’, rel_jaaropbrengst);

return true;

This script is triggered by this flow:

1 Like

when i try this in my script I get this error;

ReferenceError: SetTimeout is not defined
at Solar Panels js: 173:43
at new Promise ()
at wait
etc etc

Is this a js problem or a homeyscript problem or?

It’s an Athom problem: they apparently removed setTimeout support.

Luckily enough, they included a wait function, so if you just remove the first line of the code (const wait = …) it should work.

So the onlything i have to do is;
wait(1000)
?

No, await wait(1000)

1 Like

Just tested and works👌