From f6f14738aec6f0b58860777489e6a2865b095078 Mon Sep 17 00:00:00 2001 From: Michael Meli Date: Sun, 22 Aug 2021 16:03:59 -0400 Subject: [PATCH] support measurement and last_reset in 2021.8 --- CHANGELOG.md | 9 ++++++++- custom_components/duke_energy_gateway/sensor.py | 7 +++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f88d2c6..62339e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/custom_components/duke_energy_gateway/sensor.py b/custom_components/duke_energy_gateway/sensor.py index 45eba90..83a9d3b 100644 --- a/custom_components/duke_energy_gateway/sensor.py +++ b/custom_components/duke_energy_gateway/sensor.py @@ -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 @@ -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): @@ -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