Skip to content

Commit

Permalink
fix: set state_class for numerical sensors
Browse files Browse the repository at this point in the history
closes #1827
  • Loading branch information
alandtse committed Jan 14, 2023
1 parent 6017a62 commit 0a0788e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion custom_components/alexa_media/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
import logging
from typing import Callable, Optional

from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
from homeassistant.components.sensor import (
SensorDeviceClass,
SensorEntity,
SensorStateClass,
)
from homeassistant.const import UnitOfTemperature, __version__ as HA_VERSION
from homeassistant.exceptions import ConfigEntryNotReady, NoEntitySpecifiedError
from homeassistant.helpers.dispatcher import async_dispatcher_connect
Expand Down Expand Up @@ -244,6 +248,7 @@ def __init__(self, coordinator, entity_id, name, media_player_device_id):
super().__init__(coordinator)
self._attr_name = name + " Temperature"
self._attr_device_class = SensorDeviceClass.TEMPERATURE
self._attr_state_class = SensorStateClass.MEASUREMENT
self._attr_native_value: Optional[
datetime.datetime
] = parse_temperature_from_coordinator(coordinator, entity_id)
Expand Down Expand Up @@ -283,6 +288,7 @@ def __init__(
).strip()
self._attr_name = name + " " + self._sensor_name
self._attr_device_class = self._sensor_name
self._attr_state_class = SensorStateClass.MEASUREMENT
self._attr_native_value: Optional[
datetime.datetime
] = parse_air_quality_from_coordinator(coordinator, entity_id, instance)
Expand Down

0 comments on commit 0a0788e

Please sign in to comment.