Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Commit

Permalink
support measurement and last_reset in 2021.8
Browse files Browse the repository at this point in the history
  • Loading branch information
mjmeli committed Aug 22, 2021
1 parent f4ad7ae commit f6f1473
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

-

## [0.0.3] - 2021-08-22

### Fixed

- Integration not working in version 2021.8. This will need to be reverted in 2021.9.

## [0.0.2] - 2021-08-22

### Added
Expand All @@ -27,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Pulls today's current energy usage into entity sensor.duke_energy_usage_today_kwh

[unreleased]: https://github.com//mjmeli/ha-duke-energy-gateway/compare/0.0.2...HEAD
[unreleased]: https://github.com//mjmeli/ha-duke-energy-gateway/compare/0.0.3...HEAD
[0.0.2]: https://github.com/mjmeli/ha-duke-energy-gateway/releases/tag/0.0.3
[0.0.2]: https://github.com/mjmeli/ha-duke-energy-gateway/releases/tag/0.0.2
[0.0.1]: https://github.com/mjmeli/ha-duke-energy-gateway/releases/tag/0.0.1
7 changes: 5 additions & 2 deletions custom_components/duke_energy_gateway/sensor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Sensor platform for Duke Energy Gateway."""
from homeassistant.components.sensor import STATE_CLASS_TOTAL_INCREASING
from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT
from homeassistant.util import dt
from pyduke_energy.types import GatewayStatus
from pyduke_energy.types import MeterInfo
Expand Down Expand Up @@ -97,7 +97,8 @@ def device_class(self):
@property
def state_class(self):
"""Return the state class of the sensor"""
return STATE_CLASS_TOTAL_INCREASING
# TODO - this will need to be changed to STATE_CLASS_TOTAL_INCREASING in 2021.9
return STATE_CLASS_MEASUREMENT

@property
def extra_state_attributes(self):
Expand All @@ -109,5 +110,7 @@ def extra_state_attributes(self):
attrs["last_measurement"] = dt.as_local(
dt.utc_from_timestamp(gw_usage[-1].timestamp)
)
# TODO - this will need to be removed in 2021.9
attrs["last_reset"] = dt.utc_from_timestamp(gw_usage[0].timestamp)

return attrs

0 comments on commit f6f1473

Please sign in to comment.