Skip to content

Commit

Permalink
when I will learn to work with ENUM's?
Browse files Browse the repository at this point in the history
  • Loading branch information
marq24 committed Jan 14, 2025
1 parent 0b58cf3 commit 9288bf8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
26 changes: 13 additions & 13 deletions custom_components/evcc_intg/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class ExtSwitchEntityDescription(SwitchEntityDescription):
ExtNumberEntityDescription(
tag=Tag.BATTERYGRIDCHARGELIMIT,
key=Tag.BATTERYGRIDCHARGELIMIT.key,
entity_category=EntityCategory.CONFIG,
entity_category=EntityCategory.CONFIG.value,
icon = "mdi:cash-multiple",
mode = NumberMode.BOX,
native_max_value=2.50,
Expand Down Expand Up @@ -442,7 +442,7 @@ class ExtSwitchEntityDescription(SwitchEntityDescription):
ExtSensorEntityDescription(
tag=Tag.GRID,
key=Tag.GRIDPOWER.key, # we keep here the KEY from the GRID_AS_PREFIX_SENSORS!
array_idx = GRID_CONTENT.POWER,
array_idx = GRID_CONTENT.POWER.value,
icon="mdi:transmission-tower",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfPower.WATT,
Expand All @@ -452,7 +452,7 @@ class ExtSwitchEntityDescription(SwitchEntityDescription):
ExtSensorEntityDescription(
tag=Tag.GRID,
key=f"{Tag.GRIDCURRENTS.key}_0", # we keep here the KEY from the GRID_AS_PREFIX_SENSORS!
tuple_idx = [GRID_CONTENT.CURRENTS, 0],
tuple_idx = [GRID_CONTENT.CURRENTS.value, 0],
icon="mdi:current-ac",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
Expand All @@ -462,7 +462,7 @@ class ExtSwitchEntityDescription(SwitchEntityDescription):
ExtSensorEntityDescription(
tag=Tag.GRID,
key=f"{Tag.GRIDCURRENTS.key}_1", # we keep here the KEY from the GRID_AS_PREFIX_SENSORS!
tuple_idx = [GRID_CONTENT.CURRENTS, 1],
tuple_idx = [GRID_CONTENT.CURRENTS.value, 1],
icon="mdi:current-ac",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
Expand All @@ -472,7 +472,7 @@ class ExtSwitchEntityDescription(SwitchEntityDescription):
ExtSensorEntityDescription(
tag=Tag.GRID,
key=f"{Tag.GRIDCURRENTS.key}_2", # we keep here the KEY from the GRID_AS_PREFIX_SENSORS!
tuple_idx = [GRID_CONTENT.CURRENTS, 2],
tuple_idx = [GRID_CONTENT.CURRENTS.value, 2],
icon="mdi:current-ac",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
Expand Down Expand Up @@ -541,7 +541,7 @@ class ExtSwitchEntityDescription(SwitchEntityDescription):
ExtSensorEntityDescription(
tag=Tag.PV,
key="pv_0_energy",
tuple_idx = [0, PV_CONTENT.ENERGY],
tuple_idx = [0, PV_CONTENT.ENERGY.value],
icon="mdi:solar-power",
state_class=SensorStateClass.TOTAL,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
Expand All @@ -552,7 +552,7 @@ class ExtSwitchEntityDescription(SwitchEntityDescription):
ExtSensorEntityDescription(
tag=Tag.PV,
key="pv_1_energy",
tuple_idx = [1, PV_CONTENT.ENERGY],
tuple_idx = [1, PV_CONTENT.ENERGY.value],
icon="mdi:solar-power",
state_class=SensorStateClass.TOTAL,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
Expand All @@ -563,7 +563,7 @@ class ExtSwitchEntityDescription(SwitchEntityDescription):
ExtSensorEntityDescription(
tag=Tag.PV,
key="pv_2_energy",
tuple_idx = [2, PV_CONTENT.ENERGY],
tuple_idx = [2, PV_CONTENT.ENERGY.value],
icon="mdi:solar-power",
state_class=SensorStateClass.TOTAL,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
Expand All @@ -574,7 +574,7 @@ class ExtSwitchEntityDescription(SwitchEntityDescription):
ExtSensorEntityDescription(
tag=Tag.PV,
key="pv_3_energy",
tuple_idx = [3, PV_CONTENT.ENERGY],
tuple_idx = [3, PV_CONTENT.ENERGY.value],
icon="mdi:solar-power",
state_class=SensorStateClass.TOTAL,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
Expand All @@ -594,7 +594,7 @@ class ExtSwitchEntityDescription(SwitchEntityDescription):
ExtSensorEntityDescription(
tag=Tag.PV,
key="pv_0_power",
tuple_idx = [0, PV_CONTENT.POWER],
tuple_idx = [0, PV_CONTENT.POWER.value],
icon="mdi:solar-power",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfPower.WATT,
Expand All @@ -605,7 +605,7 @@ class ExtSwitchEntityDescription(SwitchEntityDescription):
ExtSensorEntityDescription(
tag=Tag.PV,
key="pv_1_power",
tuple_idx = [1, PV_CONTENT.POWER],
tuple_idx = [1, PV_CONTENT.POWER.value],
icon="mdi:solar-power",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfPower.WATT,
Expand All @@ -616,7 +616,7 @@ class ExtSwitchEntityDescription(SwitchEntityDescription):
ExtSensorEntityDescription(
tag=Tag.PV,
key="pv_2_power",
tuple_idx = [2, PV_CONTENT.POWER],
tuple_idx = [2, PV_CONTENT.POWER.value],
icon="mdi:solar-power",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfPower.WATT,
Expand All @@ -627,7 +627,7 @@ class ExtSwitchEntityDescription(SwitchEntityDescription):
ExtSensorEntityDescription(
tag=Tag.PV,
key="pv_3_power",
tuple_idx = [3, PV_CONTENT.POWER],
tuple_idx = [3, PV_CONTENT.POWER.value],
icon="mdi:solar-power",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfPower.WATT,
Expand Down
2 changes: 1 addition & 1 deletion custom_components/evcc_intg/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/marq24/ha-evcc/issues",
"requirements": [],
"version": "2025.1.6"
"version": "2025.1.7"
}
4 changes: 2 additions & 2 deletions custom_components/evcc_intg/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ def native_value(self):
if self.entity_description.factor is not None:
value = float(value)/self.entity_description.factor

except (IndexError, ValueError, TypeError) as err:
_LOGGER.debug(f"tag: {self.tag} (idx:{self.idx}) caused {err}")
except (IndexError, ValueError, TypeError, KeyError) as err:
_LOGGER.debug(f"tag: {self.tag} (idx: '{self.idx}') (value: '{value}') caused {err}")
value = None

# make sure that we do not return unknown or smaller values
Expand Down

0 comments on commit 9288bf8

Please sign in to comment.