Skip to content

Commit

Permalink
Merge pull request #177 from vincentwolsink/relay_data
Browse files Browse the repository at this point in the history
Add relay frequency, show only line voltage of connected lines
  • Loading branch information
vincentwolsink authored Nov 25, 2024
2 parents 0df8855 + 9ed4ae7 commit b0cfc68
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
8 changes: 8 additions & 0 deletions custom_components/enphase_envoy/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,14 @@ def get_model_name(model, hardware_id):
device_class=SensorDeviceClass.VOLTAGE,
suggested_display_precision=3,
),
SensorEntityDescription(
key="relay_data_frequency",
name="Frequency",
native_unit_of_measurement=UnitOfFrequency.HERTZ,
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.FREQUENCY,
suggested_display_precision=3,
),
SensorEntityDescription(
key="relay_data_last_reading",
name="Last Reading",
Expand Down
7 changes: 4 additions & 3 deletions custom_components/enphase_envoy/envoy_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ def parse_devicedata(data):
"sn": value["sn"],
"active": value["active"],
"temperature": last_reading["temperature"],
"voltage_l1": last_reading["VrmsL1N"] / 1000,
"voltage_l2": last_reading["VrmsL2N"] / 1000,
"voltage_l3": last_reading["VrmsL3N"] / 1000,
"voltage_l1": int(last_reading["VrmsL1N"]) / 1000,
"voltage_l2": int(last_reading["VrmsL2N"]) / 1000,
"voltage_l3": int(last_reading["VrmsL3N"]) / 1000,
"frequency": int(last_reading["freqInmHz"]) / 1000,
"state_change_count": last_reading["stateChngCnt"],
"gone": value["modGone"],
"last_reading": last_reading["endDate"],
Expand Down
11 changes: 11 additions & 0 deletions custom_components/enphase_envoy/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ async def async_setup_entry(
_LOGGER.debug(f"Relay Data Sensor DATA {relay}")
device_name = f"Relay {relay}"
serial_number = relay

if sensor_description.key.endswith(("l1", "l2", "l3")):
line = sensor_description.key[-2:].replace("l", "line")
line_connected = (
coordinator.data.get("relay_info", {})
.get(relay, {})
.get(f"{line}-connected")
)
if line_connected is False:
continue

entities.append(
EnvoyRelayEntity(
description=sensor_description,
Expand Down

0 comments on commit b0cfc68

Please sign in to comment.