mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Remove last_reset
attribute and set state class to total_increasing
for mysensors energy sensors (#54827)
This commit is contained in:
parent
9c7ea786a7
commit
e98d50f6d1
@ -9,6 +9,7 @@ from homeassistant.components import mysensors
|
|||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
STATE_CLASS_MEASUREMENT,
|
STATE_CLASS_MEASUREMENT,
|
||||||
|
STATE_CLASS_TOTAL_INCREASING,
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
)
|
)
|
||||||
@ -42,7 +43,6 @@ from homeassistant.const import (
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.util.dt import utc_from_timestamp
|
|
||||||
|
|
||||||
from .const import MYSENSORS_DISCOVERY, DiscoveryInfo
|
from .const import MYSENSORS_DISCOVERY, DiscoveryInfo
|
||||||
from .helpers import on_unload
|
from .helpers import on_unload
|
||||||
@ -122,8 +122,7 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||||||
key="V_KWH",
|
key="V_KWH",
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=STATE_CLASS_TOTAL_INCREASING,
|
||||||
last_reset=utc_from_timestamp(0),
|
|
||||||
),
|
),
|
||||||
"V_LIGHT_LEVEL": SensorEntityDescription(
|
"V_LIGHT_LEVEL": SensorEntityDescription(
|
||||||
key="V_LIGHT_LEVEL",
|
key="V_LIGHT_LEVEL",
|
||||||
|
@ -10,6 +10,7 @@ from homeassistant.components.sensor import (
|
|||||||
ATTR_LAST_RESET,
|
ATTR_LAST_RESET,
|
||||||
ATTR_STATE_CLASS,
|
ATTR_STATE_CLASS,
|
||||||
STATE_CLASS_MEASUREMENT,
|
STATE_CLASS_MEASUREMENT,
|
||||||
|
STATE_CLASS_TOTAL_INCREASING,
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_DEVICE_CLASS,
|
ATTR_DEVICE_CLASS,
|
||||||
@ -24,7 +25,6 @@ from homeassistant.const import (
|
|||||||
TEMP_FAHRENHEIT,
|
TEMP_FAHRENHEIT,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.util.dt import utc_from_timestamp
|
|
||||||
from homeassistant.util.unit_system import IMPERIAL_SYSTEM, METRIC_SYSTEM, UnitSystem
|
from homeassistant.util.unit_system import IMPERIAL_SYSTEM, METRIC_SYSTEM, UnitSystem
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
@ -92,8 +92,7 @@ async def test_energy_sensor(
|
|||||||
assert state.state == "18000"
|
assert state.state == "18000"
|
||||||
assert state.attributes[ATTR_DEVICE_CLASS] == DEVICE_CLASS_ENERGY
|
assert state.attributes[ATTR_DEVICE_CLASS] == DEVICE_CLASS_ENERGY
|
||||||
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == ENERGY_KILO_WATT_HOUR
|
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == ENERGY_KILO_WATT_HOUR
|
||||||
assert state.attributes[ATTR_STATE_CLASS] == STATE_CLASS_MEASUREMENT
|
assert state.attributes[ATTR_STATE_CLASS] == STATE_CLASS_TOTAL_INCREASING
|
||||||
assert state.attributes[ATTR_LAST_RESET] == utc_from_timestamp(0).isoformat()
|
|
||||||
|
|
||||||
|
|
||||||
async def test_sound_sensor(
|
async def test_sound_sensor(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user