Skip to content

Commit

Permalink
Force all cache files to /config #43
Browse files Browse the repository at this point in the history
  • Loading branch information
autoSteve committed Jun 18, 2024
1 parent a3dadc7 commit 2e8d961
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion custom_components/solcast_solar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
options = ConnectionOptions(
entry.options[CONF_API_KEY],
SOLCAST_URL,
hass.config.path('solcast.json'),
hass.config.path('/config/solcast.json'),
tz,
optdamp,
entry.options[CUSTOM_HOUR_SENSOR],
Expand Down
14 changes: 7 additions & 7 deletions custom_components/solcast_solar/solcastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ async def sites_data(self):
params = {"format": "json", "api_key": spl.strip()}
async with async_timeout.timeout(60):
if len(sp) == 1:
apiCacheFileName = "solcast-sites.json"
apiCacheFileName = "/config/solcast-sites.json"
else:
apiCacheFileName = "solcast-sites-%s.json" % (spl,)
apiCacheFileName = "/config/solcast-sites-%s.json" % (spl,)
_LOGGER.debug(f"SOLCAST apiCacheEnabled={str(self.apiCacheEnabled)}, {apiCacheFileName}={str(file_exists(apiCacheFileName))}")
if self.apiCacheEnabled and file_exists(apiCacheFileName):
_LOGGER.debug(f"SOLCAST - loading cached sites data")
Expand Down Expand Up @@ -204,9 +204,9 @@ async def sites_usage(self):
_LOGGER.debug(f"SOLCAST - getting API limit and usage from solcast for {sitekey}")
async with async_timeout.timeout(60):
if len(sp) == 1:
apiCacheFileName = "solcast-usage.json"
apiCacheFileName = "/config/solcast-usage.json"
else:
apiCacheFileName = "solcast-usage-%s.json" % (spl,)
apiCacheFileName = "/config/solcast-usage-%s.json" % (spl,)
resp: ClientResponse = await self.aiohttp_session.get(
url=f"https://api.solcast.com.au/json/reply/GetUserUsageAllowance", params=params, ssl=False
)
Expand Down Expand Up @@ -610,9 +610,9 @@ async def http_data(self, dopast = False):
_LOGGER.debug(f"SOLCAST - API polling for rooftop {site['resource_id']}")
#site=site['resource_id'], apikey=site['apikey'],
if len(self._sites) == 1:
usageCacheFileName = "solcast-usage.json"
usageCacheFileName = "/config/solcast-usage.json"
else:
usageCacheFileName = "solcast-usage-%s.json" % (site['apikey'],)
usageCacheFileName = "/config/solcast-usage-%s.json" % (site['apikey'],)
result = await self.http_data_call(usageCacheFileName, site['resource_id'], site['apikey'], dopast)
if not result:
failure = True
Expand Down Expand Up @@ -750,7 +750,7 @@ async def fetch_data(self, usageCacheFileName, path= "error", hours=168, site=""
_LOGGER.debug(f"SOLCAST - fetch_data code url - {url}")

async with async_timeout.timeout(480):
apiCacheFileName = cachedname + "_" + site + ".json"
apiCacheFileName = '/config/' + cachedname + "_" + site + ".json"
if self.apiCacheEnabled and file_exists(apiCacheFileName):
_LOGGER.debug(f"SOLCAST - Getting cached testing data for site {site}")
status = 404
Expand Down

0 comments on commit 2e8d961

Please sign in to comment.