Skip to content

Commit

Permalink
Add grid profile sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentwolsink committed Nov 2, 2023
1 parent 6e631c7 commit 78f7abe
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion custom_components/enphase_envoy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async def async_update_data():
options.get("getdata_timeout", DEFAULT_GETDATA_TIMEOUT)
):
try:
await envoy_reader.getData()
await envoy_reader.get_data()
except httpx.HTTPStatusError as err:
raise ConfigEntryAuthFailed from err
except httpx.HTTPError as err:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/enphase_envoy/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> EnvoyRead
)

try:
await envoy_reader.getData()
await envoy_reader.get_data()
except httpx.HTTPStatusError as err:
raise InvalidAuth from err
except (RuntimeError, httpx.HTTPError) as err:
Expand Down
7 changes: 7 additions & 0 deletions custom_components/enphase_envoy/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
UnitOfElectricCurrent,
UnitOfTemperature,
POWER_VOLT_AMPERE_REACTIVE,
EntityCategory,
)

DOMAIN = "enphase_envoy"
Expand Down Expand Up @@ -212,6 +213,12 @@ def get_model_name(model, hardware_id):
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.APPARENT_POWER,
),
SensorEntityDescription(
key="grid_profile",
name="Grid Profile",
icon="mdi:transmission-tower",
entity_category=EntityCategory.DIAGNOSTIC,
),
)
ADDITIONAL_METRICS.extend(
[
Expand Down
3 changes: 3 additions & 0 deletions custom_components/enphase_envoy/envoy_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
ENDPOINT_URL_STREAM = "https://{}/stream/meter"
ENDPOINT_URL_PRODUCTION_REPORT = "https://{}/ivp/meters/reports/production"
ENDPOINT_URL_PDM_ENERGY = "https://{}/ivp/pdm/energy"
ENDPOINT_URL_INSTALLER_AGF = "https://{}/installer/agf/index.json"

ENVOY_MODEL_M = "Metered"
ENVOY_MODEL_S = "Standard"
Expand Down Expand Up @@ -375,6 +376,7 @@ class EnvoyStandard(EnvoyData):
envoy_software_build_epoch_value = "endpoint_home_json_results.software_build_epoch"
envoy_update_status_value = "endpoint_home_json_results.update_status"
serial_number_value = "endpoint_info_results.envoy_info.device.sn"
grid_profile_value = "endpoint_installer_agf.selected_profile"

@envoy_property()
def envoy_info(self):
Expand Down Expand Up @@ -674,6 +676,7 @@ def url(endpoint, *a, **kw):
url("inventory_results", ENDPOINT_URL_INVENTORY, cache=300)
url("production_report", ENDPOINT_URL_PRODUCTION_REPORT, cache=0)
iurl("pdm_energy", ENDPOINT_URL_PDM_ENERGY)
iurl("installer_agf", ENDPOINT_URL_INSTALLER_AGF)

# If IPv6 address then enclose host in brackets
try:
Expand Down

0 comments on commit 78f7abe

Please sign in to comment.