Skip to content

Commit

Permalink
Fixes (#429)
Browse files Browse the repository at this point in the history
* Add version info to auto-generated dashboard
* Update dynamic-entities-card.yaml

---------

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
  • Loading branch information
springfall2008 and pre-commit-ci-lite[bot] authored Dec 5, 2023
1 parent 0b89af1 commit 2b409ea
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
26 changes: 17 additions & 9 deletions apps/predbat/predbat.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import appdaemon.plugins.hass.hassapi as hass
import adbase as ad

THIS_VERSION = "v7.14.1"
THIS_VERSION = "v7.14.3"
TIME_FORMAT = "%Y-%m-%dT%H:%M:%S%z"
TIME_FORMAT_SECONDS = "%Y-%m-%dT%H:%M:%S.%f%z"
TIME_FORMAT_OCTOPUS = "%Y-%m-%d %H:%M:%S%z"
Expand Down Expand Up @@ -3100,7 +3100,9 @@ def record_status(self, message, debug="", had_errors=False, notify=False, extra
self.call_notify("Predbat status change to: " + message + extra)

self.dashboard_item(
self.prefix + ".status", state=message, attributes={"friendly_name": "Status", "icon": "mdi:information", "last_updated": datetime.now(), "debug": debug}
self.prefix + ".status",
state=message,
attributes={"friendly_name": "Status", "icon": "mdi:information", "last_updated": datetime.now(), "debug": debug, "version": THIS_VERSION},
)
if had_errors:
self.had_errors = True
Expand Down Expand Up @@ -5762,7 +5764,7 @@ def publish_discharge_limit(self, discharge_window, discharge_limits, best):
state=discharge_limit_percent,
attributes={
"results": discharge_limit_time,
"rate" : discharge_average,
"rate": discharge_average,
"friendly_name": "Predicted discharge limit best",
"state_class": "measurement",
"unit_of_measurement": "%",
Expand Down Expand Up @@ -5810,7 +5812,7 @@ def publish_discharge_limit(self, discharge_window, discharge_limits, best):
state=discharge_limit_percent,
attributes={
"results": discharge_limit_time,
"rate" : discharge_average,
"rate": discharge_average,
"friendly_name": "Predicted discharge limit",
"state_class": "measurement",
"unit_of_measurement": "%",
Expand Down Expand Up @@ -5912,7 +5914,7 @@ def publish_charge_limit(self, charge_limit, charge_window, charge_limit_percent
"state_class": "measurement",
"unit_of_measurement": "%",
"icon": "mdi:battery-charging",
"rate" : charge_average_first,
"rate": charge_average_first,
},
)
self.dashboard_item(
Expand Down Expand Up @@ -5960,7 +5962,7 @@ def publish_charge_limit(self, charge_limit, charge_window, charge_limit_percent
"state_class": "measurement",
"unit_of_measurement": "%",
"icon": "mdi:battery-charging",
"rate" : charge_average_first,
"rate": charge_average_first,
},
)
self.dashboard_item(
Expand Down Expand Up @@ -8506,6 +8508,12 @@ def fetch_sensor_data(self):
elif self.octopus_intelligent_charging:
octopus_ready_time = self.get_arg("octopus_ready_time", None)
octopus_limit = self.get_arg("octopus_charge_limit", None)
if octopus_limit:
try:
octopus_limit = float(octopus_limit)
except ValueError:
self.log("Warn: octopus_limit is set to a bad value {} in apps.yaml, must be a number".format(octopus_limit))
octopus_limit = None
if octopus_limit:
octopus_limit = self.dp2(float(octopus_limit) * self.car_charging_battery_size[0] / 100.0)
self.car_charging_limit[0] = min(self.car_charging_limit[0], octopus_limit)
Expand Down Expand Up @@ -8574,7 +8582,7 @@ def fetch_sensor_data(self):
saving_rate = event.get("octopoints_per_kwh", saving_rate * octopoints_per_penny) / octopoints_per_penny # Octopoints per pence
if code:
self.log("Joining Octopus saving event code {} start {} end {} price per kWh {}".format(code, start, end, saving_rate))
self.call_service("octopus_energy/join_octoplus_saving_session_event", event_code = code, entity_id = entity_id)
self.call_service("octopus_energy/join_octoplus_saving_session_event", event_code=code, entity_id=entity_id)

if joined_events:
for event in joined_events:
Expand Down Expand Up @@ -9246,7 +9254,7 @@ def create_entity_list(self):
"""

text = ""
text += "# Predbat Dashboard\n"
text += "# Predbat Dashboard - {}\n".format(THIS_VERSION)
text += "type: entities\n"
text += "Title: Predbat\n"
text += "entities:\n"
Expand Down Expand Up @@ -9580,4 +9588,4 @@ def run_time_loop_balance(self, cb_args):
except Exception as e:
self.log("ERROR: Exception raised {}".format(e))
self.record_status("ERROR: Exception raised {}".format(e))
raise e
raise e
7 changes: 5 additions & 2 deletions dynamic-entities-card.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
type: vertical-stack
title: Predbat 🦇
cards:
- type: entity
entity: predbat.status
- type: entities
entities:
- entity: predbat.status
- entity: update.predbat_version
- entity: select.predbat_mode
- type: custom:collapsable-cards
title: 🔀 Control
defaultOpen: false
Expand Down

0 comments on commit 2b409ea

Please sign in to comment.