Skip to content

Commit

Permalink
Update sensor after purge.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcwillox committed Jan 4, 2020
1 parent a3c2dcf commit e3571ca
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions custom_components/auto_backup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ async def new_snapshot(self, data, full=False):

# add to pending snapshots and update sensor.
self._pending_snapshots = 1
if (self.update_sensor_callback):
if self.update_sensor_callback:
self.update_sensor_callback()

# make request to create new snapshot.
Expand Down Expand Up @@ -345,7 +345,7 @@ async def new_snapshot(self, data, full=False):

# remove from pending snapshots and update sensor.
self._pending_snapshots = 0
if (self.update_sensor_callback):
if self.update_sensor_callback:
self.update_sensor_callback()

# purging old snapshots
Expand Down Expand Up @@ -376,6 +376,12 @@ async def purge_snapshots(self):
f"{DOMAIN}.purged_snapshots", {"snapshots": snapshots_purged}
)

# update sensor after purge.
if self.update_sensor_callback:
self.update_sensor_callback()
else:
_LOGGER.debug("No snapshots required purging.")

async def _purge_snapshot(self, slug):
"""Purge an individual snapshot from Hass.io."""
_LOGGER.debug("Attempting to remove snapshot: %s", slug)
Expand Down

0 comments on commit e3571ca

Please sign in to comment.