Replace the usage of unit constants by enumerations in Tests [o-r] (#85936)
This commit is contained in:
parent
e5f67c9119
commit
72d3fa6d89
13 changed files with 151 additions and 146 deletions
|
@ -24,15 +24,14 @@ from homeassistant.const import (
|
||||||
ATTR_STATE,
|
ATTR_STATE,
|
||||||
ATTR_UNIT_OF_MEASUREMENT,
|
ATTR_UNIT_OF_MEASUREMENT,
|
||||||
ATTR_VIA_DEVICE,
|
ATTR_VIA_DEVICE,
|
||||||
ELECTRIC_POTENTIAL_VOLT,
|
|
||||||
LIGHT_LUX,
|
LIGHT_LUX,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
PRESSURE_CBAR,
|
|
||||||
PRESSURE_MBAR,
|
|
||||||
STATE_OFF,
|
STATE_OFF,
|
||||||
STATE_ON,
|
STATE_ON,
|
||||||
STATE_UNKNOWN,
|
STATE_UNKNOWN,
|
||||||
TEMP_CELSIUS,
|
UnitOfElectricPotential,
|
||||||
|
UnitOfPressure,
|
||||||
|
UnitOfTemperature,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.entity import EntityCategory
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
|
||||||
|
@ -96,7 +95,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "25.1",
|
ATTR_STATE: "25.1",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/10.111111111111/temperature",
|
ATTR_UNIQUE_ID: "/10.111111111111/temperature",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -135,7 +134,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "25.1",
|
ATTR_STATE: "25.1",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/12.111111111111/TAI8570/temperature",
|
ATTR_UNIQUE_ID: "/12.111111111111/TAI8570/temperature",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEFAULT_DISABLED: True,
|
ATTR_DEFAULT_DISABLED: True,
|
||||||
|
@ -145,7 +144,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "1025.1",
|
ATTR_STATE: "1025.1",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/12.111111111111/TAI8570/pressure",
|
ATTR_UNIQUE_ID: "/12.111111111111/TAI8570/pressure",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: PRESSURE_MBAR,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfPressure.MBAR,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
Platform.SWITCH: [
|
Platform.SWITCH: [
|
||||||
|
@ -276,7 +275,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: STATE_UNKNOWN,
|
ATTR_STATE: STATE_UNKNOWN,
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/22.111111111111/temperature",
|
ATTR_UNIQUE_ID: "/22.111111111111/temperature",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -298,7 +297,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "25.1",
|
ATTR_STATE: "25.1",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/26.111111111111/temperature",
|
ATTR_UNIQUE_ID: "/26.111111111111/temperature",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEFAULT_DISABLED: True,
|
ATTR_DEFAULT_DISABLED: True,
|
||||||
|
@ -358,7 +357,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "969.3",
|
ATTR_STATE: "969.3",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/26.111111111111/B1-R1-A/pressure",
|
ATTR_UNIQUE_ID: "/26.111111111111/B1-R1-A/pressure",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: PRESSURE_MBAR,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfPressure.MBAR,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEFAULT_DISABLED: True,
|
ATTR_DEFAULT_DISABLED: True,
|
||||||
|
@ -378,7 +377,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "3.0",
|
ATTR_STATE: "3.0",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/26.111111111111/VAD",
|
ATTR_UNIQUE_ID: "/26.111111111111/VAD",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: ELECTRIC_POTENTIAL_VOLT,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfElectricPotential.VOLT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEFAULT_DISABLED: True,
|
ATTR_DEFAULT_DISABLED: True,
|
||||||
|
@ -388,7 +387,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "4.7",
|
ATTR_STATE: "4.7",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/26.111111111111/VDD",
|
ATTR_UNIQUE_ID: "/26.111111111111/VDD",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: ELECTRIC_POTENTIAL_VOLT,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfElectricPotential.VOLT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEFAULT_DISABLED: True,
|
ATTR_DEFAULT_DISABLED: True,
|
||||||
|
@ -398,7 +397,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "0.1",
|
ATTR_STATE: "0.1",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/26.111111111111/vis",
|
ATTR_UNIQUE_ID: "/26.111111111111/vis",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: ELECTRIC_POTENTIAL_VOLT,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfElectricPotential.VOLT,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
Platform.SWITCH: [
|
Platform.SWITCH: [
|
||||||
|
@ -430,7 +429,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "27.0",
|
ATTR_STATE: "27.0",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/28.111111111111/temperature",
|
ATTR_UNIQUE_ID: "/28.111111111111/temperature",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -454,7 +453,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "27.0",
|
ATTR_STATE: "27.0",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/28.222222222222/temperature",
|
ATTR_UNIQUE_ID: "/28.222222222222/temperature",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -478,7 +477,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "27.0",
|
ATTR_STATE: "27.0",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/28.222222222223/temperature",
|
ATTR_UNIQUE_ID: "/28.222222222223/temperature",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -683,7 +682,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "27.0",
|
ATTR_STATE: "27.0",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/30.111111111111/temperature",
|
ATTR_UNIQUE_ID: "/30.111111111111/temperature",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEFAULT_DISABLED: True,
|
ATTR_DEFAULT_DISABLED: True,
|
||||||
|
@ -694,7 +693,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "173.8",
|
ATTR_STATE: "173.8",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/30.111111111111/typeX/temperature",
|
ATTR_UNIQUE_ID: "/30.111111111111/typeX/temperature",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEFAULT_DISABLED: True,
|
ATTR_DEFAULT_DISABLED: True,
|
||||||
|
@ -704,7 +703,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "3.0",
|
ATTR_STATE: "3.0",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/30.111111111111/volt",
|
ATTR_UNIQUE_ID: "/30.111111111111/volt",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: ELECTRIC_POTENTIAL_VOLT,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfElectricPotential.VOLT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEFAULT_DISABLED: True,
|
ATTR_DEFAULT_DISABLED: True,
|
||||||
|
@ -714,7 +713,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "0.1",
|
ATTR_STATE: "0.1",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/30.111111111111/vis",
|
ATTR_UNIQUE_ID: "/30.111111111111/vis",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: ELECTRIC_POTENTIAL_VOLT,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfElectricPotential.VOLT,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -779,7 +778,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "28.2",
|
ATTR_STATE: "28.2",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/3B.111111111111/temperature",
|
ATTR_UNIQUE_ID: "/3B.111111111111/temperature",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -801,7 +800,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "29.1",
|
ATTR_STATE: "29.1",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/42.111111111111/temperature",
|
ATTR_UNIQUE_ID: "/42.111111111111/temperature",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -841,7 +840,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "25.1",
|
ATTR_STATE: "25.1",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/EF.111111111111/humidity/temperature",
|
ATTR_UNIQUE_ID: "/EF.111111111111/humidity/temperature",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -885,7 +884,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "43.1",
|
ATTR_STATE: "43.1",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/EF.111111111112/moisture/sensor.2",
|
ATTR_UNIQUE_ID: "/EF.111111111112/moisture/sensor.2",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: PRESSURE_CBAR,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfPressure.CBAR,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.PRESSURE,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.PRESSURE,
|
||||||
|
@ -894,7 +893,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "44.1",
|
ATTR_STATE: "44.1",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/EF.111111111112/moisture/sensor.3",
|
ATTR_UNIQUE_ID: "/EF.111111111112/moisture/sensor.3",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: PRESSURE_CBAR,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfPressure.CBAR,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
Platform.SWITCH: [
|
Platform.SWITCH: [
|
||||||
|
@ -1066,7 +1065,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "13.9",
|
ATTR_STATE: "13.9",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/7E.111111111111/EDS0068/temperature",
|
ATTR_UNIQUE_ID: "/7E.111111111111/EDS0068/temperature",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.PRESSURE,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.PRESSURE,
|
||||||
|
@ -1075,7 +1074,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "1012.2",
|
ATTR_STATE: "1012.2",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/7E.111111111111/EDS0068/pressure",
|
ATTR_UNIQUE_ID: "/7E.111111111111/EDS0068/pressure",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: PRESSURE_MBAR,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfPressure.MBAR,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.ILLUMINANCE,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.ILLUMINANCE,
|
||||||
|
@ -1116,7 +1115,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "13.9",
|
ATTR_STATE: "13.9",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/7E.222222222222/EDS0066/temperature",
|
ATTR_UNIQUE_ID: "/7E.222222222222/EDS0066/temperature",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.PRESSURE,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.PRESSURE,
|
||||||
|
@ -1125,7 +1124,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||||
ATTR_STATE: "1012.2",
|
ATTR_STATE: "1012.2",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "/7E.222222222222/EDS0066/pressure",
|
ATTR_UNIQUE_ID: "/7E.222222222222/EDS0066/pressure",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: PRESSURE_MBAR,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfPressure.MBAR,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,11 +16,11 @@ from homeassistant.const import (
|
||||||
ATTR_ICON,
|
ATTR_ICON,
|
||||||
ATTR_UNIT_OF_MEASUREMENT,
|
ATTR_UNIT_OF_MEASUREMENT,
|
||||||
CURRENCY_EURO,
|
CURRENCY_EURO,
|
||||||
ELECTRIC_CURRENT_AMPERE,
|
UnitOfElectricCurrent,
|
||||||
ELECTRIC_POTENTIAL_VOLT,
|
UnitOfElectricPotential,
|
||||||
ENERGY_KILO_WATT_HOUR,
|
UnitOfEnergy,
|
||||||
POWER_WATT,
|
UnitOfPower,
|
||||||
VOLUME_LITERS,
|
UnitOfVolume,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
|
@ -45,7 +45,7 @@ async def test_smartmeter(
|
||||||
assert state.state == "877"
|
assert state.state == "877"
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Power Consumption"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Power Consumption"
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == POWER_WATT
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfPower.WATT
|
||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.POWER
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.POWER
|
||||||
assert ATTR_ICON not in state.attributes
|
assert ATTR_ICON not in state.attributes
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ async def test_smartmeter(
|
||||||
state.attributes.get(ATTR_FRIENDLY_NAME) == "Energy Consumption - High Tariff"
|
state.attributes.get(ATTR_FRIENDLY_NAME) == "Energy Consumption - High Tariff"
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL_INCREASING
|
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL_INCREASING
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == ENERGY_KILO_WATT_HOUR
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfEnergy.KILO_WATT_HOUR
|
||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.ENERGY
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.ENERGY
|
||||||
assert ATTR_ICON not in state.attributes
|
assert ATTR_ICON not in state.attributes
|
||||||
|
|
||||||
|
@ -102,7 +102,9 @@ async def test_phases(
|
||||||
assert state.state == "233.6"
|
assert state.state == "233.6"
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Voltage Phase L1"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Voltage Phase L1"
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == ELECTRIC_POTENTIAL_VOLT
|
assert (
|
||||||
|
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfElectricPotential.VOLT
|
||||||
|
)
|
||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.VOLTAGE
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.VOLTAGE
|
||||||
assert ATTR_ICON not in state.attributes
|
assert ATTR_ICON not in state.attributes
|
||||||
|
|
||||||
|
@ -114,7 +116,9 @@ async def test_phases(
|
||||||
assert state.state == "1.6"
|
assert state.state == "1.6"
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Current Phase L1"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Current Phase L1"
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == ELECTRIC_CURRENT_AMPERE
|
assert (
|
||||||
|
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfElectricCurrent.AMPERE
|
||||||
|
)
|
||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.CURRENT
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.CURRENT
|
||||||
assert ATTR_ICON not in state.attributes
|
assert ATTR_ICON not in state.attributes
|
||||||
|
|
||||||
|
@ -126,7 +130,7 @@ async def test_phases(
|
||||||
assert state.state == "315"
|
assert state.state == "315"
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Power Consumed Phase L1"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Power Consumed Phase L1"
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == POWER_WATT
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfPower.WATT
|
||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.POWER
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.POWER
|
||||||
assert ATTR_ICON not in state.attributes
|
assert ATTR_ICON not in state.attributes
|
||||||
|
|
||||||
|
@ -160,7 +164,7 @@ async def test_settings(
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
||||||
assert (
|
assert (
|
||||||
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
||||||
== f"{CURRENCY_EURO}/{ENERGY_KILO_WATT_HOUR}"
|
== f"{CURRENCY_EURO}/{UnitOfEnergy.KILO_WATT_HOUR}"
|
||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get("sensor.settings_energy_production_price_low")
|
state = hass.states.get("sensor.settings_energy_production_price_low")
|
||||||
|
@ -173,7 +177,7 @@ async def test_settings(
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
||||||
assert (
|
assert (
|
||||||
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
||||||
== f"{CURRENCY_EURO}/{ENERGY_KILO_WATT_HOUR}"
|
== f"{CURRENCY_EURO}/{UnitOfEnergy.KILO_WATT_HOUR}"
|
||||||
)
|
)
|
||||||
|
|
||||||
assert entry.device_id
|
assert entry.device_id
|
||||||
|
@ -203,7 +207,7 @@ async def test_watermeter(
|
||||||
assert state.state == "112.0"
|
assert state.state == "112.0"
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Consumption Day"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Consumption Day"
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL_INCREASING
|
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL_INCREASING
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == VOLUME_LITERS
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfVolume.LITERS
|
||||||
|
|
||||||
assert entry.device_id
|
assert entry.device_id
|
||||||
device_entry = device_registry.async_get(entry.device_id)
|
device_entry = device_registry.async_get(entry.device_id)
|
||||||
|
|
|
@ -42,7 +42,6 @@ from homeassistant.const import (
|
||||||
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
CONTENT_TYPE_TEXT_PLAIN,
|
CONTENT_TYPE_TEXT_PLAIN,
|
||||||
DEGREE,
|
DEGREE,
|
||||||
ENERGY_KILO_WATT_HOUR,
|
|
||||||
EVENT_STATE_CHANGED,
|
EVENT_STATE_CHANGED,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
STATE_CLOSED,
|
STATE_CLOSED,
|
||||||
|
@ -55,8 +54,8 @@ from homeassistant.const import (
|
||||||
STATE_OPEN,
|
STATE_OPEN,
|
||||||
STATE_OPENING,
|
STATE_OPENING,
|
||||||
STATE_UNLOCKED,
|
STATE_UNLOCKED,
|
||||||
TEMP_CELSIUS,
|
UnitOfEnergy,
|
||||||
TEMP_FAHRENHEIT,
|
UnitOfTemperature,
|
||||||
)
|
)
|
||||||
from homeassistant.core import split_entity_id
|
from homeassistant.core import split_entity_id
|
||||||
from homeassistant.helpers import entity_registry
|
from homeassistant.helpers import entity_registry
|
||||||
|
@ -898,7 +897,7 @@ async def sensor_fixture(hass, registry):
|
||||||
domain=sensor.DOMAIN,
|
domain=sensor.DOMAIN,
|
||||||
platform="test",
|
platform="test",
|
||||||
unique_id="sensor_1",
|
unique_id="sensor_1",
|
||||||
unit_of_measurement=TEMP_CELSIUS,
|
unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
original_device_class=SensorDeviceClass.TEMPERATURE,
|
original_device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
suggested_object_id="outside_temperature",
|
suggested_object_id="outside_temperature",
|
||||||
original_name="Outside Temperature",
|
original_name="Outside Temperature",
|
||||||
|
@ -924,7 +923,7 @@ async def sensor_fixture(hass, registry):
|
||||||
domain=sensor.DOMAIN,
|
domain=sensor.DOMAIN,
|
||||||
platform="test",
|
platform="test",
|
||||||
unique_id="sensor_3",
|
unique_id="sensor_3",
|
||||||
unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
original_device_class=SensorDeviceClass.POWER,
|
original_device_class=SensorDeviceClass.POWER,
|
||||||
suggested_object_id="radio_energy",
|
suggested_object_id="radio_energy",
|
||||||
original_name="Radio Energy",
|
original_name="Radio Energy",
|
||||||
|
@ -940,7 +939,7 @@ async def sensor_fixture(hass, registry):
|
||||||
domain=sensor.DOMAIN,
|
domain=sensor.DOMAIN,
|
||||||
platform="test",
|
platform="test",
|
||||||
unique_id="sensor_4",
|
unique_id="sensor_4",
|
||||||
unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
suggested_object_id="television_energy",
|
suggested_object_id="television_energy",
|
||||||
original_name="Television Energy",
|
original_name="Television Energy",
|
||||||
)
|
)
|
||||||
|
@ -951,7 +950,7 @@ async def sensor_fixture(hass, registry):
|
||||||
domain=sensor.DOMAIN,
|
domain=sensor.DOMAIN,
|
||||||
platform="test",
|
platform="test",
|
||||||
unique_id="sensor_5",
|
unique_id="sensor_5",
|
||||||
unit_of_measurement=f"SEK/{ENERGY_KILO_WATT_HOUR}",
|
unit_of_measurement=f"SEK/{UnitOfEnergy.KILO_WATT_HOUR}",
|
||||||
suggested_object_id="electricity_price",
|
suggested_object_id="electricity_price",
|
||||||
original_name="Electricity price",
|
original_name="Electricity price",
|
||||||
)
|
)
|
||||||
|
@ -1015,7 +1014,7 @@ async def sensor_fixture(hass, registry):
|
||||||
domain=sensor.DOMAIN,
|
domain=sensor.DOMAIN,
|
||||||
platform="test",
|
platform="test",
|
||||||
unique_id="sensor_11",
|
unique_id="sensor_11",
|
||||||
unit_of_measurement=TEMP_FAHRENHEIT,
|
unit_of_measurement=UnitOfTemperature.FAHRENHEIT,
|
||||||
original_device_class=SensorDeviceClass.TEMPERATURE,
|
original_device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
suggested_object_id="fahrenheit",
|
suggested_object_id="fahrenheit",
|
||||||
original_name="Fahrenheit",
|
original_name="Fahrenheit",
|
||||||
|
@ -1035,7 +1034,7 @@ async def climate_fixture(hass, registry):
|
||||||
domain=climate.DOMAIN,
|
domain=climate.DOMAIN,
|
||||||
platform="test",
|
platform="test",
|
||||||
unique_id="climate_1",
|
unique_id="climate_1",
|
||||||
unit_of_measurement=TEMP_CELSIUS,
|
unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
suggested_object_id="heatpump",
|
suggested_object_id="heatpump",
|
||||||
original_name="HeatPump",
|
original_name="HeatPump",
|
||||||
)
|
)
|
||||||
|
@ -1054,7 +1053,7 @@ async def climate_fixture(hass, registry):
|
||||||
domain=climate.DOMAIN,
|
domain=climate.DOMAIN,
|
||||||
platform="test",
|
platform="test",
|
||||||
unique_id="climate_2",
|
unique_id="climate_2",
|
||||||
unit_of_measurement=TEMP_CELSIUS,
|
unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
suggested_object_id="ecobee",
|
suggested_object_id="ecobee",
|
||||||
original_name="Ecobee",
|
original_name="Ecobee",
|
||||||
)
|
)
|
||||||
|
@ -1075,7 +1074,7 @@ async def climate_fixture(hass, registry):
|
||||||
domain=climate.DOMAIN,
|
domain=climate.DOMAIN,
|
||||||
platform="test",
|
platform="test",
|
||||||
unique_id="climate_3",
|
unique_id="climate_3",
|
||||||
unit_of_measurement=TEMP_CELSIUS,
|
unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
suggested_object_id="fritzdect",
|
suggested_object_id="fritzdect",
|
||||||
original_name="Fritz!DECT",
|
original_name="Fritz!DECT",
|
||||||
)
|
)
|
||||||
|
@ -1275,7 +1274,7 @@ async def input_number_fixture(hass, registry):
|
||||||
unique_id="input_number_3",
|
unique_id="input_number_3",
|
||||||
suggested_object_id="target_temperature",
|
suggested_object_id="target_temperature",
|
||||||
original_name="Target temperature",
|
original_name="Target temperature",
|
||||||
unit_of_measurement=TEMP_CELSIUS,
|
unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
)
|
)
|
||||||
set_state_with_entry(hass, input_number_3, 22.7)
|
set_state_with_entry(hass, input_number_3, 22.7)
|
||||||
data["input_number_3"] = input_number_3
|
data["input_number_3"] = input_number_3
|
||||||
|
|
|
@ -14,8 +14,8 @@ from homeassistant.components.sensor import (
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_DEVICE_CLASS,
|
ATTR_DEVICE_CLASS,
|
||||||
ATTR_UNIT_OF_MEASUREMENT,
|
ATTR_UNIT_OF_MEASUREMENT,
|
||||||
TEMP_CELSIUS,
|
|
||||||
Platform,
|
Platform,
|
||||||
|
UnitOfTemperature,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
@ -52,14 +52,14 @@ async def test_sensors_no_job(hass: HomeAssistant, mock_config_entry, mock_api):
|
||||||
state = hass.states.get("sensor.mock_title_heatbed")
|
state = hass.states.get("sensor.mock_title_heatbed")
|
||||||
assert state is not None
|
assert state is not None
|
||||||
assert state.state == "41.9"
|
assert state.state == "41.9"
|
||||||
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == TEMP_CELSIUS
|
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == UnitOfTemperature.CELSIUS
|
||||||
assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.TEMPERATURE
|
assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.TEMPERATURE
|
||||||
assert state.attributes[ATTR_STATE_CLASS] == SensorStateClass.MEASUREMENT
|
assert state.attributes[ATTR_STATE_CLASS] == SensorStateClass.MEASUREMENT
|
||||||
|
|
||||||
state = hass.states.get("sensor.mock_title_nozzle_temperature")
|
state = hass.states.get("sensor.mock_title_nozzle_temperature")
|
||||||
assert state is not None
|
assert state is not None
|
||||||
assert state.state == "47.8"
|
assert state.state == "47.8"
|
||||||
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == TEMP_CELSIUS
|
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == UnitOfTemperature.CELSIUS
|
||||||
assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.TEMPERATURE
|
assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.TEMPERATURE
|
||||||
assert state.attributes[ATTR_STATE_CLASS] == SensorStateClass.MEASUREMENT
|
assert state.attributes[ATTR_STATE_CLASS] == SensorStateClass.MEASUREMENT
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@ from homeassistant.const import (
|
||||||
ATTR_FRIENDLY_NAME,
|
ATTR_FRIENDLY_NAME,
|
||||||
ATTR_ICON,
|
ATTR_ICON,
|
||||||
ATTR_UNIT_OF_MEASUREMENT,
|
ATTR_UNIT_OF_MEASUREMENT,
|
||||||
ENERGY_KILO_WATT_HOUR,
|
UnitOfEnergy,
|
||||||
POWER_WATT,
|
UnitOfPower,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
|
@ -36,7 +36,7 @@ async def test_sensors(
|
||||||
assert state.state == "17762.1"
|
assert state.state == "17762.1"
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Energy Consumption"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Energy Consumption"
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.TOTAL_INCREASING
|
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.TOTAL_INCREASING
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == ENERGY_KILO_WATT_HOUR
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfEnergy.KILO_WATT_HOUR
|
||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.ENERGY
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.ENERGY
|
||||||
assert ATTR_ICON not in state.attributes
|
assert ATTR_ICON not in state.attributes
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ async def test_sensors(
|
||||||
assert state.state == "21214.6"
|
assert state.state == "21214.6"
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Energy Production"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Energy Production"
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.TOTAL_INCREASING
|
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.TOTAL_INCREASING
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == ENERGY_KILO_WATT_HOUR
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfEnergy.KILO_WATT_HOUR
|
||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.ENERGY
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.ENERGY
|
||||||
assert ATTR_ICON not in state.attributes
|
assert ATTR_ICON not in state.attributes
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ async def test_sensors(
|
||||||
assert state.state == "338"
|
assert state.state == "338"
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Power Flow"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Power Flow"
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == POWER_WATT
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfPower.WATT
|
||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.POWER
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.POWER
|
||||||
assert ATTR_ICON not in state.attributes
|
assert ATTR_ICON not in state.attributes
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,10 @@ from homeassistant.const import (
|
||||||
ATTR_FRIENDLY_NAME,
|
ATTR_FRIENDLY_NAME,
|
||||||
ATTR_ICON,
|
ATTR_ICON,
|
||||||
ATTR_UNIT_OF_MEASUREMENT,
|
ATTR_UNIT_OF_MEASUREMENT,
|
||||||
ELECTRIC_POTENTIAL_VOLT,
|
UnitOfElectricPotential,
|
||||||
ENERGY_KILO_WATT_HOUR,
|
UnitOfEnergy,
|
||||||
ENERGY_WATT_HOUR,
|
UnitOfPower,
|
||||||
POWER_KILO_WATT,
|
UnitOfTemperature,
|
||||||
POWER_WATT,
|
|
||||||
TEMP_CELSIUS,
|
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
|
@ -44,7 +42,7 @@ async def test_sensors(
|
||||||
== "Frenck's Solar Farm Energy consumed"
|
== "Frenck's Solar Farm Energy consumed"
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL_INCREASING
|
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL_INCREASING
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == ENERGY_WATT_HOUR
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfEnergy.WATT_HOUR
|
||||||
assert ATTR_ICON not in state.attributes
|
assert ATTR_ICON not in state.attributes
|
||||||
|
|
||||||
state = hass.states.get("sensor.frenck_s_solar_farm_energy_generated")
|
state = hass.states.get("sensor.frenck_s_solar_farm_energy_generated")
|
||||||
|
@ -60,7 +58,7 @@ async def test_sensors(
|
||||||
== "Frenck's Solar Farm Energy generated"
|
== "Frenck's Solar Farm Energy generated"
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL_INCREASING
|
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL_INCREASING
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == ENERGY_WATT_HOUR
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfEnergy.WATT_HOUR
|
||||||
assert ATTR_ICON not in state.attributes
|
assert ATTR_ICON not in state.attributes
|
||||||
|
|
||||||
state = hass.states.get("sensor.frenck_s_solar_farm_efficiency")
|
state = hass.states.get("sensor.frenck_s_solar_farm_efficiency")
|
||||||
|
@ -74,7 +72,7 @@ async def test_sensors(
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
||||||
assert (
|
assert (
|
||||||
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
||||||
== f"{ENERGY_KILO_WATT_HOUR}/{POWER_KILO_WATT}"
|
== f"{UnitOfEnergy.KILO_WATT_HOUR}/{UnitOfPower.KILO_WATT}"
|
||||||
)
|
)
|
||||||
assert ATTR_DEVICE_CLASS not in state.attributes
|
assert ATTR_DEVICE_CLASS not in state.attributes
|
||||||
assert ATTR_ICON not in state.attributes
|
assert ATTR_ICON not in state.attributes
|
||||||
|
@ -91,7 +89,7 @@ async def test_sensors(
|
||||||
state.attributes.get(ATTR_FRIENDLY_NAME) == "Frenck's Solar Farm Power consumed"
|
state.attributes.get(ATTR_FRIENDLY_NAME) == "Frenck's Solar Farm Power consumed"
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == POWER_WATT
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfPower.WATT
|
||||||
assert ATTR_ICON not in state.attributes
|
assert ATTR_ICON not in state.attributes
|
||||||
|
|
||||||
state = hass.states.get("sensor.frenck_s_solar_farm_power_generated")
|
state = hass.states.get("sensor.frenck_s_solar_farm_power_generated")
|
||||||
|
@ -107,7 +105,7 @@ async def test_sensors(
|
||||||
== "Frenck's Solar Farm Power generated"
|
== "Frenck's Solar Farm Power generated"
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == POWER_WATT
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfPower.WATT
|
||||||
assert ATTR_ICON not in state.attributes
|
assert ATTR_ICON not in state.attributes
|
||||||
|
|
||||||
state = hass.states.get("sensor.frenck_s_solar_farm_temperature")
|
state = hass.states.get("sensor.frenck_s_solar_farm_temperature")
|
||||||
|
@ -120,7 +118,7 @@ async def test_sensors(
|
||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.TEMPERATURE
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.TEMPERATURE
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Frenck's Solar Farm Temperature"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Frenck's Solar Farm Temperature"
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == TEMP_CELSIUS
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfTemperature.CELSIUS
|
||||||
assert ATTR_ICON not in state.attributes
|
assert ATTR_ICON not in state.attributes
|
||||||
|
|
||||||
state = hass.states.get("sensor.frenck_s_solar_farm_voltage")
|
state = hass.states.get("sensor.frenck_s_solar_farm_voltage")
|
||||||
|
@ -133,7 +131,9 @@ async def test_sensors(
|
||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.VOLTAGE
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.VOLTAGE
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Frenck's Solar Farm Voltage"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Frenck's Solar Farm Voltage"
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == ELECTRIC_POTENTIAL_VOLT
|
assert (
|
||||||
|
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfElectricPotential.VOLT
|
||||||
|
)
|
||||||
assert ATTR_ICON not in state.attributes
|
assert ATTR_ICON not in state.attributes
|
||||||
|
|
||||||
assert entry.device_id
|
assert entry.device_id
|
||||||
|
|
|
@ -23,7 +23,7 @@ from homeassistant.const import (
|
||||||
CONF_LONGITUDE,
|
CONF_LONGITUDE,
|
||||||
CONF_RADIUS,
|
CONF_RADIUS,
|
||||||
EVENT_HOMEASSISTANT_START,
|
EVENT_HOMEASSISTANT_START,
|
||||||
LENGTH_KILOMETERS,
|
UnitOfLength,
|
||||||
)
|
)
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
@ -124,7 +124,7 @@ async def test_setup(hass):
|
||||||
2018, 9, 22, 8, 10, tzinfo=datetime.timezone.utc
|
2018, 9, 22, 8, 10, tzinfo=datetime.timezone.utc
|
||||||
),
|
),
|
||||||
ATTR_STATUS: "Status 1",
|
ATTR_STATUS: "Status 1",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: LENGTH_KILOMETERS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfLength.KILOMETERS,
|
||||||
ATTR_SOURCE: "qld_bushfire",
|
ATTR_SOURCE: "qld_bushfire",
|
||||||
ATTR_ICON: "mdi:fire",
|
ATTR_ICON: "mdi:fire",
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ async def test_setup(hass):
|
||||||
ATTR_LATITUDE: 38.1,
|
ATTR_LATITUDE: 38.1,
|
||||||
ATTR_LONGITUDE: -3.1,
|
ATTR_LONGITUDE: -3.1,
|
||||||
ATTR_FRIENDLY_NAME: "Title 2",
|
ATTR_FRIENDLY_NAME: "Title 2",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: LENGTH_KILOMETERS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfLength.KILOMETERS,
|
||||||
ATTR_SOURCE: "qld_bushfire",
|
ATTR_SOURCE: "qld_bushfire",
|
||||||
ATTR_ICON: "mdi:fire",
|
ATTR_ICON: "mdi:fire",
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ async def test_setup(hass):
|
||||||
ATTR_LATITUDE: 38.2,
|
ATTR_LATITUDE: 38.2,
|
||||||
ATTR_LONGITUDE: -3.2,
|
ATTR_LONGITUDE: -3.2,
|
||||||
ATTR_FRIENDLY_NAME: "Title 3",
|
ATTR_FRIENDLY_NAME: "Title 3",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: LENGTH_KILOMETERS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfLength.KILOMETERS,
|
||||||
ATTR_SOURCE: "qld_bushfire",
|
ATTR_SOURCE: "qld_bushfire",
|
||||||
ATTR_ICON: "mdi:fire",
|
ATTR_ICON: "mdi:fire",
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ from homeassistant.components.recorder.statistics import (
|
||||||
list_statistic_ids,
|
list_statistic_ids,
|
||||||
)
|
)
|
||||||
from homeassistant.components.recorder.util import session_scope
|
from homeassistant.components.recorder.util import session_scope
|
||||||
from homeassistant.const import TEMP_CELSIUS
|
from homeassistant.const import UnitOfTemperature
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import recorder as recorder_helper
|
from homeassistant.helpers import recorder as recorder_helper
|
||||||
|
@ -1693,7 +1693,7 @@ def record_states(hass):
|
||||||
sns1_attr = {
|
sns1_attr = {
|
||||||
"device_class": "temperature",
|
"device_class": "temperature",
|
||||||
"state_class": "measurement",
|
"state_class": "measurement",
|
||||||
"unit_of_measurement": TEMP_CELSIUS,
|
"unit_of_measurement": UnitOfTemperature.CELSIUS,
|
||||||
}
|
}
|
||||||
sns2_attr = {
|
sns2_attr = {
|
||||||
"device_class": "humidity",
|
"device_class": "humidity",
|
||||||
|
|
|
@ -24,18 +24,18 @@ from homeassistant.const import (
|
||||||
ATTR_UNIT_OF_MEASUREMENT,
|
ATTR_UNIT_OF_MEASUREMENT,
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
ENERGY_KILO_WATT_HOUR,
|
|
||||||
LENGTH_KILOMETERS,
|
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
POWER_KILO_WATT,
|
|
||||||
STATE_NOT_HOME,
|
STATE_NOT_HOME,
|
||||||
STATE_OFF,
|
STATE_OFF,
|
||||||
STATE_ON,
|
STATE_ON,
|
||||||
STATE_UNKNOWN,
|
STATE_UNKNOWN,
|
||||||
TEMP_CELSIUS,
|
|
||||||
TIME_MINUTES,
|
|
||||||
VOLUME_LITERS,
|
|
||||||
Platform,
|
Platform,
|
||||||
|
UnitOfEnergy,
|
||||||
|
UnitOfLength,
|
||||||
|
UnitOfPower,
|
||||||
|
UnitOfTemperature,
|
||||||
|
UnitOfTime,
|
||||||
|
UnitOfVolume,
|
||||||
)
|
)
|
||||||
|
|
||||||
ATTR_DEFAULT_DISABLED = "default_disabled"
|
ATTR_DEFAULT_DISABLED = "default_disabled"
|
||||||
|
@ -133,7 +133,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: "141",
|
ATTR_STATE: "141",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_battery_autonomy",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777999_battery_autonomy",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: LENGTH_KILOMETERS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfLength.KILOMETERS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.ENERGY,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.ENERGY,
|
||||||
|
@ -141,7 +141,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: "31",
|
ATTR_STATE: "31",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_battery_available_energy",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777999_battery_available_energy",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: ENERGY_KILO_WATT_HOUR,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.BATTERY,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.BATTERY,
|
||||||
|
@ -164,7 +164,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: "20",
|
ATTR_STATE: "20",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_battery_temperature",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777999_battery_temperature",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.ENUM,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.ENUM,
|
||||||
|
@ -189,7 +189,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: "0.027",
|
ATTR_STATE: "0.027",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_charging_power",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777999_charging_power",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: POWER_KILO_WATT,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfPower.KILO_WATT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_ENTITY_ID: "sensor.reg_number_charging_remaining_time",
|
ATTR_ENTITY_ID: "sensor.reg_number_charging_remaining_time",
|
||||||
|
@ -197,7 +197,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: "145",
|
ATTR_STATE: "145",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_charging_remaining_time",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777999_charging_remaining_time",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TIME_MINUTES,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfTime.MINUTES,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.DISTANCE,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.DISTANCE,
|
||||||
|
@ -206,7 +206,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: "49114",
|
ATTR_STATE: "49114",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.TOTAL_INCREASING,
|
ATTR_STATE_CLASS: SensorStateClass.TOTAL_INCREASING,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_mileage",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777999_mileage",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: LENGTH_KILOMETERS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfLength.KILOMETERS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.TEMPERATURE,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.TEMPERATURE,
|
||||||
|
@ -214,7 +214,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: "8.0",
|
ATTR_STATE: "8.0",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_outside_temperature",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777999_outside_temperature",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_ENTITY_ID: "sensor.reg_number_hvac_soc_threshold",
|
ATTR_ENTITY_ID: "sensor.reg_number_hvac_soc_threshold",
|
||||||
|
@ -362,7 +362,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: "128",
|
ATTR_STATE: "128",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_battery_autonomy",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777999_battery_autonomy",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: LENGTH_KILOMETERS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfLength.KILOMETERS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.ENERGY,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.ENERGY,
|
||||||
|
@ -370,7 +370,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: "0",
|
ATTR_STATE: "0",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_battery_available_energy",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777999_battery_available_energy",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: ENERGY_KILO_WATT_HOUR,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.BATTERY,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.BATTERY,
|
||||||
|
@ -393,7 +393,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: STATE_UNKNOWN,
|
ATTR_STATE: STATE_UNKNOWN,
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_battery_temperature",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777999_battery_temperature",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.ENUM,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.ENUM,
|
||||||
|
@ -418,7 +418,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: STATE_UNKNOWN,
|
ATTR_STATE: STATE_UNKNOWN,
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_charging_power",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777999_charging_power",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: POWER_KILO_WATT,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfPower.KILO_WATT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_ENTITY_ID: "sensor.reg_number_charging_remaining_time",
|
ATTR_ENTITY_ID: "sensor.reg_number_charging_remaining_time",
|
||||||
|
@ -426,7 +426,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: STATE_UNKNOWN,
|
ATTR_STATE: STATE_UNKNOWN,
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_charging_remaining_time",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777999_charging_remaining_time",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TIME_MINUTES,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfTime.MINUTES,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.DISTANCE,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.DISTANCE,
|
||||||
|
@ -435,7 +435,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: "49114",
|
ATTR_STATE: "49114",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.TOTAL_INCREASING,
|
ATTR_STATE_CLASS: SensorStateClass.TOTAL_INCREASING,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_mileage",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777999_mileage",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: LENGTH_KILOMETERS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfLength.KILOMETERS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.TEMPERATURE,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.TEMPERATURE,
|
||||||
|
@ -443,7 +443,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: STATE_UNKNOWN,
|
ATTR_STATE: STATE_UNKNOWN,
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_outside_temperature",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777999_outside_temperature",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_ENTITY_ID: "sensor.reg_number_hvac_soc_threshold",
|
ATTR_ENTITY_ID: "sensor.reg_number_hvac_soc_threshold",
|
||||||
|
@ -591,7 +591,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: "141",
|
ATTR_STATE: "141",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_battery_autonomy",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777123_battery_autonomy",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: LENGTH_KILOMETERS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfLength.KILOMETERS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.ENERGY,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.ENERGY,
|
||||||
|
@ -599,7 +599,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: "31",
|
ATTR_STATE: "31",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_battery_available_energy",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777123_battery_available_energy",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: ENERGY_KILO_WATT_HOUR,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.BATTERY,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.BATTERY,
|
||||||
|
@ -622,7 +622,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: "20",
|
ATTR_STATE: "20",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_battery_temperature",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777123_battery_temperature",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.ENUM,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.ENUM,
|
||||||
|
@ -647,7 +647,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: "27.0",
|
ATTR_STATE: "27.0",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_charging_power",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777123_charging_power",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: POWER_KILO_WATT,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfPower.KILO_WATT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_ENTITY_ID: "sensor.reg_number_charging_remaining_time",
|
ATTR_ENTITY_ID: "sensor.reg_number_charging_remaining_time",
|
||||||
|
@ -655,7 +655,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: "145",
|
ATTR_STATE: "145",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_charging_remaining_time",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777123_charging_remaining_time",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: TIME_MINUTES,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfTime.MINUTES,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.DISTANCE,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.DISTANCE,
|
||||||
|
@ -664,7 +664,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: "35",
|
ATTR_STATE: "35",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_fuel_autonomy",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777123_fuel_autonomy",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: LENGTH_KILOMETERS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfLength.KILOMETERS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.VOLUME,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.VOLUME,
|
||||||
|
@ -673,7 +673,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: "3",
|
ATTR_STATE: "3",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_fuel_quantity",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777123_fuel_quantity",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: VOLUME_LITERS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfVolume.LITERS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.DISTANCE,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.DISTANCE,
|
||||||
|
@ -682,7 +682,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: "5567",
|
ATTR_STATE: "5567",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.TOTAL_INCREASING,
|
ATTR_STATE_CLASS: SensorStateClass.TOTAL_INCREASING,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_mileage",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777123_mileage",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: LENGTH_KILOMETERS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfLength.KILOMETERS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.ENUM,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.ENUM,
|
||||||
|
@ -789,7 +789,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: "35",
|
ATTR_STATE: "35",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_fuel_autonomy",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777123_fuel_autonomy",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: LENGTH_KILOMETERS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfLength.KILOMETERS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.VOLUME,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.VOLUME,
|
||||||
|
@ -798,7 +798,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: "3",
|
ATTR_STATE: "3",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
ATTR_STATE_CLASS: SensorStateClass.MEASUREMENT,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_fuel_quantity",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777123_fuel_quantity",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: VOLUME_LITERS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfVolume.LITERS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.DISTANCE,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.DISTANCE,
|
||||||
|
@ -807,7 +807,7 @@ MOCK_VEHICLES = {
|
||||||
ATTR_STATE: "5567",
|
ATTR_STATE: "5567",
|
||||||
ATTR_STATE_CLASS: SensorStateClass.TOTAL_INCREASING,
|
ATTR_STATE_CLASS: SensorStateClass.TOTAL_INCREASING,
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_mileage",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777123_mileage",
|
||||||
ATTR_UNIT_OF_MEASUREMENT: LENGTH_KILOMETERS,
|
ATTR_UNIT_OF_MEASUREMENT: UnitOfLength.KILOMETERS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ATTR_DEFAULT_DISABLED: True,
|
ATTR_DEFAULT_DISABLED: True,
|
||||||
|
|
|
@ -11,9 +11,9 @@ from homeassistant import config as hass_config
|
||||||
from homeassistant.components.rest.const import DOMAIN
|
from homeassistant.components.rest.const import DOMAIN
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ENTITY_ID,
|
ATTR_ENTITY_ID,
|
||||||
DATA_MEGABYTES,
|
|
||||||
SERVICE_RELOAD,
|
SERVICE_RELOAD,
|
||||||
STATE_UNAVAILABLE,
|
STATE_UNAVAILABLE,
|
||||||
|
UnitOfInformation,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
@ -44,12 +44,12 @@ async def test_setup_with_endpoint_timeout_with_recovery(hass: HomeAssistant) ->
|
||||||
"timeout": 30,
|
"timeout": 30,
|
||||||
"sensor": [
|
"sensor": [
|
||||||
{
|
{
|
||||||
"unit_of_measurement": DATA_MEGABYTES,
|
"unit_of_measurement": UnitOfInformation.MEGABYTES,
|
||||||
"name": "sensor1",
|
"name": "sensor1",
|
||||||
"value_template": "{{ value_json.sensor1 }}",
|
"value_template": "{{ value_json.sensor1 }}",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"unit_of_measurement": DATA_MEGABYTES,
|
"unit_of_measurement": UnitOfInformation.MEGABYTES,
|
||||||
"name": "sensor2",
|
"name": "sensor2",
|
||||||
"value_template": "{{ value_json.sensor2 }}",
|
"value_template": "{{ value_json.sensor2 }}",
|
||||||
},
|
},
|
||||||
|
@ -158,12 +158,12 @@ async def test_setup_minimum_resource_template(hass: HomeAssistant) -> None:
|
||||||
"timeout": 30,
|
"timeout": 30,
|
||||||
"sensor": [
|
"sensor": [
|
||||||
{
|
{
|
||||||
"unit_of_measurement": DATA_MEGABYTES,
|
"unit_of_measurement": UnitOfInformation.MEGABYTES,
|
||||||
"name": "sensor1",
|
"name": "sensor1",
|
||||||
"value_template": "{{ value_json.sensor1 }}",
|
"value_template": "{{ value_json.sensor1 }}",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"unit_of_measurement": DATA_MEGABYTES,
|
"unit_of_measurement": UnitOfInformation.MEGABYTES,
|
||||||
"name": "sensor2",
|
"name": "sensor2",
|
||||||
"value_template": "{{ value_json.sensor2 }}",
|
"value_template": "{{ value_json.sensor2 }}",
|
||||||
},
|
},
|
||||||
|
|
|
@ -20,10 +20,10 @@ from homeassistant.const import (
|
||||||
ATTR_ENTITY_ID,
|
ATTR_ENTITY_ID,
|
||||||
ATTR_UNIT_OF_MEASUREMENT,
|
ATTR_UNIT_OF_MEASUREMENT,
|
||||||
CONTENT_TYPE_JSON,
|
CONTENT_TYPE_JSON,
|
||||||
DATA_MEGABYTES,
|
|
||||||
SERVICE_RELOAD,
|
SERVICE_RELOAD,
|
||||||
STATE_UNKNOWN,
|
STATE_UNKNOWN,
|
||||||
TEMP_CELSIUS,
|
UnitOfInformation,
|
||||||
|
UnitOfTemperature,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
|
@ -193,7 +193,7 @@ async def test_setup_get(hass: HomeAssistant) -> None:
|
||||||
"method": "GET",
|
"method": "GET",
|
||||||
"value_template": "{{ value_json.key }}",
|
"value_template": "{{ value_json.key }}",
|
||||||
"name": "foo",
|
"name": "foo",
|
||||||
"unit_of_measurement": TEMP_CELSIUS,
|
"unit_of_measurement": UnitOfTemperature.CELSIUS,
|
||||||
"verify_ssl": "true",
|
"verify_ssl": "true",
|
||||||
"timeout": 30,
|
"timeout": 30,
|
||||||
"authentication": "basic",
|
"authentication": "basic",
|
||||||
|
@ -220,7 +220,7 @@ async def test_setup_get(hass: HomeAssistant) -> None:
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
state = hass.states.get("sensor.foo")
|
state = hass.states.get("sensor.foo")
|
||||||
assert state.state == ""
|
assert state.state == ""
|
||||||
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == TEMP_CELSIUS
|
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == UnitOfTemperature.CELSIUS
|
||||||
assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.TEMPERATURE
|
assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.TEMPERATURE
|
||||||
assert state.attributes[ATTR_STATE_CLASS] is SensorStateClass.MEASUREMENT
|
assert state.attributes[ATTR_STATE_CLASS] is SensorStateClass.MEASUREMENT
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ async def test_setup_get_digest_auth(hass: HomeAssistant) -> None:
|
||||||
"method": "GET",
|
"method": "GET",
|
||||||
"value_template": "{{ value_json.key }}",
|
"value_template": "{{ value_json.key }}",
|
||||||
"name": "foo",
|
"name": "foo",
|
||||||
"unit_of_measurement": DATA_MEGABYTES,
|
"unit_of_measurement": UnitOfInformation.MEGABYTES,
|
||||||
"verify_ssl": "true",
|
"verify_ssl": "true",
|
||||||
"timeout": 30,
|
"timeout": 30,
|
||||||
"authentication": "digest",
|
"authentication": "digest",
|
||||||
|
@ -366,7 +366,7 @@ async def test_setup_post(hass: HomeAssistant) -> None:
|
||||||
"value_template": "{{ value_json.key }}",
|
"value_template": "{{ value_json.key }}",
|
||||||
"payload": '{ "device": "toaster"}',
|
"payload": '{ "device": "toaster"}',
|
||||||
"name": "foo",
|
"name": "foo",
|
||||||
"unit_of_measurement": DATA_MEGABYTES,
|
"unit_of_measurement": UnitOfInformation.MEGABYTES,
|
||||||
"verify_ssl": "true",
|
"verify_ssl": "true",
|
||||||
"timeout": 30,
|
"timeout": 30,
|
||||||
"authentication": "basic",
|
"authentication": "basic",
|
||||||
|
@ -398,7 +398,7 @@ async def test_setup_get_xml(hass: HomeAssistant) -> None:
|
||||||
"method": "GET",
|
"method": "GET",
|
||||||
"value_template": "{{ value_json.dog }}",
|
"value_template": "{{ value_json.dog }}",
|
||||||
"name": "foo",
|
"name": "foo",
|
||||||
"unit_of_measurement": DATA_MEGABYTES,
|
"unit_of_measurement": UnitOfInformation.MEGABYTES,
|
||||||
"verify_ssl": "true",
|
"verify_ssl": "true",
|
||||||
"timeout": 30,
|
"timeout": 30,
|
||||||
}
|
}
|
||||||
|
@ -409,7 +409,7 @@ async def test_setup_get_xml(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
state = hass.states.get("sensor.foo")
|
state = hass.states.get("sensor.foo")
|
||||||
assert state.state == "abc"
|
assert state.state == "abc"
|
||||||
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == DATA_MEGABYTES
|
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == UnitOfInformation.MEGABYTES
|
||||||
|
|
||||||
|
|
||||||
@respx.mock
|
@respx.mock
|
||||||
|
@ -451,7 +451,7 @@ async def test_update_with_json_attrs(hass: HomeAssistant) -> None:
|
||||||
"value_template": "{{ value_json.key }}",
|
"value_template": "{{ value_json.key }}",
|
||||||
"json_attributes": ["key"],
|
"json_attributes": ["key"],
|
||||||
"name": "foo",
|
"name": "foo",
|
||||||
"unit_of_measurement": DATA_MEGABYTES,
|
"unit_of_measurement": UnitOfInformation.MEGABYTES,
|
||||||
"verify_ssl": "true",
|
"verify_ssl": "true",
|
||||||
"timeout": 30,
|
"timeout": 30,
|
||||||
}
|
}
|
||||||
|
@ -483,7 +483,7 @@ async def test_update_with_no_template(hass: HomeAssistant) -> None:
|
||||||
"method": "GET",
|
"method": "GET",
|
||||||
"json_attributes": ["key"],
|
"json_attributes": ["key"],
|
||||||
"name": "foo",
|
"name": "foo",
|
||||||
"unit_of_measurement": DATA_MEGABYTES,
|
"unit_of_measurement": UnitOfInformation.MEGABYTES,
|
||||||
"verify_ssl": "true",
|
"verify_ssl": "true",
|
||||||
"timeout": 30,
|
"timeout": 30,
|
||||||
"headers": {"Accept": "text/xml"},
|
"headers": {"Accept": "text/xml"},
|
||||||
|
@ -519,7 +519,7 @@ async def test_update_with_json_attrs_no_data(
|
||||||
"value_template": "{{ value_json.key }}",
|
"value_template": "{{ value_json.key }}",
|
||||||
"json_attributes": ["key"],
|
"json_attributes": ["key"],
|
||||||
"name": "foo",
|
"name": "foo",
|
||||||
"unit_of_measurement": DATA_MEGABYTES,
|
"unit_of_measurement": UnitOfInformation.MEGABYTES,
|
||||||
"verify_ssl": "true",
|
"verify_ssl": "true",
|
||||||
"timeout": 30,
|
"timeout": 30,
|
||||||
"headers": {"Accept": "text/xml"},
|
"headers": {"Accept": "text/xml"},
|
||||||
|
@ -556,7 +556,7 @@ async def test_update_with_json_attrs_not_dict(
|
||||||
"value_template": "{{ value_json.key }}",
|
"value_template": "{{ value_json.key }}",
|
||||||
"json_attributes": ["key"],
|
"json_attributes": ["key"],
|
||||||
"name": "foo",
|
"name": "foo",
|
||||||
"unit_of_measurement": DATA_MEGABYTES,
|
"unit_of_measurement": UnitOfInformation.MEGABYTES,
|
||||||
"verify_ssl": "true",
|
"verify_ssl": "true",
|
||||||
"timeout": 30,
|
"timeout": 30,
|
||||||
"headers": {"Accept": "text/xml"},
|
"headers": {"Accept": "text/xml"},
|
||||||
|
@ -594,7 +594,7 @@ async def test_update_with_json_attrs_bad_JSON(
|
||||||
"value_template": "{{ value_json.key }}",
|
"value_template": "{{ value_json.key }}",
|
||||||
"json_attributes": ["key"],
|
"json_attributes": ["key"],
|
||||||
"name": "foo",
|
"name": "foo",
|
||||||
"unit_of_measurement": DATA_MEGABYTES,
|
"unit_of_measurement": UnitOfInformation.MEGABYTES,
|
||||||
"verify_ssl": "true",
|
"verify_ssl": "true",
|
||||||
"timeout": 30,
|
"timeout": 30,
|
||||||
"headers": {"Accept": "text/xml"},
|
"headers": {"Accept": "text/xml"},
|
||||||
|
@ -638,7 +638,7 @@ async def test_update_with_json_attrs_with_json_attrs_path(hass: HomeAssistant)
|
||||||
"json_attributes_path": "$.toplevel.second_level",
|
"json_attributes_path": "$.toplevel.second_level",
|
||||||
"json_attributes": ["some_json_key", "some_json_key2"],
|
"json_attributes": ["some_json_key", "some_json_key2"],
|
||||||
"name": "foo",
|
"name": "foo",
|
||||||
"unit_of_measurement": DATA_MEGABYTES,
|
"unit_of_measurement": UnitOfInformation.MEGABYTES,
|
||||||
"verify_ssl": "true",
|
"verify_ssl": "true",
|
||||||
"timeout": 30,
|
"timeout": 30,
|
||||||
"headers": {"Accept": "text/xml"},
|
"headers": {"Accept": "text/xml"},
|
||||||
|
@ -677,7 +677,7 @@ async def test_update_with_xml_convert_json_attrs_with_json_attrs_path(
|
||||||
"json_attributes_path": "$.toplevel.second_level",
|
"json_attributes_path": "$.toplevel.second_level",
|
||||||
"json_attributes": ["some_json_key", "some_json_key2"],
|
"json_attributes": ["some_json_key", "some_json_key2"],
|
||||||
"name": "foo",
|
"name": "foo",
|
||||||
"unit_of_measurement": DATA_MEGABYTES,
|
"unit_of_measurement": UnitOfInformation.MEGABYTES,
|
||||||
"verify_ssl": "true",
|
"verify_ssl": "true",
|
||||||
"timeout": 30,
|
"timeout": 30,
|
||||||
}
|
}
|
||||||
|
@ -715,7 +715,7 @@ async def test_update_with_xml_convert_json_attrs_with_jsonattr_template(
|
||||||
"json_attributes_path": "$.response",
|
"json_attributes_path": "$.response",
|
||||||
"json_attributes": ["led0", "led1", "temp0", "time0", "ver"],
|
"json_attributes": ["led0", "led1", "temp0", "time0", "ver"],
|
||||||
"name": "foo",
|
"name": "foo",
|
||||||
"unit_of_measurement": DATA_MEGABYTES,
|
"unit_of_measurement": UnitOfInformation.MEGABYTES,
|
||||||
"verify_ssl": "true",
|
"verify_ssl": "true",
|
||||||
"timeout": 30,
|
"timeout": 30,
|
||||||
}
|
}
|
||||||
|
@ -756,7 +756,7 @@ async def test_update_with_application_xml_convert_json_attrs_with_jsonattr_temp
|
||||||
"json_attributes_path": "$.main",
|
"json_attributes_path": "$.main",
|
||||||
"json_attributes": ["dog", "cat"],
|
"json_attributes": ["dog", "cat"],
|
||||||
"name": "foo",
|
"name": "foo",
|
||||||
"unit_of_measurement": DATA_MEGABYTES,
|
"unit_of_measurement": UnitOfInformation.MEGABYTES,
|
||||||
"verify_ssl": "true",
|
"verify_ssl": "true",
|
||||||
"timeout": 30,
|
"timeout": 30,
|
||||||
}
|
}
|
||||||
|
@ -793,7 +793,7 @@ async def test_update_with_xml_convert_bad_xml(
|
||||||
"value_template": "{{ value_json.toplevel.master_value }}",
|
"value_template": "{{ value_json.toplevel.master_value }}",
|
||||||
"json_attributes": ["key"],
|
"json_attributes": ["key"],
|
||||||
"name": "foo",
|
"name": "foo",
|
||||||
"unit_of_measurement": DATA_MEGABYTES,
|
"unit_of_measurement": UnitOfInformation.MEGABYTES,
|
||||||
"verify_ssl": "true",
|
"verify_ssl": "true",
|
||||||
"timeout": 30,
|
"timeout": 30,
|
||||||
}
|
}
|
||||||
|
@ -830,7 +830,7 @@ async def test_update_with_failed_get(
|
||||||
"value_template": "{{ value_json.toplevel.master_value }}",
|
"value_template": "{{ value_json.toplevel.master_value }}",
|
||||||
"json_attributes": ["key"],
|
"json_attributes": ["key"],
|
||||||
"name": "foo",
|
"name": "foo",
|
||||||
"unit_of_measurement": DATA_MEGABYTES,
|
"unit_of_measurement": UnitOfInformation.MEGABYTES,
|
||||||
"verify_ssl": "true",
|
"verify_ssl": "true",
|
||||||
"timeout": 30,
|
"timeout": 30,
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@ from homeassistant.const import (
|
||||||
ATTR_ICON,
|
ATTR_ICON,
|
||||||
ATTR_UNIT_OF_MEASUREMENT,
|
ATTR_UNIT_OF_MEASUREMENT,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
PRECIPITATION_MILLIMETERS,
|
|
||||||
STATE_UNKNOWN,
|
STATE_UNKNOWN,
|
||||||
|
UnitOfPrecipitationDepth,
|
||||||
UnitOfTemperature,
|
UnitOfTemperature,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -287,7 +287,10 @@ async def test_sensor_attributes(hass, monkeypatch):
|
||||||
assert rain_state
|
assert rain_state
|
||||||
assert rain_state.attributes["device_class"] == SensorDeviceClass.PRECIPITATION
|
assert rain_state.attributes["device_class"] == SensorDeviceClass.PRECIPITATION
|
||||||
assert rain_state.attributes["state_class"] == SensorStateClass.TOTAL_INCREASING
|
assert rain_state.attributes["state_class"] == SensorStateClass.TOTAL_INCREASING
|
||||||
assert rain_state.attributes["unit_of_measurement"] == PRECIPITATION_MILLIMETERS
|
assert (
|
||||||
|
rain_state.attributes["unit_of_measurement"]
|
||||||
|
== UnitOfPrecipitationDepth.MILLIMETERS
|
||||||
|
)
|
||||||
|
|
||||||
humidity_state = hass.states.get("sensor.humidity_device")
|
humidity_state = hass.states.get("sensor.humidity_device")
|
||||||
assert humidity_state
|
assert humidity_state
|
||||||
|
|
|
@ -7,7 +7,7 @@ from homeassistant.const import (
|
||||||
ATTR_UNIT_OF_MEASUREMENT,
|
ATTR_UNIT_OF_MEASUREMENT,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||||
TEMP_CELSIUS,
|
UnitOfTemperature,
|
||||||
)
|
)
|
||||||
from homeassistant.core import State
|
from homeassistant.core import State
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ async def test_one_sensor(hass, rfxtrx):
|
||||||
state.attributes.get("friendly_name")
|
state.attributes.get("friendly_name")
|
||||||
== "WT260,WT260H,WT440H,WT450,WT450H 05:02 Temperature"
|
== "WT260,WT260H,WT440H,WT450,WT450H 05:02 Temperature"
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == TEMP_CELSIUS
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfTemperature.CELSIUS
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
@ -88,7 +88,7 @@ async def test_one_sensor_no_datatype(hass, rfxtrx):
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "unknown"
|
assert state.state == "unknown"
|
||||||
assert state.attributes.get("friendly_name") == f"{base_name} Temperature"
|
assert state.attributes.get("friendly_name") == f"{base_name} Temperature"
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == TEMP_CELSIUS
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfTemperature.CELSIUS
|
||||||
|
|
||||||
state = hass.states.get(f"{base_id}_humidity")
|
state = hass.states.get(f"{base_id}_humidity")
|
||||||
assert state
|
assert state
|
||||||
|
@ -141,7 +141,7 @@ async def test_several_sensors(hass, rfxtrx):
|
||||||
state.attributes.get("friendly_name")
|
state.attributes.get("friendly_name")
|
||||||
== "WT260,WT260H,WT440H,WT450,WT450H 05:02 Temperature"
|
== "WT260,WT260H,WT440H,WT450,WT450H 05:02 Temperature"
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == TEMP_CELSIUS
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfTemperature.CELSIUS
|
||||||
|
|
||||||
state = hass.states.get("sensor.wt260_wt260h_wt440h_wt450_wt450h_06_01_temperature")
|
state = hass.states.get("sensor.wt260_wt260h_wt440h_wt450_wt450h_06_01_temperature")
|
||||||
assert state
|
assert state
|
||||||
|
@ -150,7 +150,7 @@ async def test_several_sensors(hass, rfxtrx):
|
||||||
state.attributes.get("friendly_name")
|
state.attributes.get("friendly_name")
|
||||||
== "WT260,WT260H,WT440H,WT450,WT450H 06:01 Temperature"
|
== "WT260,WT260H,WT440H,WT450,WT450H 06:01 Temperature"
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == TEMP_CELSIUS
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfTemperature.CELSIUS
|
||||||
|
|
||||||
state = hass.states.get("sensor.wt260_wt260h_wt440h_wt450_wt450h_06_01_humidity")
|
state = hass.states.get("sensor.wt260_wt260h_wt440h_wt450_wt450h_06_01_humidity")
|
||||||
assert state
|
assert state
|
||||||
|
@ -191,7 +191,7 @@ async def test_discover_sensor(hass, rfxtrx_automatic):
|
||||||
state = hass.states.get(f"{base_id}_temperature")
|
state = hass.states.get(f"{base_id}_temperature")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "18.4"
|
assert state.state == "18.4"
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == TEMP_CELSIUS
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfTemperature.CELSIUS
|
||||||
|
|
||||||
state = hass.states.get(f"{base_id}_battery")
|
state = hass.states.get(f"{base_id}_battery")
|
||||||
assert state
|
assert state
|
||||||
|
@ -223,7 +223,7 @@ async def test_discover_sensor(hass, rfxtrx_automatic):
|
||||||
state = hass.states.get(f"{base_id}_temperature")
|
state = hass.states.get(f"{base_id}_temperature")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "14.9"
|
assert state.state == "14.9"
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == TEMP_CELSIUS
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfTemperature.CELSIUS
|
||||||
|
|
||||||
state = hass.states.get(f"{base_id}_battery")
|
state = hass.states.get(f"{base_id}_battery")
|
||||||
assert state
|
assert state
|
||||||
|
@ -255,7 +255,7 @@ async def test_discover_sensor(hass, rfxtrx_automatic):
|
||||||
state = hass.states.get(f"{base_id}_temperature")
|
state = hass.states.get(f"{base_id}_temperature")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "17.9"
|
assert state.state == "17.9"
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == TEMP_CELSIUS
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfTemperature.CELSIUS
|
||||||
|
|
||||||
state = hass.states.get(f"{base_id}_battery")
|
state = hass.states.get(f"{base_id}_battery")
|
||||||
assert state
|
assert state
|
||||||
|
|
Loading…
Add table
Reference in a new issue