Skip to content

Commit

Permalink
Add all-time kWh sensor and enable voltage sensor by default due to c…
Browse files Browse the repository at this point in the history
…hange in power balancer logic
  • Loading branch information
sirkojon committed Jul 15, 2024
1 parent d6b3f1d commit e8e6fd2
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion custom_components/chuck_control/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def unique_id(self) -> str | None:

@property
def entity_registry_enabled_default(self) -> bool:
return False
return True


class ConnectorPower(SensorEntity):
Expand Down Expand Up @@ -646,6 +646,48 @@ def state_attributes(self) -> dict[str, Any]:
return {"connector_count ": self.chargebox.get_connectors_count()}


class ChargeBoxTotalEnergy(SensorEntity):
def __init__(self, chargebox) -> None:
self.chargebox = chargebox
self.friendly_name_appendix = "Total energy"
self.friendly_name = get_friendly_name(self)

@property
def name(self) -> str:
return self.friendly_name

@property
def device_info(self) -> DeviceInfo:
return self.chargebox.get_device_info()

@property
def state(self) -> Any:
return round(self.chargebox.get_energy_total() / 1000, 4)

@property
def unique_id(self) -> str:
return f"{self.chargebox.info['serialNumber']}_energy_total"

@property
def device_class(self) -> SensorDeviceClass:
return SensorDeviceClass.ENERGY

@property
def state_class(self) -> SensorStateClass:
return SensorStateClass.MEASUREMENT

@property
def unit_of_measurement(self) -> str:
return UnitOfEnergy.KILO_WATT_HOUR

def update(self) -> None:
self.chargebox.update()

@property
def state_attributes(self) -> dict[str, Any]:
return {"connector_count ": self.chargebox.get_connectors_count()}


class ConnectorInternalTemp(SensorEntity):
def __init__(self, chargebox, connector_id) -> None:
self.chargebox = chargebox
Expand Down

0 comments on commit e8e6fd2

Please sign in to comment.