From 052b8fa9f8e2aa2c1cf69d6adeb4c67146e97b96 Mon Sep 17 00:00:00 2001 From: marq24 Date: Tue, 21 May 2024 10:41:42 +0200 Subject: [PATCH] - don't include loadpoint name in entity names, if only one loadpoint is configured in evcc - code cleanup --- README.md | 2 +- custom_components/evcc_intg/__init__.py | 8 +- custom_components/evcc_intg/binary_sensor.py | 3 +- custom_components/evcc_intg/button.py | 3 +- custom_components/evcc_intg/const.py | 805 +------------------ custom_components/evcc_intg/manifest.json | 2 +- custom_components/evcc_intg/number.py | 4 +- custom_components/evcc_intg/select.py | 11 +- custom_components/evcc_intg/sensor.py | 16 +- custom_components/evcc_intg/switch.py | 3 +- 10 files changed, 31 insertions(+), 826 deletions(-) diff --git a/README.md b/README.md index a26e2ec..4c92e08 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ Please note, that some of the available sensors are __not__ enabled by default. Please see the separate document where you can find examples [how to provide your evcc instance with HA sensor data](https://github.com/marq24/ha-evcc/blob/main/HA_AS_EVCC_SOURCE.md). -## Are you are go-eCharger V3 or higher User? +## Are you are go-eCharger V3 (or higher) User? Do you know, that as owners of a go-eCharger (V3+) there is no need to use evcc for solar surplus charging? Even without any additional hardware! Home Assistant and the __go-eCharger APIv2 Connect__ Integration is all you need. Get all details from [https://github.com/marq24/ha-goecharger-api2](https://github.com/marq24/ha-goecharger-api2). diff --git a/custom_components/evcc_intg/__init__.py b/custom_components/evcc_intg/__init__.py index 7bdce14..34500e6 100644 --- a/custom_components/evcc_intg/__init__.py +++ b/custom_components/evcc_intg/__init__.py @@ -166,10 +166,10 @@ async def read_evcc_config_on_startup(self): # c) load point configuration (like 1/3 phase options) initdata = await self.bridge.read_all_data() - if "version" in initdata: - self._version = initdata["version"] - elif "availableVersion" in initdata: - self._version = initdata["availableVersion"] + if Tag.VERSION.key in initdata: + self._version = initdata[Tag.VERSION.key] + elif Tag.AVAILABLEVERSION.key in initdata: + self._version = initdata[Tag.AVAILABLEVERSION.key] self._device_info_dict = { "identifiers": { diff --git a/custom_components/evcc_intg/binary_sensor.py b/custom_components/evcc_intg/binary_sensor.py index b861ed0..bb1d248 100644 --- a/custom_components/evcc_intg/binary_sensor.py +++ b/custom_components/evcc_intg/binary_sensor.py @@ -20,6 +20,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, add_ entity = EvccBinarySensor(coordinator, description) entities.append(entity) + multi_loadpoint_config = len(coordinator._loadpoint) > 1 for a_lp_key in coordinator._loadpoint: load_point_config = coordinator._loadpoint[a_lp_key] lp_api_index = int(a_lp_key) @@ -33,7 +34,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, add_ idx=lp_api_index, key=f"{a_stub.tag.key}_{lp_api_index}_{lp_id_addon}", translation_key=a_stub.tag.key, - name_addon=lp_name_addon, + name_addon=lp_name_addon if multi_loadpoint_config else None, icon=a_stub.icon, device_class=a_stub.device_class, unit_of_measurement=a_stub.unit_of_measurement, diff --git a/custom_components/evcc_intg/button.py b/custom_components/evcc_intg/button.py index 299bae4..af59c1f 100644 --- a/custom_components/evcc_intg/button.py +++ b/custom_components/evcc_intg/button.py @@ -19,6 +19,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, add_ entity = EvccButton(coordinator, description) entities.append(entity) + multi_loadpoint_config = len(coordinator._loadpoint) > 1 for a_lp_key in coordinator._loadpoint: load_point_config = coordinator._loadpoint[a_lp_key] lp_api_index = int(a_lp_key) @@ -32,7 +33,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, add_ idx=lp_api_index, key=f"{a_stub.tag.key}_{lp_api_index}_{lp_id_addon}", translation_key=a_stub.tag.key, - name_addon=lp_name_addon, + name_addon=lp_name_addon if multi_loadpoint_config else None, icon=a_stub.icon, device_class=a_stub.device_class, unit_of_measurement=a_stub.unit_of_measurement, diff --git a/custom_components/evcc_intg/const.py b/custom_components/evcc_intg/const.py index 951ea12..f59e7eb 100644 --- a/custom_components/evcc_intg/const.py +++ b/custom_components/evcc_intg/const.py @@ -35,10 +35,10 @@ ------------------------------------------------------------------- """ - SERVICE_SET_LOADPOINT_PLAN: Final = "set_loadpoint_plan" SERVICE_SET_VEHICLE_PLAN: Final = "set_vehicle_plan" + @dataclass class EntityDescriptionStub(metaclass=FrozenOrThawed, frozen_or_thawed=True): tag: Tag = None, @@ -48,6 +48,7 @@ class EntityDescriptionStub(metaclass=FrozenOrThawed, frozen_or_thawed=True): entity_category: EntityCategory | None = None entity_registry_enabled_default: bool = True + @dataclass class ExtBinarySensorEntityDescriptionStub(EntityDescriptionStub): icon_off: str | None = None @@ -61,6 +62,7 @@ class ExtBinarySensorEntityDescription(BinarySensorEntityDescription): icon_off: str | None = None + @dataclass class ExtButtonEntityDescriptionStub(EntityDescriptionStub): payload: str | None = None @@ -111,6 +113,7 @@ class ExtSensorEntityDescriptionStub(EntityDescriptionStub): state_class: SensorStateClass | str | None = None suggested_display_precision: int | None = None native_unit_of_measurement: str | None = None + array_idx: int | None = None factor: int | None = None @@ -120,6 +123,7 @@ class ExtSensorEntityDescription(SensorEntityDescription): tag: Tag = None idx: int | None = None name_addon: str | None = None + array_idx: int | None = None factor: int | None = None @@ -133,6 +137,7 @@ class ExtSwitchEntityDescription(SwitchEntityDescription): tag: Tag = None idx: int | None = None name_addon: str | None = None + icon_off: str | None = None @@ -561,804 +566,6 @@ class ExtSwitchEntityDescription(SwitchEntityDescription): entity_registry_enabled_default=False ), ] -# SENSOR_SENSORS = [ -# # INDEXED Values... -# # nrg -# ExtSensorEntityDescription( -# key=Tag.NRG.key, -# idx=0, -# suggested_display_precision=2, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfElectricPotential.VOLT, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.VOLTAGE, -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.NRG.key, -# idx=1, -# suggested_display_precision=2, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfElectricPotential.VOLT, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.VOLTAGE, -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.NRG.key, -# idx=2, -# suggested_display_precision=2, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfElectricPotential.VOLT, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.VOLTAGE, -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.NRG.key, -# idx=3, -# suggested_display_precision=2, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfElectricPotential.VOLT, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.VOLTAGE, -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.NRG.key, -# idx=4, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.CURRENT, -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.NRG.key, -# idx=5, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.CURRENT, -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.NRG.key, -# idx=6, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.CURRENT, -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.NRG.key, -# idx=7, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfPower.WATT, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.POWER, -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.NRG.key, -# idx=8, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfPower.WATT, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.POWER, -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.NRG.key, -# idx=9, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfPower.WATT, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.POWER, -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.NRG.key, -# idx=10, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfPower.WATT, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.POWER, -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.NRG.key, -# idx=11, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfPower.WATT, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.POWER, -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.NRG.key, -# idx=12, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=PERCENTAGE, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.POWER_FACTOR, -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.NRG.key, -# idx=13, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=PERCENTAGE, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.POWER_FACTOR, -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.NRG.key, -# idx=14, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=PERCENTAGE, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.POWER_FACTOR, -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.NRG.key, -# idx=15, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=PERCENTAGE, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.POWER_FACTOR, -# entity_registry_enabled_default=True -# ), -# # tma -# ExtSensorEntityDescription( -# key=Tag.TMA.key, -# idx=0, -# suggested_display_precision=1, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfTemperature.CELSIUS, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.TEMPERATURE, -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.TMA.key, -# idx=1, -# suggested_display_precision=1, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfTemperature.CELSIUS, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.TEMPERATURE, -# entity_registry_enabled_default=True -# ), -# -# # cdi -> object -# ExtSensorEntityDescription( -# key=Tag.CDI.key, -# idx="type", -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=None, -# icon="mdi:counter", -# entity_registry_enabled_default=False -# ), -# ExtSensorEntityDescription( -# key=Tag.CDI.key, -# idx="value", -# factor=60000, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfTime.MINUTES, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=None, -# icon="mdi:timer-outline", -# entity_registry_enabled_default=True -# ), -# # atp -> object [NOT IMPLEMENTED YET] -# # TODO:HERE -# # ExtSensorEntityDescription( -# # key=Tag.ATP.key, -# # idx="???", -# # entity_category=EntityCategory.DIAGNOSTIC, -# # native_unit_of_measurement=None, -# # state_class=SensorStateClass.MEASUREMENT, -# # device_class=None, -# # icon="mdi:mdi:bug-outline", -# # entity_registry_enabled_default=False -# # ), -# # awcp -> object -# ExtSensorEntityDescription( -# key=Tag.AWCP.key, -# idx="marketprice", -# suggested_display_precision=2, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=CURRENCY_CENT, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=None, -# icon="mdi:cash", -# entity_registry_enabled_default=False -# ), -# # ccu -> object [not testable yet] - But looks like this is only the progress for -# # the update -> so we will ignore it for now! -# # TODO:HERE -# # ExtSensorEntityDescription( -# # key=Tag.CCU.key, -# # idx="", -# # entity_category=EntityCategory.DIAGNOSTIC, -# # native_unit_of_measurement=None, -# # state_class=SensorStateClass.MEASUREMENT, -# # device_class=None, -# # icon="mdi:gauge", -# # entity_registry_enabled_default=False -# # ), -# # ccw -> object -# ExtSensorEntityDescription( -# key=Tag.CCW.key, -# idx="ssid", -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=None, -# icon="mdi:wifi", -# entity_registry_enabled_default=False -# ), -# -# # LOOKUP-Values [always two Sensors!] -# # car -# # cus -# # err -# # modelstatus -# # ffb -# # frm -# # lck -# # pwm -# # wsms -# # wst -# ExtSensorEntityDescription( -# key=Tag.CAR.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=None, -# device_class=None, -# icon="mdi:state-machine", -# entity_registry_enabled_default=False -# ), -# ExtSensorEntityDescription( -# key=Tag.CAR.key, -# lookup=True, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=None, -# device_class=None, -# icon="mdi:state-machine", -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.CUS.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=None, -# device_class=None, -# icon="mdi:lock-question", -# entity_registry_enabled_default=False -# ), -# ExtSensorEntityDescription( -# key=Tag.CUS.key, -# lookup=True, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=None, -# device_class=None, -# icon="mdi:lock-question", -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.ERR.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=None, -# device_class=None, -# icon="mdi:alert-circle-outline", -# entity_registry_enabled_default=False -# ), -# ExtSensorEntityDescription( -# key=Tag.ERR.key, -# lookup=True, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=None, -# device_class=None, -# icon="mdi:alert-circle-outline", -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.MODELSTATUS.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=None, -# device_class=None, -# icon="mdi:state-machine", -# entity_registry_enabled_default=False -# ), -# ExtSensorEntityDescription( -# key=Tag.MODELSTATUS.key, -# lookup=True, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=None, -# device_class=None, -# icon="mdi:state-machine", -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.FFB.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=None, -# device_class=None, -# icon="mdi:lock-open-check-outline", -# entity_registry_enabled_default=False -# ), -# ExtSensorEntityDescription( -# key=Tag.FFB.key, -# lookup=True, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=None, -# device_class=None, -# icon="mdi:lock-open-check-outline", -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.FRM.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=None, -# device_class=None, -# icon="mdi:transmission-tower-export", -# entity_registry_enabled_default=False -# ), -# ExtSensorEntityDescription( -# key=Tag.FRM.key, -# lookup=True, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=None, -# device_class=None, -# icon="mdi:transmission-tower-export", -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.LCK.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=None, -# device_class=None, -# icon="mdi:lock-open-alert-outline", -# entity_registry_enabled_default=False -# ), -# ExtSensorEntityDescription( -# key=Tag.LCK.key, -# lookup=True, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=None, -# device_class=None, -# icon="mdi:lock-open-alert-outline", -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.PWM.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=None, -# device_class=None, -# icon="mdi:bug-outline", -# entity_registry_enabled_default=False -# ), -# ExtSensorEntityDescription( -# key=Tag.PWM.key, -# lookup=True, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=None, -# device_class=None, -# icon="mdi:bug-outline", -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.WSMS.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=None, -# device_class=None, -# icon="mdi:wifi-settings", -# entity_registry_enabled_default=False -# ), -# ExtSensorEntityDescription( -# key=Tag.WSMS.key, -# lookup=True, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=None, -# device_class=None, -# icon="mdi:wifi-settings", -# entity_registry_enabled_default=False -# ), -# ExtSensorEntityDescription( -# key=Tag.WST.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=None, -# device_class=None, -# icon="mdi:wifi", -# entity_registry_enabled_default=False -# ), -# ExtSensorEntityDescription( -# key=Tag.WST.key, -# lookup=True, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=None, -# device_class=None, -# icon="mdi:wifi", -# entity_registry_enabled_default=True -# ), -# -# # TIMES from here... -# # fsptws -# # inva -# # lbp -# # lccfc -# # lccfi -# # lcctc -# # lfspt -# # lmsc -# # lpsc -# # rbt -# ExtSensorEntityDescription( -# key=Tag.FSPTWS.key, -# factor=60000, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfTime.MINUTES, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=None, -# icon="mdi:timer-outline", -# entity_registry_enabled_default=False -# ), -# ExtSensorEntityDescription( -# key=Tag.INVA.key, -# factor=1000, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfTime.SECONDS, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=None, -# icon="mdi:timer-outline", -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.LBP.key, -# factor=60000, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfTime.MINUTES, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=None, -# icon="mdi:button-pointer", -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.LCCFC.key, -# factor=60000, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfTime.MINUTES, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=None, -# icon="mdi:timer-outline", -# entity_registry_enabled_default=False -# ), -# ExtSensorEntityDescription( -# key=Tag.LCCFI.key, -# factor=60000, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfTime.MINUTES, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=None, -# icon="mdi:timer-outline", -# entity_registry_enabled_default=False -# ), -# ExtSensorEntityDescription( -# key=Tag.LCCTC.key, -# factor=60000, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfTime.MINUTES, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=None, -# icon="mdi:timer-outline", -# entity_registry_enabled_default=False -# ), -# ExtSensorEntityDescription( -# key=Tag.LFSPT.key, -# factor=60000, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfTime.MINUTES, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=None, -# icon="mdi:timer-outline", -# entity_registry_enabled_default=False -# ), -# ExtSensorEntityDescription( -# key=Tag.LMSC.key, -# factor=1000, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfTime.SECONDS, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=None, -# icon="mdi:timer-outline", -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.LPSC.key, -# factor=1000, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfTime.SECONDS, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=None, -# icon="mdi:timer-outline", -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.RBT.key, -# factor=3600000, # time in full hours! -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfTime.HOURS, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=None, -# icon="mdi:timer-outline", -# entity_registry_enabled_default=True -# ), -# -# # So finally the normal sensor here... -# # acu -# ExtSensorEntityDescription( -# key=Tag.ACU.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.CURRENT, -# entity_registry_enabled_default=True -# ), -# # amt -# ExtSensorEntityDescription( -# key=Tag.AMT.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfTemperature.CELSIUS, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.TEMPERATURE, -# entity_registry_enabled_default=True -# ), -# # cbl -# ExtSensorEntityDescription( -# key=Tag.CBL.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.CURRENT, -# entity_registry_enabled_default=False -# ), -# # deltaa -# ExtSensorEntityDescription( -# key=Tag.DELTAA.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.CURRENT, -# entity_registry_enabled_default=False -# ), -# # deltap -# ExtSensorEntityDescription( -# key=Tag.DELTAP.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfPower.WATT, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.POWER, -# entity_registry_enabled_default=False -# ), -# # eto -# ExtSensorEntityDescription( -# key=Tag.ETO.key, -# factor=1000, -# suggested_display_precision=2, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, -# state_class=SensorStateClass.TOTAL_INCREASING, -# device_class=SensorDeviceClass.ENERGY, -# icon="mdi:lightning-bolt", -# entity_registry_enabled_default=True -# ), -# # ferm -# # NOT-AVAILABLE in MY DATA ?! -# # TODO:HERE! -# -# # fhz -# ExtSensorEntityDescription( -# key=Tag.FHZ.key, -# suggested_display_precision=3, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfFrequency.HERTZ, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=None, -# icon="mdi:current-ac", -# entity_registry_enabled_default=False -# ), -# # loa -# ExtSensorEntityDescription( -# key=Tag.LOA.key, -# name="Load balancing available current", -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.CURRENT, -# entity_registry_enabled_default=True -# ), -# # map -# ExtSensorEntityDescription( -# key=Tag.MAP.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=None, -# icon="mdi:vector-triangle", -# entity_registry_enabled_default=True -# ), -# # mmp -# ExtSensorEntityDescription( -# key=Tag.MMP.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfPower.WATT, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.POWER, -# icon="mdi:bug-outline", -# entity_registry_enabled_default=True -# ), -# # nif -# ExtSensorEntityDescription( -# key=Tag.NIF.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=None, -# icon="mdi:navigation-variant-outline", -# entity_registry_enabled_default=False -# ), -# # pakku -# ExtSensorEntityDescription( -# key=Tag.PAKKU.key, -# suggested_display_precision=2, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfPower.WATT, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.POWER, -# icon="mdi:home-battery-outline", -# entity_registry_enabled_default=True -# ), -# # pgrid -# ExtSensorEntityDescription( -# key=Tag.PGRID.key, -# suggested_display_precision=2, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfPower.WATT, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.POWER, -# icon="mdi:transmission-tower-export", -# entity_registry_enabled_default=True -# ), -# # pnp -# ExtSensorEntityDescription( -# key=Tag.PNP.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=None, -# icon="mdi:counter", -# entity_registry_enabled_default=False -# ), -# # ppv -# ExtSensorEntityDescription( -# key=Tag.PPV.key, -# suggested_display_precision=2, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfPower.WATT, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.POWER, -# icon="mdi:solar-power", -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.PVOPT_AVERAGEPAKKU.key, -# suggested_display_precision=2, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfPower.WATT, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.POWER, -# icon="mdi:home-battery-outline", -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.PVOPT_AVERAGEPGRID.key, -# suggested_display_precision=2, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfPower.WATT, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.POWER, -# icon="mdi:transmission-tower-export", -# entity_registry_enabled_default=True -# ), -# ExtSensorEntityDescription( -# key=Tag.PVOPT_AVERAGEPPV.key, -# suggested_display_precision=2, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfPower.WATT, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.POWER, -# icon="mdi:solar-power", -# entity_registry_enabled_default=True -# ), -# # rbc -# ExtSensorEntityDescription( -# key=Tag.RBC.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=SensorStateClass.TOTAL_INCREASING, -# device_class=None, -# icon="mdi:counter", -# entity_registry_enabled_default=True -# ), -# # rfb -# ExtSensorEntityDescription( -# key=Tag.RFB.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=None, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=None, -# entity_registry_enabled_default=False -# ), -# # rssi -# ExtSensorEntityDescription( -# key=Tag.RSSI.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.SIGNAL_STRENGTH, -# icon="mdi:wifi-strength-2", -# entity_registry_enabled_default=True -# ), -# # tpa -# ExtSensorEntityDescription( -# key=Tag.TPA.key, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfPower.WATT, -# state_class=SensorStateClass.MEASUREMENT, -# device_class=SensorDeviceClass.POWER, -# entity_registry_enabled_default=True -# ), -# # wh -# ExtSensorEntityDescription( -# key=Tag.WH.key, -# factor=1000, -# suggested_display_precision=2, -# entity_category=EntityCategory.DIAGNOSTIC, -# native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, -# state_class=SensorStateClass.TOTAL_INCREASING, -# icon="mdi:lightning-bolt", -# device_class=SensorDeviceClass.ENERGY, -# entity_registry_enabled_default=True -# ), -# # wsc -> later (if at all) -# # wsm -> later (if at all) -# -# ] SWITCH_SENSORS = [ ExtSwitchEntityDescription( diff --git a/custom_components/evcc_intg/manifest.json b/custom_components/evcc_intg/manifest.json index 23a2d2a..5558f78 100644 --- a/custom_components/evcc_intg/manifest.json +++ b/custom_components/evcc_intg/manifest.json @@ -10,5 +10,5 @@ "iot_class": "local_polling", "issue_tracker": "https://github.com/marq24/ha-evcc/issues", "requirements": [], - "version": "2024.5.1" + "version": "2024.5.2" } diff --git a/custom_components/evcc_intg/number.py b/custom_components/evcc_intg/number.py index d8f1599..f440ce7 100644 --- a/custom_components/evcc_intg/number.py +++ b/custom_components/evcc_intg/number.py @@ -19,7 +19,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, add_ entity = EvccNumber(coordinator, description) entities.append(entity) - # generating the dynamic NUMBER_SENSORS + multi_loadpoint_config = len(coordinator._loadpoint) > 1 for a_lp_key in coordinator._loadpoint: load_point_config = coordinator._loadpoint[a_lp_key] lp_api_index = int(a_lp_key) @@ -32,7 +32,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, add_ idx = lp_api_index, key = f"{a_stub.tag.key}_{lp_api_index}_{lp_id_addon}", translation_key = a_stub.tag.key, - name_addon = lp_name_addon, + name_addon = lp_name_addon if multi_loadpoint_config else None, icon = a_stub.icon, device_class = a_stub.device_class, unit_of_measurement = a_stub.unit_of_measurement, diff --git a/custom_components/evcc_intg/select.py b/custom_components/evcc_intg/select.py index b8f7f74..368acc4 100644 --- a/custom_components/evcc_intg/select.py +++ b/custom_components/evcc_intg/select.py @@ -40,7 +40,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, add_ if description.tag in SOCS_TAG_LIST: entities_min_max_dict[entity.entity_id.split('.')[1].lower()] = entity - # generating the dynamic SELECT_SENSORS + multi_loadpoint_config = len(coordinator._loadpoint) > 1 for a_lp_key in coordinator._loadpoint: load_point_config = coordinator._loadpoint[a_lp_key] lp_api_index = int(a_lp_key) @@ -54,7 +54,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, add_ idx=lp_api_index, key=f"{a_stub.tag.key}_{lp_api_index}_{lp_id_addon}", translation_key=a_stub.tag.key, - name_addon=lp_name_addon, + name_addon=lp_name_addon if multi_loadpoint_config else None, icon=a_stub.icon, device_class=a_stub.device_class, unit_of_measurement=a_stub.unit_of_measurement, @@ -62,15 +62,14 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, add_ entity_registry_enabled_default=a_stub.entity_registry_enabled_default, # the entity type specific values... - options=a_stub.tag.options, + options=["null"] + list( + coordinator._vehicle.keys()) if a_stub.tag == Tag.VEHICLENAME else a_stub.tag.options, ) - # we might need to patch the 'auto-mode' from the phases selector + # we might need to patch(remove) the 'auto-mode' from the phases selector if a_stub.tag == Tag.PHASES and not lp_has_phase_auto_option: description.options = description.options[1:] description.translation_key = f"{description.translation_key}_fixed" - elif a_stub.tag == Tag.VEHICLENAME: - description.options = ["null"] + list(coordinator._vehicle.keys()) entity = EvccSelect(coordinator, description) diff --git a/custom_components/evcc_intg/sensor.py b/custom_components/evcc_intg/sensor.py index c716cb8..61367d8 100644 --- a/custom_components/evcc_intg/sensor.py +++ b/custom_components/evcc_intg/sensor.py @@ -20,6 +20,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, add_ entity = EvccSensor(coordinator, description) entities.append(entity) + multi_loadpoint_config = len(coordinator._loadpoint) > 1 for a_lp_key in coordinator._loadpoint: load_point_config = coordinator._loadpoint[a_lp_key] lp_api_index = int(a_lp_key) @@ -31,9 +32,9 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, add_ description = ExtSensorEntityDescription( tag=a_stub.tag, idx=lp_api_index, - key=f"{a_stub.tag.key}_{lp_api_index}_{lp_id_addon}", - translation_key=a_stub.tag.key, - name_addon=lp_name_addon, + key=f"{a_stub.tag.key}_{lp_api_index}_{lp_id_addon}" if a_stub.array_idx is None else f"{a_stub.tag.key}_{lp_api_index}_{a_stub.array_idx}_{lp_id_addon}", + translation_key=a_stub.tag.key if a_stub.array_idx is None else f"{a_stub.tag.key}_{a_stub.array_idx}", + name_addon=lp_name_addon if multi_loadpoint_config else None, icon=a_stub.icon, device_class=a_stub.device_class, unit_of_measurement=a_stub.unit_of_measurement, @@ -44,15 +45,10 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, add_ state_class=a_stub.state_class, native_unit_of_measurement=a_stub.native_unit_of_measurement, suggested_display_precision=a_stub.suggested_display_precision, - array_idx = a_stub.array_idx, - factor = a_stub.factor + array_idx=a_stub.array_idx, + factor=a_stub.factor ) - # for sure there is a smarter way to code this - if description.array_idx is not None: - description.key = f"{a_stub.tag.key}_{lp_api_index}_{a_stub.array_idx}_{lp_id_addon}" - description.translation_key = f"{a_stub.tag.key}_{a_stub.array_idx}" - entity = EvccSensor(coordinator, description) entities.append(entity) diff --git a/custom_components/evcc_intg/switch.py b/custom_components/evcc_intg/switch.py index 5b1adf4..976b537 100644 --- a/custom_components/evcc_intg/switch.py +++ b/custom_components/evcc_intg/switch.py @@ -21,6 +21,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, add_ entity = EvccSwitch(coordinator, description) entities.append(entity) + multi_loadpoint_config = len(coordinator._loadpoint) > 1 for a_lp_key in coordinator._loadpoint: load_point_config = coordinator._loadpoint[a_lp_key] lp_api_index = int(a_lp_key) @@ -34,7 +35,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, add_ idx=lp_api_index, key=f"{a_stub.tag.key}_{lp_api_index}_{lp_id_addon}", translation_key=a_stub.tag.key, - name_addon=lp_name_addon, + name_addon=lp_name_addon if multi_loadpoint_config else None, icon=a_stub.icon, device_class=a_stub.device_class, unit_of_measurement=a_stub.unit_of_measurement,