Skip to content

Commit

Permalink
Merge pull request #71 from vincentwolsink/fix_model_name
Browse files Browse the repository at this point in the history
Add missing places to expose detected envoy model
  • Loading branch information
vincentwolsink authored Aug 1, 2023
2 parents 4b37fc2 + 581ab45 commit 2ecdb56
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
14 changes: 11 additions & 3 deletions custom_components/enphase_envoy/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,13 @@ def device_info(self) -> DeviceInfo or None:
"""Return the device_info of the device."""
if not self._device_serial_number:
return None

model = self.coordinator.data.get("envoy_info", {}).get("model", "Standard")

return DeviceInfo(
identifiers={(DOMAIN, str(self._device_serial_number))},
manufacturer="Enphase",
model="Envoy",
model=f"Envoy-S {model}",
name=self._device_name,
)

Expand Down Expand Up @@ -202,10 +205,11 @@ def device_info(self) -> DeviceInfo or None:
"""Return the device_info of the device."""
if not self._device_serial_number:
return None

return DeviceInfo(
identifiers={(DOMAIN, str(self._device_serial_number))},
manufacturer="Enphase",
model="Envoy",
model="Inverter",
name=self._device_name,
)

Expand Down Expand Up @@ -277,7 +281,11 @@ def device_info(self) -> DeviceInfo | None:
if self._parent_device:
device_info_kw["via_device"] = (DOMAIN, self._parent_device)

if self.MODEL == "Relay":
if self.MODEL == "Envoy":
model = self.coordinator.data.get("envoy_info", {}).get("model", "Standard")
self.MODEL = f"Envoy-S {model}"

elif self.MODEL == "Relay":
info = self.coordinator.data.get("relay_info", {}).get(
self._device_serial_number, {}
)
Expand Down
10 changes: 3 additions & 7 deletions custom_components/enphase_envoy/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,9 @@ def device_info(self) -> DeviceInfo | None:
if not self._device_serial_number:
return None

sw_version = None
hw_version = None
model = None
if self.coordinator.data.get("envoy_info"):
sw_version = self.coordinator.data.get("envoy_info").get("software", None)
hw_version = self.coordinator.data.get("envoy_info").get("pn", None)
model = self.coordinator.data.get("envoy_info").get("model", None)
sw_version = self.coordinator.data.get("envoy_info", {}).get("software", None)
hw_version = self.coordinator.data.get("envoy_info", {}).get("pn", None)
model = self.coordinator.data.get("envoy_info", {}).get("model", "Standard")

return DeviceInfo(
identifiers={(DOMAIN, str(self._device_serial_number))},
Expand Down
5 changes: 4 additions & 1 deletion custom_components/enphase_envoy/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,13 @@ def device_info(self) -> DeviceInfo or None:
"""Return the device_info of the device."""
if not self._device_serial_number:
return None

model = self.coordinator.data.get("envoy_info", {}).get("model", "Standard")

return DeviceInfo(
identifiers={(DOMAIN, str(self._device_serial_number))},
manufacturer="Enphase",
model="Envoy",
model=f"Envoy-S {model}",
name=self._device_name,
)

Expand Down

0 comments on commit 2ecdb56

Please sign in to comment.