Skip to content

Commit

Permalink
Merge pull request #69 from maorcc/bug-fix-3-0-2
Browse files Browse the repository at this point in the history
bug fix state class for sensor
  • Loading branch information
elad-bar committed Jun 2, 2024
2 parents f602af3 + b78edd9 commit 793cc24
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v3.0.3

- Fix state class to total

## v3.0.2

- Fix unload integration process
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,55 +71,55 @@ class IntegrationNumberEntityDescription(
key=EntityKeys.LAST_READ,
entity_type=EntityType.METER,
device_class=SensorDeviceClass.WATER,
state_class=SensorStateClass.TOTAL_INCREASING,
state_class=SensorStateClass.TOTAL,
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
reset_policy=ResetPolicy.MONTHLY,
),
IntegrationSensorEntityDescription(
key=EntityKeys.MONTHLY_CONSUMPTION,
entity_type=EntityType.METER,
device_class=SensorDeviceClass.WATER,
state_class=SensorStateClass.TOTAL_INCREASING,
state_class=SensorStateClass.TOTAL,
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
reset_policy=ResetPolicy.MONTHLY,
),
IntegrationSensorEntityDescription(
key=EntityKeys.TODAYS_CONSUMPTION,
entity_type=EntityType.METER,
device_class=SensorDeviceClass.WATER,
state_class=SensorStateClass.TOTAL_INCREASING,
state_class=SensorStateClass.TOTAL,
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
reset_policy=ResetPolicy.DAILY,
),
IntegrationSensorEntityDescription(
key=EntityKeys.YESTERDAYS_CONSUMPTION,
entity_type=EntityType.METER,
device_class=SensorDeviceClass.WATER,
state_class=SensorStateClass.TOTAL_INCREASING,
state_class=SensorStateClass.TOTAL,
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
reset_policy=ResetPolicy.DAILY,
),
IntegrationSensorEntityDescription(
key=EntityKeys.HIGH_RATE_CONSUMPTION,
entity_type=EntityType.METER,
device_class=SensorDeviceClass.WATER,
state_class=SensorStateClass.TOTAL_INCREASING,
state_class=SensorStateClass.TOTAL,
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
reset_policy=ResetPolicy.MONTHLY,
),
IntegrationSensorEntityDescription(
key=EntityKeys.LOW_RATE_CONSUMPTION,
entity_type=EntityType.METER,
device_class=SensorDeviceClass.WATER,
state_class=SensorStateClass.TOTAL_INCREASING,
state_class=SensorStateClass.TOTAL,
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
reset_policy=ResetPolicy.MONTHLY,
),
IntegrationSensorEntityDescription(
key=EntityKeys.LOW_RATE_TOTAL_COST,
entity_type=EntityType.METER,
entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.TOTAL_INCREASING,
state_class=SensorStateClass.TOTAL,
native_unit_of_measurement=UNIT_COST,
icon="mdi:currency-ils",
reset_policy=ResetPolicy.MONTHLY,
Expand All @@ -139,7 +139,7 @@ class IntegrationNumberEntityDescription(
key=EntityKeys.HIGH_RATE_TOTAL_COST,
entity_type=EntityType.METER,
entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.TOTAL_INCREASING,
state_class=SensorStateClass.TOTAL,
native_unit_of_measurement=UNIT_COST,
icon="mdi:currency-ils",
reset_policy=ResetPolicy.MONTHLY,
Expand All @@ -159,7 +159,7 @@ class IntegrationNumberEntityDescription(
key=EntityKeys.SEWAGE_TOTAL_COST,
entity_type=EntityType.METER,
entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.TOTAL_INCREASING,
state_class=SensorStateClass.TOTAL,
native_unit_of_measurement=UNIT_COST,
icon="mdi:currency-ils",
reset_policy=ResetPolicy.MONTHLY,
Expand Down
2 changes: 1 addition & 1 deletion custom_components/citymind_water_meter/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/maorcc/citymind_water_meter/issues",
"requirements": [],
"version": "3.0.2"
"version": "3.0.3"
}
1 change: 1 addition & 0 deletions custom_components/citymind_water_meter/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(
entity_description.native_unit_of_measurement
)

self._attr_state_class = entity_description.state_class
self._attr_last_reset = self._get_last_reset()

def _get_last_reset(self) -> datetime | None:
Expand Down

0 comments on commit 793cc24

Please sign in to comment.