added some more constants
This commit is contained in:
@@ -10,6 +10,8 @@ from homeassistant.core import callback
|
||||
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD, CONF_NAME
|
||||
|
||||
from .const import (
|
||||
CONF_ACCOUNTS,
|
||||
CONF_TERRITORY,
|
||||
DEFAULT_CONF_PASSWORD,
|
||||
DEFAULT_CONF_USERNAME,
|
||||
DOMAIN,
|
||||
@@ -70,12 +72,13 @@ class FplFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
if result == LOGIN_RESULT_OK:
|
||||
info = await api.get_basic_info()
|
||||
|
||||
accounts = info["accounts"]
|
||||
accounts = info[CONF_ACCOUNTS]
|
||||
|
||||
# accounts = await api.async_get_open_accounts()
|
||||
await api.logout()
|
||||
|
||||
user_input["accounts"] = accounts
|
||||
user_input[CONF_ACCOUNTS] = accounts
|
||||
user_input[CONF_TERRITORY] = info[CONF_TERRITORY]
|
||||
|
||||
return self.async_create_entry(title=username, data=user_input)
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
"""Constants for fpl."""
|
||||
#
|
||||
DEBUG = False
|
||||
|
||||
TIMEOUT = 5
|
||||
API_HOST = "https://www.fpl.com"
|
||||
|
||||
@@ -55,3 +53,10 @@ LOGIN_RESULT_INVALIDUSER = "NOTVALIDUSER"
|
||||
LOGIN_RESULT_INVALIDPASSWORD = "FAILEDPASSWORD"
|
||||
LOGIN_RESULT_UNAUTHORIZED = "UNAUTHORIZED"
|
||||
LOGIN_RESULT_FAILURE = "FAILURE"
|
||||
|
||||
|
||||
CONF_TERRITORY = "territory"
|
||||
CONF_ACCOUNTS = "account"
|
||||
|
||||
FPL_MAINREGION = "FL01"
|
||||
FPL_NORTHWEST = "FL02"
|
||||
|
||||
@@ -3,11 +3,13 @@ import sys
|
||||
import json
|
||||
import logging
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
import async_timeout
|
||||
|
||||
|
||||
from .const import (
|
||||
CONF_ACCOUNTS,
|
||||
CONF_TERRITORY,
|
||||
FPL_MAINREGION,
|
||||
LOGIN_RESULT_FAILURE,
|
||||
LOGIN_RESULT_OK,
|
||||
TIMEOUT,
|
||||
@@ -24,10 +26,6 @@ _LOGGER = logging.getLogger(__package__)
|
||||
URL_TERRITORY = API_HOST + "/cs/customer/v1/territoryid/public/territory"
|
||||
|
||||
|
||||
FPL_MAINREGION = "FL01"
|
||||
FPL_NORTHWEST = "FL02"
|
||||
|
||||
|
||||
class NoTerrytoryAvailableException(Exception):
|
||||
"""Thrown when not possible to determine user territory"""
|
||||
|
||||
@@ -88,51 +86,25 @@ class FplApi:
|
||||
"""returns basic info for sensor initialization"""
|
||||
await self.initialize()
|
||||
data = {}
|
||||
data["territory"] = self._territory
|
||||
data["accounts"] = await self.apiClient.get_open_accounts()
|
||||
data[CONF_TERRITORY] = self._territory
|
||||
data[CONF_ACCOUNTS] = await self.apiClient.get_open_accounts()
|
||||
|
||||
return data
|
||||
|
||||
async def async_get_data(self) -> dict:
|
||||
"""Get data from fpl api"""
|
||||
await self.initialize()
|
||||
data = {
|
||||
"as_of_days": 5,
|
||||
"avg_high_temp": 89,
|
||||
"billStartDate": "07-27-2022",
|
||||
"billToDateKWH": "196",
|
||||
"bill_to_date": 160.1,
|
||||
"budget_bill": True,
|
||||
"budget_billing_bill_to_date": 18.61,
|
||||
"budget_billing_daily_avg": 3.72,
|
||||
"budget_billing_projected_bill": 111.69,
|
||||
"current_bill_date": "2022-07-27",
|
||||
"dailyAverageKWH": 39,
|
||||
"daily_avg": 5.25,
|
||||
"daily_usage": [],
|
||||
"defered_amount": -6.84,
|
||||
"delMtrReading": "15929",
|
||||
"energy_percent_by_applicance": {},
|
||||
"meterSerialNo": "20948426",
|
||||
"next_bill_date": "2022-08-26",
|
||||
"projectedKWH": "1176",
|
||||
"projected_bill": 163.77,
|
||||
"recMtrReading": "",
|
||||
"remaining_days": 25,
|
||||
"service_days": 30,
|
||||
}
|
||||
data["accounts"] = []
|
||||
data = {}
|
||||
data[CONF_ACCOUNTS] = []
|
||||
|
||||
data["territory"] = self._territory
|
||||
|
||||
print(self._territory)
|
||||
data[CONF_TERRITORY] = self._territory
|
||||
|
||||
login_result = await self.apiClient.login()
|
||||
|
||||
if login_result == LOGIN_RESULT_OK:
|
||||
accounts = await self.apiClient.get_open_accounts()
|
||||
|
||||
data["accounts"] = accounts
|
||||
data[CONF_ACCOUNTS] = accounts
|
||||
for account in accounts:
|
||||
data[account] = await self.apiClient.update(account)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user