Skip to content

Commit ffe809f

Browse files
Merge pull request #184 from vincentwolsink/device_data_active
Only read device_data for active devices
2 parents 6b2d3a5 + 6196621 commit ffe809f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

custom_components/enphase_envoy/envoy_reader.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ def has_metering_setup(json):
6868
def parse_devicedata(data):
6969
idd = {}
7070
for key, value in data.items():
71-
if isinstance(value, dict) and "devName" in value and value["devName"] == "pcu":
71+
if (
72+
isinstance(value, dict)
73+
and value.get("devName") == "pcu"
74+
and value.get("active") is True
75+
):
7276
channel = value["channels"][0] # unclear when there might be a channel > 0
7377
lifetime = channel["lifetime"]
7478
last_reading = channel["lastReading"]
@@ -97,8 +101,8 @@ def parse_devicedata(data):
97101
}
98102
elif (
99103
isinstance(value, dict)
100-
and "devName" in value
101-
and value["devName"] == "nsrb"
104+
and value.get("devName") == "nsrb"
105+
and value.get("active") is True
102106
):
103107
channel = value["channels"][0] # unclear when there might be a channel > 0
104108
last_reading = channel["lastReading"]

0 commit comments

Comments
 (0)