mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Fix zwave_js meter sensor state class (#53716)
This commit is contained in:
parent
120a0bead0
commit
3c0e4b1fd9
@ -229,8 +229,6 @@ class ZWaveNumericSensor(ZwaveSensorBase):
|
|||||||
class ZWaveMeterSensor(ZWaveNumericSensor, RestoreEntity):
|
class ZWaveMeterSensor(ZWaveNumericSensor, RestoreEntity):
|
||||||
"""Representation of a Z-Wave Meter CC sensor."""
|
"""Representation of a Z-Wave Meter CC sensor."""
|
||||||
|
|
||||||
_attr_state_class = STATE_CLASS_MEASUREMENT
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ConfigEntry,
|
||||||
@ -241,6 +239,7 @@ class ZWaveMeterSensor(ZWaveNumericSensor, RestoreEntity):
|
|||||||
super().__init__(config_entry, client, info)
|
super().__init__(config_entry, client, info)
|
||||||
|
|
||||||
# Entity class attributes
|
# Entity class attributes
|
||||||
|
self._attr_state_class = STATE_CLASS_MEASUREMENT
|
||||||
self._attr_last_reset = dt.utc_from_timestamp(0)
|
self._attr_last_reset = dt.utc_from_timestamp(0)
|
||||||
self._attr_device_class = DEVICE_CLASS_POWER
|
self._attr_device_class = DEVICE_CLASS_POWER
|
||||||
if self.info.primary_value.metadata.unit == "kWh":
|
if self.info.primary_value.metadata.unit == "kWh":
|
||||||
|
@ -3,7 +3,7 @@ from unittest.mock import patch
|
|||||||
|
|
||||||
from zwave_js_server.event import Event
|
from zwave_js_server.event import Event
|
||||||
|
|
||||||
from homeassistant.components.sensor import ATTR_LAST_RESET
|
from homeassistant.components.sensor import ATTR_LAST_RESET, STATE_CLASS_MEASUREMENT
|
||||||
from homeassistant.components.zwave_js.const import (
|
from homeassistant.components.zwave_js.const import (
|
||||||
ATTR_METER_TYPE,
|
ATTR_METER_TYPE,
|
||||||
ATTR_VALUE,
|
ATTR_VALUE,
|
||||||
@ -62,6 +62,7 @@ async def test_energy_sensors(hass, hank_binary_switch, integration):
|
|||||||
assert state.state == "0.0"
|
assert state.state == "0.0"
|
||||||
assert state.attributes["unit_of_measurement"] == POWER_WATT
|
assert state.attributes["unit_of_measurement"] == POWER_WATT
|
||||||
assert state.attributes["device_class"] == DEVICE_CLASS_POWER
|
assert state.attributes["device_class"] == DEVICE_CLASS_POWER
|
||||||
|
assert state.attributes["state_class"] == STATE_CLASS_MEASUREMENT
|
||||||
|
|
||||||
state = hass.states.get(ENERGY_SENSOR)
|
state = hass.states.get(ENERGY_SENSOR)
|
||||||
|
|
||||||
@ -69,6 +70,7 @@ async def test_energy_sensors(hass, hank_binary_switch, integration):
|
|||||||
assert state.state == "0.16"
|
assert state.state == "0.16"
|
||||||
assert state.attributes["unit_of_measurement"] == ENERGY_KILO_WATT_HOUR
|
assert state.attributes["unit_of_measurement"] == ENERGY_KILO_WATT_HOUR
|
||||||
assert state.attributes["device_class"] == DEVICE_CLASS_ENERGY
|
assert state.attributes["device_class"] == DEVICE_CLASS_ENERGY
|
||||||
|
assert state.attributes["state_class"] == STATE_CLASS_MEASUREMENT
|
||||||
|
|
||||||
|
|
||||||
async def test_disabled_notification_sensor(hass, multisensor_6, integration):
|
async def test_disabled_notification_sensor(hass, multisensor_6, integration):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user