Kosten und Einsparungen in TypeScript berechnen
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Mit TypeScript können Sie eigene Berechnungen erstellen. Anhand des Codes unten auf dieser Seite können Sie ermitteln, ob es langfristig günstiger ist, Solarmodule zu installieren oder weiterhin Ihre Stromrechnung zu bezahlen.
Hier eine allgemeine Aufschlüsselung, wie die Kosten für Solarmodule im Code ermittelt werden.
Teil 1: Systemanforderungen und -einrichtung
Definieren Sie zuerst Ihren aktuellen Stromverbrauch und Ihre Rechnungen:
- Wie viel Strom verbrauchen Sie pro Monat? (
monthlyKwhEnergyConsumption
)
- Wie viel kostet dieser Strom? (
energyCostPerKwh
)
Geben Sie als Nächstes Ihre Pläne für das Sonnensystem ein:
- Wie viele Module? (
panelsCount
)
- Wie leistungsstark sind die Module? (
panelCapacityWatts
)
- Wie viel kostet die Installation? (
installationCostPerWatt
)
- Gibt es Rabatte auf das System? (
solarIncentives
)
Teil 2: Berechnungen
Anhand der eingegebenen Werte berechnet der Code Folgendes:
yearlyProductionAcKwh
: Die jährliche Strommenge, die Ihre Solarmodule insgesamt erzeugen können.
totalCostWithSolar
: Die Stromkosten über viele Jahre mit Solarmodulen.
totalCostWithoutSolar
: Die Stromkosten über viele Jahre ohne Solarmodule.
Teil 3: Ergebnisse
Der Code gibt Ihnen außerdem folgende Informationen:
savings
: Die Differenz zwischen den Kosten mit und ohne Solarmodule.
breakEvenYear
: Nach wie vielen Jahren entsprechen die Kosten der Solarmodule den Einsparungen beim Stromverbrauch.
Beispielcode
// Solar configuration, from buildingInsights.solarPotential.solarPanelConfigs
let panelsCount = 20;
let yearlyEnergyDcKwh = 12000;
// Basic settings
let monthlyAverageEnergyBill: number = 300;
let energyCostPerKwh = 0.31;
let panelCapacityWatts = 400;
let solarIncentives: number = 7000;
let installationCostPerWatt: number = 4.0;
let installationLifeSpan: number = 20;
// Advanced settings
let dcToAcDerate = 0.85;
let efficiencyDepreciationFactor = 0.995;
let costIncreaseFactor = 1.022;
let discountRate = 1.04;
// Solar installation
let installationSizeKw: number = (panelsCount * panelCapacityWatts) / 1000;
let installationCostTotal: number = installationCostPerWatt * installationSizeKw * 1000;
// Energy consumption
let monthlyKwhEnergyConsumption: number = monthlyAverageEnergyBill / energyCostPerKwh;
let yearlyKwhEnergyConsumption: number = monthlyKwhEnergyConsumption * 12;
// Energy produced for installation life span
let initialAcKwhPerYear: number = yearlyEnergyDcKwh * dcToAcDerate;
let yearlyProductionAcKwh: number[] = [...Array(installationLifeSpan).keys()].map(
(year) => initialAcKwhPerYear * efficiencyDepreciationFactor ** year,
);
// Cost with solar for installation life span
let yearlyUtilityBillEstimates: number[] = yearlyProductionAcKwh.map(
(yearlyKwhEnergyProduced, year) => {
const billEnergyKwh = yearlyKwhEnergyConsumption - yearlyKwhEnergyProduced;
const billEstimate =
(billEnergyKwh * energyCostPerKwh * costIncreaseFactor ** year) / discountRate ** year;
return Math.max(billEstimate, 0); // bill cannot be negative
},
);
let remainingLifetimeUtilityBill: number = yearlyUtilityBillEstimates.reduce((x, y) => x + y, 0);
let totalCostWithSolar: number =
installationCostTotal + remainingLifetimeUtilityBill - solarIncentives;
console.log(`Cost with solar: $${totalCostWithSolar.toFixed(2)}`);
// Cost without solar for installation life span
let yearlyCostWithoutSolar: number[] = [...Array(installationLifeSpan).keys()].map(
(year) => (monthlyAverageEnergyBill * 12 * costIncreaseFactor ** year) / discountRate ** year,
);
let totalCostWithoutSolar: number = yearlyCostWithoutSolar.reduce((x, y) => x + y, 0);
console.log(`Cost without solar: $${totalCostWithoutSolar.toFixed(2)}`);
// Savings with solar for installation life span
let savings: number = totalCostWithoutSolar - totalCostWithSolar;
console.log(`Savings: $${savings.toFixed(2)} in ${installationLifeSpan} years`);
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2025-03-09 (UTC).
[null,null,["Zuletzt aktualisiert: 2025-03-09 (UTC)."],[[["\u003cp\u003eThis webpage provides TypeScript code to calculate and compare the long-term costs of using solar panels versus continuing with your current electricity bill.\u003c/p\u003e\n"],["\u003cp\u003eThe code considers factors such as electricity consumption, solar panel system specifications, installation costs, incentives, and energy cost inflation to project expenses over time.\u003c/p\u003e\n"],["\u003cp\u003eBy comparing the total cost with and without solar, you can determine the potential savings and the break-even point for your solar panel investment.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code requires inputting your specific energy usage, solar panel system details, and financial parameters to generate personalized results.\u003c/p\u003e\n"]]],["The provided TypeScript code calculates the long-term cost-effectiveness of installing solar panels. It takes inputs like monthly energy consumption, electricity cost, panel count, panel capacity, installation cost, and incentives. The code then computes the annual electricity generation from solar panels, the total electricity cost with and without solar over a set lifespan, the difference in savings between both options, and the break-even year where the savings match the investment cost.\n"],null,["# Calculate costs and savings in TypeScript\n\n**European Economic Area (EEA) developers** If your billing address is in the European Economic Area, effective on 8 July 2025, the [Google\n| Maps Platform EEA Terms of Service](https://cloud.google.com/terms/maps-platform/eea) will apply to your use of the Services. [Learn more](/maps/comms/eea/faq). In addition, certain content from the Solar API will no longer be returned. [Learn more](/maps/comms/eea/solar).\n\nYou can create your own calculations using TypeScript. The code at the bottom of\nthis page helps you determine whether it's cheaper in the long run to install\nsolar panels or continue paying your electricity bill as is.\n\nHere's a high-level breakdown of how the code determines solar panel costs.\n\nPart 1: System needs and setup\n------------------------------\n\nFirst, define your current electricity usage and bills:\n\n- How much electricity do you use each month? (`monthlyKwhEnergyConsumption`)\n- How much does that electricity cost? (`energyCostPerKwh`)\n\nNext, enter your solar system plans:\n\n- How many panels? (`panelsCount`)\n- How powerful are the panels? (`panelCapacityWatts`)\n- How much does installation cost? (`installationCostPerWatt`)\n- Any discounts on the system? (`solarIncentives`)\n\nPart 2: Calculations\n--------------------\n\nBased on the inputted values, the code calculates:\n\n- `yearlyProductionAcKwh`: The total annual electricity your solar panels can generate.\n- `totalCostWithSolar`: The cost of electricity over many years **with** solar panels.\n- `totalCostWithoutSolar`: The cost of electricity over many years **without** solar panels.\n\nPart 3: Results\n---------------\n\nThe code also tells you the following:\n\n- `savings`: The difference between the cost with and without solar panels.\n- `breakEvenYear`: How many years until the cost of solar panels equals the savings on electricity.\n\nExample code\n------------\n\n\n```typescript\n// Solar configuration, from buildingInsights.solarPotential.solarPanelConfigs\nlet panelsCount = 20;\nlet yearlyEnergyDcKwh = 12000;\n\n// Basic settings\nlet monthlyAverageEnergyBill: number = 300;\nlet energyCostPerKwh = 0.31;\nlet panelCapacityWatts = 400;\nlet solarIncentives: number = 7000;\nlet installationCostPerWatt: number = 4.0;\nlet installationLifeSpan: number = 20;\n\n// Advanced settings\nlet dcToAcDerate = 0.85;\nlet efficiencyDepreciationFactor = 0.995;\nlet costIncreaseFactor = 1.022;\nlet discountRate = 1.04;\n\n// Solar installation\nlet installationSizeKw: number = (panelsCount * panelCapacityWatts) / 1000;\nlet installationCostTotal: number = installationCostPerWatt * installationSizeKw * 1000;\n\n// Energy consumption\nlet monthlyKwhEnergyConsumption: number = monthlyAverageEnergyBill / energyCostPerKwh;\nlet yearlyKwhEnergyConsumption: number = monthlyKwhEnergyConsumption * 12;\n\n// Energy produced for installation life span\nlet initialAcKwhPerYear: number = yearlyEnergyDcKwh * dcToAcDerate;\nlet yearlyProductionAcKwh: number[] = [...Array(installationLifeSpan).keys()].map(\n (year) =\u003e initialAcKwhPerYear * efficiencyDepreciationFactor ** year,\n);\n\n// Cost with solar for installation life span\nlet yearlyUtilityBillEstimates: number[] = yearlyProductionAcKwh.map(\n (yearlyKwhEnergyProduced, year) =\u003e {\n const billEnergyKwh = yearlyKwhEnergyConsumption - yearlyKwhEnergyProduced;\n const billEstimate =\n (billEnergyKwh * energyCostPerKwh * costIncreaseFactor ** year) / discountRate ** year;\n return Math.max(billEstimate, 0); // bill cannot be negative\n },\n);\nlet remainingLifetimeUtilityBill: number = yearlyUtilityBillEstimates.reduce((x, y) =\u003e x + y, 0);\nlet totalCostWithSolar: number =\n installationCostTotal + remainingLifetimeUtilityBill - solarIncentives;\nconsole.log(`Cost with solar: $${totalCostWithSolar.toFixed(2)}`);\n\n// Cost without solar for installation life span\nlet yearlyCostWithoutSolar: number[] = [...Array(installationLifeSpan).keys()].map(\n (year) =\u003e (monthlyAverageEnergyBill * 12 * costIncreaseFactor ** year) / discountRate ** year,\n);\nlet totalCostWithoutSolar: number = yearlyCostWithoutSolar.reduce((x, y) =\u003e x + y, 0);\nconsole.log(`Cost without solar: $${totalCostWithoutSolar.toFixed(2)}`);\n\n// Savings with solar for installation life span\nlet savings: number = totalCostWithoutSolar - totalCostWithSolar;\nconsole.log(`Savings: $${savings.toFixed(2)} in ${installationLifeSpan} years`);https://github.com/googlemaps-samples/js-solar-potential/blob/1892b99f1a8e4d7254c8b4426cfe9c8d492108b2/src/routes/sections/SolarPotentialSection.svelte#L53-L108\n```\n| **Note:** Read the [guide](/maps/documentation/javascript/using-typescript) on using TypeScript and Google Maps.\n\n\u003cbr /\u003e"]]