Skip to content

Commit a72eeb1

Browse files
Merge pull request #69 from vincentwolsink/envoy_model
Expose detected Envoy model
2 parents 160554e + 85e163d commit a72eeb1

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

custom_components/enphase_envoy/envoy_reader.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
ENDPOINT_URL_STREAM = "https://{}/stream/meter"
3636
ENDPOINT_URL_PDM_ENERGY = "https://{}/ivp/pdm/energy"
3737

38-
ENVOY_MODEL_S = "PC"
39-
ENVOY_MODEL_C = "P"
38+
ENVOY_MODEL_M = "Metered"
39+
ENVOY_MODEL_S = "Standard"
4040

4141
# paths for the enlighten installer token
4242
ENLIGHTEN_AUTH_URL = "https://enlighten.enphaseenergy.com/login/login.json"
@@ -374,6 +374,7 @@ def envoy_info(self):
374374
"software": self.get("envoy_software"),
375375
"software_build_epoch": self.get("envoy_software_build_epoch"),
376376
"update_status": self.get("envoy_update_status_value"),
377+
"model": self.reader.endpoint_type,
377378
}
378379

379380
production_value = path_by_token(
@@ -568,7 +569,7 @@ def __new__(cls, *a, **kw):
568569

569570

570571
def getEnvoyDataClass(envoy_type, production_json):
571-
if envoy_type == ENVOY_MODEL_C:
572+
if envoy_type == ENVOY_MODEL_S:
572573
return EnvoyStandard
573574

574575
# It is a metered Envoy, check the production json if the eim entry has activeCount > 0
@@ -986,7 +987,7 @@ async def stream_reader(self, meter_callback=None, loop=None):
986987
# First, login, etc, make sure we have a token.
987988
await self.init_authentication()
988989

989-
if not self.isMeteringEnabled or self.endpoint_type != ENVOY_MODEL_S:
990+
if not self.isMeteringEnabled or self.endpoint_type != ENVOY_MODEL_M:
990991
_LOGGER.debug(
991992
"Metering is not enabled or endpoint type '%s' not supported",
992993
self.endpoint_type,
@@ -1171,15 +1172,15 @@ async def detect_model(self):
11711172
self.endpoint_production_json_results.json()
11721173
)
11731174
):
1174-
self.endpoint_type = ENVOY_MODEL_S
1175+
self.endpoint_type = ENVOY_MODEL_M
11751176

11761177
else:
11771178
await self.update_endpoints(["endpoint_production_v1_results"])
11781179
if (
11791180
self.endpoint_production_v1_results
11801181
and self.endpoint_production_v1_results.status_code == 200
11811182
):
1182-
self.endpoint_type = ENVOY_MODEL_C # Envoy-C, standard envoy
1183+
self.endpoint_type = ENVOY_MODEL_S
11831184

11841185
if not self.endpoint_type:
11851186
raise RuntimeError(
@@ -1293,7 +1294,7 @@ def run_stream(self):
12931294
print("Reading stream...")
12941295
loop = asyncio.get_event_loop()
12951296
self.data = EnvoyMeteredWithCT(self)
1296-
self.endpoint_type = ENVOY_MODEL_S
1297+
self.endpoint_type = ENVOY_MODEL_M
12971298
data_results = loop.run_until_complete(
12981299
asyncio.gather(self.stream_reader(), return_exceptions=False)
12991300
)

custom_components/enphase_envoy/sensor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,16 @@ def device_info(self) -> DeviceInfo | None:
244244

245245
sw_version = None
246246
hw_version = None
247+
model = None
247248
if self.coordinator.data.get("envoy_info"):
248249
sw_version = self.coordinator.data.get("envoy_info").get("software", None)
249250
hw_version = self.coordinator.data.get("envoy_info").get("pn", None)
251+
model = self.coordinator.data.get("envoy_info").get("model", None)
250252

251253
return DeviceInfo(
252254
identifiers={(DOMAIN, str(self._device_serial_number))},
253255
manufacturer="Enphase",
254-
model="Envoy",
256+
model=f"Envoy-S {model}",
255257
name=self._device_name,
256258
sw_version=sw_version,
257259
hw_version=hw_version,

0 commit comments

Comments
 (0)