Skip to content

Commit

Permalink
chore: clean
Browse files Browse the repository at this point in the history
  • Loading branch information
m4dm4rtig4n committed May 29, 2024
1 parent a3ddb89 commit a6c18d1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/models/ajax.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@ def import_data(self, target=None):
}

def new_account(self, configs):
print(vars(configs))
self.usage_point_id = configs["usage_point_id"]
title(f"[{self.usage_point_id}] Ajout d'un nouveau point de livraison:")
output = {}
Expand Down
1 change: 0 additions & 1 deletion src/models/export_home_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def __init__(self, usage_point_id):
self.usage_point = DB.get_usage_point(self.usage_point_id)
self.mqtt = MQTT
self.tempo_color = None
print(self.config.__dict__)

def load_config(self):
"""Load the configuration for Home Assistant.
Expand Down
13 changes: 5 additions & 8 deletions src/models/query_daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ def daterange(start_date, end_date):


class Daily:
"""
The 'Daily' class represents a daily data retrieval and manipulation process for a specific usage point. It provides methods for fetching, resetting, deleting, and blacklisting daily data.
"""The 'Daily' class represents a daily data retrieval and manipulation process for a specific usage point. It provides methods for fetching, resetting, deleting, and blacklisting daily data.
Attributes:
config (dict): The configuration settings.
Expand Down Expand Up @@ -107,9 +106,8 @@ def __init__(self, headers, usage_point_id, measure_type="consumption"):
if measure_type == "consumption":
if hasattr(self.usage_point_config, "consumption_price_base"):
self.base_price = self.usage_point_config.consumption_price_base
else:
if hasattr(self.usage_point_config, "production_price"):
self.base_price = self.usage_point_config.production_price
elif hasattr(self.usage_point_config, "production_price"):
self.base_price = self.usage_point_config.production_price

def run(self, begin, end):
begin_str = begin.strftime(self.date_format)
Expand Down Expand Up @@ -255,7 +253,7 @@ def get(self):
"error": True,
"description": "MyElectricalData est indisponible.",
}
if "error" in response and response["error"]:
if response.get("error"):
logging.error("Echec de la récupération des données")
logging.error(f'=> {response["description"]}')
logging.error(f"=> {begin.strftime(self.date_format)} -> {end.strftime(self.date_format)}")
Expand Down Expand Up @@ -284,15 +282,14 @@ def fetch(self, date):
datetime.combine(date - timedelta(days=2), datetime.min.time()),
datetime.combine(date + timedelta(days=2), datetime.min.time()),
)
if "error" in result and result["error"]:
if result.get("error"):
return {
"error": True,
"notif": result["description"],
"fail_count": self.db.get_daily_fail_count(self.usage_point_id, date, self.measure_type),
}
for item in result:
if date.strftime(self.date_format) in item["date"]:
print(Stat(self.usage_point_id, self.measure_type).get_daily(date, "hc"))
item["hc"] = Stat(self.usage_point_id, self.measure_type).get_daily(date, "hc")
item["hp"] = Stat(self.usage_point_id, self.measure_type).get_daily(date, "hp")
return item
Expand Down

0 comments on commit a6c18d1

Please sign in to comment.