Skip to content

Commit

Permalink
Merge pull request #110 from corneel27/addon
Browse files Browse the repository at this point in the history
Addon versie 2024.5.6
  • Loading branch information
corneel27 committed Jul 15, 2024
2 parents 1b78ddc + bfb5859 commit 0b98bdc
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 17 deletions.
6 changes: 6 additions & 0 deletions dao/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog 刀 DAO
# Day Ahead Optimization
## [V2024.5.6]
- When there is "no battery" configured in the settings the program produced an "list indexout of range".
This error is solved.
- The error messages are now more clear and accurate: correct filename and line nr.
- There was an error in the dasbboard invoking a report (Report\Balans). This error is solved.

## [V2024.5.5]
There is a fourth source added to get day-ahead prices: **tibber**.<br>
In cases as on June 25th when Nordpool and Entsoe don't have epex prices you can get them from Tibber.
Expand Down
2 changes: 1 addition & 1 deletion dao/config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: 刀 Day Ahead Optimization
version: "2024.5.5"
version: "2024.5.6"
slug: day_ahead_opt
description: Docker used by Home Assistant Community Add-ons for day ahead optimizations
url: https://github.com/corneel27/day-ahead/
Expand Down
2 changes: 1 addition & 1 deletion dao/prog/da_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def run_task_function(self, task, logfile: bool = False):
self.set_last_activity()
except Exception as ex:
logging.error(ex)
logging.error(error_handling())
logging.error(error_handling(ex))
if logfile:
file_handler.flush()
file_handler.close()
Expand Down
13 changes: 5 additions & 8 deletions dao/prog/da_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,15 +543,12 @@ def get_energy_balance_data(self, periode, _vanaf=None, _tot=None):
code_result = self.db_da.run_select_query(sql)
code_result.index = pd.to_datetime(code_result["tijd"])
#self.add_col_df(code_result, result, key)
code_result.rename(columns={key: "temp"})
result = pd.concat([result, code_result["temp"]], axis=0)
result.assign(key = key +"temp")

if code_result.shape[0] == 0:
# datetime.datetime.combine(vanaf, datetime.time(0,0)) - datetime.timedelta(hours=1)
last_moment = vanaf
else:
if len(code_result)>0:
self.add_col_df(code_result, result, key)
last_moment = code_result['tot'].iloc[-1] + datetime.timedelta(hours=1)
else:
last_moment = vanaf

if last_moment < tot:
ha_result = None
if categorie["sensors"] == "calc":
Expand Down
7 changes: 3 additions & 4 deletions dao/prog/day_ahead.py
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,7 @@ def calc_optimum(self):
self.call_service("set_datetime", entity_id=entity_stop_laden,
datetime=new_state_stop_laden)
except Exception as ex:
error_str = utils.error_handling()
error_str = utils.error_handling(ex)
logging.error(ex)
logging.error(f"Onverwachte fout: {error_str}")
else:
Expand Down Expand Up @@ -1826,10 +1826,9 @@ def calc_optimum(self):
bottom, top = axis22.get_ylim()
if bottom > 0:
axis22.set_ylim([0, top])
lns = ln1[0]
for b in range(B)[1:]:
lns = []
for b in range(B):
lns += ln1[b]
# lns += ln2 + ln3 + ln4
if ln2:
lns += ln2
if ln3:
Expand Down
27 changes: 25 additions & 2 deletions dao/prog/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pandas as pd
from requests import post
import logging
import traceback


def make_data_path():
Expand Down Expand Up @@ -244,6 +245,28 @@ def version_number(version_str: str) -> int:
lst.reverse()
return sum(x * (100 ** i) for i, x in enumerate(lst))

def log_exc_plus():
"""
Print the usual traceback information,
"""
tb = sys.exc_info()[2]
while 1:
if not tb.tb_next:
break
tb = tb.tb_next
stack = []
f = tb.tb_frame
while f:
stack.append(f)
f = f.f_back
stack.reverse()
traceback.print_exc()
for frame in stack:
logging.error(f"File: {frame.f_code.co_filename}, line {frame.f_lineno}, in {frame.f_code.co_name}")

def error_handling():
return ' {}. {}, regelnummer: {}'.format(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2].tb_lineno)

def error_handling(ex):
if logging.root.level == logging.DEBUG:
logging.exception(ex)
else:
log_exc_plus()
2 changes: 1 addition & 1 deletion dao/prog/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2024.5.5'
__version__ = '2024.5.6'

0 comments on commit 0b98bdc

Please sign in to comment.