Add support for additional fields to nut (#83265)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
0c1abd5f10
commit
af107d7853
3 changed files with 159 additions and 0 deletions
|
@ -514,6 +514,55 @@ SENSOR_TYPES: Final[dict[str, SensorEntityDescription]] = {
|
|||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
"input.bypass.frequency": SensorEntityDescription(
|
||||
key="input.bypass.frequency",
|
||||
name="Input Bypass Frequency",
|
||||
native_unit_of_measurement=UnitOfFrequency.HERTZ,
|
||||
device_class=SensorDeviceClass.FREQUENCY,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
"input.bypass.phases": SensorEntityDescription(
|
||||
key="input.bypass.phases",
|
||||
name="Input Bypass Phases",
|
||||
icon="mdi:information-outline",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
"input.current": SensorEntityDescription(
|
||||
key="input.current",
|
||||
name="Input Current",
|
||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||
device_class=SensorDeviceClass.CURRENT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
"input.phases": SensorEntityDescription(
|
||||
key="input.phases",
|
||||
name="Input Phases",
|
||||
icon="mdi:information-outline",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
"input.realpower": SensorEntityDescription(
|
||||
key="input.realpower",
|
||||
name="Current Input Real Power",
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
"output.power.nominal": SensorEntityDescription(
|
||||
key="output.power.nominal",
|
||||
name="Nominal Output Power",
|
||||
native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE,
|
||||
device_class=SensorDeviceClass.APPARENT_POWER,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
"output.current": SensorEntityDescription(
|
||||
key="output.current",
|
||||
name="Output Current",
|
||||
|
@ -563,6 +612,39 @@ SENSOR_TYPES: Final[dict[str, SensorEntityDescription]] = {
|
|||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
"output.phases": SensorEntityDescription(
|
||||
key="output.phases",
|
||||
name="Output Phases",
|
||||
icon="mdi:information-outline",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
"output.power": SensorEntityDescription(
|
||||
key="output.power",
|
||||
name="Output Apparent Power",
|
||||
native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE,
|
||||
device_class=SensorDeviceClass.APPARENT_POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
"output.realpower": SensorEntityDescription(
|
||||
key="output.realpower",
|
||||
name="Current Output Real Power",
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
"output.realpower.nominal": SensorEntityDescription(
|
||||
key="output.realpower.nominal",
|
||||
name="Nominal Output Real Power",
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
"ambient.humidity": SensorEntityDescription(
|
||||
key="ambient.humidity",
|
||||
name="Ambient Humidity",
|
||||
|
|
53
tests/components/nut/fixtures/EATON5P1550.json
Normal file
53
tests/components/nut/fixtures/EATON5P1550.json
Normal file
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"battery.charge": "100",
|
||||
"battery.current": "0",
|
||||
"battery.runtime": "17820",
|
||||
"battery.runtime.low": "180",
|
||||
"battery.temperature": "0",
|
||||
"battery.voltage": "38",
|
||||
"device.description": "Eaton 5P 1550",
|
||||
"device.mfr": "EATON",
|
||||
"device.model": "Eaton 5P 1550",
|
||||
"device.type": "ups",
|
||||
"driver.name": "snmp-ups",
|
||||
"driver.parameter.mibs": "ietf",
|
||||
"driver.parameter.pollfreq": "15",
|
||||
"driver.parameter.pollinterval": "2",
|
||||
"driver.parameter.snmp_version": "v1",
|
||||
"driver.parameter.synchronous": "auto",
|
||||
"driver.version": "2.8.0",
|
||||
"driver.version.data": "ietf MIB 1.54",
|
||||
"driver.version.internal": "1.21",
|
||||
"input.bypass.frequency": "0",
|
||||
"input.bypass.phases": "0",
|
||||
"input.current": "0.10",
|
||||
"input.frequency": "50",
|
||||
"input.frequency.nominal": "50",
|
||||
"input.phases": "1",
|
||||
"input.realpower": "0",
|
||||
"input.transfer.high": "294",
|
||||
"input.transfer.low": "160",
|
||||
"input.voltage": "247",
|
||||
"input.voltage.nominal": "230",
|
||||
"output.current": "0",
|
||||
"output.frequency": "50",
|
||||
"output.frequency.nominal": "50",
|
||||
"output.phases": "1",
|
||||
"output.power.nominal": "1550",
|
||||
"output.realpower": "0",
|
||||
"output.realpower.nominal": "1100",
|
||||
"output.voltage": "247",
|
||||
"output.voltage.nominal": "230",
|
||||
"ups.beeper.status": "disabled",
|
||||
"ups.firmware: INV": "02.14.0026",
|
||||
"ups.firmware.aux": "Network Management Card V6.00 LE",
|
||||
"ups.load": "0",
|
||||
"ups.mfr": "EATON",
|
||||
"ups.model": "Eaton 5P 1550",
|
||||
"ups.start.auto": "yes",
|
||||
"ups.status": "OL",
|
||||
"ups.test.result": "done and passed",
|
||||
"ups.timer.reboot": "-1",
|
||||
"ups.timer.shutdown": "-1",
|
||||
"ups.timer.start": "-1"
|
||||
}
|
|
@ -189,6 +189,30 @@ async def test_dl650elcd(hass):
|
|||
)
|
||||
|
||||
|
||||
async def test_eaton5p1550(hass):
|
||||
"""Test creation of EATON5P1550 sensors."""
|
||||
|
||||
config_entry = await async_init_integration(hass, "EATON5P1550")
|
||||
registry = er.async_get(hass)
|
||||
entry = registry.async_get("sensor.ups1_battery_charge")
|
||||
assert entry
|
||||
assert entry.unique_id == f"{config_entry.entry_id}_battery.charge"
|
||||
|
||||
state = hass.states.get("sensor.ups1_battery_charge")
|
||||
assert state.state == "100"
|
||||
|
||||
expected_attributes = {
|
||||
"device_class": "battery",
|
||||
"friendly_name": "Ups1 Battery Charge",
|
||||
"unit_of_measurement": PERCENTAGE,
|
||||
}
|
||||
# Only test for a subset of attributes in case
|
||||
# HA changes the implementation and a new one appears
|
||||
assert all(
|
||||
state.attributes[key] == attr for key, attr in expected_attributes.items()
|
||||
)
|
||||
|
||||
|
||||
async def test_blazer_usb(hass):
|
||||
"""Test creation of blazer_usb sensors."""
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue