Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions src/opower/utilities/nipsco.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""NIPSCO (Northern Indiana Public Service Company)."""

from typing import Any

import aiohttp

from ..exceptions import InvalidAuth
from .base import UtilityBase


class Nipsco(UtilityBase):
"""NIPSCO utility implementation."""

@staticmethod
def name() -> str:
"""Return the name of the utility."""
return "Northern Indiana Public Service Company (NIPSCO)"

@staticmethod
def subdomain() -> str:
"""Return the opower.com subdomain for this utility."""
return "nipsco"

def utilitycode(self) -> str:
"""Return the opower.com utility code."""
return "nie"

@staticmethod
def timezone() -> str:
"""Return the timezone."""
return "America/Indiana/Indianapolis"

@staticmethod
async def async_login(
session: aiohttp.ClientSession,
username: str,
password: str,
login_data: dict[str, Any],
) -> str:
"""Login to the NIPSCO opower portal."""
async with session.post(
"https://nipsco.opower.com/ei/edge/apis/user-account-control-v1/cws/v1/nie/account/signin",
json={"username": username, "password": password},
headers={"x-requested-with": "XMLHttpRequest"},
raise_for_status=False,
) as resp:
if resp.status in (401, 403):
raise InvalidAuth("Invalid NIPSCO credentials")
resp.raise_for_status()

return ""
Loading