Skip to content

Commit

Permalink
added unit to 'CHARGETOTALIMPORT' - solve issue #7
Browse files Browse the repository at this point in the history
  • Loading branch information
marq24 committed Jun 18, 2024
1 parent be6e828 commit 7a71975
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
7 changes: 4 additions & 3 deletions custom_components/evcc_intg/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,10 @@ class ExtSwitchEntityDescription(SwitchEntityDescription):
ExtSensorEntityDescriptionStub(
tag=Tag.CHARGETOTALIMPORT,
icon="mdi:transmission-tower-export",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=None,
device_class=None
state_class=SensorStateClass.TOTAL_INCREASING,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
suggested_display_precision=2
),
ExtSensorEntityDescriptionStub(
tag=Tag.CHARGEDENERGY,
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.6.1"
"version": "2024.6.2"
}
3 changes: 3 additions & 0 deletions custom_components/evcc_intg/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ def state(self):
value = round(float(value)/self.entity_description.factor, 2)
else:
value = round(float(value)/self.entity_description.factor, self.entity_description.suggested_display_precision)
elif self.entity_description.suggested_display_precision is not None:
value = round(float(value), self.entity_description.suggested_display_precision)


except IndexError:
value = "unknown"
Expand Down

0 comments on commit 7a71975

Please sign in to comment.