Skip to content

Commit

Permalink
Update coordinator.py
Browse files Browse the repository at this point in the history
  • Loading branch information
barleybobs authored Feb 28, 2024
1 parent 712c504 commit a90654a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions custom_components/ecowater_softener/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ async def _async_update_data(self):
if str(data_json['out_of_salt']).lower() == 'today':
data[OUT_OF_SALT_ON] = datetime.today().strftime('%Y-%m-%d')
elif str(data_json['out_of_salt']).lower() == 'tomorrow':
data[OUT_OF_SALT_ON] = (datetime.today() + datetime.timedelta(days=1)).strftime('%Y-%m-%d')
data[OUT_OF_SALT_ON] = (datetime.today() + timedelta(days=1)).strftime('%Y-%m-%d')
elif str(data_json['out_of_salt']).lower() == 'yesterday':
data[OUT_OF_SALT_ON] = (datetime.today() - timedelta(days=1)).strftime('%Y-%m-%d')
# Runs correct datetime.strptime() depending on date format entered during setup.
elif self._dateformat == "dd/mm/yyyy":
data[OUT_OF_SALT_ON] = datetime.strptime(data_json['out_of_salt'], '%d/%m/%Y').strftime('%Y-%m-%d')
Expand All @@ -80,4 +82,4 @@ async def _async_update_data(self):

return data
except Exception as e:
raise UpdateFailed(f"Error communicating with API: {e}")
raise UpdateFailed(f"Error communicating with API: {e}")

0 comments on commit a90654a

Please sign in to comment.