tronikos / opower

A Python library for getting historical and forecasted usage/cost from utilities that use opower.com such as PG&E
Apache License 2.0
65 stars 59 forks source link

Fix issue in Exelon with multiple accounts #25

Closed paultyng closed 1 year ago

paultyng commented 1 year ago

Fixes #22 for BGE, unsure about the presence of the .euapi paths on other providers.

For the parts shared with the supertype it may be better to refactor for some reusability.

paultyng commented 1 year ago

Pushed the fixes from your review. Confirmed this still works for me:

PS ...> python src/demo.py --utility bge --username XXX --password XXX

Current bill forecast: Forecast(account=Account(customer=Customer(uuid='XXX'), uuid='XXX', utility_account_id='XXX', meter_type=<MeterType.ELEC: 'ELEC'>), start_date=datetime.date(2023, 7, 21), end_date=datetime.date(2023, 8, 19), current_date=datetime.date(2023, 8, 7), unit_of_measure=<UnitOfMeasure.KWH: 'KWH'>, usage_to_date=855.0, cost_to_date=136.0, forecasted_usage=1706.0, forecasted_cost=271.0, typical_usage=1313.0, typical_cost=173.0)

Getting historical data: meter= ELEC aggregate_type= day start_date= 2023-07-31 09:55:22.658842 end_date= 2023-08-07 09:55:22.658842
start_time      end_time        consumption     provided_cost   start_minus_prev_end    end_minus_prev_end
2023-07-31 00:00:00-04:00       2023-08-01 00:00:00-04:00       55.17   8.4652848       None    None
2023-08-01 00:00:00-04:00       2023-08-02 00:00:00-04:00       68.74   10.5474656      0:00:00 1 day, 0:00:00
2023-08-02 00:00:00-04:00       2023-08-03 00:00:00-04:00       39.57   6.0716208       0:00:00 1 day, 0:00:00
2023-08-03 00:00:00-04:00       2023-08-04 00:00:00-04:00       67.12   10.2988928      0:00:00 1 day, 0:00:00
2023-08-04 00:00:00-04:00       2023-08-05 00:00:00-04:00       50.19   7.7011536       0:00:00 1 day, 0:00:00
paultyng commented 1 year ago

Ok, pushed fixes and made the account fetching common between the two locations. It could possibly be memoized in case both branches were invoked for some of the accounts, but I'm not very familiar with Python so just left it as is.

This still works for my account, but obviously unable to test that it still works with pepco/delmarva.