Skip to content

Commit

Permalink
fix state class for TEMP statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
pszafer committed Oct 30, 2023
1 parent 0eb7ba5 commit e596706
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 3 additions & 1 deletion custom_components/bosch/sensor/energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from datetime import timedelta, datetime
from bosch_thermostat_client.const import UNITS
from .statistic_helper import StatisticHelper
from homeassistant.components.sensor import SensorDeviceClass
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
from homeassistant.const import (
ENERGY_KILO_WATT_HOUR,
STATE_UNAVAILABLE,
Expand Down Expand Up @@ -87,6 +87,8 @@ def __init__(
super().__init__(name=sensor_attributes.get("name"), uuid=uuid, **kwargs)
self._unit_of_measurement = sensor_attributes.get(UNITS)
self._attr_device_class = sensor_attributes.get("deviceClass", SensorDeviceClass.ENERGY)
if self._attr_state_class and self._attr_device_class == SensorDeviceClass.TEMPERATURE:
self._attr_device_class = SensorStateClass.MEASUREMENT

@property
def device_name(self) -> str:
Expand Down
2 changes: 0 additions & 2 deletions custom_components/bosch/sensor/statistic_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
from __future__ import annotations
import logging
import asyncio
from typing import Any
from datetime import datetime, timedelta
from homeassistant.components.recorder.models import (
StatisticData,
StatisticMetaData,
timestamp_to_datetime_or_none,
datetime_to_timestamp_or_none,
)
from sqlalchemy.exc import IntegrityError
Expand Down

0 comments on commit e596706

Please sign in to comment.