apearson / southern-company-api

Node.js Library to access utility data from Southern Company power utilities (Alabama Power, Georgia Power, Mississippi Power)
BSD 3-Clause "New" or "Revised" License
40 stars 7 forks source link

GA Power Testing #140

Open paulhwangfti opened 4 months ago

paulhwangfti commented 4 months ago

I created a small node application to try and acquire some monthly usage data and was met with the following error.

C:\Users\phwang\Downloads\test-javascript\node_modules\southern-company-api\dist\main.js:117
                throw new Error(`Could not find ScWebToken in response`);
                      ^

Error: Could not find ScWebToken in response
    at SouthernCompanyAPI.<anonymous> (C:\Users\phwang\Downloads\test-javascript\node_modules\southern-company-api\dist\main.js:117:23)
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\phwang\Downloads\test-javascript\node_modules\southern-company-api\dist\main.js:5:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

The API doesn't seem to be working (at least for GA Power) and I essentially did a copy-paste of how the API should be used as shown in the Readme.md

paulhwangfti commented 4 months ago

Here's my exact app.js if needed

var express = require('express');
var SouthernCompanyAPI = require('southern-company-api').SouthernCompanyAPI;
var app = express();

app.get('/', function (req, res) {
  res.send('Hello World!');
});

const username = 'omit';
const password = 'omit';
var monthlyDataJson = "failed";

const getUsage = async () => {
  console.log('Getting Usage...');
  console.log('Username: ' + username);
  console.log('Password: ' + password);

  /* Instantiating API */
  const SouthernCompany = new SouthernCompanyAPI({
    username: username,
    password: password,
  });

  /* Listening for login success */
  SouthernCompany.on('connected', ()=>{
    console.info('Connected...');

    async function fetchMonthly() {
      /* Getting Monthly Data */
      const monthlyData = await SouthernCompany.getMonthlyData();

      /* Printing Monthly Data */
      console.info('Monthly Data', JSON.stringify(monthlyData));
    }
    fetchMonthly();

    async function fetchDaily() {
      /* Getting Daily Data */
      const startDate = new Date(2020, 2, 1);
      const endDate = new Date();
      const dailyData = await SouthernCompany.getDailyData(startDate, endDate);

      /* Printing daily data */
      console.info('Daily Data', JSON.stringify(dailyData));
    }
    fetchDaily();
  });

  /* Listening for any errors */
  SouthernCompany.on('error', console.error);
}

getUsage().then(() => {
    app.listen(3000, function () {
        console.log('Example app listening on port 3000!');
        console.log(monthlyDataJson);
    });
});
apearson commented 2 weeks ago

I haven't pushed a new version to npm yet but if you can pull the latest from this repo and try now.

If not, I should have a new version on npm in a day or so

apearson commented 2 weeks ago

3.1.0 has been published