diff --git a/hatasmota/const.py b/hatasmota/const.py index f8e998a..ca275dd 100644 --- a/hatasmota/const.py +++ b/hatasmota/const.py @@ -102,11 +102,7 @@ SENSOR_ATTRIBUTE_WIFI_DOWNTIME: Final = "Downtime" SENSOR_ATTRIBUTE_MQTTCOUNT: Final = "MqttCount" -SENSOR_ACTIVE_ENERGYEXPORT: Final = "ExportActive" -SENSOR_ACTIVE_ENERGYIMPORT: Final = "ImportActive" -SENSOR_ACTIVE_POWERUSAGE: Final = "ActivePower" SENSOR_AMBIENT: Final = "Ambient" -SENSOR_APPARENT_POWERUSAGE: Final = "ApparentPower" SENSOR_BATTERY: Final = "Battery" SENSOR_CCT: Final = "CCT" SENSOR_CF1: Final = "CF1" @@ -116,12 +112,21 @@ SENSOR_COLOR_BLUE: Final = "Blue" SENSOR_COLOR_GREEN: Final = "Green" SENSOR_COLOR_RED: Final = "Red" +SENSOR_CURRENT_NEUTRAL: Final = "CurrentNeutral" SENSOR_CURRENT: Final = "Current" -SENSOR_CURRENTNEUTRAL: Final = "CurrentNeutral" SENSOR_DEWPOINT: Final = "DewPoint" SENSOR_DISTANCE: Final = "Distance" SENSOR_ECO2: Final = "eCO2" +SENSOR_ENERGY_EXPORT_ACTIVE: Final = "ExportActive" +SENSOR_ENERGY_EXPORT_REACTIVE: Final = "ExportReactive" +SENSOR_ENERGY_IMPORT_ACTIVE: Final = "ImportActive" +SENSOR_ENERGY_IMPORT_REACTIVE: Final = "ImportReactive" +SENSOR_ENERGY_IMPORT_TODAY: Final = "Today" +SENSOR_ENERGY_IMPORT_TOTAL_TARIFF: Final = "TotalTariff" +SENSOR_ENERGY_IMPORT_TOTAL: Final = "Total" +SENSOR_ENERGY_IMPORT_YESTERDAY: Final = "Yesterday" SENSOR_ENERGY_OTHER: Final = "Energy_other" +SENSOR_ENERGY_TOTAL_START_TIME: Final = "TotalStartTime" SENSOR_ENERGY: Final = "Energy" SENSOR_FREQUENCY: Final = "Frequency" SENSOR_HUMIDITY: Final = "Humidity" @@ -133,18 +138,18 @@ SENSOR_PB10: Final = "PB10" SENSOR_PB2_5: Final = "PB2.5" SENSOR_PB5: Final = "PB5" -SENSOR_PHASEANGLE: Final = "PhaseAngle" +SENSOR_PHASE_ANGLE: Final = "PhaseAngle" SENSOR_PM1: Final = "PM1" SENSOR_PM10: Final = "PM10" SENSOR_PM2_5: Final = "PM2.5" -SENSOR_POWERFACTOR: Final = "Factor" -SENSOR_POWERUSAGE: Final = "Power" +SENSOR_POWER_ACTIVE: Final = "ActivePower" +SENSOR_POWER_APPARENT: Final = "ApparentPower" +SENSOR_POWER_FACTOR: Final = "Factor" +SENSOR_POWER: Final = "Power" +SENSOR_PRESSURE_AT_SEA_LEVEL: Final = "SeaPressure" SENSOR_PRESSURE: Final = "Pressure" -SENSOR_PRESSUREATSEALEVEL: Final = "SeaPressure" SENSOR_PROXIMITY: Final = "Proximity" -SENSOR_REACTIVE_ENERGYEXPORT: Final = "ExportReactive" -SENSOR_REACTIVE_ENERGYIMPORT: Final = "ImportReactive" -SENSOR_REACTIVE_POWERUSAGE: Final = "ReactivePower" +SENSOR_POWER_REACTIVE: Final = "ReactivePower" SENSOR_SPEED: Final = "Speed" SENSOR_STATUS_IP: Final = "status_ip" SENSOR_STATUS_LAST_RESTART_TIME: Final = "last_restart_time" @@ -157,14 +162,9 @@ SENSOR_STATUS_VERSION: Final = "status_version" SENSOR_SWITCH: Final = "Switch" SENSOR_TEMPERATURE: Final = "Temperature" -SENSOR_TODAY: Final = "Today" -SENSOR_TOTAL_START_TIME: Final = "TotalStartTime" -SENSOR_TOTAL_TARIFF: Final = "TotalTariff" -SENSOR_TOTAL: Final = "Total" SENSOR_TVOC: Final = "TVOC" SENSOR_VOLTAGE: Final = "Voltage" SENSOR_WEIGHT: Final = "Weight" -SENSOR_YESTERDAY: Final = "Yesterday" SENSOR_STATUS_BATTERY_PERCENTAGE: Final = "status_battery_percentage" diff --git a/hatasmota/sensor.py b/hatasmota/sensor.py index 3e5879a..f7b62d4 100644 --- a/hatasmota/sensor.py +++ b/hatasmota/sensor.py @@ -28,11 +28,7 @@ PRESSURE_MMHG, REACTIVE_ENERGY_KILO_VOLT_AMPERE_HOUR, REACTIVE_POWER, - SENSOR_ACTIVE_ENERGYEXPORT, - SENSOR_ACTIVE_ENERGYIMPORT, - SENSOR_ACTIVE_POWERUSAGE, SENSOR_AMBIENT, - SENSOR_APPARENT_POWERUSAGE, SENSOR_BATTERY, SENSOR_CCT, SENSOR_CF1, @@ -43,12 +39,21 @@ SENSOR_COLOR_GREEN, SENSOR_COLOR_RED, SENSOR_CURRENT, - SENSOR_CURRENTNEUTRAL, + SENSOR_CURRENT_NEUTRAL, SENSOR_DEWPOINT, SENSOR_DISTANCE, SENSOR_ECO2, SENSOR_ENERGY, + SENSOR_ENERGY_EXPORT_ACTIVE, + SENSOR_ENERGY_EXPORT_REACTIVE, + SENSOR_ENERGY_IMPORT_ACTIVE, + SENSOR_ENERGY_IMPORT_REACTIVE, + SENSOR_ENERGY_IMPORT_TODAY, + SENSOR_ENERGY_IMPORT_TOTAL, + SENSOR_ENERGY_IMPORT_TOTAL_TARIFF, + SENSOR_ENERGY_IMPORT_YESTERDAY, SENSOR_ENERGY_OTHER, + SENSOR_ENERGY_TOTAL_START_TIME, SENSOR_FREQUENCY, SENSOR_HUMIDITY, SENSOR_ILLUMINANCE, @@ -59,31 +64,26 @@ SENSOR_PB2_5, SENSOR_PB5, SENSOR_PB10, - SENSOR_PHASEANGLE, + SENSOR_PHASE_ANGLE, SENSOR_PM1, SENSOR_PM2_5, SENSOR_PM10, - SENSOR_POWERFACTOR, - SENSOR_POWERUSAGE, + SENSOR_POWER, + SENSOR_POWER_ACTIVE, + SENSOR_POWER_APPARENT, + SENSOR_POWER_FACTOR, + SENSOR_POWER_REACTIVE, SENSOR_PRESSURE, - SENSOR_PRESSUREATSEALEVEL, + SENSOR_PRESSURE_AT_SEA_LEVEL, SENSOR_PROXIMITY, - SENSOR_REACTIVE_ENERGYEXPORT, - SENSOR_REACTIVE_ENERGYIMPORT, - SENSOR_REACTIVE_POWERUSAGE, SENSOR_SPEED, SENSOR_TEMPERATURE, - SENSOR_TODAY, - SENSOR_TOTAL, - SENSOR_TOTAL_START_TIME, - SENSOR_TOTAL_TARIFF, SENSOR_TVOC, SENSOR_UNIT_PRESSURE, SENSOR_UNIT_SPEED, SENSOR_UNIT_TEMPERATURE, SENSOR_VOLTAGE, SENSOR_WEIGHT, - SENSOR_YESTERDAY, SPEED_FEET_PER_SECOND, SPEED_KILOMETERS_PER_HOUR, SPEED_KNOT, @@ -112,7 +112,6 @@ # QUANTITY UNIT CLASS/ICON # SENSOR_AMBIENT LX "dev_cla":"illuminance" -# SENSOR_APPARENT_POWERUSAGE VA "dev_cla":"power" # SENSOR_BATTERY % "dev_cla":"battery" # SENSOR_CCT K "ic":"mdi:temperature-kelvin" # SENSOR_CO2 ppm "ic":"mdi:molecule-co2" @@ -123,6 +122,10 @@ # SENSOR_DEWPOINT "ic":"mdi:weather-rainy" # SENSOR_DISTANCE Cm "ic":"mdi:leak" # SENSOR_ECO2 ppm "ic":"mdi:molecule-co2" +# SENSOR_ENERGY_IMPORT_TODAY kWh "dev_cla":"power" +# SENSOR_ENERGY_IMPORT_TOTAL kWh "dev_cla":"power" +# SENSOR_ENERGY_IMPORT_YESTERDAY kWh "dev_cla":"power" +# SENSOR_ENERGY_TOTAL_START_TIME "ic":"mdi:progress-clock" # SENSOR_FREQUENCY Hz "ic":"mdi:current-ac" # SENSOR_HUMIDITY % "dev_cla":"humidity" # SENSOR_ILLUMINANCE LX "dev_cla":"illuminance" @@ -136,28 +139,21 @@ # SENSOR_PM1 µg/m³ "ic":"mdi:air-filter" # SENSOR_PM10 µg/m³ "ic":"mdi:air-filter" # SENSOR_PM2_5 µg/m³ "ic":"mdi:air-filter" -# SENSOR_POWERFACTOR Cos φ "ic":"mdi:alpha-f-circle-outline" -# SENSOR_POWERUSAGE W "dev_cla":"power" +# SENSOR_POWER W "dev_cla":"power" +# SENSOR_POWER_APPARENT VA "dev_cla":"power" +# SENSOR_POWER_FACTOR Cos φ "ic":"mdi:alpha-f-circle-outline" +# SENSOR_POWER_REACTIVE VAr "dev_cla":"power" # SENSOR_PRESSURE "dev_cla":"pressure" -# SENSOR_PRESSUREATSEALEVEL "dev_cla":"pressure" +# SENSOR_PRESSURE_AT_SEA_LEVEL "dev_cla":"pressure" # SENSOR_PROXIMITY "ic":"mdi:ruler" -# SENSOR_REACTIVE_POWERUSAGE VAr "dev_cla":"power" # SENSOR_TEMPERATURE "dev_cla":"temperature" -# SENSOR_TODAY kWh "dev_cla":"power" -# SENSOR_TOTAL kWh "dev_cla":"power" -# SENSOR_TOTAL_START_TIME "ic":"mdi:progress-clock" # SENSOR_TVOC ppb "ic":"mdi:air-filter" # SENSOR_VOLTAGE V "ic":"mdi:alpha-v-circle-outline" # SENSOR_WEIGHT Kg "ic":"mdi:scale" -# SENSOR_YESTERDAY kWh "dev_cla":"power" SENSOR_UNIT_MAP = { - SENSOR_ACTIVE_ENERGYEXPORT: ENERGY_KILO_WATT_HOUR, - SENSOR_ACTIVE_ENERGYIMPORT: ENERGY_KILO_WATT_HOUR, - SENSOR_ACTIVE_POWERUSAGE: POWER_WATT, SENSOR_AMBIENT: LIGHT_LUX, - SENSOR_APPARENT_POWERUSAGE: ELECTRICAL_VOLT_AMPERE, SENSOR_BATTERY: PERCENTAGE, SENSOR_CCT: TEMP_KELVIN, SENSOR_CF1: CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, @@ -167,11 +163,20 @@ SENSOR_COLOR_BLUE: "B", SENSOR_COLOR_GREEN: "G", SENSOR_COLOR_RED: "R", + SENSOR_CURRENT_NEUTRAL: ELECTRICAL_CURRENT_AMPERE, SENSOR_CURRENT: ELECTRICAL_CURRENT_AMPERE, - SENSOR_CURRENTNEUTRAL: ELECTRICAL_CURRENT_AMPERE, SENSOR_DISTANCE: LENGTH_CENTIMETERS, SENSOR_ECO2: CONCENTRATION_PARTS_PER_MILLION, SENSOR_ENERGY: ENERGY_KILO_WATT_HOUR, + SENSOR_ENERGY_EXPORT_ACTIVE: ENERGY_KILO_WATT_HOUR, + SENSOR_ENERGY_EXPORT_REACTIVE: REACTIVE_ENERGY_KILO_VOLT_AMPERE_HOUR, + SENSOR_ENERGY_IMPORT_ACTIVE: ENERGY_KILO_WATT_HOUR, + SENSOR_ENERGY_IMPORT_REACTIVE: REACTIVE_ENERGY_KILO_VOLT_AMPERE_HOUR, + SENSOR_ENERGY_IMPORT_TODAY: ENERGY_KILO_WATT_HOUR, + SENSOR_ENERGY_IMPORT_TOTAL_TARIFF: ENERGY_KILO_WATT_HOUR, + SENSOR_ENERGY_IMPORT_TOTAL: ENERGY_KILO_WATT_HOUR, + SENSOR_ENERGY_IMPORT_YESTERDAY: ENERGY_KILO_WATT_HOUR, + SENSOR_ENERGY_TOTAL_START_TIME: None, SENSOR_FREQUENCY: FREQUENCY_HERTZ, SENSOR_HUMIDITY: PERCENTAGE, SENSOR_ILLUMINANCE: LIGHT_LUX, @@ -182,24 +187,19 @@ SENSOR_PB10: "ppd", SENSOR_PB2_5: "ppd", SENSOR_PB5: "ppd", - SENSOR_PHASEANGLE: DEGREE, + SENSOR_PHASE_ANGLE: DEGREE, SENSOR_PM1: CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, SENSOR_PM10: CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, SENSOR_PM2_5: CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, - SENSOR_POWERFACTOR: None, - SENSOR_POWERUSAGE: POWER_WATT, + SENSOR_POWER: POWER_WATT, + SENSOR_POWER_ACTIVE: POWER_WATT, + SENSOR_POWER_APPARENT: ELECTRICAL_VOLT_AMPERE, + SENSOR_POWER_FACTOR: None, + SENSOR_POWER_REACTIVE: REACTIVE_POWER, SENSOR_PROXIMITY: " ", - SENSOR_REACTIVE_ENERGYEXPORT: REACTIVE_ENERGY_KILO_VOLT_AMPERE_HOUR, - SENSOR_REACTIVE_ENERGYIMPORT: REACTIVE_ENERGY_KILO_VOLT_AMPERE_HOUR, - SENSOR_REACTIVE_POWERUSAGE: REACTIVE_POWER, - SENSOR_TODAY: ENERGY_KILO_WATT_HOUR, - SENSOR_TOTAL_START_TIME: None, - SENSOR_TOTAL_TARIFF: ENERGY_KILO_WATT_HOUR, - SENSOR_TOTAL: ENERGY_KILO_WATT_HOUR, SENSOR_TVOC: CONCENTRATION_PARTS_PER_BILLION, SENSOR_VOLTAGE: VOLT, SENSOR_WEIGHT: MASS_KILOGRAMS, - SENSOR_YESTERDAY: ENERGY_KILO_WATT_HOUR, } SUPPORTED_PRESSURE_UNITS = [PRESSURE_HPA, PRESSURE_MMHG] @@ -216,12 +216,12 @@ SENSOR_DYNAMIC_UNIT_MAP = { SENSOR_DEWPOINT: (SENSOR_UNIT_TEMPERATURE, SUPPORTED_TEMPERATURE_UNITS), SENSOR_PRESSURE: (SENSOR_UNIT_PRESSURE, SUPPORTED_PRESSURE_UNITS), - SENSOR_PRESSUREATSEALEVEL: (SENSOR_UNIT_PRESSURE, SUPPORTED_PRESSURE_UNITS), + SENSOR_PRESSURE_AT_SEA_LEVEL: (SENSOR_UNIT_PRESSURE, SUPPORTED_PRESSURE_UNITS), SENSOR_SPEED: (SENSOR_UNIT_SPEED, SUPPORTED_SPEED_UNITS), SENSOR_TEMPERATURE: (SENSOR_UNIT_TEMPERATURE, SUPPORTED_TEMPERATURE_UNITS), } -LAST_RESET_SENSOR_MAP = {SENSOR_TOTAL: SENSOR_TOTAL_START_TIME} +LAST_RESET_SENSOR_MAP = {SENSOR_ENERGY_IMPORT_TOTAL: SENSOR_ENERGY_TOTAL_START_TIME} _LOGGER = logging.getLogger(__name__)