Skip to content

Commit

Permalink
Merge pull request #102 from fboundy/dev
Browse files Browse the repository at this point in the history
3.6.3 - Bug fixes
  • Loading branch information
fboundy authored Feb 1, 2024
2 parents 4585bdb + 749c4c1 commit 204a65b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/pv_opt/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pv_opt:
overwrite_ha_on_restart: true
redact_personal_data_from_log: true

consumption_history_days: 2
consumption_history_days: 7

# ========================================
# Plant parameters
Expand Down
10 changes: 9 additions & 1 deletion apps/pv_opt/pv_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,7 @@ def _load_args(self, items=None):
over_write = self.args.get("overwrite_ha_on_restart", True)

change_entities = []
self.yaml_config = {}

self.log("Reading arguments from YAML:")
self.log("-----------------------------------")
Expand Down Expand Up @@ -855,6 +856,7 @@ def _load_args(self, items=None):
self.log(
f" {item:34s} = {str(self.config[item]):57s} {str(self.get_config(item)):>6s}: value(s) in YAML"
)
self.yaml_config[item] = self.config[item]

elif "id_" in item:
if min([self.entity_exists(v) for v in values]):
Expand All @@ -866,6 +868,7 @@ def _load_args(self, items=None):
self.log(
f" {item:34s} = {str(self.config[item]):57s} {str(self.get_config(item)):>6s}: value(s) in YAML"
)
self.yaml_config[item] = self.config[item]

elif self.entity_exists(self.get_default_config(item)):
self.config[item] = self.get_default_config(item)
Expand Down Expand Up @@ -902,6 +905,7 @@ def _load_args(self, items=None):
self.log(
f" {item:34s} = {str(self.config[item]):57s} {str(self.get_config(item)):>6s}: value in YAML"
)
self.yaml_config[item] = self.config[item]

elif min(arg_types[str]):
if self.debug:
Expand All @@ -915,6 +919,7 @@ def _load_args(self, items=None):
self.log(
f" {item:34s} = {str(self.config[item]):57s} {str(self.get_config(item)):>6s}: value in YAML"
)
self.yaml_config[item] = self.config[item]

else:
ha_values = [self.get_ha_value(entity_id=v) for v in values]
Expand Down Expand Up @@ -999,6 +1004,7 @@ def _load_args(self, items=None):
self.log(
f" {item:34s} = {str(self.config[item]):57s} {str(self.get_config(item)):>6s}: value in YAML"
)
self.yaml_config[item] = self.config[item]

elif (
len(values) > 1
Expand Down Expand Up @@ -1063,6 +1069,8 @@ def _load_args(self, items=None):

self.log("")

self.log(f">>> {self.yaml_config}")

self._expose_configs(over_write)

def _name_from_item(self, item):
Expand Down Expand Up @@ -1146,7 +1154,7 @@ def _expose_configs(self, over_write=True):

self.set_state(state=state, entity_id=entity_id)

elif item in self.config:
elif item in self.yaml_config:
state = self.get_state(entity_id)
new_state = str(self._state_from_value(self.config[item]))
if over_write and state != new_state:
Expand Down

0 comments on commit 204a65b

Please sign in to comment.