mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Fix Solaredge integration in case the data is not complete (#43557)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
4bcb6c0ec6
commit
035860ebb2
@ -425,22 +425,21 @@ class SolarEdgeEnergyDetailsService(SolarEdgeDataService):
|
|||||||
self.data = {}
|
self.data = {}
|
||||||
self.attributes = {}
|
self.attributes = {}
|
||||||
self.unit = energy_details["unit"]
|
self.unit = energy_details["unit"]
|
||||||
meters = energy_details["meters"]
|
|
||||||
|
|
||||||
for entity in meters:
|
for meter in energy_details["meters"]:
|
||||||
for key, data in entity.items():
|
if "type" not in meter or "values" not in meter:
|
||||||
if key == "type" and data in [
|
continue
|
||||||
"Production",
|
if meter["type"] not in [
|
||||||
"SelfConsumption",
|
"Production",
|
||||||
"FeedIn",
|
"SelfConsumption",
|
||||||
"Purchased",
|
"FeedIn",
|
||||||
"Consumption",
|
"Purchased",
|
||||||
]:
|
"Consumption",
|
||||||
energy_type = data
|
]:
|
||||||
if key == "values":
|
continue
|
||||||
for row in data:
|
if len(meter["values"][0]) == 2:
|
||||||
self.data[energy_type] = row["value"]
|
self.data[meter["type"]] = meter["values"][0]["value"]
|
||||||
self.attributes[energy_type] = {"date": row["date"]}
|
self.attributes[meter["type"]] = {"date": meter["values"][0]["date"]}
|
||||||
|
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Updated SolarEdge energy details: %s, %s", self.data, self.attributes
|
"Updated SolarEdge energy details: %s, %s", self.data, self.attributes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user