Skip to content

Commit

Permalink
Merge pull request #98 from vincentwolsink/minor_fixes
Browse files Browse the repository at this point in the history
Minor tweaks/fixes
  • Loading branch information
vincentwolsink authored Nov 2, 2023
2 parents 3695cd9 + 5c2b154 commit 954c404
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 28 deletions.
34 changes: 17 additions & 17 deletions custom_components/enphase_envoy/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,23 @@ async def async_step_user(self, user_input=None):
"time_between_update", DEFAULT_SCAN_INTERVAL
),
): vol.All(vol.Coerce(int), vol.Range(min=5)),
vol.Optional(
"getdata_timeout",
default=self.config_entry.options.get(
"getdata_timeout", DEFAULT_GETDATA_TIMEOUT
),
): vol.All(vol.Coerce(int), vol.Range(min=30)),
vol.Optional(
DISABLE_INSTALLER_ACCOUNT_USE,
default=(
self.config_entry.options.get(
DISABLE_INSTALLER_ACCOUNT_USE,
self.config_entry.data.get(
DISABLE_INSTALLER_ACCOUNT_USE, False
),
)
),
): bool,
vol.Optional(
"disable_negative_production",
default=self.config_entry.options.get(
Expand All @@ -263,27 +280,10 @@ async def async_step_user(self, user_input=None):
"realtime_update_throttle", DEFAULT_REALTIME_UPDATE_THROTTLE
),
): vol.All(vol.Coerce(int), vol.Range(min=0)),
vol.Optional(
DISABLE_INSTALLER_ACCOUNT_USE,
default=(
self.config_entry.options.get(
DISABLE_INSTALLER_ACCOUNT_USE,
self.config_entry.data.get(
DISABLE_INSTALLER_ACCOUNT_USE, False
),
)
),
): bool,
vol.Optional(
ENABLE_ADDITIONAL_METRICS,
default=self.config_entry.options.get(ENABLE_ADDITIONAL_METRICS, False),
): bool,
vol.Optional(
"getdata_timeout",
default=self.config_entry.options.get(
"getdata_timeout", DEFAULT_GETDATA_TIMEOUT
),
): vol.All(vol.Coerce(int), vol.Range(min=30)),
}
return self.async_show_form(step_id="user", data_schema=vol.Schema(schema))

Expand Down
4 changes: 4 additions & 0 deletions custom_components/enphase_envoy/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,13 @@ def get_model_name(model, hardware_id):
key="inverters_producing",
name="Producing",
device_class=BinarySensorDeviceClass.POWER,
entity_category=EntityCategory.DIAGNOSTIC,
),
BinarySensorEntityDescription(
key="inverters_communicating",
name="Communicating",
device_class=BinarySensorDeviceClass.CONNECTIVITY,
entity_category=EntityCategory.DIAGNOSTIC,
),
BinarySensorEntityDescription(
key="grid_status",
Expand All @@ -363,11 +365,13 @@ def get_model_name(model, hardware_id):
key="relays_communicating",
name="Communicating",
device_class=BinarySensorDeviceClass.CONNECTIVITY,
entity_category=EntityCategory.DIAGNOSTIC,
),
BinarySensorEntityDescription(
key="relays_forced",
name="Forced",
device_class=BinarySensorDeviceClass.TAMPER,
entity_category=EntityCategory.DIAGNOSTIC,
),
BinarySensorEntityDescription(
key="firmware",
Expand Down
17 changes: 12 additions & 5 deletions custom_components/enphase_envoy/envoy_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def iter():
if key == "reportDate":
yield "report_date", time.strftime(
"%Y-%m-%d %H:%M:%S", time.localtime(value)
)
) if value else None
elif key == "dcVoltageINmV":
yield "dc_voltage", int(value) / 1000
elif key == "dcCurrentINmA":
Expand Down Expand Up @@ -212,7 +212,11 @@ def prop(f):

def path_by_token(owner, installer=None):
def path(cls):
if cls.reader.token_type == "installer" and installer:
if (
cls.reader.token_type == "installer"
and not cls.reader.disable_installer_account_use
and installer
):
return installer
return owner

Expand Down Expand Up @@ -439,18 +443,21 @@ def inverters_production(self):
data = self.get("inverters_data")

def iter():
if self.reader.token_type == "installer":
if (
self.reader.token_type == "installer"
and not self.reader.disable_installer_account_use
):
for item in data:
yield item["serialNumber"], {
"watt": item["ac_power"],
"report_data": item["report_date"],
"report_date": item["report_date"],
}
else:
# endpoint_production_inverters endpoint
for item in data:
yield item["serialNumber"], {
"watt": item["lastReportWatts"],
"report_data": time.strftime(
"report_date": time.strftime(
"%Y-%m-%d %H:%M:%S", time.localtime(item["lastReportDate"])
),
}
Expand Down
6 changes: 3 additions & 3 deletions custom_components/enphase_envoy/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
"user": {
"title": "Envoy options",
"data": {
"enable_realtime_updates": "Enable realtime updates (only for metered envoys)",
"enable_realtime_updates": "[Envoy-S Metered] Enable realtime updates",
"realtime_update_throttle": "Minimum time between realtime entity updates [s]",
"disable_negative_production": "Disable negative production values",
"disable_negative_production": "[Envoy-S Metered] Disable negative production values",
"time_between_update": "Minimum time between entity updates [s]",
"getdata_timeout": "Timeout value for fetching data from envoy [s]",
"enable_additional_metrics": "[Metered only] Enable additional metrics like total amps, frequency, apparent and reactive power and power factor.",
"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"
},
"data_description": {
Expand Down
6 changes: 3 additions & 3 deletions custom_components/enphase_envoy/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
"user": {
"title": "Envoy opties",
"data": {
"enable_realtime_updates": "Gebruik real-time updates (werkt alleen met metered envoys)",
"enable_realtime_updates": "[Envoy-S Metered] Gebruik real-time updates",
"realtime_update_throttle": "Minimale tijd tussen real-time updates [s]",
"disable_negative_production": "Voorkom negatieve productie waardes",
"disable_negative_production": "[Envoy-S Metered] Voorkom negatieve productie waardes",
"time_between_update": "Minimum tijd tussen entity updates [s]",
"getdata_timeout": "Maximum tijd voor het ophalen van data vanaf envoy [s]",
"enable_additional_metrics": "[Metered only] Extra metrics inschakelen, zoals total amps, frequency, apparent en reactive power en power factor.",
"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"
},
"data_description": {
Expand Down

0 comments on commit 954c404

Please sign in to comment.