Skip to content

Commit 7c64ef1

Browse files
committed
chore: Updated fan club mock
1 parent 57ab2ed commit 7c64ef1

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

custom_components/octopus_energy/api_client/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,8 +909,9 @@ async def async_get_fan_club_discounts(self, account_id: str) -> FanClubResponse
909909
url = f'{self._base_url}/v1/graphql/'
910910
payload = { "query": fan_club_discount_query.format(account_id=account_id) }
911911
headers = { "Authorization": f"JWT {self._graphql_token}", integration_context_header: request_context }
912-
async with client.post(url, json=payload, headers=headers) as heat_pump_response:
913-
response = await self.__async_read_response__(heat_pump_response, url)
912+
async with client.post(url, json=payload, headers=headers) as fan_club_response:
913+
response = await self.__async_read_response__(fan_club_response, url)
914+
_LOGGER.debug(f'async_get_fan_club_discounts response: {response}')
914915

915916
if (response is not None
916917
and "data" in response

custom_components/octopus_energy/fan_club/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ def get_fan_club_number(discountSource: str):
4242
return discountSource.split(":")[0].strip()
4343

4444
def mock_fan_club_forecast() -> FanClubResponse:
45+
# This is based on data provided by https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/discussions/538#discussioncomment-7613665
4546
now: datetime = utcnow()
4647
now_thirty_minute = now.replace(minute=30 if now.minute >= 30 else 0, second=0, microsecond=0)
4748
historic = []
49+
# Data is in 30 minute intervals
4850
current = now_thirty_minute
4951
for i in range(0, 48):
5052
current = current - timedelta(minutes=30)
@@ -54,7 +56,8 @@ def mock_fan_club_forecast() -> FanClubResponse:
5456
})
5557

5658
forecast = []
57-
current = now_thirty_minute
59+
# Data is in 1 hour intervals
60+
current = now.replace(minute=0, second=0, microsecond=0)
5861
for i in range(0, 48):
5962
current = current + timedelta(minutes=60)
6063
forecast.append({

0 commit comments

Comments
 (0)