Skip to content

Commit

Permalink
v4.0.18
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg committed May 10, 2024
1 parent 72b3cdc commit 1a7f29b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
11 changes: 10 additions & 1 deletion custom_components/solcast_solar/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ async def setup(self):
self._previousenergy = d

try:
#4.0.18 - added reset usage call to reset usage sensors at UTC midnight
async_track_utc_time_change(self._hass, self.update_utcmidnight_usage_sensor_data, hour=0,minute=0)
async_track_utc_time_change(self._hass, self.update_integration_listeners, second=0)
except Exception as error:
_LOGGER.error("SOLCAST - Error coordinator setup: %s", traceback.format_exc())
Expand All @@ -52,9 +54,16 @@ async def update_integration_listeners(self, *args):
#_LOGGER.error("SOLCAST - update_integration_listeners: %s", traceback.format_exc())
pass

async def update_utcmidnight_usage_sensor_data(self, *args):
try:
self.solcast.sites_usage()
except Exception:
#_LOGGER.error("SOLCAST - update_utcmidnight_usage_sensor_data: %s", traceback.format_exc())
pass

async def service_event_update(self, *args):
await self.solcast.http_data(dopast=False)
await self.solcast.sites_weather()
await self.solcast.http_data(dopast=False)
await self.update_integration_listeners()

async def service_event_delete_old_solcast_json_file(self, *args):
Expand Down
2 changes: 1 addition & 1 deletion custom_components/solcast_solar/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/oziee/ha-solcast-solar/issues",
"requirements": ["aiohttp>=3.8.5", "datetime>=4.3", "isodate>=0.6.1"],
"version": "4.0.17"
"version": "4.0.18"
}
4 changes: 3 additions & 1 deletion custom_components/solcast_solar/solcastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ async def load_saved_data(self):
with open(self._filename) as data_file:
jsonData = json.load(data_file, cls=JSONDecoder)
json_version = jsonData.get("version", 1)
self._weather = jsonData.get("weather", "unknown")
_LOGGER.debug(f"SOLCAST - load_saved_data file exists.. file type is {type(jsonData)}")
if json_version == _JSON_VERSION:
self._loaded_data = True
Expand Down Expand Up @@ -537,7 +538,8 @@ async def http_data(self, dopast = False):

self._data["last_updated"] = dt.now(timezone.utc).isoformat()
await self.sites_usage()
self._data['version'] = _JSON_VERSION
self._data["version"] = _JSON_VERSION
self._data["weather"] = self._weather
self._loaded_data = True

await self.buildforcastdata()
Expand Down
4 changes: 4 additions & 0 deletions info.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
### Changes

v4.0.18
- fixed weather sensor value not persisting
- reset the api limit and usage sensors at UTC midnight (reset usage)

v4.0.17
- updated Slovak translation thanks @misa1515
- added sensor for Solcast weather description
Expand Down

0 comments on commit 1a7f29b

Please sign in to comment.