mirror of
https://github.com/home-assistant/core.git
synced 2025-11-13 13:00:11 +00:00
Add ambient temperature and humidity status sensors to NUT (#124181)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
@@ -5,17 +5,23 @@ from unittest.mock import patch
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.nut.const import DOMAIN
|
||||
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CONF_PORT,
|
||||
CONF_RESOURCES,
|
||||
PERCENTAGE,
|
||||
STATE_UNKNOWN,
|
||||
UnitOfElectricPotential,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from .util import _get_mock_nutclient, async_init_integration
|
||||
from .util import (
|
||||
_get_mock_nutclient,
|
||||
_test_sensor_and_attributes,
|
||||
async_init_integration,
|
||||
)
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
@@ -32,7 +38,7 @@ from tests.common import MockConfigEntry
|
||||
"blazer_usb",
|
||||
],
|
||||
)
|
||||
async def test_devices(
|
||||
async def test_ups_devices(
|
||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, model: str
|
||||
) -> None:
|
||||
"""Test creation of device sensors."""
|
||||
@@ -67,7 +73,7 @@ async def test_devices(
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_devices_with_unique_ids(
|
||||
async def test_ups_devices_with_unique_ids(
|
||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, model: str, unique_id: str
|
||||
) -> None:
|
||||
"""Test creation of device sensors with unique ids."""
|
||||
@@ -92,6 +98,65 @@ async def test_devices_with_unique_ids(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("model", "unique_id_base"),
|
||||
[
|
||||
(
|
||||
"EATON-EPDU-G3",
|
||||
"EATON_ePDU MA 00U-C IN: TYPE 00A 0P OUT: 00xTYPE_A000A00000_",
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_pdu_devices_with_unique_ids(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
model: str,
|
||||
unique_id_base: str,
|
||||
) -> None:
|
||||
"""Test creation of device sensors with unique ids."""
|
||||
|
||||
await _test_sensor_and_attributes(
|
||||
hass,
|
||||
entity_registry,
|
||||
model,
|
||||
unique_id=f"{unique_id_base}input.voltage",
|
||||
device_id="sensor.ups1_input_voltage",
|
||||
state_value="122.91",
|
||||
expected_attributes={
|
||||
"device_class": SensorDeviceClass.VOLTAGE,
|
||||
"state_class": SensorStateClass.MEASUREMENT,
|
||||
"friendly_name": "Ups1 Input voltage",
|
||||
"unit_of_measurement": UnitOfElectricPotential.VOLT,
|
||||
},
|
||||
)
|
||||
|
||||
await _test_sensor_and_attributes(
|
||||
hass,
|
||||
entity_registry,
|
||||
model,
|
||||
unique_id=f"{unique_id_base}ambient.humidity.status",
|
||||
device_id="sensor.ups1_ambient_humidity_status",
|
||||
state_value="good",
|
||||
expected_attributes={
|
||||
"device_class": SensorDeviceClass.ENUM,
|
||||
"friendly_name": "Ups1 Ambient humidity status",
|
||||
},
|
||||
)
|
||||
|
||||
await _test_sensor_and_attributes(
|
||||
hass,
|
||||
entity_registry,
|
||||
model,
|
||||
unique_id=f"{unique_id_base}ambient.temperature.status",
|
||||
device_id="sensor.ups1_ambient_temperature_status",
|
||||
state_value="good",
|
||||
expected_attributes={
|
||||
"device_class": SensorDeviceClass.ENUM,
|
||||
"friendly_name": "Ups1 Ambient temperature status",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
async def test_state_sensors(hass: HomeAssistant) -> None:
|
||||
"""Test creation of status display sensors."""
|
||||
entry = MockConfigEntry(
|
||||
|
||||
Reference in New Issue
Block a user