Skip to content

Commit

Permalink
Fix issue with restoring state from json when numeric values are stri…
Browse files Browse the repository at this point in the history
…ngs #14
  • Loading branch information
mdeweerd committed Nov 30, 2023
1 parent 6a109f9 commit f6f33ff
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apps/meters_to_ha/meters_to_ha.py
Original file line number Diff line number Diff line change
Expand Up @@ -2536,7 +2536,7 @@ def update_grdf_device(self, json_file):

if isinstance(response, dict) and "state" in response:
entity_data = response
previous_kWh = response["state"]
previous_kWh = float(response["state"])
if previous_kWh is not None:
try:
previous_kWh = float(previous_kWh)
Expand Down Expand Up @@ -2587,11 +2587,11 @@ def update_grdf_device(self, json_file):
if "grdf" in state:
grdf_state = state["grdf"]
self.mylog(f"grdf_state: {grdf_state!r}", "~~")
previous_kWh = grdf_state["state"]
previous_kWh = float(grdf_state["state"])
previous_date_str = grdf_state["attributes"]["date_time"]
previous_date = dt.datetime.fromisoformat(previous_date_str)
if "m3" in grdf_state:
previous_m3 = grdf_state["m3"]
previous_m3 = float(grdf_state["m3"])

self.mylog(
f"Previous {previous_m3} m3 {previous_kWh} kWh {previous_date}"
Expand Down

0 comments on commit f6f33ff

Please sign in to comment.