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

iberdrola-api-v2

v0.0.4

Published

A NodeJS Wrapper for Iberdrola Consumptions API v2

Downloads

12

Readme

An unofficial wrapper for Iberdrola API in NodeJS based on zoilomora and alvaro-octal version.

Installation

npm install --save iberdrola-api-v2

Usage

Iberdrola API is based on cookie sessions, so before making any request, you have wait until the request fisnishes.

var iberdrola = require('iberdrola-api-v2').login({
    email: '',
    password: '',
    token: ''
});

iberdrola.ready.then(() => {

    // Make requests

});

Alternativelly you can skip the Select Contract method by simply adding it to the credentials

var iberdrola = require('iberdrola-api-v2').login({
    email: '',
    password: '',
    token: '',
    contract: ''
});

iberdrola.ready.then(() => {

    // Login & Contract selected

}).catch((error) => {
    if (error === 'no-access') console.error('Unable to login');
    else if (error === 'no-contract') console.error('Unable to select contract');
    else console.error('Unexcepted error', error);
});

Methods

Every method returns a Promise:

Get Contracts

An account may have 0 to N contracts, most method require to have a selected contract.

iberdrola.getContracts().then((result) => {
    console.log({
        constracts: result
    })
}).catch(() => {
    console.error('Unable to list contracts')
});

// Output:

{
    direccion: 'False street 123',
    cups: 'ES0000000000000000XX',
    tipo: '',
    tipUsoEnergiaCorto: '',
    tipUsoEnergiaLargo: '',
    estContrato: 'Alta',
    codContrato: '0000000',
    esTelegestionado: true,
    presion: '0.00',
    fecUltActua: '01.01.2019',
    esTelemedido: false,
    tipSisLectura: 'TG',
    estadoAlta: true
}

Select Contract

Once you have selected to contract to operate, pick the codContrato value, this step is required in order to proceed with the following method.

iberdrola.selectContract('<codContrato>').then(() => {

    console.log('Contract selected');
    
    // Execute the following methods

}).catch(() => {
    console.error('Unable to select contract')
});

Get Reading

This method obtains your actual consumption (may take a while).


iberdrola.getReading().then((result) => {
    console.log({
        reading: result
    });
}).catch(() => {
    console.error('Unable to get reading');
});

// Output

{
    hour: 19,
    consumption: 238.95
}

Get Date Limits

This method gets the min and max (JS) dates in which you will be able to retreive data.


iberdrola.getDateLimits().then((result) => {
    console.log({
        limits: result
    });
}).catch(() => {
    console.error('Unable to get date limits');
});

// Output

{
    min: 2018-06-20T00:00:00.000Z,
    max: 2019-01-01T00:00:00.000Z
}

Get Readings of Day

This method obtains the consuption (watts/hour) of every hour of a given day.


iberdrola.getReadingsOfDay('2019-02-08').then((result) => {
    console.log({
        readings: result
    });
}).catch(() => {
    console.error('Unable to get readings of day');
});

// Output

[
     { hour: 0, consumption: 123 },
     { hour: 1, consumption: 213 },
     [...]
     { hour: 23, consumption: 253 }
]

Get Exports of Day

This method obtains the production (watts/hour) of every hour of a given day.


iberdrola.getExportsOfDay('2019-02-08').then((result) => {
    console.log({
        readings: result
    });
}).catch(() => {
    console.error('Unable to get readings of day');
});

// Output

[
     { hour: 0, generation: 0 },
     { hour: 1, generation: 213 },
     [...]
     { hour: 23, generation: 253 }
]

License

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.