Skip to content

Commit

Permalink
Fix state_class for sensors #127 #109
Browse files Browse the repository at this point in the history
  • Loading branch information
xZetsubou committed Feb 5, 2024
1 parent bbd2fc2 commit 3a68cf6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions custom_components/localtuya/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
DOMAIN,
STATE_CLASSES_SCHEMA,
SensorStateClass,
SensorEntity,
)
from homeassistant.const import (
CONF_DEVICE_CLASS,
Expand Down Expand Up @@ -38,7 +39,7 @@ def flow_schema(dps):
}


class LocaltuyaSensor(LocalTuyaEntity):
class LocaltuyaSensor(LocalTuyaEntity, SensorEntity):
"""Representation of a Tuya sensor."""

def __init__(
Expand All @@ -53,7 +54,7 @@ def __init__(
self._state = STATE_UNKNOWN

@property
def state(self):
def native_value(self):
"""Return sensor state."""
return self._state

Expand All @@ -68,7 +69,7 @@ def state_class(self) -> str | None:
return self._config.get(CONF_STATE_CLASS)

@property
def unit_of_measurement(self):
def native_unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return self._config.get(CONF_UNIT_OF_MEASUREMENT)

Expand Down

0 comments on commit 3a68cf6

Please sign in to comment.