Skip to content

Commit

Permalink
feat: non invoiced sensor added in profile (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
geertmeersman authored Aug 24, 2023
2 parents 7e509d4 + 19bb0b4 commit 19ec4d2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
20 changes: 20 additions & 0 deletions custom_components/nexxtmove/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,26 @@ def fetch_data(self):
state=len(charge_latest.get("charges")),
extra_attributes=charge_latest,
)
non_invoiced_charges = []
non_invoiced_amount = 0
for charge in charge_latest.get("charges"):
if charge.get("cleared") is False:
non_invoiced_charges.append(charge)
non_invoiced_amount += charge.get("costVat")

key = format_entity_name(f"{self.username} non invoiced")
data[key] = NexxtmoveItem(
name="Non invoiced",
key=key,
type="euro",
sensor_type="sensor",
device_key=device_key,
device_name=device_name,
device_model=device_model,
state=non_invoiced_amount,
extra_attributes={"charges": non_invoiced_charges},
)
_LOGGER.critical(non_invoiced_charges)
consumption = self.consumption()
if consumption.get("consumptionInKwh") is not None:
charges = self.charges()
Expand Down
9 changes: 5 additions & 4 deletions custom_components/nexxtmove/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,25 @@ class NexxtmoveSensorDescription(SensorEntityDescription):
),
NexxtmoveSensorDescription(key="counter", icon="mdi:counter"),
NexxtmoveSensorDescription(key="charging_device", icon="mdi:ev-station"),
NexxtmoveSensorDescription(key="charging_point", icon="mdi:ev-plug-ccs2"),
NexxtmoveSensorDescription(key="charging_point", icon="mdi:ev-plug-type1"),
NexxtmoveSensorDescription(
key="charging_events", icon="mdi:calendar-multiple-check"
),
NexxtmoveSensorDescription(
key="price", suggested_display_precision=1, icon="mdi:currency-eur"
key="price", suggested_display_precision=2, icon="mdi:currency-eur"
),
NexxtmoveSensorDescription(key="charges", icon="mdi:currency-eur"),
NexxtmoveSensorDescription(
key="euro",
icon="mdi:currency-eur",
suggested_display_precision=1,
suggested_display_precision=2,
device_class=SensorDeviceClass.MONETARY,
native_unit_of_measurement=CURRENCY_EURO,
),
NexxtmoveSensorDescription(
key="pricekwh",
icon="mdi:currency-eur",
suggested_display_precision=2,
device_class=SensorDeviceClass.MONETARY,
),
NexxtmoveSensorDescription(key="residential_location", icon="mdi:home"),
Expand Down Expand Up @@ -162,7 +163,7 @@ def extra_state_attributes(self):
if not self.coordinator.data:
return {}
attributes = {
"last_nexxtmove_sync": self.last_synced,
"last_synced": self.last_synced,
}
if len(self.item.extra_attributes) > 0:
for attr in self.item.extra_attributes:
Expand Down

0 comments on commit 19ec4d2

Please sign in to comment.