Skip to content

Commit

Permalink
State class changes (#15)
Browse files Browse the repository at this point in the history
* Switch state class to total increasing

* Remove last reset
https://developers.home-assistant.io/blog/2021/08/16/state_class_total

* Bump Version
  • Loading branch information
HandyHat authored Sep 1, 2021
1 parent d34bfcf commit 7b072c7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 22 deletions.
10 changes: 2 additions & 8 deletions custom_components/hildebrandglow_dcc/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@
"config_flow": true,
"documentation": "https://github.com/HandyHat/ha-hildebrandglow",
"issue_tracker": "https://github.com/HandyHat/ha-hildebrandglow/issues",
"requirements": ["pytz"],
"ssdp": [],
"zeroconf": [],
"homekit": {},
"dependencies": [],
"codeowners": ["@handyhat"],
"iot_class": "cloud_polling",
"version": "0.3.2"

}
"version": "0.3.3"
}
14 changes: 2 additions & 12 deletions custom_components/hildebrandglow_dcc/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytz
from homeassistant.components.sensor import (
DEVICE_CLASS_ENERGY,
STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL_INCREASING,
SensorEntity,
)
from homeassistant.config_entries import ConfigEntry
Expand Down Expand Up @@ -58,7 +58,7 @@ class GlowConsumptionCurrent(SensorEntity):

available = True

_attr_state_class = STATE_CLASS_MEASUREMENT
_attr_state_class = STATE_CLASS_TOTAL_INCREASING

def __init__(self, glow: Glow, resource: Dict[str, Any]):
"""Initialize the sensor."""
Expand Down Expand Up @@ -120,16 +120,6 @@ def unit_of_measurement(self) -> Optional[str]:
return ENERGY_KILO_WATT_HOUR
return None

@property
def last_reset(self):
"Returns midnight for current day"
tz = pytz.timezone("Europe/London") # choose timezone
# Get correct date for the midnight using given timezone.
today = datetime.now(tz).date()
# Get midnight in the correct timezone (taking into account DST)
midnight = tz.localize(datetime.combine(today, time(0, 0)), is_dst=None)
return midnight

async def async_update(self) -> None:
"""Fetch new state data for the sensor.
Expand Down
3 changes: 2 additions & 1 deletion hacs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"name": "Hildebrand Glow (DCC)",
"render_readme": true,
"domains": ["sensor"],
"country": ["GB"]
"country": ["GB"],
"homeassistant": "2021.9.0"
}
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
autopep8==1.5.7
homeassistant==2021.8.8
homeassistant==2021.9.0
isort==5.9.3
pylint==2.9.6

0 comments on commit 7b072c7

Please sign in to comment.