Skip to content

Commit

Permalink
Put back timing of yesterday data (#1583)
Browse files Browse the repository at this point in the history
* Put back timing of yesterday data

* Add files via upload
  • Loading branch information
springfall2008 authored Nov 2, 2024
1 parent 30696de commit 9ac2b02
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions apps/predbat/predbat.py
Original file line number Diff line number Diff line change
Expand Up @@ -7574,7 +7574,7 @@ def calculate_yesterday(self):
yesterday_load_step = self.step_data_history(self.load_minutes, 0, forward=False, scale_today=1.0, scale_fixed=1.0, base_offset=24 * 60 + self.minutes_now)
yesterday_pv_step = self.step_data_history(self.pv_today, 0, forward=False, scale_today=1.0, scale_fixed=1.0, base_offset=24 * 60 + self.minutes_now)
yesterday_pv_step_zero = self.step_data_history(None, 0, forward=False, scale_today=1.0, scale_fixed=1.0, base_offset=24 * 60 + self.minutes_now)
minutes_back = (self.now_utc_real - self.midnight_utc).total_seconds() / 60
minutes_back = self.minutes_now + 1

# Get SoC history to find yesterday SoC
soc_kwh_data = self.get_history_wrapper(entity_id=self.prefix + ".soc_kw_h0", days=2)
Expand Down Expand Up @@ -7624,8 +7624,8 @@ def calculate_yesterday(self):
return
cost_data = self.minute_data(cost_today_data[0], 2, self.now_utc, "state", "last_updated", backwards=True, clean_increment=False, smoothing=False, divide_by=1.0, scale=1.0)
cost_data_per_kwh = self.minute_data(cost_today_data[0], 2, self.now_utc, "p/kWh", "last_updated", attributes=True, backwards=True, clean_increment=False, smoothing=False, divide_by=1.0, scale=1.0)
cost_yesterday = cost_data.get(minutes_back + 5, 0.0)
cost_yesterday_per_kwh = cost_data_per_kwh.get(minutes_back + 5, 0.0)
cost_yesterday = cost_data.get(minutes_back, 0.0)
cost_yesterday_per_kwh = cost_data_per_kwh.get(minutes_back, 0.0)

cost_today_car_data = self.get_history_wrapper(entity_id=self.prefix + ".cost_today_car", days=2)
if not cost_today_car_data:
Expand All @@ -7636,8 +7636,8 @@ def calculate_yesterday(self):
else:
cost_data_car = self.minute_data(cost_today_car_data[0], 2, self.now_utc, "state", "last_updated", backwards=True, clean_increment=False, smoothing=False, divide_by=1.0, scale=1.0)
cost_data_car_per_kwh = self.minute_data(cost_today_car_data[0], 2, self.now_utc, "p/kWh", "last_updated", attributes=True, backwards=True, clean_increment=False, smoothing=False, divide_by=1.0, scale=1.0)
cost_yesterday_car = cost_data_car.get(minutes_back + 5, 0.0)
cost_car_per_kwh = cost_data_car_per_kwh.get(minutes_back + 5, 0.0)
cost_yesterday_car = cost_data_car.get(minutes_back, 0.0)
cost_car_per_kwh = cost_data_car_per_kwh.get(minutes_back, 0.0)

# Save state
self.dashboard_item(
Expand Down Expand Up @@ -10164,7 +10164,6 @@ def expose_config(self, name, value, quiet=True, event=False, force=False, in_pr
if item:
enabled = self.user_config_item_enabled(item)
if not enabled:
self.log("Not updating HA config {} to {} as disabled".format(name, value))
item["value"] = None
else:
entity = item.get("entity")
Expand All @@ -10180,8 +10179,6 @@ def expose_config(self, name, value, quiet=True, event=False, force=False, in_pr
self.inverter_needs_reset_force = name
self.log("Set reset inverter force true due to reset_inverter_force on item {}".format(name))
item["value"] = value
if not quiet:
self.log("Updating HA config {} to {}".format(name, value))
if item["type"] == "input_number":
"""INPUT_NUMBER"""
icon = item.get("icon", "mdi:numeric")
Expand Down Expand Up @@ -10562,8 +10559,6 @@ def load_user_config(self, quiet=True, register=False):
ha_value = None

if not enabled:
if not quiet:
self.log("Note: Disabled configuration item {}".format(name))
item["value"] = None

# Remove the state if the entity still exists
Expand Down

0 comments on commit 9ac2b02

Please sign in to comment.