|
@@ -1,9 +1,8 @@
|
|
|
"""Tests for the PC321-TY Power Clamp Energy meter"""
|
|
"""Tests for the PC321-TY Power Clamp Energy meter"""
|
|
|
|
|
|
|
|
from homeassistant.components.sensor import (
|
|
from homeassistant.components.sensor import (
|
|
|
- STATE_CLASS_MEASUREMENT,
|
|
|
|
|
- STATE_CLASS_TOTAL_INCREASING,
|
|
|
|
|
SensorDeviceClass,
|
|
SensorDeviceClass,
|
|
|
|
|
+ SensorStateClass,
|
|
|
)
|
|
)
|
|
|
from homeassistant.const import (
|
|
from homeassistant.const import (
|
|
|
UnitOfElectricCurrent,
|
|
UnitOfElectricCurrent,
|
|
@@ -55,7 +54,7 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
|
|
|
"name": "sensor_energy",
|
|
"name": "sensor_energy",
|
|
|
"unit": UnitOfEnergy.KILO_WATT_HOUR,
|
|
"unit": UnitOfEnergy.KILO_WATT_HOUR,
|
|
|
"device_class": SensorDeviceClass.ENERGY,
|
|
"device_class": SensorDeviceClass.ENERGY,
|
|
|
- "state_class": STATE_CLASS_TOTAL_INCREASING,
|
|
|
|
|
|
|
+ "state_class": SensorStateClass.TOTAL_INCREASING,
|
|
|
"testdata": (12345, 123.45),
|
|
"testdata": (12345, 123.45),
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
@@ -63,7 +62,7 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
|
|
|
"name": "sensor_voltage_a",
|
|
"name": "sensor_voltage_a",
|
|
|
"unit": UnitOfElectricPotential.VOLT,
|
|
"unit": UnitOfElectricPotential.VOLT,
|
|
|
"device_class": SensorDeviceClass.VOLTAGE,
|
|
"device_class": SensorDeviceClass.VOLTAGE,
|
|
|
- "state_class": STATE_CLASS_MEASUREMENT,
|
|
|
|
|
|
|
+ "state_class": SensorStateClass.MEASUREMENT,
|
|
|
"testdata": (2348, 234.8),
|
|
"testdata": (2348, 234.8),
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
@@ -71,21 +70,21 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
|
|
|
"name": "sensor_current_a",
|
|
"name": "sensor_current_a",
|
|
|
"unit": UnitOfElectricCurrent.AMPERE,
|
|
"unit": UnitOfElectricCurrent.AMPERE,
|
|
|
"device_class": SensorDeviceClass.CURRENT,
|
|
"device_class": SensorDeviceClass.CURRENT,
|
|
|
- "state_class": STATE_CLASS_MEASUREMENT,
|
|
|
|
|
|
|
+ "state_class": SensorStateClass.MEASUREMENT,
|
|
|
"testdata": (4567, 4.567),
|
|
"testdata": (4567, 4.567),
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
"dps": POWER1_DP,
|
|
"dps": POWER1_DP,
|
|
|
"name": "sensor_power_a",
|
|
"name": "sensor_power_a",
|
|
|
"unit": UnitOfPower.WATT,
|
|
"unit": UnitOfPower.WATT,
|
|
|
- "state_class": STATE_CLASS_MEASUREMENT,
|
|
|
|
|
|
|
+ "state_class": SensorStateClass.MEASUREMENT,
|
|
|
"device_class": SensorDeviceClass.POWER,
|
|
"device_class": SensorDeviceClass.POWER,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
"dps": PFACTOR1_DP,
|
|
"dps": PFACTOR1_DP,
|
|
|
"name": "sensor_power_factor_a",
|
|
"name": "sensor_power_factor_a",
|
|
|
"device_class": SensorDeviceClass.POWER_FACTOR,
|
|
"device_class": SensorDeviceClass.POWER_FACTOR,
|
|
|
- "state_class": STATE_CLASS_MEASUREMENT,
|
|
|
|
|
|
|
+ "state_class": SensorStateClass.MEASUREMENT,
|
|
|
"testdata": (5000, 50.00),
|
|
"testdata": (5000, 50.00),
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
@@ -99,7 +98,7 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
|
|
|
"name": "sensor_voltage_b",
|
|
"name": "sensor_voltage_b",
|
|
|
"unit": UnitOfElectricPotential.VOLT,
|
|
"unit": UnitOfElectricPotential.VOLT,
|
|
|
"device_class": SensorDeviceClass.VOLTAGE,
|
|
"device_class": SensorDeviceClass.VOLTAGE,
|
|
|
- "state_class": STATE_CLASS_MEASUREMENT,
|
|
|
|
|
|
|
+ "state_class": SensorStateClass.MEASUREMENT,
|
|
|
"testdata": (2348, 234.8),
|
|
"testdata": (2348, 234.8),
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
@@ -107,7 +106,7 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
|
|
|
"name": "sensor_current_b",
|
|
"name": "sensor_current_b",
|
|
|
"unit": UnitOfElectricCurrent.AMPERE,
|
|
"unit": UnitOfElectricCurrent.AMPERE,
|
|
|
"device_class": SensorDeviceClass.CURRENT,
|
|
"device_class": SensorDeviceClass.CURRENT,
|
|
|
- "state_class": STATE_CLASS_MEASUREMENT,
|
|
|
|
|
|
|
+ "state_class": SensorStateClass.MEASUREMENT,
|
|
|
"testdata": (4567, 4.567),
|
|
"testdata": (4567, 4.567),
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
@@ -115,13 +114,13 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
|
|
|
"name": "sensor_power_b",
|
|
"name": "sensor_power_b",
|
|
|
"unit": UnitOfPower.WATT,
|
|
"unit": UnitOfPower.WATT,
|
|
|
"device_class": SensorDeviceClass.POWER,
|
|
"device_class": SensorDeviceClass.POWER,
|
|
|
- "state_class": STATE_CLASS_MEASUREMENT,
|
|
|
|
|
|
|
+ "state_class": SensorStateClass.MEASUREMENT,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
"dps": PFACTOR2_DP,
|
|
"dps": PFACTOR2_DP,
|
|
|
"name": "sensor_power_factor_b",
|
|
"name": "sensor_power_factor_b",
|
|
|
"device_class": SensorDeviceClass.POWER_FACTOR,
|
|
"device_class": SensorDeviceClass.POWER_FACTOR,
|
|
|
- "state_class": STATE_CLASS_MEASUREMENT,
|
|
|
|
|
|
|
+ "state_class": SensorStateClass.MEASUREMENT,
|
|
|
"testdata": (5000, 50.00),
|
|
"testdata": (5000, 50.00),
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
@@ -135,7 +134,7 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
|
|
|
"name": "sensor_voltage_c",
|
|
"name": "sensor_voltage_c",
|
|
|
"unit": UnitOfElectricPotential.VOLT,
|
|
"unit": UnitOfElectricPotential.VOLT,
|
|
|
"device_class": SensorDeviceClass.VOLTAGE,
|
|
"device_class": SensorDeviceClass.VOLTAGE,
|
|
|
- "state_class": STATE_CLASS_MEASUREMENT,
|
|
|
|
|
|
|
+ "state_class": SensorStateClass.MEASUREMENT,
|
|
|
"testdata": (2348, 234.8),
|
|
"testdata": (2348, 234.8),
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
@@ -143,21 +142,21 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
|
|
|
"name": "sensor_current_c",
|
|
"name": "sensor_current_c",
|
|
|
"unit": UnitOfElectricCurrent.AMPERE,
|
|
"unit": UnitOfElectricCurrent.AMPERE,
|
|
|
"device_class": SensorDeviceClass.CURRENT,
|
|
"device_class": SensorDeviceClass.CURRENT,
|
|
|
- "state_class": STATE_CLASS_MEASUREMENT,
|
|
|
|
|
|
|
+ "state_class": SensorStateClass.MEASUREMENT,
|
|
|
"testdata": (4567, 4.567),
|
|
"testdata": (4567, 4.567),
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
"dps": POWER3_DP,
|
|
"dps": POWER3_DP,
|
|
|
"name": "sensor_power_c",
|
|
"name": "sensor_power_c",
|
|
|
"unit": UnitOfPower.WATT,
|
|
"unit": UnitOfPower.WATT,
|
|
|
- "state_class": STATE_CLASS_MEASUREMENT,
|
|
|
|
|
|
|
+ "state_class": SensorStateClass.MEASUREMENT,
|
|
|
"device_class": SensorDeviceClass.POWER,
|
|
"device_class": SensorDeviceClass.POWER,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
"dps": PFACTOR3_DP,
|
|
"dps": PFACTOR3_DP,
|
|
|
"name": "sensor_power_factor_c",
|
|
"name": "sensor_power_factor_c",
|
|
|
"device_class": SensorDeviceClass.POWER_FACTOR,
|
|
"device_class": SensorDeviceClass.POWER_FACTOR,
|
|
|
- "state_class": STATE_CLASS_MEASUREMENT,
|
|
|
|
|
|
|
+ "state_class": SensorStateClass.MEASUREMENT,
|
|
|
"testdata": (5000, 50.00),
|
|
"testdata": (5000, 50.00),
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
@@ -171,21 +170,21 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
|
|
|
"name": "sensor_total_current",
|
|
"name": "sensor_total_current",
|
|
|
"unit": UnitOfElectricCurrent.AMPERE,
|
|
"unit": UnitOfElectricCurrent.AMPERE,
|
|
|
"device_class": SensorDeviceClass.CURRENT,
|
|
"device_class": SensorDeviceClass.CURRENT,
|
|
|
- "state_class": STATE_CLASS_MEASUREMENT,
|
|
|
|
|
|
|
+ "state_class": SensorStateClass.MEASUREMENT,
|
|
|
"testdata": (12345, 12.345),
|
|
"testdata": (12345, 12.345),
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
"dps": TOTALPOWER_DP,
|
|
"dps": TOTALPOWER_DP,
|
|
|
"name": "sensor_total_active_power",
|
|
"name": "sensor_total_active_power",
|
|
|
"unit": UnitOfPower.WATT,
|
|
"unit": UnitOfPower.WATT,
|
|
|
- "state_class": STATE_CLASS_MEASUREMENT,
|
|
|
|
|
|
|
+ "state_class": SensorStateClass.MEASUREMENT,
|
|
|
"device_class": SensorDeviceClass.POWER,
|
|
"device_class": SensorDeviceClass.POWER,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
"dps": FREQUENCY_DP,
|
|
"dps": FREQUENCY_DP,
|
|
|
"name": "sensor_frequency",
|
|
"name": "sensor_frequency",
|
|
|
"unit": UnitOfFrequency.HERTZ,
|
|
"unit": UnitOfFrequency.HERTZ,
|
|
|
- "state_class": STATE_CLASS_MEASUREMENT,
|
|
|
|
|
|
|
+ "state_class": SensorStateClass.MEASUREMENT,
|
|
|
"device_class": SensorDeviceClass.FREQUENCY,
|
|
"device_class": SensorDeviceClass.FREQUENCY,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
@@ -193,7 +192,7 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
|
|
|
"name": "sensor_temperature",
|
|
"name": "sensor_temperature",
|
|
|
"unit": UnitOfTemperature.CELSIUS,
|
|
"unit": UnitOfTemperature.CELSIUS,
|
|
|
"device_class": SensorDeviceClass.TEMPERATURE,
|
|
"device_class": SensorDeviceClass.TEMPERATURE,
|
|
|
- "state_class": STATE_CLASS_MEASUREMENT,
|
|
|
|
|
|
|
+ "state_class": SensorStateClass.MEASUREMENT,
|
|
|
"testdata": (234, 23.4),
|
|
"testdata": (234, 23.4),
|
|
|
},
|
|
},
|
|
|
]
|
|
]
|