Merge branch 'hotfix/Issue18_19'
This commit is contained in:
@@ -36,7 +36,7 @@ class FplEntity(CoordinatorEntity):
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
attributes = {
|
attributes = {
|
||||||
"attribution": ATTRIBUTION,
|
"attribution": ATTRIBUTION,
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class FplApi(object):
|
|||||||
"""login and get account information"""
|
"""login and get account information"""
|
||||||
result = LOGIN_RESULT_OK
|
result = LOGIN_RESULT_OK
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(TIMEOUT, loop=asyncio.get_event_loop()):
|
async with async_timeout.timeout(TIMEOUT):
|
||||||
response = await self._session.get(
|
response = await self._session.get(
|
||||||
URL_LOGIN, auth=aiohttp.BasicAuth(self._username, self._password)
|
URL_LOGIN, auth=aiohttp.BasicAuth(self._username, self._password)
|
||||||
)
|
)
|
||||||
@@ -84,15 +84,16 @@ class FplApi(object):
|
|||||||
|
|
||||||
async def logout(self):
|
async def logout(self):
|
||||||
_LOGGER.info("Logging out")
|
_LOGGER.info("Logging out")
|
||||||
async with async_timeout.timeout(TIMEOUT, loop=asyncio.get_event_loop()):
|
URL = "https://www.fpl.com/api/resources/logout"
|
||||||
await self._session.get("https://www.fpl.com/api/resources/logout")
|
async with async_timeout.timeout(TIMEOUT):
|
||||||
|
await self._session.get(URL)
|
||||||
|
|
||||||
async def async_get_open_accounts(self):
|
async def async_get_open_accounts(self):
|
||||||
_LOGGER.info(f"Getting accounts")
|
_LOGGER.info(f"Getting accounts")
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(TIMEOUT, loop=asyncio.get_event_loop()):
|
async with async_timeout.timeout(TIMEOUT):
|
||||||
response = await self._session.get(URL_RESOURCES_HEADER)
|
response = await self._session.get(URL_RESOURCES_HEADER)
|
||||||
|
|
||||||
js = await response.json()
|
js = await response.json()
|
||||||
@@ -112,7 +113,7 @@ class FplApi(object):
|
|||||||
_LOGGER.info(f"Getting Data")
|
_LOGGER.info(f"Getting Data")
|
||||||
data = {}
|
data = {}
|
||||||
|
|
||||||
async with async_timeout.timeout(TIMEOUT, loop=asyncio.get_event_loop()):
|
async with async_timeout.timeout(TIMEOUT):
|
||||||
response = await self._session.get(
|
response = await self._session.get(
|
||||||
URL_RESOURCES_ACCOUNT.format(account=account)
|
URL_RESOURCES_ACCOUNT.format(account=account)
|
||||||
)
|
)
|
||||||
@@ -175,7 +176,7 @@ class FplApi(object):
|
|||||||
data = {}
|
data = {}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(TIMEOUT, loop=asyncio.get_event_loop()):
|
async with async_timeout.timeout(TIMEOUT):
|
||||||
response = await self._session.get(
|
response = await self._session.get(
|
||||||
URL_RESOURCES_PROJECTED_BILL.format(
|
URL_RESOURCES_PROJECTED_BILL.format(
|
||||||
account=account,
|
account=account,
|
||||||
@@ -208,7 +209,7 @@ class FplApi(object):
|
|||||||
|
|
||||||
URL = "https://www.fpl.com/api/resources/account/{account}/budgetBillingGraph/premiseDetails"
|
URL = "https://www.fpl.com/api/resources/account/{account}/budgetBillingGraph/premiseDetails"
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(TIMEOUT, loop=asyncio.get_event_loop()):
|
async with async_timeout.timeout(TIMEOUT):
|
||||||
response = await self._session.get(URL.format(account=account))
|
response = await self._session.get(URL.format(account=account))
|
||||||
if response.status == 200:
|
if response.status == 200:
|
||||||
r = (await response.json())["data"]
|
r = (await response.json())["data"]
|
||||||
@@ -242,7 +243,7 @@ class FplApi(object):
|
|||||||
URL = "https://www.fpl.com/api/resources/account/{account}/budgetBillingGraph"
|
URL = "https://www.fpl.com/api/resources/account/{account}/budgetBillingGraph"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(TIMEOUT, loop=asyncio.get_event_loop()):
|
async with async_timeout.timeout(TIMEOUT):
|
||||||
response = await self._session.get(URL.format(account=account))
|
response = await self._session.get(URL.format(account=account))
|
||||||
if response.status == 200:
|
if response.status == 200:
|
||||||
r = (await response.json())["data"]
|
r = (await response.json())["data"]
|
||||||
@@ -278,7 +279,7 @@ class FplApi(object):
|
|||||||
|
|
||||||
data = {}
|
data = {}
|
||||||
|
|
||||||
async with async_timeout.timeout(TIMEOUT, loop=asyncio.get_event_loop()):
|
async with async_timeout.timeout(TIMEOUT):
|
||||||
response = await self._session.post(URL.format(account=account), json=JSON)
|
response = await self._session.post(URL.format(account=account), json=JSON)
|
||||||
if response.status == 200:
|
if response.status == 200:
|
||||||
r = (await response.json())["data"]
|
r = (await response.json())["data"]
|
||||||
@@ -317,7 +318,7 @@ class FplApi(object):
|
|||||||
JSON = {"startDate": str(lastBilledDate.strftime("%m%d%Y"))}
|
JSON = {"startDate": str(lastBilledDate.strftime("%m%d%Y"))}
|
||||||
data = {}
|
data = {}
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(TIMEOUT, loop=asyncio.get_event_loop()):
|
async with async_timeout.timeout(TIMEOUT):
|
||||||
response = await self._session.post(
|
response = await self._session.post(
|
||||||
URL.format(account=account), json=JSON
|
URL.format(account=account), json=JSON
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user