{
  "schemaVersion": 1,
  "slug": "electricity-cost-calculator",
  "category": "household",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "93ea414526145b51fed9ed0af3b6ef2c9a66def3f3155338fb8f3de1aee91fa3",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/electricity-cost-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "E_y = 365 × q × (W ÷ 1000 × h + W_s ÷ 1000 × (24 − h)); C_h = W ÷ 1000 × r × q",
    "vars": [
      [
        "W",
        "Running power (W)"
      ],
      [
        "h",
        "Daily running hours"
      ],
      [
        "q",
        "Number of devices"
      ],
      [
        "W_s",
        "Standby power (W)"
      ],
      [
        "E_y",
        "Yearly energy (kWh)"
      ],
      [
        "r",
        "Electricity rate per kWh"
      ],
      [
        "C_h",
        "Active-use cost per hour for selected quantity"
      ]
    ],
    "note": "Standby hours = 24 − h. Daily/monthly/yearly totals include quantity q and active plus standby energy; monthly uses entered billing days, annual uses 365 days. C_h covers active use for all selected devices and excludes standby."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const mergedResult=(()=>{\nif((true&&(!Number.isFinite(watts)||watts<0.1||watts>1000000))||(true&&(!Number.isFinite(hoursPerDay)||hoursPerDay<0||hoursPerDay>24))||(true&&(!Number.isFinite(daysPerMonth)||daysPerMonth<1||daysPerMonth>31))||(true&&(!Number.isFinite(rate)||rate<0||rate>100))||(true&&(!Number.isFinite(quantity)||quantity<1||quantity>10000))||(true&&(!Number.isFinite(standbyWatts)||standbyWatts<0||standbyWatts>1000)))return{__error:'inputError'};\nconst q=Math.max(1,Math.round(quantity)); const activeKwhDay=watts/1000*hoursPerDay*q; const standbyKwhDay=standbyWatts/1000*(24-hoursPerDay)*q; const totalKwhDay=activeKwhDay+standbyKwhDay; const year=totalKwhDay*365; return {monthlyKwh:totalKwhDay*daysPerMonth,kwhPerDay:totalKwhDay,costPerDay:totalKwhDay*rate,costPerMonth:totalKwhDay*daysPerMonth*rate,costPerYear:year*rate,kwhPerYear:year,standbyCostPerYear:standbyKwhDay*365*rate,costPerHour:watts/1000*rate*q};\n})();return mergedResult.__error?{\"kwhPerDay\":null,\"costPerDay\":null,\"costPerMonth\":null,\"costPerYear\":null,\"kwhPerYear\":null,\"standbyCostPerYear\":null,\"costPerHour\":null,\"monthlyKwh\":null,...mergedResult}:mergedResult;",
    "inputs": [
      {
        "name": "watts",
        "type": "number",
        "default": 1500,
        "min": 0.1,
        "max": 1000000,
        "step": 0.1,
        "requiredValue": true,
        "strictRange": true
      },
      {
        "name": "hoursPerDay",
        "type": "number",
        "default": 4,
        "min": 0,
        "max": 24,
        "step": 0.1,
        "slider": true,
        "requiredValue": true,
        "strictRange": true
      },
      {
        "name": "daysPerMonth",
        "type": "number",
        "default": 30,
        "min": 1,
        "max": 31,
        "step": 1,
        "slider": true,
        "requiredValue": true,
        "strictRange": true
      },
      {
        "name": "rate",
        "type": "number",
        "default": 0.17,
        "min": 0,
        "max": 100,
        "step": 0.001,
        "requiredValue": true,
        "strictRange": true
      },
      {
        "name": "quantity",
        "type": "number",
        "default": 1,
        "min": 1,
        "max": 10000,
        "step": 1,
        "advanced": true,
        "requiredValue": true,
        "strictRange": true
      },
      {
        "name": "standbyWatts",
        "type": "number",
        "default": 0,
        "min": 0,
        "max": 1000,
        "step": 0.1,
        "advanced": true,
        "requiredValue": true,
        "strictRange": true
      }
    ],
    "outputs": [
      {
        "name": "kwhPerDay",
        "precision": 3,
        "unit": "kWh"
      },
      {
        "name": "costPerDay",
        "precision": 3,
        "unit": "$"
      },
      {
        "name": "costPerMonth",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "costPerYear",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "kwhPerYear",
        "precision": 1,
        "unit": "kWh"
      },
      {
        "name": "standbyCostPerYear",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "costPerHour",
        "precision": 4,
        "unit": "$"
      },
      {
        "name": "monthlyKwh",
        "precision": 3,
        "unit": "kWh"
      }
    ],
    "interpret": null
  }
}
