Skip to content

Conversation

@tronikos
Copy link
Member

@tronikos tronikos commented Jul 30, 2025

Breaking change

Proposed change

Bump Opower library
tronikos/opower@v0.12.4...v0.15.1

It includes fixes for the following utilities:

  • Duquesne Light Company
  • Pacific Gas & Electric (PG&E)

The changes in the integration are:

  • Support MFA flow (credentials -> mfa_options -> mfa_code) needed by PG&E. The result of async_submit_mfa_code is stored in login_data in the config entry and passed to subsequent async_login calls so that we can skip MFA. For PG&E this will work for 180 days before an MfaChallenge is raised which will trigger reauth to submit a new MFA code.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@joostlek joostlek modified the milestones: 2025.8.0b0, 2025.8.0 Jul 30, 2025
@joostlek
Copy link
Member

Can you elaborate a bit on why you would need to use a separate addon?

@tronikos
Copy link
Member Author

Now pge.com requires some headers (nifmwh7vqx-a to nifmwh7vqx-z) whose values are computed in JavaScript so it's hard to do that in Python. The add-on runs a headless browser that takes care of the login flow and returns the opower access token that the Opower integration needs. That token is only valid for a short time (under 30 minutes) and we don't have the refresh token so every 12 hours that the Opower integration refreshes data it delegates the login flow to the add-on to extract a fresh access token for opower.com.

Copy link
Contributor

@NoRi2909 NoRi2909 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few strings that need to be converted from title- to sentence-case.

tronikos and others added 2 commits July 31, 2025 09:25
Co-authored-by: Norbert Rittel <norbert@rittel.de>
@tronikos
Copy link
Member Author

tronikos commented Aug 1, 2025

Drafting it because I'm close to performing the PG&E login without the need of a separate add-on.

@tronikos
Copy link
Member Author

tronikos commented Aug 3, 2025

I removed the dependency to the login service. This is ready for review. I hope it can be reviewed and merged before the August release. Thanks!

@tronikos tronikos marked this pull request as ready for review August 3, 2025 06:27
@frenck frenck requested a review from Copilot August 5, 2025 10:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR upgrades the Opower library from version 0.12.4 to 0.15.1 to fix authentication issues with Pacific Gas & Electric (PG&E) and Duquesne Light Company, and adds support for interactive multi-factor authentication (MFA) flow.

  • Upgrades Opower library dependency to version 0.15.1
  • Implements interactive MFA flow with support for code selection and submission
  • Refactors config flow to use separate steps for utility selection, credentials, MFA options, and MFA code

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
requirements_all.txt Updates Opower library version from 0.12.4 to 0.15.1
requirements_test_all.txt Updates test requirements for Opower library
homeassistant/components/opower/manifest.json Updates integration requirements to use new Opower version
homeassistant/components/opower/const.py Adds new constant for login data storage
homeassistant/components/opower/coordinator.py Updates to handle MfaChallenge exception and pass login data
homeassistant/components/opower/config_flow.py Major refactor to support multi-step MFA flow
homeassistant/components/opower/strings.json Updates UI strings for new MFA flow steps
tests/components/opower/test_config_flow.py Comprehensive test updates for new MFA flow functionality

@frenck frenck marked this pull request as draft August 5, 2025 11:01
@tronikos tronikos marked this pull request as ready for review August 5, 2025 19:12
Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @tronikos 👍

../Frenck

@frenck frenck merged commit 0aeff36 into home-assistant:dev Aug 6, 2025
48 checks passed
frenck pushed a commit that referenced this pull request Aug 6, 2025
Co-authored-by: Norbert Rittel <norbert@rittel.de>
},
"mfa_code": {
"title": "Enter security code",
"description": "A security code has been sent via your selected method. Please enter it below to complete login.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed this (post-merge) while doing the translations in Lokalise:

As the totp_secret string above talks about using an authenticator app I wonder if "… has been sent …" here is a wording that does fit for that use case?

Copy link
Member Author

@tronikos tronikos Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently only one utility uses this flow that can either email you or text you the security code. But you are right, the MFA could be done via an authenticator app. In fact I expect someone from the community to change the current utility that takes TOTP secret to work with a security code in which case this description here would be confusing. In addition, there are utilities that don't ask you how you want to receive the code and I've code it if mfa_options is empty to come directly to this step to enter the security code. So in that scenario the description here would also be confusing since they didn't select any method. I changed the string in #150247 to avoid these issues. Thanks!

"mfa": {
"description": "The TOTP secret below is not one of the 6-digit time-based numeric codes. It is a string of around 16 characters containing the shared secret that enables your authenticator app to generate the correct time-based code at the appropriate time. See the documentation.",
"credentials": {
"title": "Enter Credentials",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also overlooked the missing sentence-casing here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 7, 2025
@tronikos tronikos deleted the opower_mfa branch August 8, 2025 04:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

5 participants