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