diff options
| author | diogo464 <[email protected]> | 2025-12-06 08:42:50 +0000 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-12-06 08:42:50 +0000 |
| commit | 0fbce715a32f5e05c2a66e5cc401105f72083ff5 (patch) | |
| tree | e11de1b9b1f6ef398cab5c07d2213464dac20c11 /src/entity_sensor.rs | |
| parent | 1bdeab31af0154fd3e66ae46ae510669be25b272 (diff) | |
added SensorClass enum
Diffstat (limited to 'src/entity_sensor.rs')
| -rw-r--r-- | src/entity_sensor.rs | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/src/entity_sensor.rs b/src/entity_sensor.rs index 4b84c66..702c9de 100644 --- a/src/entity_sensor.rs +++ b/src/entity_sensor.rs | |||
| @@ -20,6 +20,129 @@ impl StateClass { | |||
| 20 | } | 20 | } |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
| 24 | pub enum SensorClass { | ||
| 25 | Generic, | ||
| 26 | ApparentPower, | ||
| 27 | Aqi, | ||
| 28 | AtmosphericPressure, | ||
| 29 | Battery, | ||
| 30 | CarbonDioxide, | ||
| 31 | CarbonMonoxide, | ||
| 32 | Current, | ||
| 33 | DataRate, | ||
| 34 | DataSize, | ||
| 35 | Date, | ||
| 36 | Distance, | ||
| 37 | Duration, | ||
| 38 | Energy, | ||
| 39 | EnergyStorage, | ||
| 40 | Enum, | ||
| 41 | Frequency, | ||
| 42 | Gas, | ||
| 43 | Humidity, | ||
| 44 | Illuminance, | ||
| 45 | Irradiance, | ||
| 46 | Moisture, | ||
| 47 | Monetary, | ||
| 48 | NitrogenDioxide, | ||
| 49 | NitrogenMonoxide, | ||
| 50 | NitrousOxide, | ||
| 51 | Ozone, | ||
| 52 | Ph, | ||
| 53 | Pm1, | ||
| 54 | Pm25, | ||
| 55 | Pm10, | ||
| 56 | PowerFactor, | ||
| 57 | Power, | ||
| 58 | Precipitation, | ||
| 59 | PrecipitationIntensity, | ||
| 60 | Pressure, | ||
| 61 | ReactivePower, | ||
| 62 | SignalStrength, | ||
| 63 | SoundPressure, | ||
| 64 | Speed, | ||
| 65 | SulphurDioxide, | ||
| 66 | Temperature, | ||
| 67 | Timestamp, | ||
| 68 | VolatileOrganicCompounds, | ||
| 69 | VolatileOrganicCompoundsParts, | ||
| 70 | Voltage, | ||
| 71 | Volume, | ||
| 72 | VolumeFlowRate, | ||
| 73 | VolumeStorage, | ||
| 74 | Water, | ||
| 75 | Weight, | ||
| 76 | WindSpeed, | ||
| 77 | Other(&'static str), | ||
| 78 | } | ||
| 79 | |||
| 80 | impl Default for SensorClass { | ||
| 81 | fn default() -> Self { | ||
| 82 | SensorClass::Generic | ||
| 83 | } | ||
| 84 | } | ||
| 85 | |||
| 86 | impl SensorClass { | ||
| 87 | pub fn as_str(&self) -> Option<&'static str> { | ||
| 88 | match self { | ||
| 89 | SensorClass::Generic => None, | ||
| 90 | SensorClass::Other(s) => Some(s), | ||
| 91 | SensorClass::ApparentPower => Some(constants::HA_DEVICE_CLASS_SENSOR_APPARENT_POWER), | ||
| 92 | SensorClass::Aqi => Some(constants::HA_DEVICE_CLASS_SENSOR_AQI), | ||
| 93 | SensorClass::AtmosphericPressure => Some(constants::HA_DEVICE_CLASS_SENSOR_ATMOSPHERIC_PRESSURE), | ||
| 94 | SensorClass::Battery => Some(constants::HA_DEVICE_CLASS_SENSOR_BATTERY), | ||
| 95 | SensorClass::CarbonDioxide => Some(constants::HA_DEVICE_CLASS_SENSOR_CARBON_DIOXIDE), | ||
| 96 | SensorClass::CarbonMonoxide => Some(constants::HA_DEVICE_CLASS_SENSOR_CARBON_MONOXIDE), | ||
| 97 | SensorClass::Current => Some(constants::HA_DEVICE_CLASS_SENSOR_CURRENT), | ||
| 98 | SensorClass::DataRate => Some(constants::HA_DEVICE_CLASS_SENSOR_DATA_RATE), | ||
| 99 | SensorClass::DataSize => Some(constants::HA_DEVICE_CLASS_SENSOR_DATA_SIZE), | ||
| 100 | SensorClass::Date => Some(constants::HA_DEVICE_CLASS_SENSOR_DATE), | ||
| 101 | SensorClass::Distance => Some(constants::HA_DEVICE_CLASS_SENSOR_DISTANCE), | ||
| 102 | SensorClass::Duration => Some(constants::HA_DEVICE_CLASS_SENSOR_DURATION), | ||
| 103 | SensorClass::Energy => Some(constants::HA_DEVICE_CLASS_SENSOR_ENERGY), | ||
| 104 | SensorClass::EnergyStorage => Some(constants::HA_DEVICE_CLASS_SENSOR_ENERGY_STORAGE), | ||
| 105 | SensorClass::Enum => Some(constants::HA_DEVICE_CLASS_SENSOR_ENUM), | ||
| 106 | SensorClass::Frequency => Some(constants::HA_DEVICE_CLASS_SENSOR_FREQUENCY), | ||
| 107 | SensorClass::Gas => Some(constants::HA_DEVICE_CLASS_SENSOR_GAS), | ||
| 108 | SensorClass::Humidity => Some(constants::HA_DEVICE_CLASS_SENSOR_HUMIDITY), | ||
| 109 | SensorClass::Illuminance => Some(constants::HA_DEVICE_CLASS_SENSOR_ILLUMINANCE), | ||
| 110 | SensorClass::Irradiance => Some(constants::HA_DEVICE_CLASS_SENSOR_IRRADIANCE), | ||
| 111 | SensorClass::Moisture => Some(constants::HA_DEVICE_CLASS_SENSOR_MOISTURE), | ||
| 112 | SensorClass::Monetary => Some(constants::HA_DEVICE_CLASS_SENSOR_MONETARY), | ||
| 113 | SensorClass::NitrogenDioxide => Some(constants::HA_DEVICE_CLASS_SENSOR_NITROGEN_DIOXIDE), | ||
| 114 | SensorClass::NitrogenMonoxide => Some(constants::HA_DEVICE_CLASS_SENSOR_NITROGEN_MONOXIDE), | ||
| 115 | SensorClass::NitrousOxide => Some(constants::HA_DEVICE_CLASS_SENSOR_NITROUS_OXIDE), | ||
| 116 | SensorClass::Ozone => Some(constants::HA_DEVICE_CLASS_SENSOR_OZONE), | ||
| 117 | SensorClass::Ph => Some(constants::HA_DEVICE_CLASS_SENSOR_PH), | ||
| 118 | SensorClass::Pm1 => Some(constants::HA_DEVICE_CLASS_SENSOR_PM1), | ||
| 119 | SensorClass::Pm25 => Some(constants::HA_DEVICE_CLASS_SENSOR_PM25), | ||
| 120 | SensorClass::Pm10 => Some(constants::HA_DEVICE_CLASS_SENSOR_PM10), | ||
| 121 | SensorClass::PowerFactor => Some(constants::HA_DEVICE_CLASS_SENSOR_POWER_FACTOR), | ||
| 122 | SensorClass::Power => Some(constants::HA_DEVICE_CLASS_SENSOR_POWER), | ||
| 123 | SensorClass::Precipitation => Some(constants::HA_DEVICE_CLASS_SENSOR_PRECIPITATION), | ||
| 124 | SensorClass::PrecipitationIntensity => Some(constants::HA_DEVICE_CLASS_SENSOR_PRECIPITATION_INTENSITY), | ||
| 125 | SensorClass::Pressure => Some(constants::HA_DEVICE_CLASS_SENSOR_PRESSURE), | ||
| 126 | SensorClass::ReactivePower => Some(constants::HA_DEVICE_CLASS_SENSOR_REACTIVE_POWER), | ||
| 127 | SensorClass::SignalStrength => Some(constants::HA_DEVICE_CLASS_SENSOR_SIGNAL_STRENGTH), | ||
| 128 | SensorClass::SoundPressure => Some(constants::HA_DEVICE_CLASS_SENSOR_SOUND_PRESSURE), | ||
| 129 | SensorClass::Speed => Some(constants::HA_DEVICE_CLASS_SENSOR_SPEED), | ||
| 130 | SensorClass::SulphurDioxide => Some(constants::HA_DEVICE_CLASS_SENSOR_SULPHUR_DIOXIDE), | ||
| 131 | SensorClass::Temperature => Some(constants::HA_DEVICE_CLASS_SENSOR_TEMPERATURE), | ||
| 132 | SensorClass::Timestamp => Some(constants::HA_DEVICE_CLASS_SENSOR_TIMESTAMP), | ||
| 133 | SensorClass::VolatileOrganicCompounds => Some(constants::HA_DEVICE_CLASS_SENSOR_VOLATILE_ORGANIC_COMPOUNDS), | ||
| 134 | SensorClass::VolatileOrganicCompoundsParts => Some(constants::HA_DEVICE_CLASS_SENSOR_VOLATILE_ORGANIC_COMPOUNDS_PARTS), | ||
| 135 | SensorClass::Voltage => Some(constants::HA_DEVICE_CLASS_SENSOR_VOLTAGE), | ||
| 136 | SensorClass::Volume => Some(constants::HA_DEVICE_CLASS_SENSOR_VOLUME), | ||
| 137 | SensorClass::VolumeFlowRate => Some(constants::HA_DEVICE_CLASS_SENSOR_VOLUME_FLOW_RATE), | ||
| 138 | SensorClass::VolumeStorage => Some(constants::HA_DEVICE_CLASS_SENSOR_VOLUME_STORAGE), | ||
| 139 | SensorClass::Water => Some(constants::HA_DEVICE_CLASS_SENSOR_WATER), | ||
| 140 | SensorClass::Weight => Some(constants::HA_DEVICE_CLASS_SENSOR_WEIGHT), | ||
| 141 | SensorClass::WindSpeed => Some(constants::HA_DEVICE_CLASS_SENSOR_WIND_SPEED), | ||
| 142 | } | ||
| 143 | } | ||
| 144 | } | ||
| 145 | |||
| 23 | #[derive(Debug, Default)] | 146 | #[derive(Debug, Default)] |
| 24 | pub struct TemperatureSensorConfig { | 147 | pub struct TemperatureSensorConfig { |
| 25 | pub common: EntityCommonConfig, | 148 | pub common: EntityCommonConfig, |
