From 6bf175456094b8c25633797ae26ec9f872d893a7 Mon Sep 17 00:00:00 2001 From: Vincent Wolsink Date: Thu, 2 Nov 2023 22:21:11 +0100 Subject: [PATCH 1/3] Rearrange configuration options --- .../enphase_envoy/config_flow.py | 34 +++++++++---------- .../enphase_envoy/translations/en.json | 6 ++-- .../enphase_envoy/translations/nl.json | 6 ++-- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/custom_components/enphase_envoy/config_flow.py b/custom_components/enphase_envoy/config_flow.py index 8c04f87..d582e88 100644 --- a/custom_components/enphase_envoy/config_flow.py +++ b/custom_components/enphase_envoy/config_flow.py @@ -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( @@ -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)) diff --git a/custom_components/enphase_envoy/translations/en.json b/custom_components/enphase_envoy/translations/en.json index bac1eec..1f2c4e5 100644 --- a/custom_components/enphase_envoy/translations/en.json +++ b/custom_components/enphase_envoy/translations/en.json @@ -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": { diff --git a/custom_components/enphase_envoy/translations/nl.json b/custom_components/enphase_envoy/translations/nl.json index 28ee402..4bd693d 100644 --- a/custom_components/enphase_envoy/translations/nl.json +++ b/custom_components/enphase_envoy/translations/nl.json @@ -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": { From 19465d167c52602772e36df4913d746c9aaa095b Mon Sep 17 00:00:00 2001 From: Vincent Wolsink Date: Thu, 2 Nov 2023 22:21:50 +0100 Subject: [PATCH 2/3] Fix some endpoints using installer token although disabled --- custom_components/enphase_envoy/envoy_reader.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/custom_components/enphase_envoy/envoy_reader.py b/custom_components/enphase_envoy/envoy_reader.py index 8ee3f2f..daaf1fb 100644 --- a/custom_components/enphase_envoy/envoy_reader.py +++ b/custom_components/enphase_envoy/envoy_reader.py @@ -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": @@ -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 @@ -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"]) ), } From 5c2b154a0ce3cc4de381b9cc0be2b59eb15da6eb Mon Sep 17 00:00:00 2001 From: Vincent Wolsink Date: Thu, 2 Nov 2023 22:22:09 +0100 Subject: [PATCH 3/3] Move some sensors to diagnostics category --- custom_components/enphase_envoy/const.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/custom_components/enphase_envoy/const.py b/custom_components/enphase_envoy/const.py index a90a228..df7f41e 100644 --- a/custom_components/enphase_envoy/const.py +++ b/custom_components/enphase_envoy/const.py @@ -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", @@ -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",