From 9ac2b0229dae8af1f43d79c82c87c9f95cb6bfda Mon Sep 17 00:00:00 2001 From: Trefor Southwell <48591903+springfall2008@users.noreply.github.com> Date: Sat, 2 Nov 2024 17:07:51 +0000 Subject: [PATCH] Put back timing of yesterday data (#1583) * Put back timing of yesterday data * Add files via upload --- apps/predbat/predbat.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/apps/predbat/predbat.py b/apps/predbat/predbat.py index 91d836f2..aa42874a 100644 --- a/apps/predbat/predbat.py +++ b/apps/predbat/predbat.py @@ -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) @@ -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: @@ -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( @@ -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") @@ -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") @@ -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