diff --git a/custom_components/enphase_envoy/const.py b/custom_components/enphase_envoy/const.py index 37a0a63..1903596 100644 --- a/custom_components/enphase_envoy/const.py +++ b/custom_components/enphase_envoy/const.py @@ -56,6 +56,13 @@ "800-01127-r02": {"name": "IQ7A Microinverter", "sku": "IQ7A-72-M-INT"}, } +BATTERY_STATE_MAPPING = { + 12: "Charging", + 13: "Discharging", + 14: "Idle. Fully charged.", + 17: "Idle. Low charge.", +} + def resolve_product_mapping(product_id): if PRODUCT_ID_MAPPING.get(product_id, None) != None: @@ -182,7 +189,7 @@ def get_model_name(model, hardware_id): ), SensorEntityDescription( key="batteries_percentFull", - name="Charged", + name="Charge", native_unit_of_measurement=PERCENTAGE, state_class=SensorStateClass.MEASUREMENT, device_class=SensorDeviceClass.BATTERY, @@ -209,9 +216,14 @@ def get_model_name(model, hardware_id): state_class=SensorStateClass.TOTAL, device_class=SensorDeviceClass.ENERGY, ), + SensorEntityDescription( + key="batteries_led_status", + name="Status", + icon="mdi:battery-sync", + ), SensorEntityDescription( key="agg_batteries_soc", - name="Batteries Charged", + name="Batteries Charge", native_unit_of_measurement=PERCENTAGE, state_class=SensorStateClass.MEASUREMENT, device_class=SensorDeviceClass.BATTERY, diff --git a/custom_components/enphase_envoy/sensor.py b/custom_components/enphase_envoy/sensor.py index 2544c56..3fa9b68 100644 --- a/custom_components/enphase_envoy/sensor.py +++ b/custom_components/enphase_envoy/sensor.py @@ -20,6 +20,7 @@ LIVE_UPDATEABLE_ENTITIES, ENABLE_ADDITIONAL_METRICS, ADDITIONAL_METRICS, + BATTERY_STATE_MAPPING, resolve_hardware_id, get_model_name, ) @@ -387,6 +388,12 @@ def native_value(self): .get("real_power_mw") / 1000 ) + elif self.entity_description.key == "batteries_led_status": + return BATTERY_STATE_MAPPING.get( + self.coordinator.data.get("batteries") + .get(self._device_serial_number) + .get("led_status") + ) else: return ( self.coordinator.data.get("batteries")