Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration option to correct lifetime production value #166

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions custom_components/enphase_envoy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
store=store,
disable_negative_production=options.get("disable_negative_production", False),
disabled_endpoints=disabled_endpoints,
lifetime_production_correction=options.get("lifetime_production_correction", 0),
)
await envoy_reader._sync_store(load=True)

Expand Down
6 changes: 6 additions & 0 deletions custom_components/enphase_envoy/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,12 @@ async def async_step_user(self, user_input=None):
"enable_pcu_comm_check",
default=self.config_entry.options.get("enable_pcu_comm_check", False),
): bool,
vol.Optional(
"lifetime_production_correction",
default=self.config_entry.options.get(
"lifetime_production_correction", 0
),
): vol.All(vol.Coerce(int)),
vol.Optional(
"disabled_endpoints",
description={"suggested_value": disabled_endpoints},
Expand Down
21 changes: 19 additions & 2 deletions custom_components/enphase_envoy/envoy_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,18 @@ def envoy_info(self):
owner="endpoint_production_v1.wattHoursToday",
installer="endpoint_pdm_energy.production.pcu.wattHoursToday",
)
lifetime_production_value = path_by_token(

_lifetime_production_path = path_by_token(
owner="endpoint_production_v1.wattHoursLifetime",
installer="endpoint_pdm_energy.production.pcu.wattHoursLifetime",
)

@envoy_property(required_endpoint="endpoint_production_v1")
def lifetime_production(self):
lifetime_production = self._resolve_path(self._lifetime_production_path)
if lifetime_production is not None:
return lifetime_production + self.reader.lifetime_production_correction

@envoy_property(required_endpoint="endpoint_production_power")
def production_power(self):
"""Return production power status reported by Envoy"""
Expand Down Expand Up @@ -542,10 +549,18 @@ def __new__(cls, *a, **kw):

_production = "endpoint_production_json.production[?(@.type=='inverters')]"
production_value = _production + ".wNow"
lifetime_production_value = path_by_token(

_lifetime_production_path = path_by_token(
owner=_production + ".whLifetime",
installer="endpoint_pdm_energy.production.pcu.wattHoursLifetime",
)

@envoy_property(required_endpoint="endpoint_production_json")
def lifetime_production(self):
lifetime_production = self._resolve_path(self._lifetime_production_path)
if lifetime_production is not None:
return lifetime_production + self.reader.lifetime_production_correction

daily_production_value = "endpoint_pdm_energy.production.pcu.wattHoursToday"

_production_ct = (
Expand Down Expand Up @@ -632,6 +647,7 @@ def __init__(
store=None,
disable_negative_production=False,
disabled_endpoints=[],
lifetime_production_correction=0,
):
"""Init the EnvoyReader."""
self.host = host.lower()
Expand All @@ -655,6 +671,7 @@ def __init__(
self.data: EnvoyData = EnvoyStandard(self)
self.required_endpoints = set() # in case we would need it..
self.disabled_endpoints = disabled_endpoints
self.lifetime_production_correction = lifetime_production_correction

self.uri_registry = {}
for key, endpoint in ENVOY_ENDPOINTS.items():
Expand Down
1 change: 1 addition & 0 deletions custom_components/enphase_envoy/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"enable_additional_metrics": "[Metered only] Enable additional metrics like total amps, frequency, apparent and reactive power and power factor.",
"disable_installer_account_use": "Do not collect data that requires installer or DIY enphase account",
"enable_pcu_comm_check": "Enable powerline communication level sensors (slow)",
"lifetime_production_correction": "Correction of lifetime production value (Wh)",
"disabled_endpoints": "[Advanced] Disabled Envoy endpoints"
},
"data_description": {
Expand Down
1 change: 1 addition & 0 deletions custom_components/enphase_envoy/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"enable_additional_metrics": "[Envoy-S Metered] Enable additional metrics like total amps, frequency, apparent and reactive power and power factor.",
"disable_installer_account_use": "Do not collect data that requires installer or DIY enphase account",
"enable_pcu_comm_check": "Enable powerline communication level sensors (slow)",
"lifetime_production_correction": "Correction of lifetime production value (Wh)",
"disabled_endpoints": "[Advanced] Disabled Envoy endpoints"
},
"data_description": {
Expand Down
1 change: 1 addition & 0 deletions custom_components/enphase_envoy/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"enable_additional_metrics": "[Envoy-S Metered] Extra metrics inschakelen, zoals total amps, frequency, apparent en reactive power en power factor.",
"disable_installer_account_use": "Haal geen data op die een installateur of DHZ enphase account vereisen",
"enable_pcu_comm_check": "Powerline communication level sensors inschakelen (langzaam)",
"lifetime_production_correction": "Correctie van lifetime production waarde (Wh)",
"disabled_endpoints": "[Geavanceerd] Uitgeschakelde Envoy endpoints"
},
"data_description": {
Expand Down
Loading