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
53 stars 49 forks source link

New provider: City of Austin Utilities #64

Closed max2697 closed 5 months ago

max2697 commented 6 months ago

This PR related to issue https://github.com/tronikos/opower/issues/63 Adding support of City of Austin Utilities provider as well as supporting DSS portal type for Opower for this

Tested locally, demo script working fine, run all precommit checks. Not sure how I could test it with HA integration.

One note: I added ability to fetch user accounts from server. Not sure if user could have multiple accounts (it's one in my case) so I hardcoded it to use first every time. In case of some problems in future with this we could think about adding additional user accounts support.

atx32 commented 5 months ago

I am also on COA Utilities and would be willing to help with testing. I have no real Python experience but was able to get an opower development environment installed.

max2697 commented 5 months ago

Hello @tronikos Thank you for your review. Unfortunately it looks impossible to avoid changes at opower.py file:

  1. opower.py has hardcoded /ei/edge/apis/ paths. For COA provider it's /webcenter/edge/apis/ (see my posts at https://github.com/tronikos/opower/issues/63)
  2. Almost all REST API endpoints for DSS require header Opower-Selected-Entities with urn:session:account: information. They will return 401 in other cases.
  3. Subdomain starts dss- for all cases (See Oracle documentation here: https://docs.oracle.com/en/industries/energy-water/digital-self-service/transactions-seamless/Content/Transactions/SeamlessIntegration/Introduction_Seamless.htm)

I would like to avoid passing my credentials because that portal have a lot of personal and financial information (name, address, bank account) but I could run and show results for every test that is required to be sure that this solution is working. Alternatively, we could make a call in Discord and share screen to make sure that it's working properly.

max2697 commented 5 months ago

Hi @atx32, you can pull my branch and run the following command:

python src/demo.py --utility coautilities --username your_username  --password your_password --aggregate_type day

Please check if it's working for you as well. It's possible that you may have a different combination of accounts, and the behavior could be different. Do you have a gas account or is it electricity only for this portal? My version is electricity only."

atx32 commented 5 months ago

I just have an electric account. It may be good to find users who have other services on the same account such as water or trash to make sure there is no issue. This is what I get for the above command (with any sort of personal IDs in the response deleted):

Current bill forecast: Forecast(account=Account(customer=Customer(uuid='(deleted)'), uuid='(deleted)', utility_account_id='(deleted)', meter_type=<MeterType.ELEC: 'ELEC'>, read_resolution=None), start_date=datetime.date(2024, 1, 2), end_date=datetime.date(2024, 2, 1), current_date=datetime.date(2024, 1, 10), unit_of_measure=<UnitOfMeasure.KWH: 'KWH'>, usage_to_date=143.0, cost_to_date=15.0, forecasted_usage=725.0, forecasted_cost=78.0, typical_usage=632.0, typical_cost=65.0)

Getting historical data: account= Account(customer=Customer(uuid='(deleted)'), uuid='(deleted)', utility_account_id='(deleted)', meter_type=<MeterType.ELEC: 'ELEC'>, read_resolution=<ReadResolution.QUARTER_HOUR: 'QUARTER_HOUR'>) aggregate_type= day start_date= 2024-01-02 23:32:58.470564 end_date= 2024-01-09 23:32:58.470583 start_time end_time consumption provided_cost start_minus_prev_end end_minus_prev_end 2024-01-02 00:00:00-06:00 2024-01-03 00:00:00-06:00 23.1624 0.946878912 None None 2024-01-03 00:00:00-06:00 2024-01-04 00:00:00-06:00 22.5942 0.923650896 0:00:00 1 day, 0:00:00 2024-01-04 00:00:00-06:00 2024-01-05 00:00:00-06:00 23.2704 0.951293952 0:00:00 1 day, 0:00:00 2024-01-05 00:00:00-06:00 2024-01-06 00:00:00-06:00 24.6132 1.006187616 0:00:00 1 day, 0:00:00 2024-01-06 00:00:00-06:00 2024-01-07 00:00:00-06:00 22.3026 0.911730288 0:00:00 1 day, 0:00:00 2024-01-07 00:00:00-06:00 2024-01-08 00:00:00-06:00 26.6346 1.088822448 0:00:00 1 day, 0:00:00

I also tried aggregate_type=hour and for the historical data get the following (only copied the first few lines):

Getting historical data: account= Account(customer=Customer(uuid='(deleted)'), uuid='(deleted)', utility_account_id='(deleted)', meter_type=<MeterType.ELEC: 'ELEC'>, read_resolution=<ReadResolution.QUARTER_HOUR: 'QUARTER_HOUR'>) aggregate_type= hour start_date= 2024-01-02 23:48:26.760628 end_date= 2024-01-09 23:48:26.760647 start_time end_time consumption provided_cost start_minus_prev_end end_minus_prev_end 2024-01-02 00:00:00-06:00 2024-01-02 01:00:00-06:00 0.798 0.03262224 None None 2024-01-02 01:00:00-06:00 2024-01-02 02:00:00-06:00 0.8508 0.034780704 0:00:00 1:00:00 2024-01-02 02:00:00-06:00 2024-01-02 03:00:00-06:00 0.8154 0.033333552 0:00:00 1:00:00 2024-01-02 03:00:00-06:00 2024-01-02 04:00:00-06:00 0.7032 0.028746816 0:00:00 1:00:00 2024-01-02 04:00:00-06:00 2024-01-02 05:00:00-06:00 0.7278 0.029752464 0:00:00 1:00:00 2024-01-02 05:00:00-06:00 2024-01-02 06:00:00-06:00 0.732 0.02992416 0:00:00 1:00:00 2024-01-02 06:00:00-06:00 2024-01-02 07:00:00-06:00 0.753 0.03078264 0:00:00 1:00:00 2024-01-02 07:00:00-06:00 2024-01-02 08:00:00-06:00 0.9072 0.037086336 0:00:00 1:00:00 2024-01-02 08:00:00-06:00 2024-01-02 09:00:00-06:00 0.7686 0.031420368 0:00:00 1:00:00 2024-01-02 09:00:00-06:00 2024-01-02 10:00:00-06:00 1.146 0.04684848 0:00:00 1:00:00 2024-01-02 10:00:00-06:00 2024-01-02 11:00:00-06:00 1.1718 0.047903184 0:00:00 1:00:00

No issues for me so far.

tronikos commented 5 months ago

Once you address my comments and I release a new version, could you please:

tronikos commented 5 months ago

I released a new version. Thanks! Please bump the version on the Home Assistant side, update documentation, and add a virtual integration.

max2697 commented 4 months ago

@atx32 New version of HA includes this provider, you could try to use it. My integration is working good for now: https://www.home-assistant.io/integrations/coautilities/

atx32 commented 4 months ago

@atx32 New version of HA includes this provider, you could try to use it. My integration is working good for now: https://www.home-assistant.io/integrations/coautilities/

I already updated HA and added the integration. Working good for me too. Thanks for putting in the time on this.