<commit_before>"""Support for APCUPSd sensors."""
from __future__ import annotations

import logging

from apcaccess.status import ALL_UNITS
import voluptuous as vol

from homeassistant.components.sensor import (
    PLATFORM_SCHEMA,
    SensorEntity,
    SensorEntityDescription,
)
from homeassistant.const import (
    CONF_RESOURCES,
    DEVICE_CLASS_TEMPERATURE,
    ELECTRIC_CURRENT_AMPERE,
    ELECTRIC_POTENTIAL_VOLT,
    FREQUENCY_HERTZ,
    PERCENTAGE,
    POWER_VOLT_AMPERE,
    POWER_WATT,
    TEMP_CELSIUS,
    TIME_MINUTES,
    TIME_SECONDS,
)
import homeassistant.helpers.config_validation as cv

from . import DOMAIN

_LOGGER = logging.getLogger(__name__)

SENSOR_PREFIX = "UPS "
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
    SensorEntityDescription(
        key="alarmdel",
        name="Alarm Delay",
        icon="mdi:alarm",
    ),
    SensorEntityDescription(
        key="ambtemp",
        name="Ambient Temperature",
        icon="mdi:thermometer",
    ),
    SensorEntityDescription(
        key="apc",
        name="Status Data",
        icon="mdi:information-outline",
    ),
    SensorEntityDescription(
        key="apcmodel",
        name="Model",
        icon="mdi:information-outline",
    ),
    SensorEntityDescription(
        key="badbatts",
        name="Bad Batteries",
        icon="mdi:information-outline",
    ),
    SensorEntityDescription(
        key="battdate",
        name="Battery Replaced",
        icon="mdi:calendar-clock",
    ),
    SensorEntityDescription(
        key="battstat",
        name="Battery Status",
        icon="mdi:information-outline",
    ),
    SensorEntityDescription(
        key="battv",
        name="Battery Voltage",
        native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
        icon="mdi:flash",
    ),
    SensorEntityDescription(
        key="bcharge",
        name="Battery",
        native_unit_of_measurement=PERCENTAGE,
        icon="mdi:battery",
    ),
    SensorEntityDescription(
        key="cable",
        name="Cable Type",
        icon="mdi:ethernet-cable",
    ),
    SensorEntityDescription(
        key="cumonbatt",
        name="Total Time on Battery",
        icon="mdi:timer-outline",
    ),
    SensorEntityDescription(
        key="date",
        name="Status Date",
        icon="mdi:calendar-clock",
    ),
    SensorEntityDescription(
        key="dipsw",
        name="Dip Switch Settings",
        icon="mdi:information-outline",
    ),
    SensorEntityDescription(
        key="dlowbatt",
        name="Low Battery Signal",
        icon="mdi:clock-alert",
    ),
    SensorEntityDescription(
        key="driver",
        name="Driver",
        icon="mdi:information-outline",
    ),
    SensorEntityDescription(
        key="dshutd",
        name="Shutdown Delay",
        icon="mdi:timer-outline",
    ),
    SensorEntityDescription(
        key="dwake",
        name="Wake Delay",
        icon="mdi:timer-outline",
    ),
    SensorEntityDescription(
        key="end apc",
        name="Date and Time",
        icon="mdi:calendar-clock",
    ),
    SensorEntityDescription(
        key="extbatts",
        name="External Batteries",
        icon="mdi:information-outline",
    ),
    SensorEntityDescription(
        key="firmware",
        name="Firmware Version",
        icon="mdi:information-outline",
    ),
    SensorEntityDescription(
        key="hitrans",
        name="Transfer High",
        native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
        icon="mdi:flash",
    ),
    SensorEntityDescription(
        key="hostname",
        name="Hostname",
        icon="mdi:information-outline",
    ),
    SensorEntityDescription(
        key="humidity",
        name="Ambient Humidity",
        native_unit_of_measurement=PERCENTAGE,
        icon="mdi:water-percent",
    ),
    SensorEntityDescription(
        key="itemp",
        name="Internal Temperature",
        native_unit_of_measurement=TEMP_CELSIUS,
        device_class=DEVICE_CLASS_TEMPERATURE,
    ),<commit_msg>Use new SensorDeviceClass in apcupsd (#61271)<commit_after>"""Support for APCUPSd sensors."""
from __future__ import annotations

import logging

from apcaccess.status import ALL_UNITS
import voluptuous as vol

from homeassistant.components.sensor import (
    PLATFORM_SCHEMA,
    SensorDeviceClass,
    SensorEntity,
    SensorEntityDescription,
)
from homeassistant.const import (
    CONF_RESOURCES,
    ELECTRIC_CURRENT_AMPERE,
    ELECTRIC_POTENTIAL_VOLT,
    FREQUENCY_HERTZ,
    PERCENTAGE,
    POWER_VOLT_AMPERE,
    POWER_WATT,
    TEMP_CELSIUS,
    TIME_MINUTES,
    TIME_SECONDS,
)
import homeassistant.helpers.config_validation as cv

from . import DOMAIN

_LOGGER = logging.getLogger(__name__)

SENSOR_PREFIX = "UPS "
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
    SensorEntityDescription(
        key="alarmdel",
        name="Alarm Delay",
        icon="mdi:alarm",
    ),
    SensorEntityDescription(
        key="ambtemp",
        name="Ambient Temperature",
        icon="mdi:thermometer",
    ),
    SensorEntityDescription(
        key="apc",
        name="Status Data",
        icon="mdi:information-outline",
    ),
    SensorEntityDescription(
        key="apcmodel",
        name="Model",
        icon="mdi:information-outline",
    ),
    SensorEntityDescription(
        key="badbatts",
        name="Bad Batteries",
        icon="mdi:information-outline",
    ),
    SensorEntityDescription(
        key="battdate",
        name="Battery Replaced",
        icon="mdi:calendar-clock",
    ),
    SensorEntityDescription(
        key="battstat",
        name="Battery Status",
        icon="mdi:information-outline",
    ),
    SensorEntityDescription(
        key="battv",
        name="Battery Voltage",
        native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
        icon="mdi:flash",
    ),
    SensorEntityDescription(
        key="bcharge",
        name="Battery",
        native_unit_of_measurement=PERCENTAGE,
        icon="mdi:battery",
    ),
    SensorEntityDescription(
        key="cable",
        name="Cable Type",
        icon="mdi:ethernet-cable",
    ),
    SensorEntityDescription(
        key="cumonbatt",
        name="Total Time on Battery",
        icon="mdi:timer-outline",
    ),
    SensorEntityDescription(
        key="date",
        name="Status Date",
        icon="mdi:calendar-clock",
    ),
    SensorEntityDescription(
        key="dipsw",
        name="Dip Switch Settings",
        icon="mdi:information-outline",
    ),
    SensorEntityDescription(
        key="dlowbatt",
        name="Low Battery Signal",
        icon="mdi:clock-alert",
    ),
    SensorEntityDescription(
        key="driver",
        name="Driver",
        icon="mdi:information-outline",
    ),
    SensorEntityDescription(
        key="dshutd",
        name="Shutdown Delay",
        icon="mdi:timer-outline",
    ),
    SensorEntityDescription(
        key="dwake",
        name="Wake Delay",
        icon="mdi:timer-outline",
    ),
    SensorEntityDescription(
        key="end apc",
        name="Date and Time",
        icon="mdi:calendar-clock",
    ),
    SensorEntityDescription(
        key="extbatts",
        name="External Batteries",
        icon="mdi:information-outline",
    ),
    SensorEntityDescription(
        key="firmware",
        name="Firmware Version",
        icon="mdi:information-outline",
    ),
    SensorEntityDescription(
        key="hitrans",
        name="Transfer High",
        native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
        icon="mdi:flash",
    ),
    SensorEntityDescription(
        key="hostname",
        name="Hostname",
        icon="mdi:information-outline",
    ),
    SensorEntityDescription(
        key="humidity",
        name="Ambient Humidity",
        native_unit_of_measurement=PERCENTAGE,
        icon="mdi:water-percent",
    ),
    SensorEntityDescription(
        key="itemp",
        name="Internal Temperature",
        native_unit_of_measurement=TEMP_CELSIUS,
        device_class=SensorDeviceClass.TEMPERATURE,
    ),
{'fraction_non_alphanumeric': 0.11458333333333333, 'fraction_numerical': 0.0006200396825396825, 'mean_word_length': 2.6149708650829226, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7577834', 'n_tokens_mistral': 2556, 'n_tokens_neox': 2520, 'n_words': 361}