Skip to content

Commit

Permalink
fixing duration entities #33
Browse files Browse the repository at this point in the history
  • Loading branch information
marq24 committed Oct 25, 2024
1 parent a0f894c commit 397a1ca
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions custom_components/evcc_intg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def __call__(self, evt: Event) -> bool:
return True

def clear_data(self):
_LOGGER.debug(f"clear_data called...")
self.bridge.clear_data()
self.data.clear()

Expand Down Expand Up @@ -215,6 +216,7 @@ async def read_evcc_config_on_startup(self):

async def _async_update_data(self) -> dict:
"""Update data via library."""
_LOGGER.debug(f"_async_update_data called")
try:
# if self.data is not None:
# _LOGGER.debug(f"number of fields before query: {len(self.data)} ")
Expand Down Expand Up @@ -357,9 +359,11 @@ async def async_write_tag(self, tag: Tag, value, idx: str = None, entity: Entity

elif tag.type == EP_TYPE.VEHICLES:
# TODO ?!
_LOGGER.debug(f"{tag} no data update!")
pass

if entity is not None:
_LOGGER.debug(f"schedule update...")
entity.async_schedule_update_ha_state(force_refresh=True)

return result
Expand Down
10 changes: 5 additions & 5 deletions custom_components/evcc_intg/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class ExtSelectEntityDescription(SelectEntityDescription):
@dataclass
class ExtSensorEntityDescriptionStub(EntityDescriptionStub):
state_class: SensorStateClass | str | None = None
suggested_unit_of_measurement: str | None = None
suggested_display_precision: int | None = None
native_unit_of_measurement: str | None = None

Expand Down Expand Up @@ -689,19 +690,18 @@ class ExtSwitchEntityDescription(SwitchEntityDescription):
tag=Tag.CHARGEDURATION,
icon="mdi:clock-digital",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfTime.MINUTES,
factor = 60000000000,
#factor = 60000000,
native_unit_of_measurement=UnitOfTime.SECONDS,
suggested_unit_of_measurement=UnitOfTime.MINUTES,
device_class=SensorDeviceClass.DURATION,
suggested_display_precision=0
),
ExtSensorEntityDescriptionStub(
tag=Tag.CHARGEREMAININGDURATION,
icon="mdi:clock-digital",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfTime.MINUTES,
native_unit_of_measurement=UnitOfTime.SECONDS,
suggested_unit_of_measurement=UnitOfTime.MINUTES,
device_class=SensorDeviceClass.DURATION,
factor = 60000000000,
suggested_display_precision=0
),
ExtSensorEntityDescriptionStub(
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": "2024.10.1"
"version": "2024.10.2"
}

0 comments on commit 397a1ca

Please sign in to comment.