mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 08:47:10 +00:00
Use device classes in solaredge_local (#83821)
This commit is contained in:
parent
fa06398721
commit
254d46b80f
@ -21,13 +21,12 @@ from homeassistant.components.sensor import (
|
||||
from homeassistant.const import (
|
||||
CONF_IP_ADDRESS,
|
||||
CONF_NAME,
|
||||
ELECTRIC_CURRENT_AMPERE,
|
||||
ELECTRIC_POTENTIAL_VOLT,
|
||||
ENERGY_WATT_HOUR,
|
||||
FREQUENCY_HERTZ,
|
||||
POWER_WATT,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfFrequency,
|
||||
UnitOfPower,
|
||||
UnitOfTemperature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
@ -63,49 +62,56 @@ SENSOR_TYPES: tuple[SolarEdgeLocalSensorEntityDescription, ...] = (
|
||||
SolarEdgeLocalSensorEntityDescription(
|
||||
key="gridvoltage",
|
||||
name="Grid Voltage",
|
||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
device_class=SensorDeviceClass.VOLTAGE,
|
||||
icon="mdi:current-ac",
|
||||
),
|
||||
SolarEdgeLocalSensorEntityDescription(
|
||||
key="dcvoltage",
|
||||
name="DC Voltage",
|
||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
device_class=SensorDeviceClass.VOLTAGE,
|
||||
icon="mdi:current-dc",
|
||||
),
|
||||
SolarEdgeLocalSensorEntityDescription(
|
||||
key="gridfrequency",
|
||||
name="Grid Frequency",
|
||||
native_unit_of_measurement=FREQUENCY_HERTZ,
|
||||
icon="mdi:current-ac",
|
||||
native_unit_of_measurement=UnitOfFrequency.HERTZ,
|
||||
device_class=SensorDeviceClass.FREQUENCY,
|
||||
),
|
||||
SolarEdgeLocalSensorEntityDescription(
|
||||
key="currentPower",
|
||||
name="Current Power",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
icon="mdi:solar-power",
|
||||
),
|
||||
SolarEdgeLocalSensorEntityDescription(
|
||||
key="energyThisMonth",
|
||||
name="Energy This Month",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
icon="mdi:solar-power",
|
||||
),
|
||||
SolarEdgeLocalSensorEntityDescription(
|
||||
key="energyThisYear",
|
||||
name="Energy This Year",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
icon="mdi:solar-power",
|
||||
),
|
||||
SolarEdgeLocalSensorEntityDescription(
|
||||
key="energyToday",
|
||||
name="Energy Today",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
icon="mdi:solar-power",
|
||||
),
|
||||
SolarEdgeLocalSensorEntityDescription(
|
||||
key="energyTotal",
|
||||
name="Lifetime Energy",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
icon="mdi:solar-power",
|
||||
),
|
||||
SolarEdgeLocalSensorEntityDescription(
|
||||
@ -118,26 +124,29 @@ SENSOR_TYPES: tuple[SolarEdgeLocalSensorEntityDescription, ...] = (
|
||||
SolarEdgeLocalSensorEntityDescription(
|
||||
key="optimizercurrent",
|
||||
name="Average Optimizer Current",
|
||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||
device_class=SensorDeviceClass.CURRENT,
|
||||
icon="mdi:solar-panel",
|
||||
),
|
||||
SolarEdgeLocalSensorEntityDescription(
|
||||
key="optimizerpower",
|
||||
name="Average Optimizer Power",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
icon="mdi:solar-panel",
|
||||
),
|
||||
SolarEdgeLocalSensorEntityDescription(
|
||||
key="optimizertemperature",
|
||||
name="Average Optimizer Temperature",
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
icon="mdi:solar-panel",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
),
|
||||
SolarEdgeLocalSensorEntityDescription(
|
||||
key="optimizervoltage",
|
||||
name="Average Optimizer Voltage",
|
||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
device_class=SensorDeviceClass.VOLTAGE,
|
||||
icon="mdi:solar-panel",
|
||||
),
|
||||
)
|
||||
@ -145,7 +154,7 @@ SENSOR_TYPES: tuple[SolarEdgeLocalSensorEntityDescription, ...] = (
|
||||
SENSOR_TYPE_INVERTER_TEMPERATURE = SolarEdgeLocalSensorEntityDescription(
|
||||
key="invertertemperature",
|
||||
name="Inverter Temperature",
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
extra_attribute="operating_mode",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
)
|
||||
@ -154,13 +163,15 @@ SENSOR_TYPES_ENERGY_IMPORT: tuple[SolarEdgeLocalSensorEntityDescription, ...] =
|
||||
SolarEdgeLocalSensorEntityDescription(
|
||||
key="currentPowerimport",
|
||||
name="current import Power",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
icon="mdi:arrow-collapse-down",
|
||||
),
|
||||
SolarEdgeLocalSensorEntityDescription(
|
||||
key="totalEnergyimport",
|
||||
name="total import Energy",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
icon="mdi:counter",
|
||||
),
|
||||
)
|
||||
@ -169,13 +180,15 @@ SENSOR_TYPES_ENERGY_EXPORT: tuple[SolarEdgeLocalSensorEntityDescription, ...] =
|
||||
SolarEdgeLocalSensorEntityDescription(
|
||||
key="currentPowerexport",
|
||||
name="current export Power",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
icon="mdi:arrow-expand-up",
|
||||
),
|
||||
SolarEdgeLocalSensorEntityDescription(
|
||||
key="totalEnergyexport",
|
||||
name="total export Energy",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
icon="mdi:counter",
|
||||
),
|
||||
)
|
||||
@ -220,7 +233,9 @@ def setup_platform(
|
||||
# Changing inverter temperature unit.
|
||||
inverter_temp_description = copy(SENSOR_TYPE_INVERTER_TEMPERATURE)
|
||||
if status.inverters.primary.temperature.units.farenheit:
|
||||
inverter_temp_description.native_unit_of_measurement = TEMP_FAHRENHEIT
|
||||
inverter_temp_description.native_unit_of_measurement = (
|
||||
UnitOfTemperature.FAHRENHEIT
|
||||
)
|
||||
|
||||
# Create entities
|
||||
entities = [
|
||||
|
Loading…
x
Reference in New Issue
Block a user