Skip to content

Commit

Permalink
Merge pull request #402 from vingerha/0.9.2
Browse files Browse the repository at this point in the history
Various
  • Loading branch information
m4dm4rtig4n authored Aug 25, 2023
2 parents 91502a8 + be23428 commit f407ddd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/models/export_home_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,14 @@ def ecowatt_delta(self, name, delta):
current_date = datetime.combine(datetime.now(), datetime.min.time()) + timedelta(days=delta)
fetch_date = current_date - timedelta(days=1)
ecowatt_data = self.db.get_ecowatt_range(fetch_date, fetch_date, "asc")
dayValue=""
if ecowatt_data:
forecast = {}
for data in ecowatt_data:
for date, value in json.loads(data.detail.replace("'", '"')).items():
date = datetime.strptime(date, self.date_format_detail)
forecast[f'{date.strftime("%H")} h'] = value
dayValue=data.value
attributes = {
"date": current_date.strftime(self.date_format),
"forecast": forecast,
Expand All @@ -258,7 +260,7 @@ def ecowatt_delta(self, name, delta):
name=f"{self.usage_point_id}.EcoWatt{name}",
uniq_id=uniq_id,
attributes=attributes,
state=123456.00
state=dayValue
)

def myelectricaldata_usage_point_id(self, measurement_direction):
Expand Down Expand Up @@ -628,4 +630,4 @@ def myelectricaldata_usage_point_id(self, measurement_direction):
attributes=attributes,
state=convert_kw(state),
device_class="energy"
)
)

0 comments on commit f407ddd

Please sign in to comment.