springfall2008 / batpred

Home battery prediction and charging automation for Home Assistant, supporting many inverter types
https://springfall2008.github.io/batpred/
114 stars 39 forks source link

Mismatch between install instructions and code - when predbat dashboard is created #1221

Closed gcoan closed 2 months ago

gcoan commented 2 months ago

Describe the bug The installation instructions are (in summary);

  1. install inverter control (eg GivTCP)
  2. install predbat/appdaemon add-on
  3. Solcast
  4. configure apps.yaml
  5. predbat creates control entities in HA, so create your dashboard (use the predbat_dashboard.yaml)
  6. all ready? remove template:true, set predbat mode to Monitor, or Charge/Discharge

Only as shown with feedback on a couple of recent new users #1210 #1218 this sequence doesn't actually work because the predbat_dashboard.yaml is not created until the first time Predbat runs when template: true is removed from apps.yaml

Expected behavior I could change the documentation for a revised sequence of activity but I think it would be better if we changed the Predbat code.

The predbat entities in HA are created by load_user_config called as part of initialize but the Predbat dashboard is created by create_entity_list() which is only called from update_time_loop or run_time_loop both of which are called after the template check at line 11004 in predbat.py

Propose that when detecting a template config the predbat dashboard is still created so users can use it to build a dashboard from before having to turn Predbat 'on':

        # Catch template configurations and exit
        if self.get_arg("template", False):
            self.log("Error: You still have a template configuration, please edit apps.yaml or restart AppDaemon if you just updated with HACS")
            self.record_status("Error: You still have a template configuration, please edit apps.yaml or restart AppDaemon if you just updated with HACS")

# create predbat dashboard
            try:
                self.create_entity_list()
            except Exception as e:
                self.log("Error: Exception raised {}".format(e))
                self.log("Error: " + traceback.format_exc())
                self.record_status("Error: Exception raised {}".format(e))
                raise e

            return

Predbat version v8.0.0

Environment details n/a

gcoan commented 2 months ago

@springfall2008 I worked out how to test this now myself and it works fine, so unless you have a real objection to this change I'll include it in my next PR

springfall2008 commented 2 months ago

Seems like a fair change to make

gcoan commented 2 months ago

Changed and tested, will include in next PR

gcoan commented 3 weeks ago

Included in 8.3.3