npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

emerald-estimator

v1.0.5

Published

A library for estimating bills from smart meter data in Ireland.

Downloads

30

Readme

Emerald Estimator

Introduction

Emerald Estimator is an open-source JavaScript library for estimating energy bills in the Republic of Ireland. It reads smart meter data provided by the ESB network and calculates energy costs based on consumption and exports.

Features

  • Parses energy consumption data from files.
  • Estimates energy bills using import and export readings.
  • Supports multiple energy providers with customizable rates.
  • Detailed consumption and cost breakdown.
  • Interpolates missing data for accuracy.

Installation

Installing Emerald Estimator in Node.js

For Node.js environments:

npm install emerald-estimator

Prerequesites: Node.js version 18 or higher.

Installing in browser environments

Include the following script tag in your HTML file to use Emerald Estimator directly in the browser from the unpkg CDN. This will make EmeraldEstimator available globally.

<script src="https://unpkg.com/emerald-estimator@latest"></script>

Note: Replace @latest in the URL with the specific version number if you want to use a particular version of the emerald-estimator library. The @latest tag will always pull the most recent version.

Usage

Initialization in Node.js

import { EnergyBillEstimator } from 'emerald-estimator';

const estimator = EnergyBillEstimator.create();

Initialization in Browser

In the browser, you don't need to import the module as it's included globally via the script tag.

<script>
    const estimator = EmeraldEstimator.create();
</script>

Loading Consumption Data

const fileContent = fs.readFileSync(filePath, 'utf8'); // or any other way to get the content of the file
estimator.withConsumption(fileContent);

fileContent is the content of the HDF file (csv file) obtained from the ESB website. See here for details.

Estimating Bills

const estimatedBills = estimator.estimate();

The estimate() method returns an object containing detailed estimation results. Here's a breakdown of its structure:

  • Provider Names: Each key in the object represents the name of an energy provider.
  • Estimation Details: For each electricity supply plan, the object includes:
    • total: The total estimated bill amount.
    • consumptionCharge: The total charge based on energy consumption.
    • standingCharge: The fixed daily charge from the provider.
    • exportReduction: The amount reduced from the bill due to energy export.
    • breakdown: An object detailing the consumption breakdown by rate. This includes:
      • consumption: The amount of energy consumed at each rate.
      • percentage: The percentage of total consumption at each rate.

Example Output

{
   "Electric Ireland Home Electric+ Night Boost":{
      "total":"2294.81",
      "consumptionCharge":"1937.62",
      "standingCharge":"357.19",
      "exportReduction":"0.00",
      "breakdown":{
         "0.1939":{
            "consumption":"1435.27",
            "percentage":"20.91"
         },
         "0.1138":{
            "consumption":"1698.63",
            "percentage":"24.75"
         },
         "0.3931":{
            "consumption":"3729.38",
            "percentage":"54.34"
         }
      }
   },
   "Plan2": {
    // Similar structure for other providers
  }
}

Build

To build Emerald Estimator for use in your project, follow these steps:

  1. Clone or download the repository to your local machine.

  2. Navigate to the root directory of the project.

  3. Run the following command to build the project:

    npm run build

This process compiles the source code into a production-ready bundle located in the dist directory, named EmeraldEstimator.bundle.js. You can then include this bundle in your project as needed.

The bundle can be integrated into various project types, including:

  • Node.js applications: Can be required as a module.
  • Web applications: Can be included as a script in HTML, accessible via the global variable EmeraldEstimator.
  • Modern JavaScript frameworks: Compatible with frameworks like React, Vue.js, and Angular.

Test

  • Build: npm run build
  • Test: npm run test
  • Clear Jest Cache: npm run clear-jest-cache
  • Test with Profiling: npm run test:profile

The library is exposed as EmeraldEstimator and is compatible with UMD (Universal Module Definition).

Dependencies

  • js-yaml
  • papaparse

Contributing

Contributions are welcome. Please submit pull requests, open issues, or suggest features.

License

Licensed under the GNU Affero General Public License (AGPL).