Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
fboundy committed Dec 22, 2023
1 parent bbc8f91 commit 9c4fe81
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions apps/pv_opt/pv_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,13 @@ def hass2df(self, entity_id, days=2, log=False):
hist = self.get_history(entity_id=entity_id, days=days)

if log:
self.log(f">>> {hist})
self.log(f">>> {hist}")
df = pd.DataFrame(hist[0]).set_index("last_updated")["state"]
df.index = pd.to_datetime(df.index, format="ISO8601")

if log:
self.log(f">>> {df}")

df = df.sort_index()
df = df[df != "unavailable"]
df = df[df != "unknown"]
Expand Down Expand Up @@ -316,7 +316,9 @@ def _estimate_capacity(self):
if "id_battery_charge_power" in self.config:
df = pd.DataFrame(
self.hass2df(
entity_id=self.config["id_battery_charge_power"], days=7, log=self.debug
entity_id=self.config["id_battery_charge_power"],
days=7,
log=self.debug,
).astype(int, errors="ignore")
).set_axis(["Power"], axis=1)

Expand Down Expand Up @@ -402,7 +404,9 @@ def _cost_today(self):
grid = (
pd.concat(
[
self.hass2df(self.config[f"id_{col}_today"], days=1,log=self.debug)
self.hass2df(
self.config[f"id_{col}_today"], days=1, log=self.debug
)
.astype(float)
.resample("30T")
.ffill()
Expand All @@ -424,14 +428,18 @@ def _cost_today(self):
grid = (
pd.concat(
[
self.hass2df(self.config["id_grid_import_power"], days=1,log=self.debug)
self.hass2df(
self.config["id_grid_import_power"], days=1, log=self.debug
)
.astype(float)
.resample("30T")
.mean()
.reindex(index)
.fillna(0)
.reindex(index),
self.hass2df(self.config["id_grid_export_power"], days=1, log=self.debug)
self.hass2df(
self.config["id_grid_export_power"], days=1, log=self.debug
)
.astype(float)
.resample("30T")
.mean()
Expand Down Expand Up @@ -1272,10 +1280,9 @@ def optimise(self):
# else:
# self.tariffs = self.config["alt_tariffs"] + [None]

x = self.hass2df(
self.config["id_battery_soc"],
days=1, log=self.debug
).astype(float)
x = self.hass2df(self.config["id_battery_soc"], days=1, log=self.debug).astype(
float
)
x = x.loc[x.loc[: self.static.index[0]].index[-1] :]
x = pd.concat(
[
Expand Down

0 comments on commit 9c4fe81

Please sign in to comment.